Reputation: 12951
I'm using GPUImage for blur effect and I make my side menu background blur (it's POC code):
UIImage *currentScreenShotImage = [Util screenshot];
GPUImageView *blurView = [[GPUImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 568)];
blurView.clipsToBounds = YES;
blurView.layer.contentsGravity = kCAGravityTop;
GPUImageiOSBlurFilter *blurFilter = [[GPUImageiOSBlurFilter alloc] init];
blurFilter.blurRadiusInPixels = 8.0f;
GPUImagePicture *picture = [[GPUImagePicture alloc] initWithImage:currentScreenShotImage];
[picture addTarget:blurFilter];
[blurFilter addTarget:blurView];
[picture processImageWithCompletionHandler:^{
[blurFilter removeAllTargets];
}];
processImageWithCompletionHandler
- The method that actually process and blur the screenshot takes 1 second (which is a lot!).
How can I make it faster or someone have different trick than screenshot?
Upvotes: 3
Views: 461
Reputation: 1166
I recommend you to use the UIImage+ImageEffects category. You could get it from the WWDC 2013 sample code (paid developer subscription required) and download iOS_UIImageEffects, you can then grab the UIImage+ImageEffects category. Or download from
That provides you with:
- (UIImage *)applyLightEffect;
- (UIImage *)applyExtraLightEffect;
- (UIImage *)applyDarkEffect;
- (UIImage *)applyTintEffectWithColor:(UIColor *)tintColor;
- (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage;
So to make a blur you just have to do:
UIImage *newImage = [image applyLightEffect];
It's quite fast. Check it out.
Upvotes: 1
Reputation: 5881
If you don't need iOS 5 support, you can use CoreImage: https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/CoreImageFilterReference/Reference/reference.html#//apple_ref/doc/filter/ci/CIGaussianBlur
Code sample: https://gist.github.com/oliland/5416438
Upvotes: 1