X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9ab6ee851ebc3200fa7d40381a06d27b4fac61d1..270a909e20a2c652fd816ad14407113ad0319c9d:/src/common/imagpng.cpp diff --git a/src/common/imagpng.cpp b/src/common/imagpng.cpp index 1815bcb1ba..e8d9f42c7e 100644 --- a/src/common/imagpng.cpp +++ b/src/common/imagpng.cpp @@ -96,7 +96,7 @@ LINKAGEMODE png_silent_warning(png_structp WXUNUSED(png_ptr), png_const_charp WX { } -bool wxPNGHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose) +bool wxPNGHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose, int WXUNUSED(index) ) { // VZ: as this function uses setjmp() the only fool proof error handling // method is to use goto (setjmp is not really C++ dtors friendly...) @@ -278,7 +278,7 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbos return FALSE; } - if (!verbose) png_set_error_fn(png_ptr, (png_voidp)NULL, png_silent_error, png_silent_warning); + if (!verbose) png_set_error_fn(png_ptr, (png_voidp)NULL, png_silent_error, png_silent_warning); png_infop info_ptr = png_create_info_struct(png_ptr); if (info_ptr == NULL) @@ -324,15 +324,16 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbos data[(x << 2) + 0] = *ptr++; data[(x << 2) + 1] = *ptr++; data[(x << 2) + 2] = *ptr++; - if ((data[(x << 2) + 0] == image->GetMaskRed()) && - (data[(x << 2) + 1] == image->GetMaskGreen()) && - (data[(x << 2) + 2] == image->GetMaskBlue())) + if (( !image->HasMask() ) || \ + (data[(x << 2) + 0] != image->GetMaskRed()) || \ + (data[(x << 2) + 1] != image->GetMaskGreen()) || \ + (data[(x << 2) + 2] != image->GetMaskBlue())) { - data[(x << 2) + 3] = 0; + data[(x << 2) + 3] = 255; } else { - data[(x << 2) + 3] = 255; + data[(x << 2) + 3] = 0; } } png_bytep row_ptr = data; @@ -346,7 +347,7 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbos return TRUE; } -bool wxPNGHandler::CanRead( wxInputStream& stream ) +bool wxPNGHandler::DoCanRead( wxInputStream& stream ) { unsigned char hdr[4];