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.
This commit is contained in:
Artur Wieczorek
2019-09-29 16:24:03 +02:00
parent 93f1384f7e
commit b21f9ff6f5

View File

@@ -936,6 +936,8 @@ wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const
double scale = GetScaleFactor(); double scale = GetScaleFactor();
ret.CreateScaled( rect.width, rect.height, GetDepth(), scale ); ret.CreateScaled( rect.width, rect.height, GetDepth(), scale );
wxASSERT_MSG( ret.IsOk(), wxT("GetSubBitmap error") ); wxASSERT_MSG( ret.IsOk(), wxT("GetSubBitmap error") );
if ( HasAlpha() )
ret.UseAlpha() ;
int destwidth = rect.width*scale ; int destwidth = rect.width*scale ;
int destheight = rect.height*scale ; int destheight = rect.height*scale ;
@@ -989,8 +991,6 @@ wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const
mask->OSXCreate( maskbuf , destwidth , destheight , rowBytes ); mask->OSXCreate( maskbuf , destwidth , destheight , rowBytes );
ret.SetMask(mask) ; ret.SetMask(mask) ;
} }
else if ( HasAlpha() )
ret.UseAlpha() ;
return ret; return ret;
} }