diff options
author | George Hazan <ghazan@miranda.im> | 2019-02-07 23:58:40 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-02-07 23:58:40 +0300 |
commit | bd864aa049acee3bd236858b29ab5e219bf79b62 (patch) | |
tree | 412d8cafc87f897244b2033cd4c9eb8f693f3315 /libs/freeimage/src/FreeImage/PluginPNG.cpp | |
parent | 62385245de7390d630cdd1459d13c69fd315a302 (diff) |
FreeImage: update to 3.18.0
Diffstat (limited to 'libs/freeimage/src/FreeImage/PluginPNG.cpp')
-rw-r--r-- | libs/freeimage/src/FreeImage/PluginPNG.cpp | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/libs/freeimage/src/FreeImage/PluginPNG.cpp b/libs/freeimage/src/FreeImage/PluginPNG.cpp index 0753192140..c64f12d465 100644 --- a/libs/freeimage/src/FreeImage/PluginPNG.cpp +++ b/libs/freeimage/src/FreeImage/PluginPNG.cpp @@ -1,9 +1,9 @@ -// ========================================================== +// ========================================================== // PNG Loader and Writer // // Design and implementation by // - Floris van den Berg (flvdberg@wxs.nl) -// - Herve Drolon (drolon@infonie.fr) +// - Hervé Drolon (drolon@infonie.fr) // - Detlev Vendt (detlev.vendt@brillit.de) // - Aaron Shumate (trek@startreker.com) // - Tanner Helland (tannerhelland@users.sf.net) @@ -50,6 +50,12 @@ typedef struct { } fi_ioStructure, *pfi_ioStructure; // ========================================================== +// Plugin Interface +// ========================================================== + +static int s_format_id; + +// ========================================================== // libpng interface // ========================================================== @@ -76,8 +82,8 @@ _FlushProc(png_structp png_ptr) { static void error_handler(png_structp png_ptr, const char *error) { - (png_structp)png_ptr; - throw error; + FreeImage_OutputMessageProc(s_format_id, error); + png_longjmp(png_ptr, 1); } // in FreeImage warnings disabled @@ -234,12 +240,6 @@ WriteMetadata(png_structp png_ptr, png_infop info_ptr, FIBITMAP *dib) { } // ========================================================== -// Plugin Interface -// ========================================================== - -static int s_format_id; - -// ========================================================== // Plugin Implementation // ========================================================== @@ -548,11 +548,13 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { // init the IO - png_set_read_fn(png_ptr, &fio, _ReadProc); + png_set_read_fn(png_ptr, &fio, _ReadProc); + + // PNG errors will be redirected here - if (setjmp(png_jmpbuf(png_ptr))) { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return NULL; + if (setjmp(png_jmpbuf(png_ptr))) { + // assume error_handler was called before by the PNG library + throw((const char*)NULL); } // because we have already read the signature... @@ -789,7 +791,9 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { if (dib) { FreeImage_Unload(dib); } - FreeImage_OutputMessageProc(s_format_id, text); + if (NULL != text) { + FreeImage_OutputMessageProc(s_format_id, text); + } return NULL; } @@ -990,6 +994,8 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void FIICCPROFILE *iccProfile = FreeImage_GetICCProfile(dib); if (iccProfile->size && iccProfile->data) { + // skip ICC profile check + png_set_option(png_ptr, PNG_SKIP_sRGB_CHECK_PROFILE, 1); png_set_iCCP(png_ptr, info_ptr, "Embedded Profile", 0, (png_const_bytep)iccProfile->data, iccProfile->size); } |