Sollyu

  • 捐赠
  • 关于
  1. 首页
  2. 原创文章
  3. 正文

[cocos2d-x 2.0.4][iOS7]图片加载错误

2015年1月4日 3706点热度 0人点赞 0条评论

说明

错误提示

<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]图片加载错误

// draw text
CGColorSpaceRef colorSpace  = CGColorSpaceCreateDeviceRGB();
CGContextRef context        = CGBitmapContextCreate(data,
                                                    dim.width,
                                                    dim.height,
                                                    8,
                                                    (int)dim.width * 4, // 此处为修改
                                                    colorSpace,
                                                    kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);

原理

因为 dim.width * 4 有可能不是整数,所以就来个强制类型转换。

本作品采用 知识共享署名 4.0 国际许可协议 进行许可
标签: 2.0.4 cocos2d-x unsupported 图片
最后更新:2015年1月4日

sollyu

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

COPYRIGHT © 2021 sollyu.com. ALL RIGHTS RESERVED.

THEME KRATOS MADE BY VTROIS

苏ICP备15007531号