This commit is contained in:
natural-law 2011-08-01 10:45:40 +08:00
commit 5b0f25466a
2 changed files with 13 additions and 4 deletions

View File

@ -85,7 +85,8 @@ public:
void clear(float r, float g, float b, float a);
/** saves the texture into a file */
bool saveBuffer(const char *name);
// para szFilePath the absolute path to save
bool saveBuffer(const char *szFilePath);
/** saves the texture into a file. The format can be JPG or PNG */
bool saveBuffer(const char *name, int format);

View File

@ -216,13 +216,21 @@ void CCRenderTexture::clear(float r, float g, float b, float a)
this->end();
}
bool CCRenderTexture::saveBuffer(const char *name)
bool CCRenderTexture::saveBuffer(const char *szFilePath)
{
return this->saveBuffer(name, kCCImageFormatJPG);
bool bRet = false;
CCImage *pImage = new CCImage();
if (pImage != NULL && getUIImageFromBuffer(pImage))
{
bRet = pImage->saveToFile(szFilePath);
}
CC_SAFE_DELETE(pImage);
return bRet;
}
bool CCRenderTexture::saveBuffer(const char *fileName, int format)
{
bool bRet = false;
CCAssert(format == kCCImageFormatJPG || format == kCCImageFormatPNG,
"the image can only be saved as JPG or PNG format");