From: Vadim Zeitlin Date: Wed, 18 Jun 2003 00:41:37 +0000 (+0000) Subject: better mask handling in wxBitmap to wxImage conversion (patch 754881) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/c8688869d94558c1741501a31648507cfe2f722d better mask handling in wxBitmap to wxImage conversion (patch 754881) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21219 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index dd6423fff7..af64aeb6f9 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -827,6 +827,13 @@ bool wxBitmap::CreateFromImage(const wxImage& image, int depth, WXHDC hdc ) wxImage wxBitmap::ConvertToImage() const { + // the colour used as transparent one in wxImage and the one it is replaced + // with when it really occurs in the bitmap + static const int MASK_RED = 1; + static const int MASK_GREEN = 2; + static const int MASK_BLUE = 3; + static const int MASK_BLUE_REPLACEMENT = 2; + wxImage image; wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") ); @@ -918,27 +925,39 @@ wxImage wxBitmap::ConvertToImage() const ::SetBkColor( memdc, RGB( 255, 255, 255 ) ); ::GetDIBits( memdc, hbitmap, 0, height, lpBits, lpDIBh, DIB_RGB_COLORS ); ::DeleteDC( memdc ); - // background color set to RGB(16,16,16) in consistent with wxGTK - unsigned char r=16, g=16, b=16; + // background color set to mask colour + unsigned char r=MASK_RED, g=MASK_GREEN, b=MASK_BLUE; ptdata = data; ptbits = lpBits; for( i=0; i