-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Closed
Milestone
Description
- cocos2d-x version: 3.17.1
- devices test on: Win32
- developing environments
- NDK version: N/A
- Xcode version: N/A
- VS version: VS2019
Steps to Reproduce:
The current implementation of RenderTexture has several issues.
Firstly, it does not set the premultiplied alpha flag on the image created by this method:
Image* RenderTexture::newImage(bool flipImage)
{
...
image->initWithRawData(buffer, savedBufferWidth * savedBufferHeight * 4, savedBufferWidth, savedBufferHeight, 8);
}
else
{
image->initWithRawData(tempData, savedBufferWidth * savedBufferHeight * 4, savedBufferWidth, savedBufferHeight, 8);
}
...
}
The correct code would be to change the initWithRawData calls to this:
image->initWithRawData(buffer, savedBufferWidth * savedBufferHeight * 4, savedBufferWidth, savedBufferHeight, 8, true);
}
else
{
image->initWithRawData(tempData, savedBufferWidth * savedBufferHeight * 4, savedBufferWidth, savedBufferHeight, 8, true);
Secondly, there is no way to choose if you want to save the file as a non-premultiplied alpha PNG.
Reversing the PMA before saving the image is possible, and a new method can be added to do this, such as: RenderTexture::saveToFileAsNonPMA().
I'll create a pull request with the changes, along with modification of the tests to cater for this new method.
This fix may work for the following reported issues:
#18980
#18193
drelaptop, wzpan and bowenZoo
Metadata
Metadata
Assignees
Labels
No labels