我想在我的 ImageView 上应用模糊。我有这段模糊代码:
- (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];
}
但是对于我在 iPad 上的 UIView
截图,模糊发生得非常慢。
有没有更快的方法来做到这一点?
最佳答案
Apple 在 WWDC 上发布了满足您需要的代码。
它是 UIImage
上的一个类别,使用 Accelerate
框架进行快速图像处理。
如果您有开发者帐户,您可以获取 UIImage
类别 here .
关于ios - iOS 上的 UIImage 模糊非常慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22935776/