You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added support for saving images with non-premultiplied alpha (#19782)
* Added RenderTexture::saveToFileAsNonPMA() to save images without PMA.
Set the PMA parameter to true when calling initWithRawData() inside RenderTexture::newImage(), since textures are PMA.
Renamed Image::premultipliedAlpha() to Image::premultiplyAlpha() to better reflect it's action, and made it public.
Added Image::reversePremultipliedAlpha() to allow the reversing of the PMA.
Updated CCImage-ios.mm to set the correct bitmapInfo for PMA and non-PMA images before saving a file.
Updated RenderTextureTest::RenderTextureSave() to cater for non-PMA file saving.
* [CCImage-ios.mm] Fixed indentation.
/** saves the texture into a file in non-PMA. The format could be JPG or PNG. The file will be saved in the Documents folder.
176
+
Returns true if the operation is successful.
177
+
* Notes: since v3.x, saveToFile will generate a custom command, which will be called in the following render->render().
178
+
* So if this function is called in a event handler, the actual save file will be called in the next frame. If we switch to a different scene, the game will crash.
179
+
* To solve this, add Director::getInstance()->getRenderer()->render(); after this function.
180
+
*
181
+
* @param filename The file name.
182
+
* @param format The image format.
183
+
* @param isRGBA The file is RGBA or not.
184
+
* @param callback When the file is save finished,it will callback this function.
185
+
* @return Returns true if the operation is successful.
0 commit comments