以下代码在iOS8上使用CIMaskedVariableBlur过滤器。该代码在64位设备上运行良好,但在32位设备上失败 - 它只返回一个黑色图像。
有什么想法吗?
/* filteredImage:adjustVariableBlurWithImage
*
* blur the image with a mask (iOS8 only)
*/
- (CGImageRef) filteredImage:(UIImage*)image adjustVariableBlurWithImage:(UIImage*)maskImage {
CGImageRef cgImage = nil;
CIContext *context = [CIContext contextWithOptions:nil];
CIImage* ciImage = [CIImage imageWithCGImage:[image CGImage]];
CIImage* ciMask = [CIImage imageWithCGImage:[maskImage CGImage]];
CIFilter *filter = [CIFilter filterWithName:@"CIMaskedVariableBlur"];
[filter setValue:ciImage forKey:kCIInputImageKey];
[filter setValue:ciMask forKey:@"inputMask"];
[filter setValue:[NSNumber numberWithFloat:2.0] forKey:kCIInputRadiusKey];
CIImage *result = [filter valueForKey:kCIOutputImageKey];
CGRect extent = [result extent];
cgImage = [context createCGImage:result fromRect:extent];
return(cgImage);
}
此图像在64位(左)和32位(右)上显示结果: