From b21f9ff6f556282c598ce01faccef135271ee2a2 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 29 Sep 2019 16:24:03 +0200 Subject: [PATCH] Fix getting a sub-bitmap of wxBitmap with alpha channel and mask Since wxBitmap can have both alpha channel values and mask we have to use alpha channel (if required) in the sub-bitmap even if the mask is provided too. See #18513. --- src/osx/core/bitmap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index 2db1333d69..3f1d177f56 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -936,6 +936,8 @@ wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const double scale = GetScaleFactor(); ret.CreateScaled( rect.width, rect.height, GetDepth(), scale ); wxASSERT_MSG( ret.IsOk(), wxT("GetSubBitmap error") ); + if ( HasAlpha() ) + ret.UseAlpha() ; int destwidth = rect.width*scale ; int destheight = rect.height*scale ; @@ -989,8 +991,6 @@ wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const mask->OSXCreate( maskbuf , destwidth , destheight , rowBytes ); ret.SetMask(mask) ; } - else if ( HasAlpha() ) - ret.UseAlpha() ; return ret; }