зеркало из https://github.com/microsoft/cocos2d-x.git
Make the API more extendable
This commit is contained in:
Родитель
7e99121af7
Коммит
33fb1dd050
|
@ -409,14 +409,32 @@ void RenderTexture::visit(Renderer *renderer, const Mat4 &parentTransform, uint3
|
|||
_orderOfArrival = 0;
|
||||
}
|
||||
|
||||
bool RenderTexture::saveToFile(const std::string& filename)
|
||||
bool RenderTexture::saveToFile(const std::string& filename, bool isRGBA)
|
||||
{
|
||||
return saveToFile(filename,Image::Format::JPG);
|
||||
std::string basename(filename);
|
||||
std::transform(basename.begin(), basename.end(), basename.begin(), ::tolower);
|
||||
|
||||
if (basename.find(".png") != std::string::npos)
|
||||
{
|
||||
return saveToFile(filename, Image::Format::PNG, isRGBA);
|
||||
}
|
||||
else if (basename.find(".jpg") != std::string::npos)
|
||||
{
|
||||
if (isRGBA) CCLOG("RGBA is not supported for JPG format.");
|
||||
return saveToFile(filename, Image::Format::JPG, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
CCLOG("Only PNG and JPG format are supported now!");
|
||||
}
|
||||
|
||||
return saveToFile(filename, Image::Format::JPG, false);
|
||||
}
|
||||
bool RenderTexture::saveToFile(const std::string& fileName, Image::Format format, bool isRGBA)
|
||||
{
|
||||
CCASSERT(format == Image::Format::JPG || format == Image::Format::PNG,
|
||||
"the image can only be saved as JPG or PNG format");
|
||||
if (isRGBA && format == Image::Format::JPG) CCLOG("RGBA is not supported for JPG format");
|
||||
|
||||
std::string fullpath = FileUtils::getInstance()->getWritablePath() + fileName;
|
||||
_saveToFileCommand.init(_globalZOrder);
|
||||
|
|
|
@ -103,7 +103,7 @@ public:
|
|||
/** saves the texture into a file using JPEG format. The file will be saved in the Documents folder.
|
||||
Returns true if the operation is successful.
|
||||
*/
|
||||
bool saveToFile(const std::string& filename);
|
||||
bool saveToFile(const std::string& filename, bool isRGBA = true);
|
||||
|
||||
/** saves the texture into a file. The format could be JPG or PNG. The file will be saved in the Documents folder.
|
||||
Returns true if the operation is successful.
|
||||
|
|
Загрузка…
Ссылка в новой задаче