]> git.saurik.com Git - wxWidgets.git/commitdiff
[ 1579793 ] numerous bug fixes when mask is used
authorRobert Roebling <robert@roebling.de>
Wed, 18 Oct 2006 17:06:11 +0000 (17:06 +0000)
committerRobert Roebling <robert@roebling.de>
Wed, 18 Oct 2006 17:06:11 +0000 (17:06 +0000)
    Corrects PNG handling and wxImage::Paste()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42092 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/image.cpp
src/common/imagpng.cpp

index ff8169fff360e4911ad30857edd7468bc495548e..a2674529dec0bd15c7957f82aeb64b074f7c5971 100644 (file)
@@ -1311,8 +1311,8 @@ void wxImage::Paste( const wxImage &image, int x, int y )
         {
             for (int i = 0; i < width; i+=3)
             {
-                if ((source_data[i]   != r) &&
-                    (source_data[i+1] != g) &&
+                if ((source_data[i]   != r) ||
+                    (source_data[i+1] != g) ||
                     (source_data[i+2] != b))
                 {
                     memcpy( target_data+i, source_data+i, 3 );
index da382259703441959b2964806727e9a5825f35a7..009f133de98c46fc8d432c4f03ae92d27987c8ba 100644 (file)
@@ -279,6 +279,7 @@ FindMaskColour(unsigned char **lines, png_uint_32 width, png_uint_32 height,
             r2 = *p++;
             g2 = *p++;
             b2 = *p++;
+            ++p; // jump over alpha
 
             wxImageHistogramEntry&
                 entry = h[wxImageHistogram:: MakeKey(r2, g2, b2)];
@@ -384,8 +385,8 @@ void CopyDataFromPNG(wxImage *image,
                         if ( IsTransparent(a) )
                         {
                             *ptrDst++ = rMask;
-                            *ptrDst++ = bMask;
                             *ptrDst++ = gMask;
+                            *ptrDst++ = bMask;
                             break;
                         }
                         // else: !transparent
@@ -452,8 +453,8 @@ void CopyDataFromPNG(wxImage *image,
                         if ( IsTransparent(a) )
                         {
                             *ptrDst++ = rMask;
-                            *ptrDst++ = bMask;
                             *ptrDst++ = gMask;
+                            *ptrDst++ = bMask;
                             break;
                         }
                         else // !transparent