首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >处理CGBitmapContextCreate的错误

处理CGBitmapContextCreate的错误
EN

Stack Overflow用户
提问于 2011-05-13 17:59:09
回答 1查看 548关注 0票数 0

如何捕获或处理在创建位图上下文期间抛出的错误?顺便说一句,我知道这个错误意味着什么,我想用它来创建一个不同的上下文。

抛出错误的函数:

代码语言:javascript
复制
CGContextRef ctx = CGBitmapContextCreate(m_PixelBuf,  
                                                 CGImageGetWidth(grayImage),  
                                                 CGImageGetHeight(grayImage),  
                                                 CGImageGetBitsPerComponent(grayImage),
                                                 CGImageGetBytesPerRow(grayImage),  
                                                 CGImageGetColorSpace(grayImage), 
                                                 CGImageGetBitmapInfo(grayImage)
                                                 );

Consol日志,错误为:

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-05-13 19:04:10

您可以在尝试创建上下文之后检查它是否为空。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5990236

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档