/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
-#pragma implementation
#pragma implementation "dcmemory.h"
#endif
{
m_hDC = (WXHDC) ::CreateCompatibleDC(NULL);
m_ok = (m_hDC != 0);
+ m_bOwnsDC = TRUE;
SetBrush(*wxWHITE_BRUSH);
SetPen(*wxBLACK_PEN);
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;
m_selectedBitmap.SetSelectedInto(this);
-#if DEBUG > 1
- wxDebugMsg("wxMemoryDC::SelectObject: Selecting HBITMAP %X\n", m_selectedBitmap.GetHBITMAP());
-#endif
- HBITMAP bm = ::SelectObject((HDC) m_hDC, (HBITMAP) m_selectedBitmap.GetHBITMAP());
+ HBITMAP bm = (HBITMAP) ::SelectObject((HDC) m_hDC, (HBITMAP) m_selectedBitmap.GetHBITMAP());
if (bm == ERROR)
{