Update transparency flag for wxBitmap created from wxIcon

Just created wxBitmap has "hasAlpha" flag set to false so it needs to be modified if source wxIcon contains transparency values.

Closes #17953.
This commit is contained in:
Artur Wieczorek
2017-09-22 09:29:41 +02:00
parent 4d388e351c
commit 3d5e84b229

View File

@@ -834,20 +834,22 @@ wxBitmapRefData::~wxBitmapRefData()
bool wxBitmap::CopyFromIcon(const wxIcon& icon) bool wxBitmap::CopyFromIcon(const wxIcon& icon)
{ {
bool created = false ;
int w = icon.GetWidth() ; int w = icon.GetWidth() ;
int h = icon.GetHeight() ; int h = icon.GetHeight() ;
Create( w , h ) ; if ( Create( w, h ) )
if ( !created )
{ {
wxMemoryDC dc ; wxMemoryDC dc ;
dc.SelectObject( *this ) ; dc.SelectObject( *this ) ;
dc.DrawIcon( icon , 0 , 0 ) ; dc.DrawIcon( icon , 0 , 0 ) ;
dc.SelectObject( wxNullBitmap ) ; dc.SelectObject( wxNullBitmap ) ;
// Assume 32 bpp icon has transparency values
UseAlpha(icon.GetDepth() == 32);
return true;
} }
return true; return false;
} }
wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits) wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits)