CIContext returns a nil CGImageRef when using a CIRandomGenerator filter
-
15-07-2021 - |
سؤال
I'm trying to get the output of the CoreImage CIRandomGenerator filter, with the following code:
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);
However, the createCGImage:fromRect: always returns a nil CGImageRef.
What am I doing wrong?
المحلول
You need to be sure to crop the extent
so that it's not infinite.
لا تنتمي إلى StackOverflow