簡體   English   中英

在iOS上非常慢的UIImage模糊

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM