本篇文章由:http://www.sollyu.com/cocos2d-x-2-0-4-ios7-image-loading-errors/
说明
错误提示
<Error>: CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component color space; kCGImageAlphaPremultipliedLast; 1266 bytes/row.
解决
定位文件 CCimage.mm 并找到函数 _initWithString
函数原型
static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAlign, const char * pFontName, int nSize, tImageInfo* pInfo)
找到代码
▼代码位置大约在301行
![[cocos2d-x 2.0.4][iOS7]图片加载错误](http://images0.cnblogs.com/blog/322009/201501/041910598882741.png)
// draw text CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(data, dim.width, dim.height, 8, (int)dim.width * 4, // 此处为修改 colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
原理
因为 dim.width * 4 有可能不是整数,所以就来个强制类型转换。
浙公网安备 33010602011771号