mirror of https://github.com/axmolengine/axmol.git
parent
2522b1ef45
commit
cb35a48885
|
@ -431,7 +431,7 @@ bool RenderTexture::saveToFileAsNonPMA(std::string_view fileName,
|
|||
auto renderer = _director->getRenderer();
|
||||
auto saveToFileCommand = renderer->nextCallbackCommand();
|
||||
saveToFileCommand->init(_globalZOrder);
|
||||
saveToFileCommand->func = AX_CALLBACK_0(RenderTexture::onSaveToFile, this, fullpath, isRGBA, true);
|
||||
saveToFileCommand->func = AX_CALLBACK_0(RenderTexture::onSaveToFile, this, std::move(fullpath), isRGBA, true);
|
||||
|
||||
renderer->addCommand(saveToFileCommand);
|
||||
return true;
|
||||
|
@ -454,26 +454,26 @@ bool RenderTexture::saveToFile(std::string_view fileName,
|
|||
auto renderer = _director->getRenderer();
|
||||
auto saveToFileCommand = renderer->nextCallbackCommand();
|
||||
saveToFileCommand->init(_globalZOrder);
|
||||
saveToFileCommand->func = AX_CALLBACK_0(RenderTexture::onSaveToFile, this, fullpath, isRGBA, false);
|
||||
saveToFileCommand->func = AX_CALLBACK_0(RenderTexture::onSaveToFile, this, std::move(fullpath), isRGBA, false);
|
||||
|
||||
_director->getRenderer()->addCommand(saveToFileCommand);
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderTexture::onSaveToFile(std::string_view filename, bool isRGBA, bool forceNonPMA)
|
||||
void RenderTexture::onSaveToFile(std::string filename, bool isRGBA, bool forceNonPMA)
|
||||
{
|
||||
auto callbackFunc = [&, filename, isRGBA, forceNonPMA](RefPtr<Image> image) {
|
||||
auto callbackFunc = [this, _filename = std::move(filename), isRGBA, forceNonPMA](RefPtr<Image> image) {
|
||||
if (image)
|
||||
{
|
||||
if (forceNonPMA && image->hasPremultipliedAlpha())
|
||||
{
|
||||
image->reversePremultipliedAlpha();
|
||||
}
|
||||
image->saveToFile(filename, !isRGBA);
|
||||
image->saveToFile(_filename, !isRGBA);
|
||||
}
|
||||
if (_saveFileCallback)
|
||||
{
|
||||
_saveFileCallback(this, filename);
|
||||
_saveFileCallback(this, _filename);
|
||||
}
|
||||
};
|
||||
newImage(callbackFunc);
|
||||
|
|
|
@ -381,7 +381,7 @@ protected:
|
|||
void onEnd();
|
||||
void clearColorAttachment();
|
||||
|
||||
void onSaveToFile(std::string_view fileName, bool isRGBA = true, bool forceNonPMA = false);
|
||||
void onSaveToFile(std::string fileName, bool isRGBA = true, bool forceNonPMA = false);
|
||||
|
||||
bool _keepMatrix = false;
|
||||
Rect _rtTextureRect;
|
||||
|
|
|
@ -296,9 +296,10 @@ void SpriteFrameCache::insertFrame(const std::shared_ptr<SpriteSheet>& spriteShe
|
|||
|
||||
bool SpriteFrameCache::eraseFrame(std::string_view frameName)
|
||||
{
|
||||
_spriteFrames.erase(frameName); // drop SpriteFrame
|
||||
// drop SpriteFrame
|
||||
const auto itFrame = _spriteFrameToSpriteSheetMap.find(frameName);
|
||||
if (itFrame != _spriteFrameToSpriteSheetMap.end())
|
||||
bool hint = itFrame != _spriteFrameToSpriteSheetMap.end();
|
||||
if (hint)
|
||||
{
|
||||
auto& spriteSheet = itFrame->second;
|
||||
spriteSheet->full = false;
|
||||
|
@ -316,9 +317,9 @@ bool SpriteFrameCache::eraseFrame(std::string_view frameName)
|
|||
//{
|
||||
// _spriteSheets.clear();
|
||||
//}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
_spriteFrames.erase(frameName);
|
||||
return hint;
|
||||
}
|
||||
|
||||
bool SpriteFrameCache::eraseFrames(const std::vector<std::string_view>& frames)
|
||||
|
|
|
@ -102,7 +102,7 @@ void RenderTextureSave::saveImageWithPremultipliedAlpha(ax::Ref* sender)
|
|||
char png[20];
|
||||
sprintf(png, "image-pma-%d.png", counter);
|
||||
|
||||
auto callback = [&](RenderTexture* rt, std::string_view path) {
|
||||
auto callback = [this](RenderTexture* rt, std::string_view path) {
|
||||
auto sprite = Sprite::create(path);
|
||||
addChild(sprite);
|
||||
sprite->setScale(0.3f);
|
||||
|
@ -127,7 +127,7 @@ void RenderTextureSave::saveImageWithNonPremultipliedAlpha(ax::Ref* sender)
|
|||
char png[20];
|
||||
sprintf(png, "image-no-pma-%d.png", counter);
|
||||
|
||||
auto callback = [&](RenderTexture* rt, std::string_view path) {
|
||||
auto callback = [this](RenderTexture* rt, std::string_view path) {
|
||||
auto sprite = Sprite::create(path);
|
||||
addChild(sprite);
|
||||
sprite->setScale(0.3f);
|
||||
|
@ -792,7 +792,7 @@ Issue16113Test::Issue16113Test()
|
|||
text->setPosition(winSize.width / 2, winSize.height / 2);
|
||||
text->Node::visit();
|
||||
target->end();
|
||||
auto callback = [&](RenderTexture* rt, std::string_view path) { rt->release(); };
|
||||
auto callback = [this](RenderTexture* rt, std::string_view path) { rt->release(); };
|
||||
target->retain();
|
||||
target->saveToFile("issue16113.png", Image::Format::PNG, true, callback);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue