From 51ddb341eeffeff2a8e2224b1efd35259d36a552 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 23 Dec 2001 01:56:08 +0000 Subject: [PATCH] sped up the mask creation by a factor of 40 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13166 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/bitmap.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 5e6f88a634..4e62f8ebd0 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -1292,6 +1292,11 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) ok = FALSE; } + // VZ: I'm leaving the old code in for now in case it is needed under Win95 + // or any other broken Windows versions but it is horribly inefficient: + // creating 100 masks for 80x80 bitmaps takes 7.8 seconds on my machine + // but only 0.2 using the new code! +#if 0 // this is not very efficient, but I can't think of a better way of doing // it for ( int w = 0; ok && (w < width); w++ ) @@ -1319,6 +1324,15 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) } } } +#else + HBRUSH hbrMask = ::CreateSolidBrush(maskColour); + HGDIOBJ hbrOld = ::SelectObject(destDC, hbrMask); + + // the ternary raster operation 0x3C004A is dest := src ^ brush + ::BitBlt(destDC, 0, 0, width, height, srcDC, 0, 0, 0x3C004A); + + ::SelectObject(destDC, hbrOld); +#endif ::SelectObject(srcDC, hbmpSrcOld); ::DeleteDC(srcDC); -- 2.47.2