X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e9c4b1a2b5b926ced938130b2694b869403397cc..9e855852c1bc24ddd49b69df5290111022a96093:/src/common/imagpng.cpp?ds=sidebyside diff --git a/src/common/imagpng.cpp b/src/common/imagpng.cpp index e200c00b6d..b3b7482131 100644 --- a/src/common/imagpng.cpp +++ b/src/common/imagpng.cpp @@ -7,25 +7,30 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "image.h" -#endif +/* + We don't put pragma implement in this file because it is already present in + src/common/image.cpp +*/ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ -#pragma hdrstop + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/defs.h" #endif +#if wxUSE_LIBPNG + #include "wx/image.h" #include "wx/bitmap.h" #include "wx/debug.h" #include "wx/log.h" #include "wx/app.h" -#if wxUSE_LIBPNG -#include "../png/png.h" -#endif +#include "png.h" #include "wx/filefn.h" #include "wx/wfstream.h" #include "wx/intl.h" @@ -48,14 +53,12 @@ // wxPNGHandler //----------------------------------------------------------------------------- -#if wxUSE_LIBPNG - #if !USE_SHARED_LIBRARIES IMPLEMENT_DYNAMIC_CLASS(wxPNGHandler,wxImageHandler) #endif - #if wxUSE_STREAMS + static void _PNG_stream_reader( png_structp png_ptr, png_bytep data, png_size_t length ) { ((wxInputStream*) png_get_io_ptr( png_ptr )) -> Read(data, length); @@ -71,7 +74,7 @@ bool wxPNGHandler::LoadFile( wxImage *image, wxInputStream& stream ) // VZ: as this function uses setjmp() the only fool proof error handling // method is to use goto (setjmp is not really C++ dtors friendly...) - unsigned char **lines = (unsigned char **) NULL; + unsigned char **lines; unsigned int i; png_infop info_ptr = (png_infop) NULL; @@ -82,17 +85,17 @@ bool wxPNGHandler::LoadFile( wxImage *image, wxInputStream& stream ) (png_error_ptr) NULL, (png_error_ptr) NULL ); if (!png_ptr) - goto error; + goto error_nolines; info_ptr = png_create_info_struct( png_ptr ); if (!info_ptr) - goto error; + goto error_nolines; if (setjmp(png_ptr->jmpbuf)) - goto error; + goto error_nolines; if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - goto error; + goto error_nolines; png_set_read_fn( png_ptr, &stream, _PNG_stream_reader); @@ -114,11 +117,11 @@ bool wxPNGHandler::LoadFile( wxImage *image, wxInputStream& stream ) image->Create( width, height ); if (!image->Ok()) - goto error; + goto error_nolines; lines = (unsigned char **)malloc( height * sizeof(unsigned char *) ); if (lines == NULL) - goto error; + goto error_nolines; for (i = 0; i < height; i++) { @@ -206,8 +209,10 @@ bool wxPNGHandler::LoadFile( wxImage *image, wxInputStream& stream ) } return TRUE; - -error: + + error_nolines: + lines = NULL; // called from before it was set + error: wxLogError(_("Couldn't load a PNG image - probably file is corrupted.")); if ( image->Ok() ) @@ -308,9 +313,10 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream ) } return TRUE; } -#endif // wxUSE_STREAMS -#endif +#endif + // wxUSE_STREAMS -// wxUSE_LIBPNG +#endif + // wxUSE_LIBPNG