Domanda

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?

È stato utile?

Soluzione

You need to be sure to crop the extent so that it's not infinite.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top