Ensure that a copy of a DIB wxBitmap remains a DIB in wxMSW
Creating a DDB from DIB with alpha doesn't work correctly due to using premultiplied alpha for the latter, but not for the former, and while we could convert it, it seems to be even better to just preserve the type of the original bitmap, as this would seem to be expected when making a copy, after all. This commit is best viewed ignoring whitespace-only changes.
This commit is contained in:
@@ -232,6 +232,21 @@ wxBitmapRefData::wxBitmapRefData(const wxBitmapRefData& data)
|
|||||||
if ( data.m_hBitmap )
|
if ( data.m_hBitmap )
|
||||||
{
|
{
|
||||||
wxDIB dib((HBITMAP)(data.m_hBitmap));
|
wxDIB dib((HBITMAP)(data.m_hBitmap));
|
||||||
|
|
||||||
|
// Cloning a DIB should create a DIB, while cloning a DDB should create
|
||||||
|
// a DDB, so check what do we have.
|
||||||
|
if ( data.m_isDIB )
|
||||||
|
{
|
||||||
|
const int w = dib.GetWidth();
|
||||||
|
const int h = dib.GetHeight();
|
||||||
|
const int d = dib.GetDepth();
|
||||||
|
|
||||||
|
wxDIB dibDst(w, h, d);
|
||||||
|
memcpy(dibDst.GetData(), dib.GetData(), wxDIB::GetLineSize(w, d)*h);
|
||||||
|
InitFromDIB(dibDst);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// DDB obtained from CopyFromDIB() can have different
|
// DDB obtained from CopyFromDIB() can have different
|
||||||
// colour depth than source DIB so we need to check it.
|
// colour depth than source DIB so we need to check it.
|
||||||
CopyFromDIB(dib);
|
CopyFromDIB(dib);
|
||||||
@@ -253,6 +268,7 @@ wxBitmapRefData::wxBitmapRefData(const wxBitmapRefData& data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif // wxUSE_WXDIB
|
#endif // wxUSE_WXDIB
|
||||||
|
|
||||||
// Ensure this is done after the block above otherwise if the color depth didn't match we'll lose the mask
|
// Ensure this is done after the block above otherwise if the color depth didn't match we'll lose the mask
|
||||||
|
|||||||
Reference in New Issue
Block a user