mirror of https://github.com/axmolengine/axmol.git
fixed #641 the user could save buffer to any path
This commit is contained in:
parent
87f0b6c63f
commit
a54fda812b
|
@ -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);
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue