X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bdffd806c3441e1d640c445ff785f5f1ea10298d..05159a2750ed2cc5945a85bc5fc6849ad1a30e75:/src/common/imagpng.cpp diff --git a/src/common/imagpng.cpp b/src/common/imagpng.cpp index 9320f2f371..7e33316411 100644 --- a/src/common/imagpng.cpp +++ b/src/common/imagpng.cpp @@ -111,8 +111,8 @@ void PNGLINKAGEMODE wx_png_error(png_structp png_ptr, png_const_charp message) { wxPNGInfoStruct *info = WX_PNG_INFO(png_ptr); - if ( info->verbose ) - wxLogError(wxString(message)); + if (info->verbose) + wxLogError( wxString::FromAscii(message) ); #ifdef USE_FAR_KEYWORD { @@ -129,8 +129,8 @@ void PNGLINKAGEMODE wx_png_warning(png_structp png_ptr, png_const_charp message) { wxPNGInfoStruct *info = WX_PNG_INFO(png_ptr); - if ( info->verbose ) - wxLogWarning(wxString(message)); + if (info->verbose) + wxLogWarning( wxString::FromAscii(message) ); } } // extern "C" @@ -188,6 +188,10 @@ bool wxPNGHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose if (color_type == PNG_COLOR_TYPE_PALETTE) png_set_expand( png_ptr ); + // Fix for Bug [ 439207 ] Monochrome PNG images come up black + if (bit_depth < 8) + png_set_expand( png_ptr ); + png_set_strip_16( png_ptr ); png_set_packing( png_ptr ); if (png_get_valid( png_ptr, info_ptr, PNG_INFO_tRNS)) @@ -418,9 +422,10 @@ bool wxPNGHandler::DoCanRead( wxInputStream& stream ) { unsigned char hdr[4]; - stream.Read(hdr, 4); - stream.SeekI(-4, wxFromCurrent); - return (hdr[0] == 0x89 && hdr[1] == 'P' && hdr[2] == 'N' && hdr[3] == 'G'); + if ( !stream.Read(hdr, WXSIZEOF(hdr)) ) + return FALSE; + + return memcmp(hdr, "\211PNG", WXSIZEOF(hdr)) == 0; } #endif // wxUSE_STREAMS