]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/imagpng.cpp
fixed typo
[wxWidgets.git] / src / common / imagpng.cpp
index 66e917422ac619472ba14fdff90bba0a21471017..d0da8f6111f7c64a2797c6522ab6993c7a27955a 100644 (file)
@@ -11,7 +11,7 @@
 // declarations
 // ============================================================================
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
 #pragma implementation "imagpng.h"
 #endif
 
@@ -220,14 +220,13 @@ CheckTransparency(unsigned char **lines,
                   png_uint_32 x, png_uint_32 y, png_uint_32 w, png_uint_32 h,
                   size_t numColBytes)
 {
-    // we start from (x + 1, y)
-    x++;
-
     // suppose that a mask will suffice and check all the remaining alpha
     // values to see if it does
     for ( ; y < h; y++ )
     {
-        unsigned const char *ptr = lines[y] + x;
+        // each pixel is numColBytes+1 bytes, offset into the current line by
+        // the current x position
+        unsigned const char *ptr = lines[y] + (x * (numColBytes + 1));
 
         for ( png_uint_32 x2 = x; x2 < w; x2++ )
         {
@@ -461,25 +460,27 @@ void CopyDataFromPNG(wxImage *image,
                     case Transparency_Mask:
                         if ( IsTransparent(a) )
                         {
-                            // if we couldn't find a unique colour for the mask, we
-                            // can have real pixels with the same value as the mask
-                            // and it's better to slightly change their colour than
-                            // to make them transparent
-                            if ( r == rMask && g == gMask && b == bMask )
-                            {
-                                r++;
-                            }
-
                             *ptrDst++ = rMask;
                             *ptrDst++ = bMask;
                             *ptrDst++ = gMask;
                             break;
                         }
-                        // else: !transparent
-
-                        // must be opaque then as otherwise we shouldn't be
-                        // using the mask at all
-                        wxASSERT_MSG( IsOpaque(a), _T("logic error") );
+                        else // !transparent
+                        {
+                            // must be opaque then as otherwise we shouldn't be
+                            // using the mask at all
+                            wxASSERT_MSG( IsOpaque(a), _T("logic error") );
+
+                            // if we couldn't find a unique colour for the
+                            // mask, we can have real pixels with the same
+                            // value as the mask and it's better to slightly
+                            // change their colour than to make them
+                            // transparent
+                            if ( r == rMask && g == gMask && b == bMask )
+                            {
+                                r++;
+                            }
+                        }
 
                         // fall through