diff --git a/ANNOUNCE b/ANNOUNCE index 2a7093283..3d4466501 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.5.4beta05 - June 16, 2011 +Libpng 1.5.4beta04 - June 16, 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.4beta05.tar.xz (LZMA-compressed, recommended) - 1.5.4beta05.tar.gz - 1.5.4beta05.tar.bz2 + 1.5.4beta04.tar.xz (LZMA-compressed, recommended) + 1.5.4beta04.tar.gz + 1.5.4beta04.tar.bz2 Source files with CRLF line endings (for Windows), without the "configure" script - lp154b05.7z (LZMA-compressed, recommended) - lp154b05.zip + lp154b04.7z (LZMA-compressed, recommended) + lp154b04.zip Other information: - 1.5.4beta05-README.txt - 1.5.4beta05-LICENSE.txt + 1.5.4beta04-README.txt + 1.5.4beta04-LICENSE.txt Changes since the last public release (1.5.2): @@ -220,8 +220,6 @@ Version 1.5.4beta04 [June 16, 2011] not enabled, png_set_strip_16() and png_do_scale_16_to_8() aren't built. Revised contrib/visupng, gregbook, and pngminim to demonstrate chop_16_to_8 -Version 1.5.4beta05 [June 16, 2011] - 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 603ae79ec..5771845be 100644 --- a/CHANGES +++ b/CHANGES @@ -3483,8 +3483,6 @@ Version 1.5.4beta04 [June 16, 2011] not enabled, png_set_strip_16() and png_do_scale_16_to_8() aren't built. Revised contrib/visupng, gregbook, and pngminim to demonstrate chop_16_to_8 -Version 1.5.4beta05 [June 16, 2011] - 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/example.c b/example.c index 142213432..74cc3bc2f 100644 --- a/example.c +++ b/example.c @@ -192,9 +192,9 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */ * low byte. */ #ifdef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED - png_set_strip_16(png_ptr); + png_set_scale_16(png_ptr); #else - png_set_chop_16(png_ptr); + png_set_strip_16(png_ptr); #endif /* Strip alpha bytes from the input data without combining with the diff --git a/libpng-manual.txt b/libpng-manual.txt index b28c835d9..6e131ed77 100644 --- a/libpng-manual.txt +++ b/libpng-manual.txt @@ -1,6 +1,6 @@ libpng-manual.txt - A description on how to use and modify libpng - libpng version 1.5.4beta05 - June 18, 2011 + libpng version 1.5.4beta04 - June 16, 2011 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2011 Glenn Randers-Pehrson @@ -11,7 +11,7 @@ libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng versions 0.97, January 1998, through 1.5.4beta05 - June 18, 2011 + libpng versions 0.97, January 1998, through 1.5.4beta04 - June 16, 2011 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2011 Glenn Randers-Pehrson @@ -847,8 +847,8 @@ interface or libpng API calls for the low level interface. For reference the settings and API calls required are: 8-bit values: - PNG_TRANSFORM_SCALE_16 | PNG_EXPAND - png_set_expand(png_ptr); png_set_scale_16(png_ptr); + PNG_TRANSFORM_STRIP_16 | PNG_EXPAND + png_set_expand(png_ptr); png_set_strip_16(png_ptr); If you must get exactly the same inaccurate results produced by default in versions prior to libpng-1.5.4, @@ -878,7 +878,7 @@ the entire image into memory, and (b) the input transformations you want to do are limited to the following set: PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_SCALE_16 Strip 16-bit samples to + PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to 8-bit PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit @@ -1404,12 +1404,12 @@ byte, unless png_set_packing() is called. 8-bit RGB data will be stored in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha() is called to insert filler bytes, either before or after each RGB triplet. 16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant -byte of the color value first, unless png_set_scale_16() is called to +byte of the color value first, unless png_set_strip_16() is called to transform it to regular RGB RGB triplets, or png_set_filler() or png_set_add alpha() is called to insert filler bytes, either before or after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can be modified with -png_set_filler(), png_set_add_alpha(), or png_set_scale_16(). +png_set_filler(), png_set_add_alpha(), or png_set_strip_16(). The following code transforms grayscale images of less than 8 to 8 bits, changes paletted images to RGB, and adds a full alpha channel if there is @@ -1446,7 +1446,7 @@ PNG can have files with 16 bits per channel. If you only can handle 8 bits per channel, this will strip the pixels down to 8-bit. if (bit_depth == 16) - png_set_scale_16(png_ptr); + png_set_strip_16(png_ptr); If you need to process the alpha channel on the image separately from the image data (for example if you convert it to a bitmap mask) it is possible to have @@ -4109,7 +4109,7 @@ reading 16-bit images, with none of the pixels being off-by-one any longer (see Clause 13.12 of the PNG specification). If you must have exactly the same inaccurate results that libpng produced by default previously, then you can use the png_set_chop_16() API instead -of png_set_scale_16(). +of png_set_strip_16(). Prior to libpng-1.5.4, the png_set_user_limits() function could only be used to reduce the width and height limits from the value of @@ -4425,13 +4425,13 @@ Other rules can be inferred by inspecting the libpng source. XIV. Y2K Compliance in libpng -June 18, 2011 +June 16, 2011 Since the PNG Development group is an ad-hoc body, we can't make an official declaration. This is your unofficial assurance that libpng from version 0.71 and -upward through 1.5.4beta05 are Y2K compliant. It is my belief that earlier +upward through 1.5.4beta04 are Y2K compliant. It is my belief that earlier versions were also Y2K compliant. Libpng only has three year fields. One is a 2-byte unsigned integer that diff --git a/libpng.3 b/libpng.3 index bf6cfbf0b..fcf40e06b 100644 --- a/libpng.3 +++ b/libpng.3 @@ -1,6 +1,6 @@ -.TH LIBPNG 3 "June 18, 2011" +.TH LIBPNG 3 "June 16, 2011" .SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.5.4beta05 +libpng \- Portable Network Graphics (PNG) Reference Library 1.5.4beta04 .SH SYNOPSIS \fI\fB @@ -955,7 +955,7 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng. .SH LIBPNG.TXT libpng-manual.txt - A description on how to use and modify libpng - libpng version 1.5.4beta05 - June 18, 2011 + libpng version 1.5.4beta04 - June 16, 2011 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2011 Glenn Randers-Pehrson @@ -966,7 +966,7 @@ libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng versions 0.97, January 1998, through 1.5.4beta05 - June 18, 2011 + libpng versions 0.97, January 1998, through 1.5.4beta04 - June 16, 2011 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2011 Glenn Randers-Pehrson @@ -1802,8 +1802,8 @@ interface or libpng API calls for the low level interface. For reference the settings and API calls required are: 8-bit values: - PNG_TRANSFORM_SCALE_16 | PNG_EXPAND - png_set_expand(png_ptr); png_set_scale_16(png_ptr); + PNG_TRANSFORM_STRIP_16 | PNG_EXPAND + png_set_expand(png_ptr); png_set_strip_16(png_ptr); If you must get exactly the same inaccurate results produced by default in versions prior to libpng-1.5.4, @@ -1833,7 +1833,7 @@ the entire image into memory, and (b) the input transformations you want to do are limited to the following set: PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_SCALE_16 Strip 16-bit samples to + PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to 8-bit PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit @@ -2359,12 +2359,12 @@ byte, unless png_set_packing() is called. 8-bit RGB data will be stored in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha() is called to insert filler bytes, either before or after each RGB triplet. 16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant -byte of the color value first, unless png_set_scale_16() is called to +byte of the color value first, unless png_set_strip_16() is called to transform it to regular RGB RGB triplets, or png_set_filler() or png_set_add alpha() is called to insert filler bytes, either before or after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can be modified with -png_set_filler(), png_set_add_alpha(), or png_set_scale_16(). +png_set_filler(), png_set_add_alpha(), or png_set_strip_16(). The following code transforms grayscale images of less than 8 to 8 bits, changes paletted images to RGB, and adds a full alpha channel if there is @@ -2401,7 +2401,7 @@ PNG can have files with 16 bits per channel. If you only can handle 8 bits per channel, this will strip the pixels down to 8-bit. if (bit_depth == 16) - png_set_scale_16(png_ptr); + png_set_strip_16(png_ptr); If you need to process the alpha channel on the image separately from the image data (for example if you convert it to a bitmap mask) it is possible to have @@ -5064,7 +5064,7 @@ reading 16-bit images, with none of the pixels being off-by-one any longer (see Clause 13.12 of the PNG specification). If you must have exactly the same inaccurate results that libpng produced by default previously, then you can use the png_set_chop_16() API instead -of png_set_scale_16(). +of png_set_strip_16(). Prior to libpng-1.5.4, the png_set_user_limits() function could only be used to reduce the width and height limits from the value of @@ -5380,13 +5380,13 @@ Other rules can be inferred by inspecting the libpng source. .SH XIV. Y2K Compliance in libpng -June 18, 2011 +June 16, 2011 Since the PNG Development group is an ad-hoc body, we can't make an official declaration. This is your unofficial assurance that libpng from version 0.71 and -upward through 1.5.4beta05 are Y2K compliant. It is my belief that earlier +upward through 1.5.4beta04 are Y2K compliant. It is my belief that earlier versions were also Y2K compliant. Libpng only has three year fields. One is a 2-byte unsigned integer that @@ -5579,7 +5579,7 @@ the first widely used release: 1.5.3rc01-02 15 10503 15.so.15.3[.0] 1.5.3beta11 15 10503 15.so.15.3[.0] 1.5.3 [omitted] - 1.5.4beta01-05 15 10504 15.so.15.4[.0] + 1.5.4beta01-03 15 10504 15.so.15.4[.0] Henceforth the source version will match the shared-library minor and patch numbers; the shared-library major version number will be @@ -5636,7 +5636,7 @@ possible without all of you. Thanks to Frank J. T. Wojcik for helping with the documentation. -Libpng version 1.5.4beta05 - June 18, 2011: +Libpng version 1.5.4beta04 - June 16, 2011: Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net). @@ -5659,7 +5659,7 @@ this sentence. This code is released under the libpng license. -libpng versions 1.2.6, August 15, 2004, through 1.5.4beta05, June 18, 2011, are +libpng versions 1.2.6, August 15, 2004, through 1.5.4beta04, June 16, 2011, are Copyright (c) 2004,2006-2007 Glenn Randers-Pehrson, and are distributed according to the same disclaimer and license as libpng-1.2.5 with the following individual added to the list of Contributing Authors @@ -5758,7 +5758,7 @@ certification mark of the Open Source Initiative. Glenn Randers-Pehrson glennrp at users.sourceforge.net -June 18, 2011 +June 16, 2011 .\" end of man page diff --git a/png.c b/png.c index 944cf22db..ca9dfd7c1 100644 --- a/png.c +++ b/png.c @@ -617,13 +617,13 @@ png_get_copyright(png_const_structp png_ptr) #else # ifdef __STDC__ return PNG_STRING_NEWLINE \ - "libpng version 1.5.4beta05 - June 16, 2011" PNG_STRING_NEWLINE \ + "libpng version 1.5.4beta05 - June 18, 2011" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2011 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ PNG_STRING_NEWLINE; # else - return "libpng version 1.5.4beta05 - June 16, 2011\ + return "libpng version 1.5.4beta05 - June 18, 2011\ Copyright (c) 1998-2011 Glenn Randers-Pehrson\ Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; @@ -2369,7 +2369,7 @@ png_build_gamma_table(png_structp png_ptr, int bit_depth) else shift = 0; /* keep all 16 bits */ - if (png_ptr->transformations & (PNG_16_TO_8 | PNG_CHOP_16_TO_8)) + if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) { /* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively * the significant bits in the *input* when the output will @@ -2390,7 +2390,7 @@ png_build_gamma_table(png_structp png_ptr, int bit_depth) * 16-bit output because the 8-bit table assumes the result will be reduced * to 8 bits. */ - if (png_ptr->transformations & (PNG_16_TO_8 | PNG_CHOP_16_TO_8)) + if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) #endif png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift, png_ptr->screen_gamma > 0 ? png_product2(png_ptr->gamma, diff --git a/png.h b/png.h index 82cb4bb46..64ce1ae43 100644 --- a/png.h +++ b/png.h @@ -902,7 +902,7 @@ PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef); #define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */ /* Added to libpng-1.5.4 */ #define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */ -#define PNG_TRANSFORM_CHOP_16 0x8000 /* read only */ +#define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */ /* Flags for MNG supported features */ #define PNG_FLAG_MNG_EMPTY_PLTE 0x01 @@ -1428,9 +1428,10 @@ PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structp png_ptr, /* Scale a 16-bit depth file down to 8-bit, accurately. */ PNG_EXPORT(48, void, png_set_scale_16, (png_structp png_ptr)); # endif -# ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED + +# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED /* Strip the second byte of information from a 16-bit depth file. */ -PNG_EXPORT(229, void, png_set_chop_16, (png_structp png_ptr)); +PNG_EXPORT(229, void, png_set_strip_16, (png_structp png_ptr)); # endif #endif diff --git a/pngpriv.h b/pngpriv.h index 4c34e8ce0..1d1903a5b 100644 --- a/pngpriv.h +++ b/pngpriv.h @@ -298,7 +298,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp; #define PNG_ENCODE_ALPHA 0x800000L /* Added to libpng-1.5.4 */ #define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */ #define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */ -#define PNG_CHOP_16_TO_8 0x4000000L +#define PNG_SCALE_16_TO_8 0x4000000L /* 0x8000000L unused */ /* 0x10000000L unused */ /* 0x20000000L unused */ @@ -824,7 +824,7 @@ PNG_EXTERN void png_do_scale_16_to_8 PNGARG((png_row_infop row_info, png_bytep row)); #endif -#ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED +#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); #endif diff --git a/pngread.c b/pngread.c index 06b5d2222..e200705f0 100644 --- a/pngread.c +++ b/pngread.c @@ -1290,16 +1290,16 @@ png_read_png(png_structp png_ptr, png_infop info_ptr, /* Tell libpng to strip 16-bit/color files down to 8 bits per color. */ # ifdef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED - if (transforms & PNG_TRANSFORM_STRIP_16) + if (transforms & PNG_TRANSFORM_SCALE_16) png_set_scale_16(png_ptr); # endif -# ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED +# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED /* Added at libpng-1.5.4. "strip_16" produces the same result that it * did in earlier versions, while "scale_16" is now more accurate. */ else - if (transforms & PNG_TRANSFORM_CHOP_16) - png_set_chop_16(png_ptr); + if (transforms & PNG_TRANSFORM_STRIP_16) + png_set_strip_16(png_ptr); #endif #endif diff --git a/pngrtran.c b/pngrtran.c index 3a16757bb..6afb23c93 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -134,7 +134,7 @@ png_set_background(png_structp png_ptr, #ifdef PNG_READ_16_TO_8_SUPPORTED /* Scale 16-bit depth files to 8-bit depth */ -# ifdef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED void PNGAPI png_set_scale_16(png_structp png_ptr) { @@ -143,26 +143,26 @@ png_set_scale_16(png_structp png_ptr) if (png_ptr == NULL) return; - png_ptr->transformations |= PNG_16_TO_8; -# ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED - png_ptr->transformations &= ~PNG_CHOP_16_TO_8; + png_ptr->transformations |= PNG_SCALE_16_TO_8; +# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED + png_ptr->transformations &= ~PNG_16_TO_8; # endif } # endif -# ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED +# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED /* Chop 16-bit depth files to 8-bit depth */ void PNGAPI -png_set_chop_16(png_structp png_ptr) +png_set_strip_16(png_structp png_ptr) { - png_debug(1, "in png_set_chop_16"); + png_debug(1, "in png_set_strip_16"); if (png_ptr == NULL) return; - png_ptr->transformations |= PNG_CHOP_16_TO_8; -# ifdef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED - png_ptr->transformations &= ~PNG_16_TO_8; + png_ptr->transformations |= PNG_16_TO_8; +# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED + png_ptr->transformations &= ~PNG_SCALE_16_TO_8; # endif } # endif @@ -1334,7 +1334,7 @@ png_init_read_transformations(png_structp png_ptr) * 6) PNG_GAMMA * 7) PNG_STRIP_ALPHA (if compose) * 8) PNG_ENCODE_ALPHA - * 9) PNG_16_TO_8 or PNG_CHOP_16_TO_8 (strip16/chop16) + * 9) PNG_16_TO_8 or PNG_SCALE_16_TO_8 (strip16/scale16) * 10) PNG_QUANTIZE (converts to palette) * 11) PNG_EXPAND_16 * 12) PNG_GRAY_TO_RGB iff PNG_BACKGROUND_IS_GRAY @@ -1874,14 +1874,14 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr) #ifdef PNG_READ_16_TO_8_SUPPORTED #ifdef PNG_READ_16BIT_SUPPORTED - if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_CHOP_16_TO_8)) && + if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) && (info_ptr->bit_depth == 16)) info_ptr->bit_depth = 8; #else /* Force chopping 16-bit input down to 8 */ if (info_ptr->bit_depth == 16) { - if (!(png_ptr->transformations & PNG_CHOP_16_TO_8)) + if (!(png_ptr->transformations & PNG_SCALE_16_TO_8)) png_ptr->transformations |=PNG_16_TO_8; info_ptr->bit_depth = 8; } diff --git a/pngvalid.c b/pngvalid.c index d491a5e0b..2cbb54209 100644 --- a/pngvalid.c +++ b/pngvalid.c @@ -5240,9 +5240,7 @@ IT(expand_16); #define PT ITSTRUCT(expand_16) #endif /* PNG_READ_EXPAND_16_SUPPORTED */ -#ifdef PNG_READ_16_TO_8_SUPPORTED -# if !defined(PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED) && \ - !defined(PNG_READ_CHOP_16_TO_8_SUPPORTED) /* the default before 1.5.4 */ +#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED /* API added in 1.5.4 */ /* png_set_scale_16 */ static void image_transform_png_set_scale_16_set(PNG_CONST image_transform *this, @@ -5263,21 +5261,6 @@ image_transform_png_set_scale_16_mod(PNG_CONST image_transform *this, if (that->green_sBIT > 8) that->green_sBIT = 8; if (that->blue_sBIT > 8) that->blue_sBIT = 8; if (that->alpha_sBIT > 8) that->alpha_sBIT = 8; - -# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED - /* The strip 16 algorithm drops the low 8 bits rather than calculating - * 1/257, so we need to adjust the permitted errors appropriately: - * Notice that this is only relevant prior to the addition of the - * png_set_chop_16 API in 1.5.4 (but 1.5.4+ always defines the above!) - */ - { - PNG_CONST double d = (255-128.5)/65535; - that->rede += d; - that->greene += d; - that->bluee += d; - that->alphae += d; - } -# endif } this->next->mod(this->next, that, pp, display); @@ -5300,18 +5283,18 @@ IT(scale_16); #define PT ITSTRUCT(scale_16) #endif -#ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED /* API added in 1.5.4 */ -/* png_set_chop_16 */ +#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED /* the default before 1.5.4 */ +/* png_set_strip_16 */ static void -image_transform_png_set_chop_16_set(PNG_CONST image_transform *this, +image_transform_png_set_strip_16(PNG_CONST image_transform *this, transform_display *that, png_structp pp, png_infop pi) { - png_set_chop_16(pp); + png_set_strip_16(pp); this->next->set(this->next, that, pp, pi); } static void -image_transform_png_set_chop_16_mod(PNG_CONST image_transform *this, +image_transform_png_set_strip_16(PNG_CONST image_transform *this, image_pixel *that, png_structp pp, PNG_CONST transform_display *display) { if (that->bit_depth == 16) @@ -5322,23 +5305,27 @@ image_transform_png_set_chop_16_mod(PNG_CONST image_transform *this, if (that->blue_sBIT > 8) that->blue_sBIT = 8; if (that->alpha_sBIT > 8) that->alpha_sBIT = 8; - /* From 1.5.4 there is a separate API to do the low byte drop; see the - * comments above for why this requires the following: - */ - { - PNG_CONST double d = (255-128.5)/65535; - that->rede += d; - that->greene += d; - that->bluee += d; - that->alphae += d; - } +# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED + /* The strip 16 algorithm drops the low 8 bits rather than calculating + * 1/257, so we need to adjust the permitted errors appropriately: + * Notice that this is only relevant prior to the addition of the + * png_set_scale_16 API in 1.5.4 (but 1.5.4+ always defines the above!) + */ + { + PNG_CONST double d = (255-128.5)/65535; + that->rede += d; + that->greene += d; + that->bluee += d; + that->alphae += d; + } +# endif } this->next->mod(this->next, that, pp, display); } static int -image_transform_png_set_chop_16_add(image_transform *this, +image_transform_png_set_strip_16(image_transform *this, PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) { UNUSED(colour_type) @@ -5349,11 +5336,10 @@ image_transform_png_set_chop_16_add(image_transform *this, return bit_depth > 8; } -IT(chop_16); +IT(strip_16); #undef PT -#define PT ITSTRUCT(chop_16) -#endif /* PNG_READ_CHOP_16_TO_8_SUPPORTED, from libpng 1.5.4 */ -#endif /* PNG_READ_16_TO_8_SUPPORTED */ +#define PT ITSTRUCT(strip_16) +#endif /* PNG_READ_STRIP_16_TO_8_SUPPORTED, from libpng 1.5.4 */ #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED /* png_set_strip_alpha */