Fix wxMSW toolbar if using mix of alpha and masks
If the user mixes bitmaps with alpha channel and without it, wxMSW
toolbar rendered the masked bitmap with black background due to changes
in 195df9af7f
In such case, convert bitmaps that don't have an alpha channel into ones
that do so that they are all consistent and can use the same rendering
method.
Fixes #17795.
This commit is contained in:
@@ -838,7 +838,7 @@ bool wxToolBar::Realize()
|
||||
wxToolBarToolBase *tool = node->GetData();
|
||||
if ( tool->IsButton() )
|
||||
{
|
||||
const wxBitmap& bmp = tool->GetNormalBitmap();
|
||||
wxBitmap bmp = tool->GetNormalBitmap();
|
||||
|
||||
const int w = bmp.GetWidth();
|
||||
const int h = bmp.GetHeight();
|
||||
@@ -848,6 +848,17 @@ bool wxToolBar::Realize()
|
||||
int xOffset = wxMax(0, (m_defaultWidth - w)/2);
|
||||
int yOffset = wxMax(0, (m_defaultHeight - h)/2);
|
||||
|
||||
#if wxUSE_IMAGE
|
||||
// If a mix of icons with alpha and without is used,
|
||||
// convert them all to use alpha.
|
||||
if (bitmap.HasAlpha() && !bmp.HasAlpha())
|
||||
{
|
||||
wxImage img = bmp.ConvertToImage();
|
||||
img.InitAlpha();
|
||||
bmp = wxBitmap(img);
|
||||
}
|
||||
#endif
|
||||
|
||||
// notice the last parameter: do use mask
|
||||
dcAllButtons.DrawBitmap(bmp, x + xOffset, yOffset, true);
|
||||
|
||||
|
Reference in New Issue
Block a user