From 9a3f24408562d5a05873d75648051d6ceec6997e Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Wed, 5 Feb 2014 22:35:26 -0600 Subject: [PATCH] [libpng17] Imported from libpng-1.7.0beta31.tar --- LICENSE | 4 +- README | 2 +- contrib/libtests/pngimage.c | 151 ++++++++++++++++++++++------------ libpng-manual.txt | 6 +- libpng.3 | 14 ++-- libpngpf.3 | 2 +- png.5 | 2 +- png.c | 4 +- pngconf.h | 2 +- projects/vstudio/readme.txt | 2 +- projects/vstudio/zlib.props | 2 +- scripts/README.txt | 2 +- scripts/pnglibconf.h.prebuilt | 2 +- 13 files changed, 121 insertions(+), 74 deletions(-) diff --git a/LICENSE b/LICENSE index 711a73c39..c2e68f0a3 100644 --- a/LICENSE +++ b/LICENSE @@ -10,7 +10,7 @@ this sentence. This code is released under the libpng license. -libpng versions 1.2.6, August 15, 2004, through 1.7.0beta31, February 2, 2014, are +libpng versions 1.2.6, August 15, 2004, through 1.7.0beta31, February 6, 2014, are Copyright (c) 2004, 2006-2014 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 @@ -108,4 +108,4 @@ certification mark of the Open Source Initiative. Glenn Randers-Pehrson glennrp at users.sourceforge.net -February 2, 2014 +February 6, 2014 diff --git a/README b/README index 5d7ff973c..fdccd7f4e 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -README for libpng version 1.7.0beta31 - February 2, 2014 (shared library 17.0) +README for libpng version 1.7.0beta31 - February 6, 2014 (shared library 17.0) See the note about version numbers near the top of png.h See INSTALL for instructions on how to install libpng. diff --git a/contrib/libtests/pngimage.c b/contrib/libtests/pngimage.c index 8096fe793..a91fbb488 100644 --- a/contrib/libtests/pngimage.c +++ b/contrib/libtests/pngimage.c @@ -36,30 +36,7 @@ # include /* because png.h did *not* include this */ #endif -#if defined(PNG_INFO_IMAGE_SUPPORTED) && defined(PNG_READ_SUPPORTED) -/* Valid transformations to perform on read: */ -#define READ_TRANSFORMS (PNG_TRANSFORM_STRIP_16|PNG_TRANSFORM_STRIP_ALPHA|\ - PNG_TRANSFORM_PACKING|PNG_TRANSFORM_PACKSWAP|PNG_TRANSFORM_EXPAND|\ - PNG_TRANSFORM_INVERT_MONO|PNG_TRANSFORM_SHIFT|PNG_TRANSFORM_BGR|\ - PNG_TRANSFORM_SWAP_ALPHA|PNG_TRANSFORM_SWAP_ENDIAN|\ - PNG_TRANSFORM_INVERT_ALPHA|PNG_TRANSFORM_GRAY_TO_RGB|\ - PNG_TRANSFORM_EXPAND_16|PNG_TRANSFORM_SCALE_16) - -/* Valid transformations to perform on write: */ -#define WRITE_TRANSFORMS (PNG_TRANSFORM_PACKING|PNG_TRANSFORM_PACKSWAP|\ - PNG_TRANSFORM_INVERT_MONO|PNG_TRANSFORM_SHIFT|PNG_TRANSFORM_BGR|\ - PNG_TRANSFORM_SWAP_ALPHA|PNG_TRANSFORM_SWAP_ENDIAN|\ - PNG_TRANSFORM_INVERT_ALPHA|PNG_TRANSFORM_STRIP_FILLER|\ - PNG_TRANSFORM_STRIP_FILLER_BEFORE|PNG_TRANSFORM_STRIP_FILLER_AFTER) - -/* Reversible transforms */ -#define RW_TRANSFORMS (READ_TRANSFORMS & WRITE_TRANSFORMS) - -/* All transforms: this is a safety feature; examine png.h and set it to the - * mask that should correspond to all the transforms. - */ -#define ALL_TRANSFORMS 0xffff - +#if defined(PNG_INFO_IMAGE_SUPPORTED) && defined(PNG_SEQUENTIAL_READ_SUPPORTED) /* If a transform is valid on both read and write this implies that if the * transform is applied to read it must also be applied on write to produce * meaningful data. This is because these transforms when performed on read @@ -119,21 +96,44 @@ static struct transform_info png_byte tested; /* the transform was tested somewhere */ } transform_info[] = { + /* List ALL the PNG_TRANSFORM_ macros here. Check for support using the READ + * macros; even if the transform is supported on write it cannot be tested + * without the read support. + */ # define T(name,chunk,cm_required,cm_absent,bd,when)\ { #name, PNG_TRANSFORM_ ## name, CHUNK_ ## chunk,\ COLOR_MASK_ ## cm_required, COLOR_MASK_ ## cm_absent, BD_ ## bd,\ TRANSFORM_ ## when, 0/*!tested*/ } +#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED T(STRIP_16, NONE, X, X, 16, R), /* drops the bottom 8 bits when bit depth is 16 */ +#endif +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED T(STRIP_ALPHA, NONE, A, X, ALL, R), /* removes the alpha channel if present */ - T(PACKING, NONE, X, X, LOW, RW), +#endif +#ifdef PNG_WRITE_PACK_SUPPORTED +# define TRANSFORM_RW_PACK TRANSFORM_RW +#else +# define TRANSFORM_RW_PACK TRANSFORM_R +#endif +#ifdef PNG_READ_PACK_SUPPORTED + T(PACKING, NONE, X, X, LOW, RW_PACK), /* unpacks low-bit-depth components into 1 byte per component on read, * reverses this on write. */ - T(PACKSWAP, NONE, X, X, LOW, RW), +#endif +#ifdef PNG_WRITE_PACKSWAP_SUPPORTED +# define TRANSFORM_RW_PACKSWAP TRANSFORM_RW +#else +# define TRANSFORM_RW_PACKSWAP TRANSFORM_R +#endif +#ifdef PNG_READ_PACKSWAP_SUPPORTED + T(PACKSWAP, NONE, X, X, LOW, RW_PACKSWAP), /* reverses the order of low-bit-depth components packed into a byte */ +#endif +#ifdef PNG_READ_EXPAND_SUPPORTED T(EXPAND, NONE, P, X, ALL, R), /* expands PLTE PNG files to RGB (no tRNS) or RGBA (tRNS) * * Note that the 'EXPAND' transform does lots of different things: */ @@ -141,24 +141,68 @@ static struct transform_info /* expands grayscale PNG files to RGB, or RGBA */ T(EXPAND, tRNS, X, A, ALL, R), /* expands the tRNS chunk in files without alpha */ - T(INVERT_MONO, NONE, X, C, ALL, RW), +#endif +#ifdef PNG_WRITE_INVERT_SUPPORTED +# define TRANSFORM_RW_INVERT TRANSFORM_RW +#else +# define TRANSFORM_RW_INVERT TRANSFORM_R +#endif +#ifdef PNG_READ_INVERT_SUPPORTED + T(INVERT_MONO, NONE, X, C, ALL, RW_INVERT), /* converts gray-scale components to 1..0 from 0..1 */ - T(SHIFT, sBIT, X, X, ALL, RW), +#endif +#ifdef PNG_WRITE_SHIFT_SUPPORTED +# define TRANSFORM_RW_SHIFT TRANSFORM_RW +#else +# define TRANSFORM_RW_SHIFT TRANSFORM_R +#endif +#ifdef PNG_READ_SHIFT_SUPPORTED + T(SHIFT, sBIT, X, X, ALL, RW_SHIFT), /* reduces component values to the original range based on the sBIT chunk, * this is only partially reversible - the low bits are lost and cannot be * recovered on write. In fact write code replicates the bits to generate * new low-order bits. */ - T(BGR, NONE, C, P, TRUE, RW), +#endif +#ifdef PNG_WRITE_BGR_SUPPORTED +# define TRANSFORM_RW_BGR TRANSFORM_RW +#else +# define TRANSFORM_RW_BGR TRANSFORM_R +#endif +#ifdef PNG_READ_BGR_SUPPORTED + T(BGR, NONE, C, P, TRUE, RW_BGR), /* reverses the rgb component values of true-color pixels */ - T(SWAP_ALPHA, NONE, A, X, TRUE, RW), +#endif +#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED +# define TRANSFORM_RW_SWAP_ALPHA TRANSFORM_RW +#else +# define TRANSFORM_RW_SWAP_ALPHA TRANSFORM_R +#endif +#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED + T(SWAP_ALPHA, NONE, A, X, TRUE, RW_SWAP_ALPHA), /* swaps the alpha channel of RGBA or GA pixels to the front - ARGB or * AG, on write reverses the process. */ - T(SWAP_ENDIAN, NONE, X, P, 16, RW), +#endif +#ifdef PNG_WRITE_SWAP_SUPPORTED +# define TRANSFORM_RW_SWAP TRANSFORM_RW +#else +# define TRANSFORM_RW_SWAP TRANSFORM_R +#endif +#ifdef PNG_READ_SWAP_SUPPORTED + T(SWAP_ENDIAN, NONE, X, P, 16, RW_SWAP), /* byte-swaps 16-bit component values */ - T(INVERT_ALPHA, NONE, A, X, TRUE, RW), +#endif +#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED +# define TRANSFORM_RW_INVERT_ALPHA TRANSFORM_RW +#else +# define TRANSFORM_RW_INVERT_ALPHA TRANSFORM_R +#endif +#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED + T(INVERT_ALPHA, NONE, A, X, TRUE, RW_INVERT_ALPHA), /* converts an alpha channel from 0..1 to 1..0 */ +#endif +#ifdef PNG_WRITE_FILLER_SUPPORTED T(STRIP_FILLER_BEFORE, NONE, A, P, TRUE, W), /* 'A' for a filler! */ /* on write skips a leading filler channel; testing requires data with a * filler channel so this is produced from RGBA or GA images by removing @@ -166,6 +210,8 @@ static struct transform_info */ T(STRIP_FILLER_AFTER, NONE, A, P, TRUE, W), /* on write strips a trailing filler channel */ +#endif +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED T(GRAY_TO_RGB, NONE, X, C, ALL, R), /* expands grayscale images to RGB, also causes the palette part of * 'EXPAND' to happen. Low bit depth grayscale images are expanded to @@ -177,6 +223,8 @@ static struct transform_info /* The 'palette' side effect mentioned above; a bit bogus but this is the * way the libpng code works. */ +#endif +#ifdef PNG_READ_EXPAND_16_SUPPORTED T(EXPAND_16, NONE, X, X, PAL, R), /* expands images to 16-bits per component, as a side effect expands * palette images to RGB and expands the tRNS chunk if present, so it can @@ -186,8 +234,11 @@ static struct transform_info /* side effect of EXPAND_16 - expands the tRNS chunk in an RGB or G 16-bit * image. */ +#endif +#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED T(SCALE_16, NONE, X, X, 16, R) /* scales 16-bit components to 8-bits. */ +#endif #undef T }; @@ -252,21 +303,20 @@ transform_name(int t) return "invalid transform"; } +/* Variables calculated by validate_T below and used to record all the supported + * transforms. Need (unsigned int) here because of the places where these + * values are used (unsigned compares in the 'exhaustive' iterator.) + */ +static unsigned int read_transforms, write_transforms, rw_transforms; + static void validate_T(void) - /* Validate the above table - this is done mainly to ensure that all the - * transforms are being tested. - */ + /* Validate the above table - this just builds the above values */ { unsigned int i; - int read_transforms = 0; - int write_transforms = 0; - int all_transforms = 0; for (i=0; ifilename, active, bad_combo, bad_combo_list, - RW_TRANSFORMS & ~bad_combo_list); + rw_transforms & ~bad_combo_list); else printf("%s: no %sbad combos found\n", dp->filename, diff --git a/libpng-manual.txt b/libpng-manual.txt index df3f9eb20..134b4663a 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.7.0beta31 - February 2, 2014 + libpng version 1.7.0beta31 - February 6, 2014 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2014 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.7.0beta31 - February 2, 2014 + libpng versions 0.97, January 1998, through 1.7.0beta31 - February 6, 2014 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2014 Glenn Randers-Pehrson @@ -5270,7 +5270,7 @@ Other rules can be inferred by inspecting the libpng source. XVII. Y2K Compliance in libpng -February 2, 2014 +February 6, 2014 Since the PNG Development group is an ad-hoc body, we can't make an official declaration. diff --git a/libpng.3 b/libpng.3 index 3bc944b8a..24c967e73 100644 --- a/libpng.3 +++ b/libpng.3 @@ -1,4 +1,4 @@ -.TH LIBPNG 3 "February 2, 2014" +.TH LIBPNG 3 "February 6, 2014" .SH NAME libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta31 .SH SYNOPSIS @@ -494,7 +494,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.7.0beta31 - February 2, 2014 + libpng version 1.7.0beta31 - February 6, 2014 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2014 Glenn Randers-Pehrson @@ -505,7 +505,7 @@ libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng versions 0.97, January 1998, through 1.7.0beta31 - February 2, 2014 + libpng versions 0.97, January 1998, through 1.7.0beta31 - February 6, 2014 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2014 Glenn Randers-Pehrson @@ -5765,7 +5765,7 @@ Other rules can be inferred by inspecting the libpng source. .SH XVII. Y2K Compliance in libpng -February 2, 2014 +February 6, 2014 Since the PNG Development group is an ad-hoc body, we can't make an official declaration. @@ -6035,7 +6035,7 @@ possible without all of you. Thanks to Frank J. T. Wojcik for helping with the documentation. -Libpng version 1.7.0beta31 - February 2, 2014: +Libpng version 1.7.0beta31 - February 6, 2014: Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net). @@ -6058,7 +6058,7 @@ this sentence. This code is released under the libpng license. -libpng versions 1.2.6, August 15, 2004, through 1.7.0beta31, February 2, 2014, are +libpng versions 1.2.6, August 15, 2004, through 1.7.0beta31, February 6, 2014, 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 @@ -6157,7 +6157,7 @@ certification mark of the Open Source Initiative. Glenn Randers-Pehrson glennrp at users.sourceforge.net -February 2, 2014 +February 6, 2014 .\" end of man page diff --git a/libpngpf.3 b/libpngpf.3 index 92df01a06..9d24855c7 100644 --- a/libpngpf.3 +++ b/libpngpf.3 @@ -1,4 +1,4 @@ -.TH LIBPNGPF 3 "February 2, 2014" +.TH LIBPNGPF 3 "February 6, 2014" .SH NAME libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta31 (private functions) diff --git a/png.5 b/png.5 index 6b0019480..3f0c50d27 100644 --- a/png.5 +++ b/png.5 @@ -1,4 +1,4 @@ -.TH PNG 5 "February 2, 2014" +.TH PNG 5 "February 6, 2014" .SH NAME png \- Portable Network Graphics (PNG) format .SH DESCRIPTION diff --git a/png.c b/png.c index bb77f01c9..340df72a5 100644 --- a/png.c +++ b/png.c @@ -696,13 +696,13 @@ png_get_copyright(png_const_structrp png_ptr) #else # ifdef __STDC__ return PNG_STRING_NEWLINE \ - "libpng version 1.7.0beta31 - February 2, 2014" PNG_STRING_NEWLINE \ + "libpng version 1.7.0beta31 - February 6, 2014" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2014 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.7.0beta31 - February 2, 2014\ + return "libpng version 1.7.0beta31 - February 6, 2014\ Copyright (c) 1998-2014 Glenn Randers-Pehrson\ Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; diff --git a/pngconf.h b/pngconf.h index eb15518ad..df9f60d20 100644 --- a/pngconf.h +++ b/pngconf.h @@ -1,7 +1,7 @@ /* pngconf.h - machine configurable file for libpng * - * libpng version 1.7.0beta31 - February 2, 2014 + * libpng version 1.7.0beta31 - February 6, 2014 * * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/projects/vstudio/readme.txt b/projects/vstudio/readme.txt index b882e9a8f..64de7c919 100644 --- a/projects/vstudio/readme.txt +++ b/projects/vstudio/readme.txt @@ -1,7 +1,7 @@ VisualStudio instructions -libpng version 1.7.0beta31 - February 2, 2014 +libpng version 1.7.0beta31 - February 6, 2014 Copyright (c) 1998-2010 Glenn Randers-Pehrson diff --git a/projects/vstudio/zlib.props b/projects/vstudio/zlib.props index 32d066189..dbbc556b3 100644 --- a/projects/vstudio/zlib.props +++ b/projects/vstudio/zlib.props @@ -2,7 +2,7 @@