From c97bec76b8ff353bc1b3c2d9840eccc3ecef1ef7 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Thu, 8 Apr 2021 00:02:13 +0200 Subject: [PATCH] Fix converting wxBitmap to wxImage (wxGTK2) Since f7247086c2 ("Fix storing wxBitmap data in GdkPixbuf", 2019-09-18), 919a4ec702 ("Fix drawing wxBitmap with mask", 2019-09-18) and other commits (see #18498, #18508) RGBA wxBitmaps with masks are drawn properly under wxGTK2 so only wxBitmap raw RGBA data should be transferred to wxImage RGBA data because mask is stored in the target wxImage separately. --- src/gtk/bitmap.cpp | 2 +- tests/graphics/bitmap.cpp | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index a1eb51a48e..0d8e35e7e0 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -836,7 +836,7 @@ wxImage wxBitmap::ConvertToImage() const // prefer pixbuf if available, it will preserve alpha and should be quicker if (HasPixbuf()) { - GdkPixbuf *pixbuf = GetPixbuf(); + GdkPixbuf *pixbuf = GetPixbufNoMask(); unsigned char* alpha = NULL; if (gdk_pixbuf_get_has_alpha(pixbuf)) { diff --git a/tests/graphics/bitmap.cpp b/tests/graphics/bitmap.cpp index d555ec395e..ef2127067a 100644 --- a/tests/graphics/bitmap.cpp +++ b/tests/graphics/bitmap.cpp @@ -318,10 +318,6 @@ TEST_CASE("BitmapTestCase::ToImage", "[bitmap][image][convertto]") } } -#if defined(__WXGTK20__) && !defined(__WXGTK3__) - // Bitmaps with both alpha and a mask don't work well in wxGTK2 so skip the test in this case. - WARN("Skipping test known not to work in wxGTK2."); -#else SECTION("RGBA bitmap with mask") { // RGBA Bitmap @@ -436,7 +432,6 @@ TEST_CASE("BitmapTestCase::ToImage", "[bitmap][image][convertto]") } CHECK(unmaskedPixelsCount == numUnmaskedPixels); } -#endif // !__WXGTK20__ } TEST_CASE("BitmapTestCase::FromImage", "[bitmap][image][convertfrom]")