我无法让新CIDepthBlurEffect
的工作。我做错了什么,还是这是一个已知问题?
下面是我在 Objective-C 中的代码:
NSDictionary *dict = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:[NSNumber numberWithBool:YES], [NSNumber numberWithBool:YES], nil] forKeys:[NSArray arrayWithObjects:kCIImageAuxiliaryDisparity, @"kCIImageApplyOrientationProperty", nil]];
CIImage *disparityImage = [CIImage imageWithData:imageData options:dict];
CIFilter *ciDepthBlurEffect = [CIFilter filterWithName:@"CIDepthBlurEffect"];
[ciDepthBlurEffect setDefaults];
[ciDepthBlurEffect setValue:disparityImage forKey:@"inputDisparityImage"];
[ciDepthBlurEffect setValue:originalImage forKey:@"inputImage"];
CIImage *outputImage = [ciDepthBlurEffect valueForKey:@"outputImage"];
EAGLContext *previewEaglContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
CIContext *context = [CIContext contextWithEAGLContext:previewEaglContext options:@{kCIContextWorkingFormat :[NSNumber numberWithInt:kCIFormatRGBAh]} ];
CGImageRef cgimg = [context createCGImage:disparityImage fromRect:[disparityImage extent]];
image = [[UIImage alloc] initWithCGImage:cgimg];
CGImageRelease(cgimg);