From 141d9e3c20c6fc2c497ab2e5699c96442040e002 Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Mon, 13 Jun 2011 11:47:00 -0500 Subject: [PATCH] [devel] Made it possible to undefine PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED to get the same (inaccurate) output as libpng-1.5.2 and earlier. --- ANNOUNCE | 20 ++++++++++++-------- CHANGES | 4 ++++ pngrtran.c | 13 +++++++++++++ 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 161e53c37..fbabdb663 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.5.3beta11 - June 11, 2011 +Libpng 1.5.3beta12 - June 13, 2011 This is not intended to be a public release. It will be replaced within a few weeks by a public version or by another test version. @@ -9,20 +9,20 @@ Files available for download: Source files with LF line endings (for Unix/Linux) and with a "configure" script - 1.5.3beta11.tar.xz (LZMA-compressed, recommended) - 1.5.3beta11.tar.gz - 1.5.3beta11.tar.bz2 + 1.5.3beta12.tar.xz (LZMA-compressed, recommended) + 1.5.3beta12.tar.gz + 1.5.3beta12.tar.bz2 Source files with CRLF line endings (for Windows), without the "configure" script - lp153b11.7z (LZMA-compressed, recommended) - lp153b11.zip + lp153b12.7z (LZMA-compressed, recommended) + lp153b12.zip Other information: - 1.5.3beta11-README.txt - 1.5.3beta11-LICENSE.txt + 1.5.3beta12-README.txt + 1.5.3beta12-LICENSE.txt Changes since the last public release (1.5.2): @@ -181,6 +181,10 @@ Version 1.5.3beta11 [June 11, 2011] necessarily fully supportable, particularly png_strncpy and png_snprintf. Added log option to pngvalid.c and attempted to improve gamma messages. +Version 1.5.3beta12 [June 13, 2011] + Made it possible to undefine PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED + to get the same (inaccurate) output as libpng-1.5.2 and earlier. + Send comments/corrections/commendations to png-mng-implement at lists.sf.net: (subscription required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement diff --git a/CHANGES b/CHANGES index f42bac020..c9571eae7 100644 --- a/CHANGES +++ b/CHANGES @@ -3443,6 +3443,10 @@ Version 1.5.3beta11 [June 11, 2011] Removed string/memory macros that are no longer used and are not necessarily fully supportable, particularly png_strncpy and png_snprintf. Added log option to pngvalid.c and attempted to improve gamma messages. + +Version 1.5.3beta12 [June 13, 2011] + Made it possible to undefine PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED + to get the same (inaccurate) output as libpng-1.5.2 and earlier. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/pngrtran.c b/pngrtran.c index 86c0558a5..5fb6f4840 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -1439,7 +1439,11 @@ png_init_read_transformations(png_structp png_ptr) * The PNG_BACKGROUND_EXPAND code above does not expand to 16 bits at * present, so that case is ok (until do_expand_16 is moved.) */ +#ifdef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED # define CHOP(x) (x)=((png_uint_16)(((png_uint_32)(x)*255+32895) >> 16)) +#else +# define CHOP(x) ((png_uint_16)((2*(png_uint_32)(x) + 257)/514)) +#endif CHOP(png_ptr->background.red); CHOP(png_ptr->background.green); CHOP(png_ptr->background.blue); @@ -2494,9 +2498,18 @@ png_do_chop(png_row_infop row_info, png_bytep row) * * (V * 255 + 32895) >> 16 */ + +#ifdef PNG_LEGACY_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED + *dp = *sp + ((((int)(*(sp + 1)) - *sp) > 128) ? 1 : 0); +#else png_int_32 tmp = *sp++; /* must be signed! */ +# ifdef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED tmp += (((int)*sp++ - tmp + 128) * 65535) >> 24; +# else + sp++; +# endif *dp++ = (png_byte)tmp; +#endif } row_info->bit_depth = 8;