From 7e7f40ed5f201c4e83624af00adb842b5d4544b3 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Mon, 28 Feb 2005 17:28:43 +0000 Subject: [PATCH] mask access row bytes fixed git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32472 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/bitmap.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mac/carbon/bitmap.cpp b/src/mac/carbon/bitmap.cpp index bd373e6ef1..b661b95f8f 100644 --- a/src/mac/carbon/bitmap.cpp +++ b/src/mac/carbon/bitmap.cpp @@ -1016,6 +1016,7 @@ wxImage wxBitmap::ConvertToImage() const bool hasAlpha = false ; bool hasMask = false ; + int maskBytesPerRow = 0 ; unsigned char *alpha = NULL ; unsigned char *mask = NULL ; if ( HasAlpha() ) @@ -1027,6 +1028,7 @@ wxImage wxBitmap::ConvertToImage() const { hasMask = true ; mask = (unsigned char*) GetMask()->GetRawAccess() ; + maskBytesPerRow = GetMask()->GetBytesPerRow() ; } if ( hasAlpha ) @@ -1044,8 +1046,9 @@ wxImage wxBitmap::ConvertToImage() const static const int MASK_BLUE = 3; static const int MASK_BLUE_REPLACEMENT = 2; - for (int yy = 0; yy < height; yy++) + for (int yy = 0; yy < height; yy++ , mask += maskBytesPerRow ) { + unsigned char * maskp = mask ; for (int xx = 0; xx < width; xx++) { long color = *((long*) source) ; @@ -1055,7 +1058,7 @@ wxImage wxBitmap::ConvertToImage() const unsigned char b = (color&0x000000FF); if ( hasMask ) { - if ( *mask++ == 0 ) + if ( *maskp++ == 0 ) { if ( r == MASK_RED && g == MASK_GREEN && b == MASK_BLUE ) b = MASK_BLUE_REPLACEMENT ; -- 2.45.2