سؤال

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top