ios - iOS 上的 UIImage 模糊非常慢

标签 ios objective-c blur

我想在我的 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/

相关文章:

ios - 谁的 View 不是窗口层次问题?

ios - 谁能帮我知道我的应用程序是否可以进入 App Store?

objective-c - 在 TabBar 控制的 iOS 应用程序中的第二个选项卡中进行交互时,将 RemoteControlEvents 接收到第一个选项卡

iphone - UITableViewCell 内的 UIScrollView 在 iPad 上具有水平分页

objective-c - cocoa :如何重新打开关闭的窗口?

jQuery 在模糊()最后一个表单字段后获得焦点

iphone - 为什么 PNG 图像有时会根据其在 View 中的位置而变得模糊

html - 如何模糊div的背景图像,而不模糊其余站点或div的内容

ios - Fscalendar 选择的事件点颜色?

ios - 我无法将 NSLogger 成功集成到我的应用程序中