iOS 8/32位上的CIMaskedVariableBlur过滤器不起作用

时间:2015-08-03 10:27:29

标签: ios 32bit-64bit cifilter

以下代码在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位(右)上显示结果:

enter image description here

0 个答案:

没有答案