Don't change bitmap depth in wxMSW when copying it.
Sometimes, creating a DDB may fail to create the bitmap of the requested depth and so a copy of wxBitmap could have a different depth than the original wxBitmap. Avoid this problem by falling back on using DIB if DDB with the right depth couldn't be created. Closes #11640. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76196 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
fee2d299b1
commit
338cf327b0
@ -243,6 +243,28 @@ wxBitmapRefData::wxBitmapRefData(const wxBitmapRefData& data)
|
||||
{
|
||||
wxDIB dib((HBITMAP)(data.m_hBitmap));
|
||||
CopyFromDIB(dib);
|
||||
BITMAP bm;
|
||||
if ( ::GetObject(m_hBitmap, sizeof(bm), &bm) != sizeof(bm) )
|
||||
{
|
||||
wxLogLastError(wxT("GetObject(hBitmap@wxBitmapRefData)"));
|
||||
}
|
||||
else if ( m_depth != bm.bmBitsPixel )
|
||||
{
|
||||
// We got DDB with a different colour depth then we wanted, so we
|
||||
// can't use it and need to continue using the DIB instead.
|
||||
wxDIB dibDst(m_width, m_height, m_depth);
|
||||
if ( dibDst.IsOk() )
|
||||
{
|
||||
memcpy(dibDst.GetData(), dib.GetData(),
|
||||
wxDIB::GetLineSize(m_width, m_depth)*m_height);
|
||||
AssignDIB(dibDst);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Nothing else left to do...
|
||||
m_depth = bm.bmBitsPixel;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // wxUSE_WXDIB
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user