如何捕获或处理在创建位图上下文期间抛出的错误?顺便说一句,我知道这个错误意味着什么,我想用它来创建一个不同的上下文。
抛出错误的函数:
CGContextRef ctx = CGBitmapContextCreate(m_PixelBuf,
CGImageGetWidth(grayImage),
CGImageGetHeight(grayImage),
CGImageGetBitsPerComponent(grayImage),
CGImageGetBytesPerRow(grayImage),
CGImageGetColorSpace(grayImage),
CGImageGetBitmapInfo(grayImage)
);Consol日志,错误为:
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发布于 2011-05-13 19:04:10
您可以在尝试创建上下文之后检查它是否为空。
https://stackoverflow.com/questions/5990236
复制相似问题