我正在尝试使用 CoreImage 框架的 CIColorCube CIFilter,我尝试了任意 3D Luts 到图像,我将 3D luts 包装到 NSData,然后作为参数传递给 CIColorCube CIFilter。但我收到 EXC_BAD_ACCESS 异常。这是我的代码:
CIContext *context = [CIContext contextWithOptions:nil]; CIFilter *filter = [CIFilter filterWithName:@"CIColorCube"];
uint8_t color_cube_data[4096*4] = {
153, 255, 255, 1,
170, 255, 255, 1,
186, 255, 255, 1,
204, 255, 255, 1,
221, 255, 255, 1,
237, 255, 255, 1,
255, 255, 255, 1};
NSData * cube_data =[NSData dataWithBytes:color_cube_data length:4096*sizeof(float)*4];
[filter setValue:originalImage forKey:kCIInputImageKey];
[filter setValue:[NSNumber numberWithFloat:16] forKey:@"inputCubeDimension"];
[filter setValue:cube_data forKey:@"inputCubeData"];
CIImage *result = [filter valueForKey:kCIOutputImageKey];
CGImageRef cgImage =[context createCGImage:result fromRect:originalImage.extent];
imgVw_Result.image=[UIImage imageWithCGImage:cgImage];
我错过了什么请帮忙谢谢