Handling error for CGBitmapContextCreate
How can I catch or handle an eror that is thrown during the creation of bitmap context? By the way开发者_StackOverflow社区 I know what the error means and I want to use it to create a different context.
Function that throws Error:
CGContextRef ctx = CGBitmapContextCreate(m_PixelBuf,
CGImageGetWidth(grayImage),
CGImageGetHeight(grayImage),
CGImageGetBitsPerComponent(grayImage),
CGImageGetBytesPerRow(grayImage),
CGImageGetColorSpace(grayImage),
CGImageGetBitmapInfo(grayImage)
);
Consol log with the error:
Fri May 13 11:47:21 C.local x[2569] <Error>: CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component color space; kCGImageAlphaLast; 616 bytes/row.
Fri May 13 11:47:21 C.local x[2569] <Error>: CGBitmapContextCreateImage: invalid context 0x0
You could check if the context is NULL after trying to create it.
精彩评论