From 4590f28f7e4bb2e4a82086f9451099d6adc57ec2 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 20 Jan 2021 19:37:12 +0100 Subject: [PATCH] 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. --- src/osx/core/bitmap.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index a4a0ac70b8..b08535ee65 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -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;