首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Cocos2D-X在Windows的plist中膨胀png失败

使用Cocos2D-X在Windows的plist中膨胀png失败
EN

Stack Overflow用户
提问于 2012-07-06 03:53:31
回答 2查看 925关注 0票数 1

我正在使用用Mac创建的plist文件运行Coco2D-X的particleWithFile()函数。使用"textureImageData“键将图像数据嵌入plist文件中。在Mac上运行良好,但在Windows上运行失败,在CCAssert(isOK)上,请参阅下面的Coco2D-X代码(CCParticleSystem.cpp):

代码语言:javascript
复制
char *textureData = (char*)valueForKey("textureImageData", dictionary);
CCAssert(textureData, "");

int dataLen = strlen(textureData);
if(dataLen != 0) 
{
    // if it fails, try to get it from the base64-gzipped data  
    int decodeLen = base64Decode((unsigned char*)textureData, (unsigned int)dataLen,          &buffer);
    CCAssert( buffer != NULL, "CCParticleSystem: error decoding textureImageData");
    CC_BREAK_IF(!buffer);

    int deflatedLen = ZipUtils::ccInflateMemory(buffer, decodeLen, &deflated);
    CCAssert( deflated != NULL, "CCParticleSystem: error ungzipping textureImageData");
    CC_BREAK_IF(!deflated);

    image = new CCImage();
    bool isOK = image->initWithImageData(deflated, deflatedLen);
    CCAssert(isOK, "CCParticleSystem: error init image with Data");
    CC_BREAK_IF(!isOK);
    m_pTexture = CCTextureCache::sharedTextureCache()->addUIImage(image, fullpath.c_str());
}

解码似乎成功通过,问题出在zlib的inflate()函数中,无法解压缩png文件。

有什么建议吗?

EN

回答 2

Stack Overflow用户

发布于 2012-07-08 21:39:08

好了,我找到问题了。

显然,我的资源不是png文件,而是tiff文件。所以Inflate()返回了一个正确的缓冲区( tiff文件-对我来说看起来太长了,所以我怀疑它是错误的),但initWithImageData()无法创建图像,因为windows上的Cocos2d-x不支持tiff。

票数 0
EN

Stack Overflow用户

发布于 2015-07-25 15:12:10

我遇到这个问题是因为我将CC_USE_TIFF设置为0。

在我将CC_USE_TIFF恢复为1之后,问题就解决了。

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

https://stackoverflow.com/questions/11351594

复制
相关文章

相似问题

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