diff --git a/ANNOUNCE b/ANNOUNCE index fb838ecf5..eb38d20c2 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -69,6 +69,8 @@ Version 1.6.3beta05 [May 8, 2013] Added a call to png_set_packing() Initialize dimension values so if sscanf fails at least we have known invalid values. + Attempt to detect configuration issues with pngdeflate, which requires + both the correct libpng and the correct zlib to function correctly. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index b7cd0a9e2..d022e237d 100644 --- a/CHANGES +++ b/CHANGES @@ -4552,6 +4552,8 @@ Version 1.6.3beta05 [May 8, 2013] Added a call to png_set_packing() Initialize dimension values so if sscanf fails at least we have known invalid values. + Attempt to detect configuration issues with pngdeflate, which requires + both the correct libpng and the correct zlib to function correctly. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/Makefile.am b/Makefile.am index 3f714ff98..9b1f9edf4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -188,7 +188,8 @@ endif $(srcdir)/scripts/pnglibconf.h.prebuilt: @echo "Attempting to build $@" >&2 @echo "This is a machine generated file, but if you want to make" >&2 - @echo "a new one simply make 'scripts/pnglibconf.out' and copy that" >&2 + @echo "a new one simply make 'scripts/pnglibconf.out', copy that" >&2 + @echo "AND set PNG_ZLIB_VERNUM to 0 (you MUST do this)" >&2 @exit 1 # The following is necessary to ensure that the local pnglibconf.h is used, not diff --git a/contrib/tools/pngdeflate.c b/contrib/tools/pngdeflate.c index 39562b3e1..ff9fdb430 100644 --- a/contrib/tools/pngdeflate.c +++ b/contrib/tools/pngdeflate.c @@ -25,20 +25,19 @@ # include "../../png.h" #endif -#if PNG_LIBPNG_VER < 10600 /* 1.6.0 */ -# error pngdeflate will not work with libpng versions prior to 1.6 +#if PNG_LIBPNG_VER < 10603 /* 1.6.3 */ +# error pngdeflate will not work with libpng versions prior to 1.6.3 #endif #ifdef PNG_READ_SUPPORTED #include #ifndef PNG_MAXIMUM_INFLATE_WINDOW -# if PNG_LIBPNG_VER != 10600 && PNG_LIBPNG_VER != 10601 && \ - PNG_LIBPNG_VER != 10602 -# error pngdeflate not supported in this libpng version -# endif +# error pngdeflate not supported in this libpng version #endif +#if PNG_ZLIB_VERNUM >= 0x1240 + /* Copied from pngpriv.h */ #ifdef __cplusplus # define png_voidcast(type, value) static_cast(value) @@ -726,8 +725,8 @@ fix_one(FILE *fp, FILE *fpIn, IDAT_info *info, png_uint_32 max_IDAT, int strip) break; /* Fall trhough */ - default: /* Keep only IHDR, PLTE */ - if (tag == png_IHDR || tag == png_PLTE) + default: /* Keep only IHDR, PLTE, tRNS */ + if (tag == png_IHDR || tag == png_PLTE || tag == png_tRNS) break; skip = 1; @@ -994,8 +993,8 @@ usage(const char *prog, int rc) # endif " --optimize (-o): Find the smallest deflate window size for the file.\n" " Also outputs a summary for each file.\n" - " --strip (-s): Remove chunks except for IHDR, PLTE, IEND, gAMA, sRGB.\n" - " If given twice remove gAMA and sRGB as well.\n" + " --strip (-s): Remove chunks except for IHDR, PLTE, IEND, tRNS, gAMA,\n" + " sRGB. If given twice remove gAMA and sRGB as well.\n" " --errors (-e): Output errors from libpng (except too-far-back).\n"); fprintf(stderr, " --warnings (-w): Output warnings from libpng.\n" @@ -1169,6 +1168,16 @@ main(int argc, const char **argv) return err != 0; } +#else /* PNG_ZLIB_VERNUM < 0x1240 */ +int +main(void) +{ + fprintf(stderr, "pngdeflate needs libpng with a zlib >=1.2.4 (not 0x%x)\n", + PNG_ZLIB_VERNUM); + return 77; +} +#endif /* PNG_ZLIB_VERNUM */ + #else /* No read support */ int diff --git a/pngrutil.c b/pngrutil.c index 34687a0f2..133cf97bf 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -367,7 +367,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) */ { int ret; /* zlib return code */ -# if ZLIB_VERNUM >= 0x1240 +# if PNG_ZLIB_VERNUM >= 0x1240 # if defined(PNG_SET_OPTION_SUPPORTED) && \ defined(PNG_MAXIMUM_INFLATE_WINDOW) @@ -394,7 +394,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) { -# if ZLIB_VERNUM < 0x1240 +# if PNG_ZLIB_VERNUM < 0x1240 ret = inflateReset(&png_ptr->zstream); # else ret = inflateReset2(&png_ptr->zstream, window_bits); @@ -403,7 +403,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) else { -# if ZLIB_VERNUM < 0x1240 +# if PNG_ZLIB_VERNUM < 0x1240 ret = inflateInit(&png_ptr->zstream); # else ret = inflateInit2(&png_ptr->zstream, window_bits); diff --git a/scripts/pnglibconf.dfa b/scripts/pnglibconf.dfa index 2d1744eab..aed476128 100755 --- a/scripts/pnglibconf.dfa +++ b/scripts/pnglibconf.dfa @@ -238,6 +238,7 @@ option ARM_NEON_CHECK disabled enables ARM_NEON setting Z_DEFAULT_COMPRESSION default @Z_DEFAULT_COMPRESSION setting Z_DEFAULT_STRATEGY default @Z_FILTERED setting Z_DEFAULT_NOFILTER_STRATEGY default @Z_DEFAULT_STRATEGY +setting ZLIB_VERNUM default @ZLIB_VERNUM setting TEXT_Z_DEFAULT_COMPRESSION default @Z_DEFAULT_COMPRESSION setting TEXT_Z_DEFAULT_STRATEGY default @Z_DEFAULT_STRATEGY diff --git a/scripts/pnglibconf.h.prebuilt b/scripts/pnglibconf.h.prebuilt index 6f90f4ce8..feedc7743 100644 --- a/scripts/pnglibconf.h.prebuilt +++ b/scripts/pnglibconf.h.prebuilt @@ -202,6 +202,7 @@ #define PNG_TEXT_Z_DEFAULT_STRATEGY 0 #define PNG_WEIGHT_SHIFT 8 #define PNG_ZBUF_SIZE 8192 +#define PNG_ZLIB_VERNUM 0 /* unknown */ #define PNG_Z_DEFAULT_COMPRESSION (-1) #define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0 #define PNG_Z_DEFAULT_STRATEGY 1