我使用GPUImage进行模糊效果,并使我的侧面菜单背景模糊(它的POC代码):
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
- 实际处理和模糊屏幕截图的方法需要1秒钟(这很多!)。
如何让它更快或有人有不同于截图的技巧?
提前10倍!答案 0 :(得分:0)
如果您不需要iOS 5支持,可以使用CoreImage:https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/CoreImageFilterReference/Reference/reference.html#//apple_ref/doc/filter/ci/CIGaussianBlur
答案 1 :(得分:0)
我建议您使用UIImage + ImageEffects类别。您可以从WWDC 2013示例代码(需要付费开发人员订阅)获取它并下载iOS_UIImageEffects,然后您可以获取UIImage + ImageEffects类别。或者从
下载它为您提供:
- (UIImage *)applyLightEffect;
- (UIImage *)applyExtraLightEffect;
- (UIImage *)applyDarkEffect;
- (UIImage *)applyTintEffectWithColor:(UIColor *)tintColor;
- (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage;
所以要做一个模糊你只需做:
UIImage *newImage = [image applyLightEffect];
这很快。看看吧。