Fix converting wxBitmap with alpha and mask to wxImage (wxOSX)

When pixel is not masked it should be stored in the target wxImage
in non-premultiplied format.
This commit is contained in:
Artur Wieczorek
2021-01-20 19:37:12 +01:00
parent efb96a352d
commit 4590f28f7e

View File

@@ -1285,6 +1285,7 @@ wxImage wxBitmap::ConvertToImage() const
r = ((color&0x0000FF00) >> 8) ;
a = (color&0x000000FF);
#endif
bool isMasked = false;
if ( hasMask )
{
if ( *maskp++ == 0x00 )
@@ -1292,6 +1293,7 @@ wxImage wxBitmap::ConvertToImage() const
r = MASK_RED ;
g = MASK_GREEN ;
b = MASK_BLUE ;
isMasked = true;
}
else if ( r == MASK_RED && g == MASK_GREEN && b == MASK_BLUE )
b = MASK_BLUE_REPLACEMENT ;
@@ -1302,7 +1304,7 @@ wxImage wxBitmap::ConvertToImage() const
*alpha++ = a ;
#if wxOSX_USE_PREMULTIPLIED_ALPHA
// this must be non-premultiplied data
if ( !hasMask && a != 0xFF && a!= 0 )
if ( !isMasked && a != 0xFF && a!= 0 )
{
r = r * 255 / a;
g = g * 255 / a;