2011-05-13 60 views
0

如何捕獲或處理在創建位圖上下文期間拋出的eror? 順便說一句,我知道錯誤意味着什麼,我想用它來創建不同的上下文。CGBitmapContextCreate的處理錯誤

函數拋出錯誤:

CGContextRef ctx = CGBitmapContextCreate(m_PixelBuf, 
               CGImageGetWidth(grayImage), 
               CGImageGetHeight(grayImage), 
               CGImageGetBitsPerComponent(grayImage), 
               CGImageGetBytesPerRow(grayImage), 
               CGImageGetColorSpace(grayImage), 
               CGImageGetBitmapInfo(grayImage) 
               ); 

康壽日誌與錯誤:

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 

回答

0

你可以檢查上下文是試圖創建之後NULL。