我正在使用 Mac 创建的 plist 文件运行 Coco2D-X 的particleWithFile() 函数。使用“textureImageData”键将图像数据嵌入到 plist 文件中。在 Mac 上它可以正常工作,但在 Windows 上它会失败,在 CCAssert(isOK) 上,请参阅下面的 Coco2D-X 代码 (CCParticleSystem.cpp):
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文件。
有什么建议么?