diff --git a/src/msw/graphics.cpp b/src/msw/graphics.cpp index cfb7ad1acc..6c528a4d2c 100644 --- a/src/msw/graphics.cpp +++ b/src/msw/graphics.cpp @@ -1112,7 +1112,12 @@ wxImage wxGDIPlusBitmapData::ConvertToImage() const const UINT h = m_bitmap->GetHeight(); 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; Rect rect(0, 0, w, h); @@ -1129,7 +1134,8 @@ wxImage wxGDIPlusBitmapData::ConvertToImage() const *imgRGB++ = (c >> 16) & 0xFF; // R *imgRGB++ = (c >> 8) & 0xFF; // G *imgRGB++ = (c >> 0) & 0xFF; // B - *imgAlpha++ = (c >> 24) & 0xFF; + if ( imgAlpha ) + *imgAlpha++ = (c >> 24) & 0xFF; } pixels += bitmapData.Stride;