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:
@@ -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);
|
||||||
img.InitAlpha();
|
// Set up wxImage buffer for alpha channel values
|
||||||
|
// only if bitmap contains alpha channel.
|
||||||
|
if ( IsAlphaPixelFormat(m_bitmap->GetPixelFormat()) )
|
||||||
|
{
|
||||||
|
img.InitAlpha();
|
||||||
|
}
|
||||||
|
|
||||||
BitmapData bitmapData;
|
BitmapData bitmapData;
|
||||||
Rect rect(0, 0, w, h);
|
Rect rect(0, 0, w, h);
|
||||||
@@ -1129,7 +1134,8 @@ 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
|
||||||
*imgAlpha++ = (c >> 24) & 0xFF;
|
if ( imgAlpha )
|
||||||
|
*imgAlpha++ = (c >> 24) & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
pixels += bitmapData.Stride;
|
pixels += bitmapData.Stride;
|
||||||
|
Reference in New Issue
Block a user