Fixed creating Cairo bitmap from wxBitmap (wxMSW).

Iterating over bit values with wxAlphaPixelData sets the internal wxBitmap's "has alpha" flag but we want to left it unchanged so we have to save its original value and restore it afterward.
This commit is contained in:
Artur Wieczorek 2016-04-11 18:06:42 +02:00
parent bac5975b02
commit 0ee25aaa76

View File

@ -1413,10 +1413,17 @@ wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitm
wxUint32* data = (wxUint32*)m_buffer; wxUint32* data = (wxUint32*)m_buffer;
if ( isSrcBpp32 ) if ( isSrcBpp32 )
{
// Using wxAlphaPixelData sets (on wxMSW and wxOSX) the internal
// "has alpha" flag but we want to leave it unchanged, so we need
// to save its current value now and restore it afterwards.
#if defined(__WXMSW__) || defined(__WXOSX__)
const bool hasAlpha = bmpSource.HasAlpha();
#endif // __WXMSW__ || __WXOSX__
{ {
// use the bitmap's alpha // use the bitmap's alpha
wxAlphaPixelData wxAlphaPixelData pixData(bmpSource);
pixData(bmpSource, wxPoint(0, 0), wxSize(m_width, m_height));
wxCHECK_RET( pixData, wxT("Failed to gain raw access to bitmap data.")); wxCHECK_RET( pixData, wxT("Failed to gain raw access to bitmap data."));
wxAlphaPixelData::Iterator p(pixData); wxAlphaPixelData::Iterator p(pixData);
@ -1452,6 +1459,13 @@ wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitm
p.OffsetY(pixData, 1); p.OffsetY(pixData, 1);
} }
} }
#if defined(__WXMSW__) || defined(__WXOSX__)
// Reset "has alpha" flag back.
// (wxBitmap::UseAlpha() is used only on wxMSW and wxOSX.)
bmpSource.UseAlpha(hasAlpha);
#endif // __WXMSW__ || __WXOSX__
}
else // no alpha else // no alpha
{ {
wxNativePixelData wxNativePixelData