X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/eaeb6a3c3754be1381d87af44e36c2a947a1493c..53faea431638ee5c0013a2c888215c751fa6437b:/src/msw/dc.cpp?ds=sidebyside diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 0efde7e988..0744dc251e 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -23,7 +23,6 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#include "wx/msw/private.h" // needs to be before #include #ifdef __BORLANDC__ #pragma hdrstop @@ -46,6 +45,8 @@ #include #include +#include "wx/msw/private.h" // needs to be before #include + #if wxUSE_COMMON_DIALOGS #if wxUSE_NORLANDER_HEADERS #include @@ -57,7 +58,7 @@ #include #endif - IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) // --------------------------------------------------------------------------- // constants @@ -1254,8 +1255,12 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, const wxBitmap& bmp = source->m_selectedBitmap; mask = bmp.GetMask(); - wxCHECK_MSG( bmp.Ok() && mask, FALSE, - _T("can't blit with mask without mask") ); + if ( !(bmp.Ok() && mask && mask->GetMaskBitmap()) ) + { + // don't give assert here because this would break existing + // programs - just silently ignore useMask parameter + useMask = FALSE; + } } COLORREF old_textground = ::GetTextColor(GetHdc()); @@ -1288,16 +1293,24 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, if (useMask) { #ifdef __WIN32__ - if ( ::MaskBlt(GetHdc(), xdest, ydest, - (int)width, (int)height, - GetHdcOf(*source), xsrc, ysrc, - (HBITMAP) mask->GetMaskBitmap(), - 0, 0, MAKEROP4(SRCCOPY, PATCOPY)) != 0 ) - { - // Success - success = TRUE; - } - else + HBITMAP hbmpMask = wxInvertMask((HBITMAP)mask->GetMaskBitmap()); + + // we want the part of the image corresponding to the mask to be + // transparent, i.e. do PATCOPY there and apply dwRop elsewhere + const wxColour& colBg = m_backgroundBrush.GetColour(); + HBRUSH hbrBg = (HBRUSH)::CreateSolidBrush(wxColourToRGB(colBg)); + HBRUSH hbrOld = (HBRUSH)::SelectObject(GetHdc(), hbrBg); + + success = ::MaskBlt(GetHdc(), xdest, ydest, width, height, + GetHdcOf(*source), xsrc, ysrc, + hbmpMask, 0, 0, + MAKEROP4(PATCOPY, dwRop)) != 0; + + (void)::SelectObject(GetHdc(), hbrOld); + ::DeleteObject(hbrOld); + ::DeleteObject(hbmpMask); + + if ( !success ) #endif // Win32 { // Blit bitmap with mask