문제

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