MCPcopy Create free account
hub / github.com/axmolengine/axmol / onSaveToFile

Method onSaveToFile

core/2d/RenderTexture.cpp:488–525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486}
487
488void RenderTexture::onSaveToFile(std::string filename, bool isRGBA, bool forceNonPMA)
489{
490 auto callbackFunc = [this, _filename = std::move(filename), isRGBA, forceNonPMA](RefPtr<Image> image) {
491 if (image)
492 {
493 if (forceNonPMA && image->hasPremultipliedAlpha())
494 {
495 _director->getJobSystem()->enqueue([self = RefPtr(this), image, _filename, isRGBA, forceNonPMA]() {
496 image->reversePremultipliedAlpha();
497
498 Director::getInstance()->getScheduler()->runOnAxmolThread([self, image, _filename, isRGBA] {
499 image->saveToFile(_filename, !isRGBA);
500 if (self->_saveFileCallback)
501 {
502 self->_saveFileCallback(self, _filename);
503 }
504 });
505 });
506 }
507 else
508 {
509 image->saveToFile(_filename, !isRGBA);
510 if (_saveFileCallback)
511 {
512 _saveFileCallback(this, _filename);
513 }
514 }
515 }
516 else
517 {
518 if (_saveFileCallback)
519 {
520 _saveFileCallback(this, _filename);
521 }
522 }
523 };
524 newImage(callbackFunc);
525}
526
527/* get buffer as Image */
528void RenderTexture::newImage(std::function<void(RefPtr<Image>)> imageCallback, bool eglCacheHint)

Callers

nothing calls this directly

Calls 7

getInstanceFunction · 0.85
hasPremultipliedAlphaMethod · 0.80
runOnAxmolThreadMethod · 0.80
RefPtrClass · 0.50
enqueueMethod · 0.45
saveToFileMethod · 0.45

Tested by

no test coverage detected