android - 在 Cocos2d-x 中加载 Base64 编码的图片

标签 android c++ iphone ios cocos2d-x

Cocos2d-x 中,我试图加载一个 base64 编码的图像字符串来创建一个 Sprite 。某处似乎有错误,因为 bool ok 总是返回 false。也许有人可以帮助我?

这是我使用的代码:

std::string source = "data:image/png;base64,iVBORw0K....."

int len = 0;
unsigned char *buffer;

len = base64Decode((unsigned char*)source.c_str(), (unsigned int)source.length(), &buffer);

CCImage* img = new CCImage(); 
bool ok = img->initWithImageData(buffer,len);

最佳答案

@MarkRansom 回答了 OP 的问题:

I don't know anything about Cocos2DX but I'm guessing the string you pass to base64Decode needs to be stripped of the meta-data at the front.

关于android - 在 Cocos2d-x 中加载 Base64 编码的图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15551657/

相关文章:

Android AccessibilityService getEventTime() 时间格式

c++ - SuperLU 库 XCode 问题

c++ - 对静态类成员的 undefined reference

ios - 滑动然后按住 - touchesBegan/touchesMoved/touchesEnded

android - Android 设备上的 GPU 编程

android - 无法在自定义通知中包含简单 View ?

google-play - 链接到 android 市场上的应用程序的确切子集

c++ - 通过静态函数增加非静态变量

ios - 在 ios 7 iPhone 中使用 sizeWithAtrributes 时,方法调用参数过多错误

iphone - self.navigationController pushViewController 没有将 Controller 添加到堆栈