X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/36308e0e02bc392eaf9bdb34dbfec048b0d13c9f..77c5e9230e558873be25c8a5472b9b9038b03466:/src/common/imagpng.cpp diff --git a/src/common/imagpng.cpp b/src/common/imagpng.cpp index 66e917422a..d0da8f6111 100644 --- a/src/common/imagpng.cpp +++ b/src/common/imagpng.cpp @@ -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