3

I have a CIImage with format kCVPixelFormatType_420YpCbCr8BiPlanarFullRange(YCC420f or N12), now I want to see what the image looks like, so I convert it to UIImage use this method:

CIImage *ciImage = [CIImage imageWithCVPixelBuffer:new_buffer];

CIContext *temporaryContext = [CIContext contextWithOptions:nil];
CGImageRef videoImage = [temporaryContext
                          createCGImage:ciImage
                               fromRect:CGRectMake(0, 0,
                                        CVPixelBufferGetWidth(new_buffer),
                                        CVPixelBufferGetHeight(new_buffer))];

UIImage *uiImage = [UIImage imageWithCGImage:videoImage];

It's works fine when the image's format is BGRA, but not for NV12, error message in console:

Render failed because a pixel format YCC420f is not supported.

Btw, the ciimage comes from a CVPixelBufferRef, and the CVPixelBufferRef comes from an address of a GL texture.

Now, what should I do?

Klein Mioke
  • 1,261
  • 2
  • 14
  • 23

1 Answers1

0

Just a simple line of code (Available from IOS 5.0)

UIImage *uiImage = [[UIImage alloc] initWithCIImage:ciImage];

Adeel
  • 859
  • 6
  • 9