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?
Just a simple line of code (Available from IOS 5.0)
UIImage *uiImage = [[UIImage alloc] initWithCIImage:ciImage];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.