I would like to apply blur on my image view. I have this code for blurring:
- (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];
}
But blurring happens very slow for screenshot of my UIView
on iPad.
Is there any faster way to do this?
Apple released code at WWDC that does what you need.
It is a category on UIImage
and uses the Accelerate
framework for fast image processing. If you have a developer account you can grab the UIImage
category here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.