我无法使新的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);
解决方法
Xcode 9 beta 2和iOS 11 beta 2的发布解决了这个问题.