core-image – 核心图像过滤器“CIDepthBlurEffect”无法在iOS 11 / Xcode 9.0上运行

前端之家收集整理的这篇文章主要介绍了core-image – 核心图像过滤器“CIDepthBlurEffect”无法在iOS 11 / Xcode 9.0上运行前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我无法使新的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的发布解决了这个问题.

猜你在找的iOS相关文章