[英]Very slow UIImage blurring on iOS
我想在我的图像视图上应用模糊。 我有这个代码模糊:
- (UIImage *)applyBlurOnImage: (UIImage *)imageToBlur withRadius: (CGFloat)blurRadius
{
CIImage *originalImage = [CIImage imageWithCGImage: imageToBlur.CGImage];
CIFilter *filter = [CIFilter filterWithName: @"CIGaussianBlur" keysAndValues: kCIInputImageKey, originalImage, @"inputRadius", @(blurRadius), nil];
CIImage *outputImage = filter.outputImage; CIContext *context = [CIContext contextWithOptions:nil];
CGImageRef outImage = [context createCGImage: outputImage fromRect: [outputImage extent]];
return [UIImage imageWithCGImage: outImage];
}
但是对于我的UIView
在iPad上的截图,模糊发生的速度非常慢。
有没有更快的方法来做到这一点?
Apple在WWDC上发布了满足您需求的代码。
它是UIImage
上的一个类别,使用Accelerate
框架进行快速图像处理。 如果您有开发者帐户,可以在此处获取UIImage
类别。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.