[master] Change some instances of PNG_READ_UNKNOWN_CHUNKS_SUPPORTED

to PNG_HANDLE_AS_UNKNOWN to make it possible to build a libpng that can
use the png_set_keep_unknown_chunks() mechanism to ignore unused chunks
without having to save unknown chunks.
This commit is contained in:
Glenn Randers-Pehrson 2009-06-15 20:50:00 -05:00
parent b278e91338
commit bbe589da44
7 changed files with 75 additions and 63 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.2.38beta01 - June 5, 2009 Libpng 1.2.38beta01 - June 12, 2009
This is not intended to be a public release. It will be replaced 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. within a few weeks by a public version or by another test version.
@ -69,16 +69,22 @@ version 1.2.37rc01 [May 27, 2009]
No changes. No changes.
versions 1.2.37 and 1.0.45 [June 4, 2009] versions 1.2.37 and 1.0.45 [June 4, 2009]
Reformatted several remaining "else statement;" and "if () statment;" into Reformatted several remaining "else statement;" and "if () statement;" into
two lines. two lines.
Added "#define PNG_NO_WRITE_SWAP" to contrib/pngminim/encoder/pngusr.h Added "#define PNG_NO_WRITE_SWAP" to contrib/pngminim/encoder/pngusr.h
and "define PNG_NO_READ_SWAP" to decoder/pngusr.h and preader/pngusr.h and "define PNG_NO_READ_SWAP" to decoder/pngusr.h and preader/pngusr.h
Added sections about the git repository and our coding style to the Added sections about the git repository and our coding style to the
documentation (merged from libpng-1.4.0beta62) documentation (merged from libpng-1.4.0beta62)
Added a section about using png_get_io_ptr() in configure scripts to detect Added a section in the documentation about using png_get_io_ptr() in
the presence of libpng. configure scripts to detect the presence of libpng.
versions 1.2.38 [June 5, 2009] version 1.2.38beta01 [June 12, 2009]
Revised libpng*.txt and libpng.3 to mention calling png_set_IHDR()
multiple times and to specify the sample order in the tRNS chunk,
because the ISO PNG specification has a typo in the tRNS table.
Changed several PNG_UNKNOWN_CHUNK_SUPPORTED to
PNG_HANDLE_AS_UNKNOWN_SUPPORTED, to make the png_set_keep mechanism
available for ignoring known chunks even when not saving unknown chunks.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net

View File

@ -2403,10 +2403,13 @@ versions 1.2.37 and 1.0.45 [June 4, 2009]
Added a section to the libpng documentation about using png_get_io_ptr() Added a section to the libpng documentation about using png_get_io_ptr()
in configure scripts to detect the presence of libpng. in configure scripts to detect the presence of libpng.
versions 1.2.38 [June 8, 2009] versions 1.2.38beta01 [June 12, 2009]
Revised libpng*.txt and libpng.3 to mention calling png_set_IHDR() Revised libpng*.txt and libpng.3 to mention calling png_set_IHDR()
multiple times and to specify the sample order in the tRNS chunk, multiple times and to specify the sample order in the tRNS chunk,
because the ISO PNG specification has a typo in the tRNS table. because the ISO PNG specification has a typo in the tRNS table.
Changed several PNG_UNKNOWN_CHUNK_SUPPORTED to
PNG_HANDLE_AS_UNKNOWN_SUPPORTED, to make the png_set_keep mechanism
available for ignoring known chunks even when not saving unknown chunks.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

22
png.h
View File

@ -1,6 +1,6 @@
/* png.h - header file for PNG reference library /* png.h - header file for PNG reference library
* *
* libpng version 1.2.38beta01 - June 5, 2009 * libpng version 1.2.38beta01 - June 12, 2009
* Copyright (c) 1998-2009 Glenn Randers-Pehrson * Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -8,7 +8,7 @@
* Authors and maintainers: * Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.2.38beta01 - June 5, 2009: Glenn * libpng versions 0.97, January 1998, through 1.2.38beta01 - June 12, 2009: Glenn
* See also "Contributing Authors", below. * See also "Contributing Authors", below.
* *
* Note about libpng version numbers: * Note about libpng version numbers:
@ -260,7 +260,7 @@
* If you modify libpng you may insert additional notices immediately following * If you modify libpng you may insert additional notices immediately following
* this sentence. * this sentence.
* *
* libpng versions 1.2.6, August 15, 2004, through 1.2.38beta01, June 5, 2009, are * libpng versions 1.2.6, August 15, 2004, through 1.2.38beta01, June 12, 2009, are
* Copyright (c) 2004, 2006-2009 Glenn Randers-Pehrson, and are * Copyright (c) 2004, 2006-2009 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.2.5 * distributed according to the same disclaimer and license as libpng-1.2.5
* with the following individual added to the list of Contributing Authors: * with the following individual added to the list of Contributing Authors:
@ -372,7 +372,7 @@
* Y2K compliance in libpng: * Y2K compliance in libpng:
* ========================= * =========================
* *
* June 5, 2009 * June 12, 2009
* *
* Since the PNG Development group is an ad-hoc body, we can't make * Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration. * an official declaration.
@ -436,7 +436,7 @@
/* Version information for png.h - this should match the version in png.c */ /* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.2.38beta01" #define PNG_LIBPNG_VER_STRING "1.2.38beta01"
#define PNG_HEADER_VERSION_STRING \ #define PNG_HEADER_VERSION_STRING \
" libpng version 1.2.38beta01 - June 5, 2009\n" " libpng version 1.2.38beta01 - June 12, 2009\n"
#define PNG_LIBPNG_VER_SONUM 0 #define PNG_LIBPNG_VER_SONUM 0
#define PNG_LIBPNG_VER_DLLNUM 13 #define PNG_LIBPNG_VER_DLLNUM 13
@ -1399,7 +1399,7 @@ struct png_struct_def
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
#endif #endif
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
int num_chunk_list; int num_chunk_list;
png_bytep chunk_list; png_bytep chunk_list;
#endif #endif
@ -2501,7 +2501,7 @@ extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr,
#endif #endif
#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ #endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
/* provide a list of chunks and how they are to be handled, if the built-in /* provide a list of chunks and how they are to be handled, if the built-in
handling or default unknown chunk handling is not desired. Any chunks not handling or default unknown chunk handling is not desired. Any chunks not
listed will be handled in the default manner. The IHDR and IEND chunks listed will be handled in the default manner. The IHDR and IEND chunks
@ -2513,6 +2513,10 @@ extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr,
*/ */
extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp
png_ptr, int keep, png_bytep chunk_list, int num_chunks)); png_ptr, int keep, png_bytep chunk_list, int num_chunks));
PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep
chunk_name));
#endif
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns));
extern PNG_EXPORT(void, png_set_unknown_chunk_location) extern PNG_EXPORT(void, png_set_unknown_chunk_location)
@ -2520,10 +2524,6 @@ extern PNG_EXPORT(void, png_set_unknown_chunk_location)
extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp
png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); png_ptr, png_infop info_ptr, png_unknown_chunkpp entries));
#endif #endif
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep
chunk_name));
#endif
/* Png_free_data() will turn off the "valid" flag for anything it frees. /* Png_free_data() will turn off the "valid" flag for anything it frees.
If you need to turn it off for a chunk that your application has freed, If you need to turn it off for a chunk that your application has freed,

View File

@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng /* pngconf.h - machine configurable file for libpng
* *
* libpng version 1.2.38beta01 - June 5, 2009 * libpng version 1.2.38beta01 - June 12, 2009
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2009 Glenn Randers-Pehrson * Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -487,7 +487,7 @@
* iTXt support was added. iTXt support was turned off by default through * iTXt support was added. iTXt support was turned off by default through
* libpng-1.2.x, to support old apps that malloc the png_text structure * libpng-1.2.x, to support old apps that malloc the png_text structure
* instead of calling png_set_text() and letting libpng malloc it. It * instead of calling png_set_text() and letting libpng malloc it. It
* was turned on by default in libpng-1.3.0. * was turned on by default in libpng-1.4.0.
*/ */
#if defined(PNG_1_0_X) || defined (PNG_1_2_X) #if defined(PNG_1_0_X) || defined (PNG_1_2_X)
@ -945,9 +945,6 @@
# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED # ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
# define PNG_UNKNOWN_CHUNKS_SUPPORTED # define PNG_UNKNOWN_CHUNKS_SUPPORTED
# endif # endif
# ifndef PNG_NO_HANDLE_AS_UNKNOWN
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# endif
#endif #endif
#if !defined(PNG_NO_READ_USER_CHUNKS) && \ #if !defined(PNG_NO_READ_USER_CHUNKS) && \
defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
@ -960,6 +957,11 @@
# undef PNG_NO_HANDLE_AS_UNKNOWN # undef PNG_NO_HANDLE_AS_UNKNOWN
# endif # endif
#endif #endif
#ifndef PNG_NO_HANDLE_AS_UNKNOWN
# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# endif
#endif
#ifndef PNG_NO_READ_OPT_PLTE #ifndef PNG_NO_READ_OPT_PLTE
# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ # define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */
#endif /* optional PLTE chunk in RGB and RGBA images */ #endif /* optional PLTE chunk in RGB and RGBA images */
@ -1087,11 +1089,11 @@
# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED # ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
# define PNG_UNKNOWN_CHUNKS_SUPPORTED # define PNG_UNKNOWN_CHUNKS_SUPPORTED
# endif # endif
# ifndef PNG_NO_HANDLE_AS_UNKNOWN #endif
#ifndef PNG_NO_HANDLE_AS_UNKNOWN
# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED # ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED # define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# endif # endif
# endif
#endif #endif
#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \ #if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
defined(PNG_WRITE_zTXt_SUPPORTED) defined(PNG_WRITE_zTXt_SUPPORTED)
@ -1248,7 +1250,7 @@ typedef char FAR * FAR * FAR * png_charppp;
#if defined(PNG_1_0_X) || defined(PNG_1_2_X) #if defined(PNG_1_0_X) || defined(PNG_1_2_X)
/* SPC - Is this stuff deprecated? */ /* SPC - Is this stuff deprecated? */
/* It'll be removed as of libpng-1.3.0 - GR-P */ /* It'll be removed as of libpng-1.4.0 - GR-P */
/* libpng typedefs for types in zlib. If zlib changes /* libpng typedefs for types in zlib. If zlib changes
* or another compression library is used, then change these. * or another compression library is used, then change these.
* Eliminates need to change all the source files. * Eliminates need to change all the source files.

View File

@ -1,7 +1,7 @@
/* pngrtran.c - transforms the data in a row for PNG readers /* pngrtran.c - transforms the data in a row for PNG readers
* *
* Last changed in libpng 1.2.37 [June 4, 2009] * Last changed in libpng 1.2.38 [June 12, 2009]
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2009 Glenn Randers-Pehrson * Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -1177,10 +1177,6 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr->transformations & PNG_EXPAND_tRNS) if (png_ptr->transformations & PNG_EXPAND_tRNS)
info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
#if 0 /* Removed from libpng-1.2.27 */
else
info_ptr->color_type |= PNG_COLOR_MASK_COLOR;
#endif
} }
if (info_ptr->bit_depth < 8) if (info_ptr->bit_depth < 8)
info_ptr->bit_depth = 8; info_ptr->bit_depth = 8;

View File

@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file /* pngrutil.c - utilities to read a PNG file
* *
* Last changed in libpng 1.2.37 [June 4, 2009] * Last changed in libpng 1.2.38 [June 12, 2009]
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2009 Glenn Randers-Pehrson * Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -2251,7 +2251,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (!(png_ptr->chunk_name[0] & 0x20)) if (!(png_ptr->chunk_name[0] & 0x20))
{ {
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) #if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
PNG_HANDLE_CHUNK_ALWAYS PNG_HANDLE_CHUNK_ALWAYS
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
@ -2263,8 +2263,11 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
} }
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) || if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
(png_ptr->read_user_chunk_fn != NULL)) #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|| (png_ptr->read_user_chunk_fn != NULL)
#endif
)
{ {
#ifdef PNG_MAX_MALLOC_64K #ifdef PNG_MAX_MALLOC_64K
if (length > (png_uint_32)65535L) if (length > (png_uint_32)65535L)
@ -2298,8 +2301,10 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (ret == 0) if (ret == 0)
{ {
if (!(png_ptr->chunk_name[0] & 0x20)) if (!(png_ptr->chunk_name[0] & 0x20))
#if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
PNG_HANDLE_CHUNK_ALWAYS) PNG_HANDLE_CHUNK_ALWAYS)
#endif
png_chunk_error(png_ptr, "unknown critical chunk"); png_chunk_error(png_ptr, "unknown critical chunk");
png_set_unknown_chunks(png_ptr, info_ptr, png_set_unknown_chunks(png_ptr, info_ptr,
&png_ptr->unknown_chunk, 1); &png_ptr->unknown_chunk, 1);

View File

@ -1,7 +1,7 @@
/* pngset.c - storage of image information into info struct /* pngset.c - storage of image information into info struct
* *
* Last changed in libpng 1.2.37 [June 4, 2009] * Last changed in libpng 1.2.38 [June 12, 2009]
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2009 Glenn Randers-Pehrson * Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -1004,7 +1004,7 @@ png_set_sPLT(png_structp png_ptr,
} }
#endif /* PNG_sPLT_SUPPORTED */ #endif /* PNG_sPLT_SUPPORTED */
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) #if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
void PNGAPI void PNGAPI
png_set_unknown_chunks(png_structp png_ptr, png_set_unknown_chunks(png_structp png_ptr,
png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)