我正在尝试使用以下代码获取 CoreImage CIRandomGenerator 过滤器的输出:
CIContext *context = [CIContext contextWithOptions:nil];
CIFilter *randomNoise = [CIFilter filterWithName:@"CIRandomGenerator"];
[randomNoise setDefaults];
CIImage *output = randomNoise.outputImage;
// This returns nil
CGImageRef ref = [context createCGImage:output
fromRect:output.extent];
self.photoView.image = [UIImage imageWithCGImage:ref];
CGImageRelease(ref);
然而,createCGImage:fromRect: 总是返回一个 nil CGImageRef。
我究竟做错了什么?