X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c4e7c2aa5822f9a6e97d8d7848b95ea2eadcd98b..520e470fdd0daef09c77938db642e4583933c90d:/src/msw/dcmemory.cpp diff --git a/src/msw/dcmemory.cpp b/src/msw/dcmemory.cpp index a89b217bcb..b0e6a77f18 100644 --- a/src/msw/dcmemory.cpp +++ b/src/msw/dcmemory.cpp @@ -10,7 +10,6 @@ ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ -#pragma implementation #pragma implementation "dcmemory.h" #endif @@ -84,8 +83,19 @@ void wxMemoryDC::SelectObject(const wxBitmap& bitmap) wxFatalError("Error in wxMemoryDC::SelectObject\nBitmap is selected in another wxMemoryDC.\nDelete the first wxMemoryDC or use SelectObject(NULL)"); return; } - - m_selectedBitmap = bitmap; + + // Check if the bitmap has the correct depth for this device context + if (bitmap.Ok() && (bitmap.GetDepth() != GetDepth())) + { + // Make a new bitmap that has the correct depth. + wxBitmap newBitmap = bitmap.GetBitmapForDC(* this); + + m_selectedBitmap = newBitmap ; + } + else + { + m_selectedBitmap = bitmap; + } if (!m_selectedBitmap.Ok()) return;