Store alpha channel in the output wxImage only if internal GDI+ bitmap contains it.

When converting internal bitmap to wxImage in wxGDIPlusBitmapData::ConvertToImage set up output alpha channel buffer only if source bitmap contains alpha channel values.
This commit is contained in:
Artur Wieczorek
2016-01-04 22:59:44 +01:00
parent ca52d09a03
commit 527c25b898

View File

@@ -1112,7 +1112,12 @@ wxImage wxGDIPlusBitmapData::ConvertToImage() const
const UINT h = m_bitmap->GetHeight(); const UINT h = m_bitmap->GetHeight();
wxImage img(w, h); wxImage img(w, h);
// Set up wxImage buffer for alpha channel values
// only if bitmap contains alpha channel.
if ( IsAlphaPixelFormat(m_bitmap->GetPixelFormat()) )
{
img.InitAlpha(); img.InitAlpha();
}
BitmapData bitmapData; BitmapData bitmapData;
Rect rect(0, 0, w, h); Rect rect(0, 0, w, h);
@@ -1129,6 +1134,7 @@ wxImage wxGDIPlusBitmapData::ConvertToImage() const
*imgRGB++ = (c >> 16) & 0xFF; // R *imgRGB++ = (c >> 16) & 0xFF; // R
*imgRGB++ = (c >> 8) & 0xFF; // G *imgRGB++ = (c >> 8) & 0xFF; // G
*imgRGB++ = (c >> 0) & 0xFF; // B *imgRGB++ = (c >> 0) & 0xFF; // B
if ( imgAlpha )
*imgAlpha++ = (c >> 24) & 0xFF; *imgAlpha++ = (c >> 24) & 0xFF;
} }