我正在使用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倍!

最佳答案

如果不需要iOS 5支持,则可以使用CoreImage:https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/CoreImageFilterReference/Reference/reference.html#//apple_ref/doc/filter/ci/CIGaussianBlur

代码示例:https://gist.github.com/oliland/5416438

关于ios - iOS-模糊效果-GPUImage-processImageWithCompletionHandler,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23906358/

10-10 20:34