Coder Social home page Coder Social logo

ios-realtimeblur's Introduction

ios-realtimeblur

Real-time blur view, like in iOS 7. (deployable on iOS5, 6 and 7)

IMAGE ALT TEXT HERE

Usage

• • • Make sure you link to the Accelerate.framework • • •

Instantiate it and use it as any other view :)

//Creates a live blur view
UIERealTimeBlurView *blurView = [[UIERealTimeBlurView alloc] initWithFrame:CGRectMake(60, 110, 200, 200)];
[self.view addSubview:blurView];

You can add all the subviews you want to it...

UIImageView *speakerImage = [[UIImageView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)];
speakerImage.image = [UIImage imageNamed:@"speaker"];
[blurView addSubview:speakerImage];

If you want to have a static rendering (useful if your view is presented modally) just set

blurView.renderStatic = YES;

You can set the tint color of the view via the tint property (still TODO: use iOS7 tintColor ;)) - The default one is clearColor

In UIERealTimeBlurView.h you can set the fps by tweaking the global var

extern const CGFloat UIERealTimeBlurViewFPS = 30.f;

Credits

If you use this component in your app, please add some credits :) The box blur algorithm is from this beautiful blog post: http://indieambitions.com/idevblogaday/perform-blur-vimage-accelerate-framework-tutorial

ios-realtimeblur's People

Contributors

a-zak avatar alexdrone avatar cbess avatar dmiedema avatar genadyo avatar macmannes avatar nicklockwood avatar svintus avatar troyharris avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ios-realtimeblur's Issues

License?

What is the license for this code?

Blurred region does not represent the area under the blurred view

I was evaluating the project and ran into what I think is an issue, unless it is intended behavior. The image that is captured, blurred and presented in the blur view is not actually the region under the blur view.

Easy to demonstrate. Change the creation of the blurView in the sample project by setting the blurRadius to zero where the blurView is created in viewDidLoad in the sample project.

//Creates a live blur view
self.blurView = [[DRNRealTimeBlurView alloc] initWithFrame:CGRectMake(60, 110, 200, 200)];
self.blurView.blurRadius = 0;        //  <=== ADD THIS LINE
[self.view addSubview:self.blurView];

You will note that the no longer blurred text shown in the blurView is from the (0,0) position in the superView, not the area directly under the blurView, as you can see the orange text in the blurView which is not under the blurView but in the upper left of the superView.

Screenshot below.

ios simulator screen shot sep 24 2013 7 19 37 pm

Blurring MKMapView in background without affecting whats in front of it

Im trying to blur a map that serves as a background to my profile page. Its working fine except that it takes what I have in front(that I dont want blurred), makes a copy, shifts it down, and blurs it too. Is there a way to avoid this? Here is a screenshot. The most noticable is the profile picture
photo sep 24 7 36 30 pm

CGContextTranslateCTM error when poping UIView

Hello,

I've used your library to implement a blur on a UIImageView (awesome work). The thing is that when I go back to the previous view, this error shows up:

"CGContextTranslateCTM: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update."

I think it's a problem within the function renderLayerWithView because the context is not present anymore.

I'll try to fixit myself. Just letting you know! thanks!

Fatal Error in Upcoming Update

I received the following error. Thought I should warn you. Great library by the way. :)

CGContextTranslateCTM: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

extremely jerky

even with less frames <10 if this is applied on a view which contains a tableview everything is extremely jerky.

Good try though. thank you for your work.

Added podspec to CocoaPods

Did you want to create the pull request/issue on CocoaPods/Specs to add this to the list? Or would you like me to go ahead with it?

JPEG compression WTF

These lines made me say WTF

NSData *imageData = UIImageJPEGRepresentation(image, kDRNRealTimeBlurViewScreenshotCompression);
image = [[UIImage imageWithData:imageData] drn_boxblurImageWithBlur:kDRNRealTimeBlurViewBlurRadius];

There is a comment that claims higher JPEG compression would lead to better performance, but that seems incredibly unlikely to me. The time and memory required to perform the compression almost certainly outweigh any benefit. Does the blur algorithm even depend on the content of the image? I presume it is just about the size of the buffer. These two lines more than double the memory required, for no good reason.

Since you need access to the raw pixel data, you should probably create a CGBitmapContext up front, using a buffer you allocate, and then render directly into that. Then you can proceed directly to the blur without making copies of anything.

CGContextTranslateCTM: invalid context 0x0. - BUG

The bug is in

  • (void)renderLayerWithView:(UIView*)superview

// the following will always return nil outside of drawRect

CGContextRef context = UIGraphicsGetCurrentContext();

// as seemingly the only reason for obtaining the context is to pass it to
// [layer renderInContext:context];

simply remove the following lines of code
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, -visibleRect.origin.x, -visibleRect.origin.y);

and replace
[layer renderInContext:context];

with
[layer renderInContext:UIGraphicsGetCurrentContext()];

Change blur view position with animation

Looks like this doesn't work correct. Trying to build something like the control center in iOS7. So if I try to present a blur view modally from the bottom of the window, the blur view isn't real time. Just statically contains its background and doesn't change as it's animated.

Any ideas how to implement this?

Speedup ios-realtimeblur ( by factor of 2-3! )

The performance of this library could be greatly improved, below is a list of recommendations to take to increase the performance:

  • To capture the raw pixels you can utilise a CGBitmapContextCreate with your own memory buffer as the first argument. This allows you to skip compressing it to a JPG and then an NSData object just to unpack it back into raw pixels using the image provider methods.
  • You can use the vImage_Buffer as both the source and destination to avoid using more memory than necessary.

Both of the above recommendations can be found here: https://gist.github.com/robertjpayne/6775157. I didn't create a pull request because the code is not heavily tested.

In the simple testing I did it resulted in a speedup of about 2-3x.

realtimeblur as scrollView view background

Hi, thank you for your work here. It really looks very good!

I'm having a small problem. I want to set realtimeblur as background of a view that contains a scrollview inside. When I scroll, everything in the blur is getting recalculated or somethings which leds my app cpu usage to 100% and the scroll became very very slow.

Is possible just to render view on bottom of realtimeblur?

Thank you,
Mário

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.