Imported from pngcrush-1.5.5.tar

This commit is contained in:
Glenn Randers-Pehrson
2001-06-09 10:30:01 -05:00
parent 4df0ff379f
commit 0f3e444307
25 changed files with 721 additions and 239 deletions

View File

@@ -41,12 +41,13 @@ case of any discrepancy, the copy in pngcrush.c shall prevail):
This is the output of "pngcrush" and "pngcrush -help": This is the output of "pngcrush" and "pngcrush -help":
| pngcrush 1.5.4, Copyright (C) 1998-2001 Glenn Randers-Pehrson
| pngcrush 1.5.5, Copyright (C) 1998-2001 Glenn Randers-Pehrson
| This is a free, open-source program. Permission is irrevocably | This is a free, open-source program. Permission is irrevocably
| granted to everyone to use this version of pngcrush without | granted to everyone to use this version of pngcrush without
| payment of any fee. | payment of any fee.
| This program was built with libpng version 1.0.11, and is | This program was built with libpng version 1.0.12, and is
| running with libpng version 1.0.11 - April 27, 2001 (header) | running with libpng version 1.0.12 - June 8, 2001 (header)
| Copyright (C) 1998-2001 Glenn Randers-Pehrson, | Copyright (C) 1998-2001 Glenn Randers-Pehrson,
| Copyright (C) 1996, 1997 Andreas Dilger, | Copyright (C) 1996, 1997 Andreas Dilger,
| Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc., | Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,
@@ -88,16 +89,20 @@ options:
-v (display more detailed information) -v (display more detailed information)
-version (display the pngcrush version) -version (display the pngcrush version)
-w compression_window_size [32, 16, 8, 4, 2, 1, 512] -w compression_window_size [32, 16, 8, 4, 2, 1, 512]
-z zlib_strategy [0, 1, or 2]
-zmem zlib_compression_mem_level [1-9, default 9]
-zitxt b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
-ztxt b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
-h (help and legal notices) -h (help and legal notices)
-p (pause) -p (pause)
| pngcrush 1.5.4, Copyright (C) 1998-2001 Glenn Randers-Pehrson | pngcrush 1.5.5, Copyright (C) 1998-2001 Glenn Randers-Pehrson
| This is a free, open-source program. Permission is irrevocably | This is a free, open-source program. Permission is irrevocably
| granted to everyone to use this version of pngcrush without | granted to everyone to use this version of pngcrush without
| payment of any fee. | payment of any fee.
| This program was built with libpng version 1.0.11, and is | This program was built with libpng version 1.0.12, and is
| running with libpng version 1.0.11 - April 27, 2001 (header) | running with libpng version 1.0.12 - June 8, 2001 (header)
| Copyright (C) 1998-2001 Glenn Randers-Pehrson, | Copyright (C) 1998-2001 Glenn Randers-Pehrson,
| Copyright (C) 1996, 1997 Andreas Dilger, | Copyright (C) 1996, 1997 Andreas Dilger,
| Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc., | Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,
@@ -310,4 +315,3 @@ options (Note: any option can be spelled out for clarity, e.g.,
e.g., type 'pngcrush -pause -help', if the help e.g., type 'pngcrush -pause -help', if the help
screen scrolls out of sight. screen scrolls out of sight.

53
png.c
View File

@@ -1,7 +1,7 @@
/* png.c - location for general purpose libpng functions /* png.c - location for general purpose libpng functions
* *
* libpng version 1.0.11 - April 27, 2001 * libpng version 1.0.12 - June 8, 2001
* Copyright (c) 1998-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2001 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.)
@@ -13,14 +13,14 @@
#include "png.h" #include "png.h"
/* Generate a compiler error if there is an old png.h in the search path. */ /* Generate a compiler error if there is an old png.h in the search path. */
typedef version_1_0_11 Your_png_h_is_not_version_1_0_11; typedef version_1_0_12 Your_png_h_is_not_version_1_0_12;
/* Version information for C files. This had better match the version /* Version information for C files. This had better match the version
* string defined in png.h. */ * string defined in png.h. */
#ifdef PNG_USE_GLOBAL_ARRAYS #ifdef PNG_USE_GLOBAL_ARRAYS
/* png_libpng_ver was changed to a function in version 1.0.5c */ /* png_libpng_ver was changed to a function in version 1.0.5c */
const char png_libpng_ver[18] = "1.0.11"; const char png_libpng_ver[18] = "1.0.12";
/* png_sig was changed to a function in version 1.0.5c */ /* png_sig was changed to a function in version 1.0.5c */
/* Place to hold the signature string for a PNG file. */ /* Place to hold the signature string for a PNG file. */
@@ -213,12 +213,12 @@ png_create_info_struct(png_structp png_ptr)
if(png_ptr == NULL) return (NULL); if(png_ptr == NULL) return (NULL);
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
if ((info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, if ((info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO,
png_ptr->malloc_fn)) != NULL) png_ptr->malloc_fn, png_ptr->mem_ptr)) != NULL)
#else #else
if ((info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO)) != NULL) if ((info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO)) != NULL)
#endif #endif
{ {
png_info_init(info_ptr); png_info_init_3(&info_ptr, sizeof(png_info));
} }
return (info_ptr); return (info_ptr);
@@ -243,7 +243,8 @@ png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
png_info_destroy(png_ptr, info_ptr); png_info_destroy(png_ptr, info_ptr);
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn); png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn,
png_ptr->mem_ptr);
#else #else
png_destroy_struct((png_voidp)info_ptr); png_destroy_struct((png_voidp)info_ptr);
#endif #endif
@@ -255,10 +256,28 @@ png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
* and applications using it are urged to use png_create_info_struct() * and applications using it are urged to use png_create_info_struct()
* instead. * instead.
*/ */
void /* PRIVATE */ #undef png_info_init
void PNGAPI
png_info_init(png_infop info_ptr) png_info_init(png_infop info_ptr)
{ {
png_debug(1, "in png_info_init\n"); /* We only come here via pre-1.0.12-compiled applications */
png_info_init_3(&info_ptr, 0);
}
void PNGAPI
png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size)
{
png_infop info_ptr = *ptr_ptr;
png_debug(1, "in png_info_init_3\n");
if(sizeof(png_info) > png_info_struct_size)
{
png_destroy_struct(info_ptr);
info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO);
*ptr_ptr = info_ptr;
}
/* set everything to 0 */ /* set everything to 0 */
png_memset(info_ptr, 0, sizeof (png_info)); png_memset(info_ptr, 0, sizeof (png_info));
} }
@@ -537,7 +556,7 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
} }
#endif #endif
png_info_init(info_ptr); png_info_init_3(&info_ptr, sizeof(png_info));
} }
/* This function returns a pointer to the io_ptr associated with the user /* This function returns a pointer to the io_ptr associated with the user
@@ -627,7 +646,7 @@ png_charp PNGAPI
png_get_copyright(png_structp png_ptr) png_get_copyright(png_structp png_ptr)
{ {
if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */ if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */
return ((png_charp) "\n libpng version 1.0.11 - April 27, 2001\n\ return ((png_charp) "\n libpng version 1.0.12 - June 8, 2001\n\
Copyright (c) 1998-2001 Glenn Randers-Pehrson\n\ Copyright (c) 1998-2001 Glenn Randers-Pehrson\n\
Copyright (c) 1996, 1997 Andreas Dilger\n\ Copyright (c) 1996, 1997 Andreas Dilger\n\
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n"); Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n");
@@ -645,8 +664,8 @@ png_get_libpng_ver(png_structp png_ptr)
{ {
/* Version of *.c files used when building libpng */ /* Version of *.c files used when building libpng */
if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */ if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
return((png_charp) "1.0.11"); return((png_charp) "1.0.12");
return((png_charp) "1.0.11"); return((png_charp) "1.0.12");
} }
png_charp PNGAPI png_charp PNGAPI
@@ -696,17 +715,15 @@ png_uint_32 PNGAPI
png_access_version_number(void) png_access_version_number(void)
{ {
/* Version of *.c files used when building libpng */ /* Version of *.c files used when building libpng */
return((png_uint_32) 10011L); return((png_uint_32) 10012L);
} }
/* this function was added to libpng 1.2.0 */
#if 0 /* delay this until version 1.2.0 */ #if !defined(PNG_USE_PNGGCCRD) && \
/* this function was added to libpng 1.0.9 (porting aid to libpng-1.2.0) */ !(defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD))
#ifndef PNG_ASSEMBLER_CODE_SUPPORTED
int PNGAPI int PNGAPI
png_mmx_support(void) png_mmx_support(void)
{ {
return -1; return -1;
} }
#endif #endif
#endif /* 0 */

92
png.h
View File

@@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library /* png.h - header file for PNG reference library
* *
* libpng version 1.0.11 - April 27, 2001 * libpng version 1.0.12 - June 8, 2001
* Copyright (c) 1998-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2001 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.)
@@ -9,7 +9,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.0.11 - April 27, 2001: Glenn * libpng versions 0.97, January 1998, through 1.0.12 - June 8, 2001: Glenn
* See also "Contributing Authors", below. * See also "Contributing Authors", below.
* *
* Note about libpng version numbers: * Note about libpng version numbers:
@@ -70,6 +70,7 @@
* 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3
* 1.0.11rc1 1 10011 2.1.0.11rc1 * 1.0.11rc1 1 10011 2.1.0.11rc1
* 1.0.11 1 10011 2.1.0.11 * 1.0.11 1 10011 2.1.0.11
* 1.0.12beta1-2 2 10012 2.1.0.11beta1-2
* *
* Henceforth the source version will match the shared-library major * Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be * and minor numbers; the shared-library major version number will be
@@ -99,7 +100,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.0.7, July 1, 2000, through 1.0.11, April 27, 2001, are * libpng versions 1.0.7, July 1, 2000, through 1.0.12, June 8, 2001, are
* Copyright (c) 2000, 2001 Glenn Randers-Pehrson, and are * Copyright (c) 2000, 2001 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.0.6 * distributed according to the same disclaimer and license as libpng-1.0.6
* with the following individuals added to the list of Contributing Authors * with the following individuals added to the list of Contributing Authors
@@ -204,13 +205,13 @@
* Y2K compliance in libpng: * Y2K compliance in libpng:
* ========================= * =========================
* *
* April 27, 2001 * June 8, 2001
* *
* 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.
* *
* This is your unofficial assurance that libpng from version 0.71 and * This is your unofficial assurance that libpng from version 0.71 and
* upward through 1.0.11 are Y2K compliant. It is my belief that earlier * upward through 1.0.12 are Y2K compliant. It is my belief that earlier
* versions were also Y2K compliant. * versions were also Y2K compliant.
* *
* Libpng only has three year fields. One is a 2-byte unsigned integer * Libpng only has three year fields. One is a 2-byte unsigned integer
@@ -266,7 +267,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.0.11" #define PNG_LIBPNG_VER_STRING "1.0.12"
#define PNG_LIBPNG_VER_SONUM 2 #define PNG_LIBPNG_VER_SONUM 2
#define PNG_LIBPNG_VER_DLLNUM %DLLNUM% #define PNG_LIBPNG_VER_DLLNUM %DLLNUM%
@@ -274,7 +275,7 @@
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 0 #define PNG_LIBPNG_VER_MINOR 0
#define PNG_LIBPNG_VER_RELEASE 11 #define PNG_LIBPNG_VER_RELEASE 12
/* This should match the numeric part of the final component of /* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero: */ * PNG_LIBPNG_VER_STRING, omitting any leading zero: */
@@ -293,7 +294,7 @@
* Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
* version 1.0.0 was mis-numbered 100 instead of 10000). From * version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */
#define PNG_LIBPNG_VER 10011 /* 1.0.11 */ #define PNG_LIBPNG_VER 10012 /* 1.0.12 */
#ifndef PNG_VERSION_INFO_ONLY #ifndef PNG_VERSION_INFO_ONLY
@@ -699,6 +700,7 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
png_byte pcal_nparams; /* number of parameters given in pcal_params */ png_byte pcal_nparams; /* number of parameters given in pcal_params */
#endif #endif
/* New members added in libpng-1.0.6 */
#ifdef PNG_FREE_ME_SUPPORTED #ifdef PNG_FREE_ME_SUPPORTED
png_uint_32 free_me; /* flags items libpng is responsible for freeing */ png_uint_32 free_me; /* flags items libpng is responsible for freeing */
#endif #endif
@@ -1139,12 +1141,6 @@ struct png_struct_def
png_charp time_buffer; /* String to hold RFC 1123 time text */ png_charp time_buffer; /* String to hold RFC 1123 time text */
#endif #endif
#ifdef PNG_USER_MEM_SUPPORTED
png_voidp mem_ptr; /* user supplied struct for mem functions */
png_malloc_ptr malloc_fn; /* function for allocating memory */
png_free_ptr free_fn; /* function for freeing memory */
#endif
/* New members added in libpng-1.0.6 */ /* New members added in libpng-1.0.6 */
#ifdef PNG_FREE_ME_SUPPORTED #ifdef PNG_FREE_ME_SUPPORTED
@@ -1161,35 +1157,59 @@ struct png_struct_def
png_bytep chunk_list; png_bytep chunk_list;
#endif #endif
/* New members added in libpng-1.0.3 */
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
png_byte rgb_to_gray_status; png_byte rgb_to_gray_status;
/* These were changed from png_byte in libpng-1.0.6 */
png_uint_16 rgb_to_gray_red_coeff; png_uint_16 rgb_to_gray_red_coeff;
png_uint_16 rgb_to_gray_green_coeff; png_uint_16 rgb_to_gray_green_coeff;
png_uint_16 rgb_to_gray_blue_coeff; png_uint_16 rgb_to_gray_blue_coeff;
#endif #endif
/* New member added in libpng-1.0.4 (renamed in 1.0.9) */
#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ #if defined(PNG_MNG_FEATURES_SUPPORTED) || \
defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
/* Note to maintainer: change this to png_uint_32 at next opportunity */ /* changed from png_byte to png_uint_32 at version 1.2.0 */
png_byte mng_features_permitted; png_byte mng_features_permitted;
#endif #endif
/* New member added in libpng-1.0.7 */
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
png_fixed_point int_gamma; png_fixed_point int_gamma;
#endif #endif
/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */
#if defined(PNG_MNG_FEATURES_SUPPORTED)
png_byte filter_type; png_byte filter_type;
#endif
#if defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD)
/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */
png_uint_32 row_buf_size; png_uint_32 row_buf_size;
#endif
/* New members added in libpng-1.2.0 */
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
png_byte mmx_bitdepth_threshold;
png_uint_32 mmx_rowbytes_threshold;
png_uint_32 asm_flags;
#endif
/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
#ifdef PNG_USER_MEM_SUPPORTED
png_voidp mem_ptr; /* user supplied struct for mem functions */
png_malloc_ptr malloc_fn; /* function for allocating memory */
png_free_ptr free_fn; /* function for freeing memory */
#endif
}; };
/* This prevents a compiler error in png_get_copyright() in png.c if png.c /* This prevents a compiler error in png_get_copyright() in png.c if png.c
and png.h are both at * version 1.0.11 and png.h are both at version 1.0.12
*/ */
typedef png_structp version_1_0_11; typedef png_structp version_1_0_12;
typedef png_struct FAR * FAR * png_structpp; typedef png_struct FAR * FAR * png_structpp;
@@ -1240,6 +1260,7 @@ extern PNG_EXPORT(void,png_set_compression_buffer_size)
/* Reset the compression stream */ /* Reset the compression stream */
extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr));
/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
extern PNG_EXPORT(png_structp,png_create_read_struct_2) extern PNG_EXPORT(png_structp,png_create_read_struct_2)
PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
@@ -1270,8 +1291,11 @@ extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(png_infop,png_create_info_struct) extern PNG_EXPORT(png_infop,png_create_info_struct)
PNGARG((png_structp png_ptr)); PNGARG((png_structp png_ptr));
/* Initialize the info structure (old interface - NOT DLL EXPORTED) */ /* Initialize the info structure (old interface - DEPRECATED) */
extern void png_info_init PNGARG((png_infop info_ptr)); extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr));
#define png_info_init(info_ptr) png_info_init_3(&info_ptr, sizeof(png_info));
extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr,
png_size_t png_info_struct_size));
/* Writes all the PNG information before the image. */ /* Writes all the PNG information before the image. */
extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr,
@@ -2229,15 +2253,23 @@ extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp
png_ptr, png_uint_32 mng_features_permitted)); png_ptr, png_uint_32 mng_features_permitted));
#endif #endif
#if 0 /* delay these until version 1.2.0 */ /* png_mmx_support will be included unconditionally starting in version 1.2.0 */
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) || defined(PNG_USE_PNGGCCRD)
/* png.c, pnggccrd.c, or pngvcrd.c */ /* png.c, pnggccrd.c, or pngvcrd.c */
extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); extern PNG_EXPORT(int,png_mmx_support) PNGARG((void));
#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
/* Strip the prepended error numbers ("#nnn ") from error and warning
* messages before passing them to the error or warning handler. */
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp
png_ptr, png_uint_32 strip_mode));
#endif #endif
/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ /* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */
#define PNG_HEADER_VERSION_STRING \ #define PNG_HEADER_VERSION_STRING \
" libpng version 1.0.11 - April 27, 2001 (header)\n" " libpng version 1.0.12 - June 8, 2001 (header)\n"
#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
/* With these routines we avoid an integer divide, which will be slower on /* With these routines we avoid an integer divide, which will be slower on
@@ -2360,6 +2392,8 @@ extern PNG_EXPORT(int,png_mmx_support) PNGARG((void));
#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L
#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L
#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L #define PNG_FLAG_LIBRARY_MISMATCH 0x20000L
#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L
#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L
/* For use in png_set_keep_unknown, png_handle_as_unknown */ /* For use in png_set_keep_unknown, png_handle_as_unknown */
#define HANDLE_CHUNK_AS_DEFAULT 0 #define HANDLE_CHUNK_AS_DEFAULT 0
@@ -2468,8 +2502,10 @@ PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf));
* (old interface - DEPRECATED - use png_create_read_struct instead). * (old interface - DEPRECATED - use png_create_read_struct instead).
*/ */
extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr));
#define png_read_init(png_ptr) png_read_init_2(png_ptr, \ #define png_read_init(png_ptr) png_read_init_3(&png_ptr, \
PNG_LIBPNG_VER_STRING, sizeof(png_struct), sizeof(png_info)); PNG_LIBPNG_VER_STRING, sizeof(png_struct));
extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr,
png_const_charp user_png_ver, png_size_t png_struct_size));
extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr,
png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t
png_info_size)); png_info_size));
@@ -2478,8 +2514,10 @@ extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr,
* (old interface - DEPRECATED - use png_create_write_struct instead). * (old interface - DEPRECATED - use png_create_write_struct instead).
*/ */
extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr));
#define png_write_init(png_ptr) png_write_init_2(png_ptr, \ #define png_write_init(png_ptr) png_write_init_3(&png_ptr, \
PNG_LIBPNG_VER_STRING, sizeof(png_struct), sizeof(png_info)); PNG_LIBPNG_VER_STRING, sizeof(png_struct));
extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr,
png_const_charp user_png_ver, png_size_t png_struct_size));
extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr,
png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t
png_info_size)); png_info_size));
@@ -2491,9 +2529,9 @@ PNG_EXTERN png_voidp png_create_struct PNGARG((int type));
PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr));
PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr
malloc_fn)); malloc_fn, png_voidp mem_ptr));
PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr,
png_free_ptr free_fn)); png_free_ptr free_fn, png_voidp mem_ptr));
/* Free any memory that info_ptr points to and reset struct. */ /* Free any memory that info_ptr points to and reset struct. */
PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,

View File

@@ -1,6 +1,6 @@
/* pngasmrd.h - assembler version of utilities to read a PNG file /* pngasmrd.h - assembler version of utilities to read a PNG file
* *
* libpng 1.0.11 - April 27, 2001 * libpng 1.0.12 - June 8, 2001
* 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) 2001 Glenn Randers-Pehrson * Copyright (c) 2001 Glenn Randers-Pehrson
* *

View File

@@ -1,6 +1,6 @@
/* pngconf.h - machine configurable file for libpng /* pngconf.h - machine configurable file for libpng
* *
* libpng 1.0.11 - April 27, 2001 * libpng 1.0.12 - June 8, 2001
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -47,8 +47,8 @@
# define PNG_WRITE_SUPPORTED # define PNG_WRITE_SUPPORTED
#endif #endif
/* Enable if you need to support PNGs that are embedded in MNG /* Enabled by default in 1.2.0. You can disable this if you don't need to
datastreams */ support PNGs that are embedded in MNG datastreams */
/* /*
#ifndef PNG_NO_MNG_FEATURES #ifndef PNG_NO_MNG_FEATURES
# ifndef PNG_MNG_FEATURES_SUPPORTED # ifndef PNG_MNG_FEATURES_SUPPORTED
@@ -93,47 +93,58 @@
* this bit of #ifdefs will define the 'correct' config variables based on * this bit of #ifdefs will define the 'correct' config variables based on
* that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but
* unnecessary. * unnecessary.
*
* Also, the precedence order is:
* ALL_STATIC (since we can't #undef something outside our namespace)
* PNG_BUILD_DLL
* PNG_STATIC
* (nothing) == PNG_USE_DLL
*/ */
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
# if defined(PNG_BUILD_DLL) # if defined(ALL_STATIC)
# if defined(PNG_BUILD_DLL)
# undef PNG_BUILD_DLL
# endif
# if defined(PNG_USE_DLL) # if defined(PNG_USE_DLL)
# undef PNG_USE_DLL # undef PNG_USE_DLL
# endif # endif
# if !defined(PNG_DLL) # if defined(PNG_DLL)
# define PNG_DLL # undef PNG_DLL
# endif # endif
# if defined(PNG_STATIC) # if !defined(PNG_STATIC)
# undef PNG_STATIC
# endif
# else
# if defined(ALL_STATIC)
# define PNG_STATIC # define PNG_STATIC
# endif # endif
# if defined(PNG_STATIC) # else
# if defined (PNG_BUILD_DLL)
# if defined(PNG_STATIC)
# undef PNG_STATIC
# endif
# if defined(PNG_USE_DLL) # if defined(PNG_USE_DLL)
# undef PNG_USE_DLL # undef PNG_USE_DLL
# endif # endif
# if defined(PNG_DLL) # if !defined(PNG_DLL)
# undef PNG_DLL # define PNG_DLL
# endif # endif
# else # else
# if defined(PNG_USE_DLL) # if defined(PNG_STATIC)
# if !defined(PNG_DLL) # if defined(PNG_USE_DLL)
# define PNG_DLL # undef PNG_USE_DLL
# endif
# if defined(PNG_DLL)
# undef PNG_DLL
# endif # endif
# else # else
# if defined(PNG_DLL) # if !defined(PNG_USE_DLL)
# define PNG_USE_DLL # define PNG_USE_DLL
# else # endif
# define PNG_USE_DLL # if !defined(PNG_DLL)
# define PNG_DLL # define PNG_DLL
# endif # endif
# endif # endif
# endif # endif
# endif # endif
#endif #endif
/* This protects us against compilers that run on a windowing system /* This protects us against compilers that run on a windowing system
* and thus don't have or would rather us not use the stdio types: * and thus don't have or would rather us not use the stdio types:
* stdin, stdout, and stderr. The only one currently used is stderr * stdin, stdout, and stderr. The only one currently used is stderr
@@ -308,7 +319,8 @@
# include "alloc.h" # include "alloc.h"
#endif #endif
#ifdef _MSC_VER #if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \
defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__))
# include <malloc.h> # include <malloc.h>
#endif #endif
@@ -580,6 +592,13 @@
# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED # define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
#endif #endif
/* Will be enabled in libpng-1.2.0 */
/*
#ifndef PNG_NO_ERROR_NUMBERS
#define PNG_ERROR_NUMBERS_SUPPORTED
#endif
*/
#ifndef PNG_NO_WRITE_FLUSH #ifndef PNG_NO_WRITE_FLUSH
# define PNG_WRITE_FLUSH_SUPPORTED # define PNG_WRITE_FLUSH_SUPPORTED
#endif #endif
@@ -611,12 +630,22 @@
* png_get_x_offset_microns() * png_get_x_offset_microns()
* png_get_y_offset_microns() * png_get_y_offset_microns()
*/ */
#ifndef PNG_NO_EASY_ACCESS #if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED)
# define PNG_EASY_ACCESS_SUPPORTED # define PNG_EASY_ACCESS_SUPPORTED
#endif #endif
/* PNG_ASSEMBLER_CODE will be enabled by default in version 1.2.0 /* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0
even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined */ even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined */
/*
#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE)
# ifndef PNG_ASSEMBLER_CODE_SUPPORTED
# define PNG_ASSEMBLER_CODE_SUPPORTED
# endif
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
# define PNG_MMX_CODE_SUPPORTED
# endif
#endif
*/
#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) #if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE)
# if defined(PNG_USE_PNGVCRD) || defined(PNG_USE_PNGGCCRD) # if defined(PNG_USE_PNGVCRD) || defined(PNG_USE_PNGGCCRD)
# ifndef PNG_ASSEMBLER_CODE_SUPPORTED # ifndef PNG_ASSEMBLER_CODE_SUPPORTED
@@ -628,6 +657,13 @@
# endif # endif
#endif #endif
/* This will be enabled by default in libpng-1.2.0 */
/*
#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED)
# define PNG_USER_MEM_SUPPORTED
#endif
*/
/* These are currently experimental features, define them if you want */ /* These are currently experimental features, define them if you want */
/* very little testing */ /* very little testing */
@@ -637,12 +673,6 @@
# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED # define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
# endif # endif
#endif #endif
#ifndef PNG_NO_USER_MEM
# define PNG_USER_MEM_SUPPORTED
#endif
#ifndef PNG_NO_ZALLOC_ZERO
# define PNG_ZALLOC_ZERO
#endif
*/ */
/* This is only for PowerPC big-endian and 680x0 systems */ /* This is only for PowerPC big-endian and 680x0 systems */

View File

@@ -25,7 +25,7 @@
* *
*/ */
#define PNGCRUSH_VERSION "1.5.4" #define PNGCRUSH_VERSION "1.5.5"
/* /*
#define PNGCRUSH_COUNT_COLORS #define PNGCRUSH_COUNT_COLORS
@@ -66,6 +66,14 @@
*/ */
/* Change log: /* Change log:
*
* Version 1.5.5 (built with libpng-1.0.12)
*
* Reset reduce_to_gray and it_is_opaque flags prior to processing each
* image.
*
* Enable removal of safe-to-copy chunks that are being handled as unknown
* e.g., "-rem time".
* *
* Version 1.5.4 (built with libpng-1.0.11) * Version 1.5.4 (built with libpng-1.0.11)
* *
@@ -787,7 +795,8 @@ png_voidp
png_debug_malloc(png_structp png_ptr, png_uint_32 size) { png_debug_malloc(png_structp png_ptr, png_uint_32 size) {
/* png_malloc has already tested for NULL; png_create_struct calls /* png_malloc has already tested for NULL; png_create_struct calls
png_debug_malloc directly, with png_ptr == NULL which is OK */ png_debug_malloc directly (with png_ptr == NULL prior to libpng-1.2.0
which is OK since we are not using a user mem_ptr) */
if (size == 0) if (size == 0)
return (png_voidp)(NULL); return (png_voidp)(NULL);
@@ -806,7 +815,8 @@ png_debug_malloc(png_structp png_ptr, png_uint_32 size) {
/* Make sure the caller isn't assuming zeroed memory. */ /* Make sure the caller isn't assuming zeroed memory. */
png_memset(pinfo->pointer, 0xdd, pinfo->size); png_memset(pinfo->pointer, 0xdd, pinfo->size);
if(verbose > 2) if(verbose > 2)
fprintf(STDERR, "Pointer %x allocated\n", (int)pinfo->pointer); fprintf(STDERR, "Pointer %x allocated %lu bytes\n",
(int)pinfo->pointer, size);
return (png_voidp)(pinfo->pointer); return (png_voidp)(pinfo->pointer);
} }
} }
@@ -837,9 +847,10 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
/* We must free the list element too, but first kill /* We must free the list element too, but first kill
the memory that is to be freed. */ the memory that is to be freed. */
memset(ptr, 0x55, pinfo->size); memset(ptr, 0x55, pinfo->size);
png_free_default(png_ptr, pinfo);
if(verbose > 2) if(verbose > 2)
fprintf(STDERR, "Pointer %x freed\n", (int)ptr); fprintf(STDERR, "Pointer %x freed %lu bytes\n", (int)ptr,
pinfo->size);
png_free_default(png_ptr, pinfo);
break; break;
} }
if (pinfo->next == NULL) { if (pinfo->next == NULL) {
@@ -2124,6 +2135,7 @@ main(int argc, char *argv[])
" The program will use a smaller window anyway when\n"); " The program will use a smaller window anyway when\n");
fprintf(STDERR, fprintf(STDERR,
" the uncompressed file is smaller than 16k.\n\n"); " the uncompressed file is smaller than 16k.\n\n");
}
fprintf(STDERR, fprintf(STDERR,
" -z zlib_strategy [0, 1, or 2]\n"); " -z zlib_strategy [0, 1, or 2]\n");
if(verbose > 1) if(verbose > 1)
@@ -2147,6 +2159,7 @@ main(int argc, char *argv[])
fprintf(STDERR, fprintf(STDERR,
" -ztxt b[efore_IDAT]|a[fter_IDAT] \"keyword\" \"text\"\n"); " -ztxt b[efore_IDAT]|a[fter_IDAT] \"keyword\" \"text\"\n");
if(verbose > 1) if(verbose > 1)
{
fprintf(STDERR, fprintf(STDERR,
"\n zTXt chunk to insert (see -text).\n\n"); "\n zTXt chunk to insert (see -text).\n\n");
png_crush_pause(); png_crush_pause();
@@ -2360,6 +2373,8 @@ main(int argc, char *argv[])
idat_length[0]=1; idat_length[0]=1;
#ifdef PNGCRUSH_COUNT_COLORS #ifdef PNGCRUSH_COUNT_COLORS
reduce_to_gray=0;
it_is_opaque=0;
output_color_type = input_color_type; output_color_type = input_color_type;
if (do_color_count) if (do_color_count)
{ {
@@ -2720,32 +2735,39 @@ main(int argc, char *argv[])
/* Process the following chunks as if safe-to-copy since it is known that /* Process the following chunks as if safe-to-copy since it is known that
recompressing the IDAT chunks has no effect on them */ recompressing the IDAT chunks has no effect on them */
#if !defined(PNG_cHRM_SUPPORTED) #if !defined(PNG_cHRM_SUPPORTED)
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS, if(keep_chunk("cHRM",argv))
(png_bytep)png_cHRM, 1); png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS,
(png_bytep)png_cHRM, 1);
#endif #endif
#if !defined(PNG_hIST_SUPPORTED) #if !defined(PNG_hIST_SUPPORTED)
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS, if(keep_chunk("hIST",argv))
(png_bytep)png_hIST, 1); png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS,
(png_bytep)png_hIST, 1);
#endif #endif
#if !defined(PNG_iCCP_SUPPORTED) #if !defined(PNG_iCCP_SUPPORTED)
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS, if(keep_chunk("iCCP",argv))
(png_bytep)png_iCCP, 1); png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS,
(png_bytep)png_iCCP, 1);
#endif #endif
#if !defined(PNG_sCAL_SUPPORTED) #if !defined(PNG_sCAL_SUPPORTED)
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS, if(keep_chunk("sCAL",argv))
(png_bytep)png_sCAL, 1); png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS,
(png_bytep)png_sCAL, 1);
#endif #endif
#if !defined(PNG_pCAL_SUPPORTED) #if !defined(PNG_pCAL_SUPPORTED)
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS, if(keep_chunk("pCAL",argv))
(png_bytep)png_pCAL, 1); png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS,
(png_bytep)png_pCAL, 1);
#endif #endif
#if !defined(PNG_sPLT_SUPPORTED) #if !defined(PNG_sPLT_SUPPORTED)
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS, if(keep_chunk("sPLT",argv))
(png_bytep)png_sPLT, 1); png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS,
(png_bytep)png_sPLT, 1);
#endif #endif
#if !defined(PNG_tIME_SUPPORTED) #if !defined(PNG_tIME_SUPPORTED)
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS, if(keep_chunk("tIME",argv))
(png_bytep)png_tIME, 1); png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS,
(png_bytep)png_tIME, 1);
#endif #endif
#else /* PNG_UINT_IHDR is defined; we are using libpng newer than 1.0.6 */ #else /* PNG_UINT_IHDR is defined; we are using libpng newer than 1.0.6 */
@@ -2761,39 +2783,60 @@ main(int argc, char *argv[])
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_IF_SAFE, png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_IF_SAFE,
NULL, 0); NULL, 0);
#if !defined(PNG_cHRM_SUPPORTED) #if !defined(PNG_cHRM_SUPPORTED)
png_save_uint_32(chunk_name, PNG_UINT_cHRM); if(keep_chunk("cHRM",argv))
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS, {
chunk_name, 1); png_save_uint_32(chunk_name, PNG_UINT_cHRM);
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS,
chunk_name, 1);
}
#endif #endif
#if !defined(PNG_hIST_SUPPORTED) #if !defined(PNG_hIST_SUPPORTED)
png_save_uint_32(chunk_name, PNG_UINT_hIST); if(keep_chunk("hIST",argv))
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS, {
chunk_name, 1); png_save_uint_32(chunk_name, PNG_UINT_hIST);
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS,
chunk_name, 1);
}
#endif #endif
#if !defined(PNG_iCCP_SUPPORTED) #if !defined(PNG_iCCP_SUPPORTED)
png_save_uint_32(chunk_name, PNG_UINT_iCCP); if(keep_chunk("iCCP",argv))
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS, {
chunk_name, 1); png_save_uint_32(chunk_name, PNG_UINT_iCCP);
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS,
chunk_name, 1);
}
#endif #endif
#if !defined(PNG_sCAL_SUPPORTED) #if !defined(PNG_sCAL_SUPPORTED)
png_save_uint_32(chunk_name, PNG_UINT_sCAL); if(keep_chunk("sCAL",argv))
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS, {
chunk_name, 1); png_save_uint_32(chunk_name, PNG_UINT_sCAL);
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS,
chunk_name, 1);
}
#endif #endif
#if !defined(PNG_pCAL_SUPPORTED) #if !defined(PNG_pCAL_SUPPORTED)
png_save_uint_32(chunk_name, PNG_UINT_pCAL); if(keep_chunk("pCAL",argv))
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS, {
chunk_name, 1); png_save_uint_32(chunk_name, PNG_UINT_pCAL);
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS,
chunk_name, 1);
}
#endif #endif
#if !defined(PNG_sPLT_SUPPORTED) #if !defined(PNG_sPLT_SUPPORTED)
png_save_uint_32(chunk_name, PNG_UINT_sPLT); if(keep_chunk("sPLT",argv))
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS, {
chunk_name, 1); png_save_uint_32(chunk_name, PNG_UINT_sPLT);
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS,
chunk_name, 1);
}
#endif #endif
#if !defined(PNG_tIME_SUPPORTED) #if !defined(PNG_tIME_SUPPORTED)
png_save_uint_32(chunk_name, PNG_UINT_tIME); if(keep_chunk("tIME",argv))
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS, {
chunk_name, 1); png_save_uint_32(chunk_name, PNG_UINT_tIME);
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_ALWAYS,
chunk_name, 1);
}
#endif #endif
#endif /* PNG_UINT_IHDR */ #endif /* PNG_UINT_IHDR */
} }
@@ -4466,7 +4509,7 @@ count_colors(FILE *fpin)
png_debug(0, "Allocating read_info structure\n"); png_debug(0, "Allocating read_info structure\n");
read_info_ptr = png_create_info_struct(read_ptr); read_info_ptr = png_create_info_struct(read_ptr);
if (read_info_ptr == NULL) if (read_info_ptr == NULL)
png_destroy_read_struct(&read_ptr, NULL, NULL); png_destroy_read_struct(&read_ptr, (png_infop)NULL, (png_infop)NULL);
} }
else else
read_info_ptr = NULL; read_info_ptr = NULL;
@@ -4839,7 +4882,7 @@ count_colors(FILE *fpin)
png_free (read_ptr, row_buf); row_buf = (png_bytep)NULL; png_free (read_ptr, row_buf); row_buf = (png_bytep)NULL;
png_debug(0, "Destroying data structs\n"); png_debug(0, "Destroying data structs\n");
png_destroy_read_struct(&read_ptr, &read_info_ptr, NULL); png_destroy_read_struct(&read_ptr, &read_info_ptr, (png_infop)NULL);
} }
else else
result=2; result=2;
@@ -4849,7 +4892,7 @@ count_colors(FILE *fpin)
fprintf(STDERR, "\nWhile checking alphas in %s ", inname); fprintf(STDERR, "\nWhile checking alphas in %s ", inname);
fprintf(STDERR,"pngcrush caught libpng error:\n %s\n\n",msg); fprintf(STDERR,"pngcrush caught libpng error:\n %s\n\n",msg);
png_free (read_ptr, row_buf); row_buf = (png_bytep)NULL; png_free (read_ptr, row_buf); row_buf = (png_bytep)NULL;
png_destroy_read_struct(&read_ptr, &read_info_ptr, NULL); png_destroy_read_struct(&read_ptr, &read_info_ptr, (png_infop)NULL);
png_debug(0, "Destroyed data structs\n"); png_debug(0, "Destroyed data structs\n");
result=2; result=2;
} }

View File

@@ -18,7 +18,8 @@
#define PNGCRUSH_LIBPNG_VER 10007 #define PNGCRUSH_LIBPNG_VER 10007
#endif #endif
#if !defined(PNG_USE_PNGGCCRD) && !defined(PNG_USE_PNGVCRD) #if !defined(PNG_USE_PNGGCCRD) && !defined(PNG_USE_PNGVCRD) && \
!defined(PNG_NO_ASSEMBLER_CODE)
#define PNG_NO_ASSEMBLER_CODE #define PNG_NO_ASSEMBLER_CODE
#endif #endif

View File

@@ -1,7 +1,7 @@
/* pngerror.c - stub functions for i/o and memory allocation /* pngerror.c - stub functions for i/o and memory allocation
* *
* libpng 1.0.11 - April 27, 2001 * libpng 1.0.12 - June 8, 2001
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -31,6 +31,38 @@ png_default_warning PNGARG((png_structp png_ptr,
void PNGAPI void PNGAPI
png_error(png_structp png_ptr, png_const_charp message) png_error(png_structp png_ptr, png_const_charp message)
{ {
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
char msg[16];
if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
{
int offset = 0;
if (*message == '#')
{
for (offset=1; offset<15; offset++)
if (*(message+offset) == ' ')
break;
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
{
int i;
for (i=0; i<offset-1; i++)
msg[i]=message[i+1];
msg[i]='\0';
message=msg;
}
else
message+=offset;
}
else
{
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
{
msg[0]='0';
msg[1]='\0';
message=msg;
}
}
}
#endif
if (png_ptr->error_fn != NULL) if (png_ptr->error_fn != NULL)
(*(png_ptr->error_fn))(png_ptr, message); (*(png_ptr->error_fn))(png_ptr, message);
@@ -47,10 +79,22 @@ png_error(png_structp png_ptr, png_const_charp message)
void PNGAPI void PNGAPI
png_warning(png_structp png_ptr, png_const_charp message) png_warning(png_structp png_ptr, png_const_charp message)
{ {
int offset = 0;
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
#endif
{
if (*message == '#')
{
for (offset=1; offset<15; offset++)
if (*(message+offset) == ' ')
break;
}
}
if (png_ptr->warning_fn != NULL) if (png_ptr->warning_fn != NULL)
(*(png_ptr->warning_fn))(png_ptr, message); (*(png_ptr->warning_fn))(png_ptr, (png_const_charp)(message+offset));
else else
png_default_warning(png_ptr, message); png_default_warning(png_ptr, (png_const_charp)(message+offset));
} }
/* These utilities are used internally to build an error message that relates /* These utilities are used internally to build an error message that relates
@@ -122,6 +166,27 @@ static void /* PRIVATE */
png_default_error(png_structp png_ptr, png_const_charp message) png_default_error(png_structp png_ptr, png_const_charp message)
{ {
#ifndef PNG_NO_CONSOLE_IO #ifndef PNG_NO_CONSOLE_IO
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
if (*message == '#')
{
int offset;
char error_number[16];
for (offset=0; offset<15; offset++)
{
error_number[offset] = *(message+offset+1);
if (*(message+offset) == ' ')
break;
}
if((offset > 1) && (offset < 15))
{
error_number[offset-1]='\0';
fprintf(stderr, "libpng error no. %s: %s\n", error_number, message+offset);
}
else
fprintf(stderr, "libpng error: %s, offset=%d\n", message,offset);
}
else
#endif
fprintf(stderr, "libpng error: %s\n", message); fprintf(stderr, "libpng error: %s\n", message);
#else #else
if (message) if (message)
@@ -154,7 +219,29 @@ static void /* PRIVATE */
png_default_warning(png_structp png_ptr, png_const_charp message) png_default_warning(png_structp png_ptr, png_const_charp message)
{ {
#ifndef PNG_NO_CONSOLE_IO #ifndef PNG_NO_CONSOLE_IO
fprintf(stderr, "libpng warning: %s\n", message); # ifdef PNG_ERROR_NUMBERS_SUPPORTED
if (*message == '#')
{
int offset;
char warning_number[16];
for (offset=0; offset<15; offset++)
{
warning_number[offset]=*(message+offset+1);
if (*(message+offset) == ' ')
break;
}
if((offset > 1) && (offset < 15))
{
warning_number[offset-1]='\0';
fprintf(stderr, "libpng warning no. %s: %s\n", warning_number,
message+offset);
}
else
fprintf(stderr, "libpng warning: %s\n", message);
}
else
# endif
fprintf(stderr, "libpng warning: %s\n", message);
#else #else
if (message) if (message)
/* appease compiler */ ; /* appease compiler */ ;
@@ -189,4 +276,15 @@ png_get_error_ptr(png_structp png_ptr)
} }
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
void
png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
{
if(png_ptr != NULL)
{
png_ptr->flags &=
((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode);
}
}
#endif

View File

@@ -6,7 +6,7 @@
* and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm * and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm
* for Intel's performance analysis of the MMX vs. non-MMX code. * for Intel's performance analysis of the MMX vs. non-MMX code.
* *
* libpng version 1.0.11 - April 27, 2001 * libpng version 1.0.12 - June 8, 2001
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2001 Glenn Randers-Pehrson
* Copyright (c) 1998, Intel Corporation * Copyright (c) 1998, Intel Corporation
@@ -333,6 +333,34 @@ static int _dif;
static int _patemp; // temp variables for Paeth routine static int _patemp; // temp variables for Paeth routine
static int _pbtemp; static int _pbtemp;
static int _pctemp; static int _pctemp;
static void /* PRIVATE */
png_squelch_warnings(void)
{
_dif = _dif;
_patemp = _patemp;
_pbtemp = _pbtemp;
_pctemp = _pctemp;
_const4 = _const4;
_const6 = _const6;
_MMXLength = _MMXLength;
_mask8_0 = _mask8_0;
_mask16_1 = _mask16_1;
_mask16_0 = _mask16_0;
_mask24_2 = _mask24_2;
_mask24_1 = _mask24_1;
_mask24_0 = _mask24_0;
_mask32_3 = _mask32_3;
_mask32_2 = _mask32_2;
_mask32_1 = _mask32_1;
_mask32_0 = _mask32_0;
_mask48_5 = _mask48_5;
_mask48_4 = _mask48_4;
_mask48_3 = _mask48_3;
_mask48_2 = _mask48_2;
_mask48_1 = _mask48_1;
_mask48_0 = _mask48_0;
}
#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
static int _mmx_supported = 2; static int _mmx_supported = 2;

View File

@@ -1,7 +1,7 @@
/* pngget.c - retrieval of values from info struct /* pngget.c - retrieval of values from info struct
* *
* libpng 1.0.11 - April 27, 2001 * libpng 1.0.12 - June 8, 2001
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -826,3 +826,4 @@ png_get_compression_buffer_size(png_structp png_ptr)
return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L); return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L);
} }

View File

@@ -1,7 +1,7 @@
/* pngmem.c - stub functions for memory allocation /* pngmem.c - stub functions for memory allocation
* *
* libpng 1.0.11 - April 27, 2001 * libpng 1.0.12 - June 8, 2001
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -27,12 +27,12 @@ png_voidp /* PRIVATE */
png_create_struct(int type) png_create_struct(int type)
{ {
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
return (png_create_struct_2(type, NULL)); return (png_create_struct_2(type, NULL, NULL));
} }
/* Alternate version of png_create_struct, for use with user-defined malloc. */ /* Alternate version of png_create_struct, for use with user-defined malloc. */
png_voidp /* PRIVATE */ png_voidp /* PRIVATE */
png_create_struct_2(int type, png_malloc_ptr malloc_fn) png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
{ {
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
png_size_t size; png_size_t size;
@@ -48,9 +48,18 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn)
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
if(malloc_fn != NULL) if(malloc_fn != NULL)
{ {
if ((struct_ptr = (*(malloc_fn))(NULL, size)) != NULL) if (mem_ptr != NULL)
{
png_struct dummy_struct;
png_structp png_ptr = &dummy_struct;
png_ptr->mem_ptr=mem_ptr;
struct_ptr = (*(malloc_fn))(png_ptr, size);
}
else
struct_ptr = (*(malloc_fn))(NULL, size);
if (struct_ptr != NULL)
png_memset(struct_ptr, 0, size); png_memset(struct_ptr, 0, size);
return (struct_ptr); return (struct_ptr);
} }
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL) if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL)
@@ -66,12 +75,13 @@ void /* PRIVATE */
png_destroy_struct(png_voidp struct_ptr) png_destroy_struct(png_voidp struct_ptr)
{ {
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL); png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL, (png_voidp)NULL);
} }
/* Free memory allocated by a png_create_struct() call */ /* Free memory allocated by a png_create_struct() call */
void /* PRIVATE */ void /* PRIVATE */
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn) png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
png_voidp mem_ptr)
{ {
#endif #endif
if (struct_ptr != NULL) if (struct_ptr != NULL)
@@ -81,6 +91,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
{ {
png_struct dummy_struct; png_struct dummy_struct;
png_structp png_ptr = &dummy_struct; png_structp png_ptr = &dummy_struct;
png_ptr->mem_ptr=mem_ptr;
(*(free_fn))(png_ptr, struct_ptr); (*(free_fn))(png_ptr, struct_ptr);
return; return;
} }
@@ -286,14 +297,14 @@ png_voidp /* PRIVATE */
png_create_struct(int type) png_create_struct(int type)
{ {
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
return (png_create_struct_2(type, NULL)); return (png_create_struct_2(type, NULL, NULL));
} }
/* Allocate memory for a png_struct or a png_info. The malloc and /* Allocate memory for a png_struct or a png_info. The malloc and
memset can be replaced by a single call to calloc() if this is thought memset can be replaced by a single call to calloc() if this is thought
to improve performance noticably.*/ to improve performance noticably.*/
png_voidp /* PRIVATE */ png_voidp /* PRIVATE */
png_create_struct_2(int type, png_malloc_ptr malloc_fn) png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
{ {
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
png_size_t size; png_size_t size;
@@ -309,7 +320,16 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn)
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
if(malloc_fn != NULL) if(malloc_fn != NULL)
{ {
if ((struct_ptr = (*(malloc_fn))(NULL, size)) != NULL) if (mem_ptr != NULL)
{
png_struct dummy_struct;
png_structp png_ptr = &dummy_struct;
png_ptr->mem_ptr=mem_ptr;
struct_ptr = (*(malloc_fn))(png_ptr, size);
}
else
struct_ptr = (*(malloc_fn))(NULL, size);
if (struct_ptr != NULL)
png_memset(struct_ptr, 0, size); png_memset(struct_ptr, 0, size);
return (struct_ptr); return (struct_ptr);
} }
@@ -337,12 +357,13 @@ void /* PRIVATE */
png_destroy_struct(png_voidp struct_ptr) png_destroy_struct(png_voidp struct_ptr)
{ {
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL); png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL, (png_voidp)NULL);
} }
/* Free memory allocated by a png_create_struct() call */ /* Free memory allocated by a png_create_struct() call */
void /* PRIVATE */ void /* PRIVATE */
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn) png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
png_voidp mem_ptr)
{ {
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
if (struct_ptr != NULL) if (struct_ptr != NULL)
@@ -352,6 +373,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
{ {
png_struct dummy_struct; png_struct dummy_struct;
png_structp png_ptr = &dummy_struct; png_structp png_ptr = &dummy_struct;
png_ptr->mem_ptr=mem_ptr;
(*(free_fn))(png_ptr, struct_ptr); (*(free_fn))(png_ptr, struct_ptr);
return; return;
} }

View File

@@ -1,7 +1,7 @@
/* pngpread.c - read a png file in push mode /* pngpread.c - read a png file in push mode
* *
* libpng 1.0.11 - April 27, 2001 * libpng 1.0.12 - June 8, 2001
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

136
pngread.c
View File

@@ -1,7 +1,7 @@
/* pngread.c - read a PNG file /* pngread.c - read a PNG file
* *
* libpng 1.0.11 - April 27, 2001 * libpng 1.0.12 - June 8, 2001
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -46,7 +46,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
png_debug(1, "in png_create_read_struct\n"); png_debug(1, "in png_create_read_struct\n");
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
(png_malloc_ptr)malloc_fn)) == NULL) (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr)) == NULL)
#else #else
if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL) if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL)
#endif #endif
@@ -92,22 +92,55 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
* only check the first digit. * only check the first digit.
*/ */
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
(user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) ||
(user_png_ver[0] == '0' && user_png_ver[2] < '9')) (user_png_ver[0] == '0' && user_png_ver[2] < '9'))
{ {
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
char msg[80];
if (user_png_ver)
{
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
user_png_ver);
png_warning(png_ptr, msg);
}
sprintf(msg, "Application is running with png.c from libpng-%.20s",
png_libpng_ver);
png_warning(png_ptr, msg);
#endif
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
png_ptr->flags=0;
#endif
png_error(png_ptr, png_error(png_ptr,
"Incompatible libpng version in application and library"); "Incompatible libpng version in application and library");
} }
/* Libpng 1.0.6 was not binary compatible, due to insertion of the /* Libpng 1.0.6 was not binary compatible, due to insertion of the
info_ptr->free_me member. Note to maintainer: this test can be info_ptr->free_me member. Libpng-1.0.1 and earlier were not
removed from version 2.0.0 and beyond because the previous test compatible due to insertion of the user transform function. Note
would have already rejected it. */ to maintainer: this test can be removed from version 1.2.0 and
beyond because the previous test would have already rejected it. */
if (user_png_ver[4] == '6' && user_png_ver[2] == '0' && if (user_png_ver[0] == '1' && user_png_ver[2] == '0' &&
user_png_ver[0] == '1' && user_png_ver[5] == '\0') (user_png_ver[4] < '2' || user_png_ver[4] == '6') &&
user_png_ver[5] == '\0')
{ {
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
char msg[80];
if (user_png_ver)
{
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
user_png_ver);
png_warning(png_ptr, msg);
}
sprintf(msg, "Application is running with png.c from libpng-%.20s",
png_libpng_ver);
png_warning(png_ptr, msg);
#endif
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
png_ptr->flags=0;
#endif
png_error(png_ptr, png_error(png_ptr,
"Application must be recompiled; version 1.0.6 was incompatible"); "Application must be recompiled; versions <= 1.0.6 were incompatible");
} }
} }
@@ -144,18 +177,64 @@ void PNGAPI
png_read_init(png_structp png_ptr) png_read_init(png_structp png_ptr)
{ {
/* We only come here via pre-1.0.7-compiled applications */ /* We only come here via pre-1.0.7-compiled applications */
png_read_init_2(png_ptr, "1.0.0", 10000, 10000); png_read_init_2(png_ptr, "1.0.6 or earlier", 0, 0);
} }
#undef png_read_init_2
void PNGAPI void PNGAPI
png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver, png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
png_size_t png_struct_size, png_size_t png_info_size) png_size_t png_struct_size, png_size_t png_info_size)
{
/* We only come here via pre-1.0.12-compiled applications */
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
if(sizeof(png_struct) > png_struct_size || sizeof(png_info) > png_info_size)
{
char msg[80];
png_ptr->warning_fn=(png_error_ptr)NULL;
if (user_png_ver)
{
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
user_png_ver);
png_warning(png_ptr, msg);
}
sprintf(msg, "Application is running with png.c from libpng-%.20s",
png_libpng_ver);
png_warning(png_ptr, msg);
}
#endif
if(sizeof(png_struct) > png_struct_size)
{
png_ptr->error_fn=(png_error_ptr)NULL;
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
png_ptr->flags=0;
#endif
png_error(png_ptr,
"The png struct allocated by the application for reading is too small.");
}
if(sizeof(png_info) > png_info_size)
{
png_ptr->error_fn=(png_error_ptr)NULL;
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
png_ptr->flags=0;
#endif
png_error(png_ptr,
"The info struct allocated by application for reading is too small.");
}
png_read_init_3(&png_ptr, user_png_ver, png_struct_size);
}
void PNGAPI
png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
png_size_t png_struct_size)
{ {
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
jmp_buf tmp_jmp; /* to save current jump buffer */ jmp_buf tmp_jmp; /* to save current jump buffer */
#endif #endif
int i=0; int i=0;
png_structp png_ptr=*ptr_ptr;
do do
{ {
if(user_png_ver[i] != png_libpng_ver[i]) if(user_png_ver[i] != png_libpng_ver[i])
@@ -163,28 +242,28 @@ png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
#ifdef PNG_LEGACY_SUPPORTED #ifdef PNG_LEGACY_SUPPORTED
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
#else #else
png_ptr->error_fn=(png_error_ptr)NULL; png_ptr->warning_fn=(png_error_ptr)NULL;
png_error(png_ptr, png_warning(png_ptr,
"Application uses deprecated png_read_init() and must be recompiled."); "Application uses deprecated png_read_init() and should be recompiled.");
break;
#endif #endif
} }
} while (png_libpng_ver[i++]); } while (png_libpng_ver[i++]);
if(sizeof(png_struct) > png_struct_size || png_debug(1, "in png_read_init_3\n");
sizeof(png_info) > png_info_size)
{
png_ptr->error_fn=(png_error_ptr)NULL;
png_error(png_ptr,
"Application and library have different sized structs. Please recompile.");
}
png_debug(1, "in png_read_init_2\n");
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
/* save jump buffer and error functions */ /* save jump buffer and error functions */
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf)); png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
#endif #endif
if(sizeof(png_struct) > png_struct_size)
{
png_destroy_struct(png_ptr);
*ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
png_ptr = *ptr_ptr;
}
/* reset all variables to 0 */ /* reset all variables to 0 */
png_memset(png_ptr, 0, sizeof (png_struct)); png_memset(png_ptr, 0, sizeof (png_struct));
@@ -715,7 +794,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
* not called png_set_interlace_handling(), the display_row buffer will * not called png_set_interlace_handling(), the display_row buffer will
* be ignored, so pass NULL to it. * be ignored, so pass NULL to it.
* *
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.11 * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.12
*/ */
void PNGAPI void PNGAPI
@@ -764,7 +843,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
* only call this function once. If you desire to have an image for * only call this function once. If you desire to have an image for
* each pass of a interlaced image, use png_read_rows() instead. * each pass of a interlaced image, use png_read_rows() instead.
* *
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.11 * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.12
*/ */
void PNGAPI void PNGAPI
png_read_image(png_structp png_ptr, png_bytepp image) png_read_image(png_structp png_ptr, png_bytepp image)
@@ -994,6 +1073,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
png_infop info_ptr = NULL, end_info_ptr = NULL; png_infop info_ptr = NULL, end_info_ptr = NULL;
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_free_ptr free_fn = NULL; png_free_ptr free_fn = NULL;
png_voidp mem_ptr = NULL;
#endif #endif
png_debug(1, "in png_destroy_read_struct\n"); png_debug(1, "in png_destroy_read_struct\n");
@@ -1009,6 +1089,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
free_fn = png_ptr->free_fn; free_fn = png_ptr->free_fn;
mem_ptr = png_ptr->mem_ptr;
#endif #endif
png_read_destroy(png_ptr, info_ptr, end_info_ptr); png_read_destroy(png_ptr, info_ptr, end_info_ptr);
@@ -1020,7 +1101,8 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
#endif #endif
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)info_ptr, free_fn); png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn,
(png_voidp)mem_ptr);
#else #else
png_destroy_struct((png_voidp)info_ptr); png_destroy_struct((png_voidp)info_ptr);
#endif #endif
@@ -1033,7 +1115,8 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1); png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1);
#endif #endif
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)end_info_ptr, free_fn); png_destroy_struct_2((png_voidp)end_info_ptr, (png_free_ptr)free_fn,
(png_voidp)mem_ptr);
#else #else
png_destroy_struct((png_voidp)end_info_ptr); png_destroy_struct((png_voidp)end_info_ptr);
#endif #endif
@@ -1043,7 +1126,8 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
if (png_ptr != NULL) if (png_ptr != NULL)
{ {
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)png_ptr, free_fn); png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
(png_voidp)mem_ptr);
#else #else
png_destroy_struct((png_voidp)png_ptr); png_destroy_struct((png_voidp)png_ptr);
#endif #endif

View File

@@ -1,7 +1,7 @@
/* pngrio.c - functions for data input /* pngrio.c - functions for data input
* *
* libpng 1.0.11 - April 27, 2001 * libpng 1.0.12 - June 8, 2001
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -26,7 +26,7 @@
void /* PRIVATE */ void /* PRIVATE */
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
png_debug1(4,"reading %d bytes\n", length); png_debug1(4,"reading %d bytes\n", (int)length);
if (png_ptr->read_data_fn != NULL) if (png_ptr->read_data_fn != NULL)
(*(png_ptr->read_data_fn))(png_ptr, data, length); (*(png_ptr->read_data_fn))(png_ptr, data, length);
else else

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
* *
* libpng 1.0.11 - April 27, 2001 * libpng 1.0.12 - June 8, 2001
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View File

@@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file /* pngrutil.c - utilities to read a PNG file
* *
* libpng 1.0.11 - April 27, 2001 * libpng 1.0.12 - June 8, 2001
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -339,7 +339,9 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_ptr->bit_depth = (png_byte)bit_depth; png_ptr->bit_depth = (png_byte)bit_depth;
png_ptr->interlaced = (png_byte)interlace_type; png_ptr->interlaced = (png_byte)interlace_type;
png_ptr->color_type = (png_byte)color_type; png_ptr->color_type = (png_byte)color_type;
#if defined(PNG_MNG_FEATURES_SUPPORTED)
png_ptr->filter_type = (png_byte)filter_type; png_ptr->filter_type = (png_byte)filter_type;
#endif
/* find number of channels */ /* find number of channels */
switch (png_ptr->color_type) switch (png_ptr->color_type)
@@ -396,6 +398,13 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_ptr->mode |= PNG_HAVE_PLTE; png_ptr->mode |= PNG_HAVE_PLTE;
if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR))
{
png_warning(png_ptr,
"Ignoring PLTE chunk in grayscale PNG");
png_crc_finish(png_ptr, length);
return;
}
#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) #if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
{ {
@@ -512,9 +521,7 @@ png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_error(png_ptr, "No image in file"); png_error(png_ptr, "No image in file");
/* to quiet compiler warnings about unused info_ptr */ info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */
if (info_ptr == NULL)
return;
} }
png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND); png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND);
@@ -1022,6 +1029,13 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
profile_length = data_length - prefix_length; profile_length = data_length - prefix_length;
if ( profile_length < 4)
{
png_free(png_ptr, chunkdata);
png_warning(png_ptr, "Profile size field missing from iCCP chunk");
return;
}
/* Check the profile_size recorded in the first 32 bits of the ICC profile */ /* Check the profile_size recorded in the first 32 bits of the ICC profile */
profile_size = ((*(chunkdata+prefix_length))<<24) | profile_size = ((*(chunkdata+prefix_length))<<24) |
((*(chunkdata+prefix_length+1))<<16) | ((*(chunkdata+prefix_length+1))<<16) |
@@ -1033,6 +1047,7 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if(profile_size > profile_length) if(profile_size > profile_length)
{ {
png_free(png_ptr, chunkdata);
png_warning(png_ptr, "Ignoring truncated iCCP profile.\n"); png_warning(png_ptr, "Ignoring truncated iCCP profile.\n");
return; return;
} }
@@ -2083,8 +2098,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_crc_finish(png_ptr, skip); png_crc_finish(png_ptr, skip);
#if !defined(PNG_READ_USER_CHUNKS_SUPPORTED) #if !defined(PNG_READ_USER_CHUNKS_SUPPORTED)
if (info_ptr == NULL) info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */
/* quiet compiler warnings about unused info_ptr */ ;
#endif #endif
} }
@@ -2545,9 +2559,7 @@ png_do_read_interlace(png_structp png_ptr)
(png_uint_32)row_info->pixel_depth + 7) >> 3); (png_uint_32)row_info->pixel_depth + 7) >> 3);
} }
#if !defined(PNG_READ_PACKSWAP_SUPPORTED) #if !defined(PNG_READ_PACKSWAP_SUPPORTED)
/* silence compiler warning */ transformations = transformations; /* silence compiler warning */
if (transformations)
return;
#endif #endif
} }
#endif /* !PNG_HAVE_ASSEMBLER_READ_INTERLACE */ #endif /* !PNG_HAVE_ASSEMBLER_READ_INTERLACE */
@@ -2964,7 +2976,9 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
png_error(png_ptr, "This image requires a row greater than 64KB"); png_error(png_ptr, "This image requires a row greater than 64KB");
#endif #endif
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, row_bytes); png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, row_bytes);
#if defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD)
png_ptr->row_buf_size = row_bytes; png_ptr->row_buf_size = row_bytes;
#endif
#ifdef PNG_MAX_MALLOC_64K #ifdef PNG_MAX_MALLOC_64K
if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L) if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L)

View File

@@ -1,7 +1,7 @@
/* pngset.c - storage of image information into info struct /* pngset.c - storage of image information into info struct
* *
* libpng 1.0.11 - April 27, 2001 * libpng 1.0.12 - June 8, 2001
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -654,8 +654,9 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
textp->key = (png_charp)png_malloc(png_ptr, textp->key = (png_charp)png_malloc(png_ptr,
(png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4)); (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4));
png_debug2(2, "Allocated %d bytes at %x in png_set_text\n", png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n",
key_len + lang_len + lang_key_len + text_length + 4, (int)textp->key); (png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4),
(int)textp->key);
png_memcpy(textp->key, text_ptr[i].key, png_memcpy(textp->key, text_ptr[i].key,
(png_size_t)(key_len)); (png_size_t)(key_len));
@@ -968,3 +969,4 @@ png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)
info_ptr->valid &= ~(mask); info_ptr->valid &= ~(mask);
} }

View File

@@ -1,7 +1,7 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers) /* pngtrans.c - transforms the data in a row (used by both readers and writers)
* *
* libpng 1.0.11 - April 27, 2001 * libpng 1.0.12 - June 8, 2001
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View File

@@ -2,7 +2,7 @@
* *
* For Intel x86 CPU and Microsoft Visual C++ compiler * For Intel x86 CPU and Microsoft Visual C++ compiler
* *
* libpng 1.0.11 - April 27, 2001 * libpng 1.0.12 - June 8, 2001
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2001 Glenn Randers-Pehrson
* Copyright (c) 1998, Intel Corporation * Copyright (c) 1998, Intel Corporation

View File

@@ -1,7 +1,7 @@
/* pngwio.c - functions for data output /* pngwio.c - functions for data output
* *
* libpng 1.0.11 - April 27, 2001 * libpng 1.0.12 - June 8, 2001
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View File

@@ -1,7 +1,7 @@
/* pngwrite.c - general routines to write a PNG file /* pngwrite.c - general routines to write a PNG file
* *
* libpng 1.0.11 - April 27, 2001 * libpng 1.0.12 - June 8, 2001
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -444,7 +444,7 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
png_debug(1, "in png_create_write_struct\n"); png_debug(1, "in png_create_write_struct\n");
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
(png_malloc_ptr)malloc_fn)) == NULL) (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr)) == NULL)
#else #else
if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL) if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL)
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
@@ -489,22 +489,55 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
* only check the first digit. * only check the first digit.
*/ */
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
(user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) ||
(user_png_ver[0] == '0' && user_png_ver[2] < '9')) (user_png_ver[0] == '0' && user_png_ver[2] < '9'))
{ {
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
char msg[80];
if (user_png_ver)
{
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
user_png_ver);
png_warning(png_ptr, msg);
}
sprintf(msg, "Application is running with png.c from libpng-%.20s",
png_libpng_ver);
png_warning(png_ptr, msg);
#endif
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
png_ptr->flags=0;
#endif
png_error(png_ptr, png_error(png_ptr,
"Incompatible libpng version in application and library"); "Incompatible libpng version in application and library");
} }
/* Libpng 1.0.6 was not binary compatible, due to insertion of the /* Libpng 1.0.6 was not binary compatible, due to insertion of the
info_ptr->free_me member. Note to maintainer: this test can be info_ptr->free_me member. Libpng-1.0.1 and earlier were not
removed from version 2.0.0 and beyond because the previous test compatible due to insertion of the user transform function. Note
would have already rejected it. */ to maintainer: this test can be removed from version 1.2.0 and
beyond because the previous test would have already rejected it. */
if (user_png_ver[4] == '6' && user_png_ver[2] == '0' && if (user_png_ver[0] == '1' && user_png_ver[2] == '0' &&
user_png_ver[0] == '1' && user_png_ver[5] == '\0') (user_png_ver[4] < '2' || user_png_ver[4] == '6') &&
user_png_ver[5] == '\0')
{ {
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
char msg[80];
if (user_png_ver)
{
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
user_png_ver);
png_warning(png_ptr, msg);
}
sprintf(msg, "Application is running with png.c from libpng-%.20s",
png_libpng_ver);
png_warning(png_ptr, msg);
#endif
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
png_ptr->flags=0;
#endif
png_error(png_ptr, png_error(png_ptr,
"Application must be recompiled; version 1.0.6 was incompatible"); "Application must be recompiled; versions <= 1.0.6 were incompatible");
} }
} }
@@ -529,13 +562,58 @@ void PNGAPI
png_write_init(png_structp png_ptr) png_write_init(png_structp png_ptr)
{ {
/* We only come here via pre-1.0.7-compiled applications */ /* We only come here via pre-1.0.7-compiled applications */
png_write_init_2(png_ptr, "1.0.0", 10000, 10000); png_write_init_2(png_ptr, "1.0.6 or earlier", 0, 0);
} }
#undef png_write_init_2
void PNGAPI void PNGAPI
png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver, png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver,
png_size_t png_struct_size, png_size_t png_info_size) png_size_t png_struct_size, png_size_t png_info_size)
{ {
/* We only come here via pre-1.0.12-compiled applications */
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
if(sizeof(png_struct) > png_struct_size || sizeof(png_info) > png_info_size)
{
char msg[80];
png_ptr->warning_fn=(png_error_ptr)NULL;
if (user_png_ver)
{
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
user_png_ver);
png_warning(png_ptr, msg);
}
sprintf(msg, "Application is running with png.c from libpng-%.20s",
png_libpng_ver);
png_warning(png_ptr, msg);
}
#endif
if(sizeof(png_struct) > png_struct_size)
{
png_ptr->error_fn=(png_error_ptr)NULL;
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
png_ptr->flags=0;
#endif
png_error(png_ptr,
"The png struct allocated by the application for writing is too small.");
}
if(sizeof(png_info) > png_info_size)
{
png_ptr->error_fn=(png_error_ptr)NULL;
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
png_ptr->flags=0;
#endif
png_error(png_ptr,
"The info struct allocated by the application for writing is too small.");
}
png_write_init_3(&png_ptr, user_png_ver, png_struct_size);
}
void PNGAPI
png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
png_size_t png_struct_size)
{
png_structp png_ptr=*ptr_ptr;
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
jmp_buf tmp_jmp; /* to save current jump buffer */ jmp_buf tmp_jmp; /* to save current jump buffer */
#endif #endif
@@ -547,28 +625,28 @@ png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver,
#ifdef PNG_LEGACY_SUPPORTED #ifdef PNG_LEGACY_SUPPORTED
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
#else #else
png_ptr->error_fn=(png_error_ptr)NULL; png_ptr->warning_fn=(png_error_ptr)NULL;
png_error(png_ptr, png_warning(png_ptr,
"Application uses deprecated png_write_init() and must be recompiled."); "Application uses deprecated png_write_init() and should be recompiled.");
break;
#endif #endif
} }
} while (png_libpng_ver[i++]); } while (png_libpng_ver[i++]);
if (sizeof(png_struct) > png_struct_size || png_debug(1, "in png_write_init_3\n");
sizeof(png_info) > png_info_size)
{
png_ptr->error_fn=(png_error_ptr)NULL;
png_error(png_ptr,
"Application and library have different sized structs. Please recompile.");
}
png_debug(1, "in png_write_init_2\n");
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
/* save jump buffer and error functions */ /* save jump buffer and error functions */
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf)); png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
#endif #endif
if (sizeof(png_struct) > png_struct_size)
{
png_destroy_struct(png_ptr);
png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
*ptr_ptr = png_ptr;
}
/* reset all variables to 0 */ /* reset all variables to 0 */
png_memset(png_ptr, 0, sizeof (png_struct)); png_memset(png_ptr, 0, sizeof (png_struct));
@@ -577,11 +655,12 @@ png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver,
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf)); png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
#endif #endif
png_set_write_fn(png_ptr, NULL, NULL, NULL);
/* initialize zbuf - compression buffer */ /* initialize zbuf - compression buffer */
png_ptr->zbuf_size = PNG_ZBUF_SIZE; png_ptr->zbuf_size = PNG_ZBUF_SIZE;
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
(png_uint_32)png_ptr->zbuf_size); (png_uint_32)png_ptr->zbuf_size);
png_set_write_fn(png_ptr, NULL, NULL, NULL);
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT,
@@ -876,6 +955,7 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
png_infop info_ptr = NULL; png_infop info_ptr = NULL;
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_free_ptr free_fn = NULL; png_free_ptr free_fn = NULL;
png_voidp mem_ptr = NULL;
#endif #endif
png_debug(1, "in png_destroy_write_struct\n"); png_debug(1, "in png_destroy_write_struct\n");
@@ -904,7 +984,8 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
#endif #endif
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)info_ptr, free_fn); png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn,
(png_voidp)mem_ptr);
#else #else
png_destroy_struct((png_voidp)info_ptr); png_destroy_struct((png_voidp)info_ptr);
#endif #endif
@@ -915,7 +996,8 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
{ {
png_write_destroy(png_ptr); png_write_destroy(png_ptr);
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)png_ptr, free_fn); png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
(png_voidp)mem_ptr);
#else #else
png_destroy_struct((png_voidp)png_ptr); png_destroy_struct((png_voidp)png_ptr);
#endif #endif

View File

@@ -1,7 +1,7 @@
/* pngwtran.c - transforms the data in a row for PNG writers /* pngwtran.c - transforms the data in a row for PNG writers
* *
* libpng 1.0.11 - April 27, 2001 * libpng 1.0.12 - June 8, 2001
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View File

@@ -1,7 +1,7 @@
/* pngwutil.c - utilities to write a PNG file /* pngwutil.c - utilities to write a PNG file
* *
* libpng 1.0.11 - April 27, 2001 * libpng 1.0.12 - June 8, 2001
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2001 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -285,7 +285,7 @@ png_text_compress(png_structp png_ptr,
comp->output_ptr = (png_charpp)png_malloc(png_ptr, comp->output_ptr = (png_charpp)png_malloc(png_ptr,
(png_uint_32)(comp->max_output_ptr * sizeof (png_charpp))); (png_uint_32)(comp->max_output_ptr * sizeof (png_charpp)));
png_memcpy(comp->output_ptr, old_ptr, png_memcpy(comp->output_ptr, old_ptr,
old_max * sizeof (png_charp)); old_max * sizeof (png_charp));
png_free(png_ptr, old_ptr); png_free(png_ptr, old_ptr);
} }
else else
@@ -460,7 +460,9 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
png_ptr->bit_depth = (png_byte)bit_depth; png_ptr->bit_depth = (png_byte)bit_depth;
png_ptr->color_type = (png_byte)color_type; png_ptr->color_type = (png_byte)color_type;
png_ptr->interlaced = (png_byte)interlace_type; png_ptr->interlaced = (png_byte)interlace_type;
#if defined(PNG_MNG_FEATURES_SUPPORTED)
png_ptr->filter_type = (png_byte)filter_type; png_ptr->filter_type = (png_byte)filter_type;
#endif
png_ptr->width = width; png_ptr->width = width;
png_ptr->height = height; png_ptr->height = height;
@@ -536,20 +538,27 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
png_debug(1, "in png_write_PLTE\n"); png_debug(1, "in png_write_PLTE\n");
if (( if ((
#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ #if defined(PNG_MNG_FEATURES_SUPPORTED) || \
defined (PNG_WRITE_EMPTY_PLTE_SUPPORTED) defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) && !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) &&
#endif #endif
num_pal == 0) || num_pal > 256) num_pal == 0) || num_pal > 256)
{
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{ {
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) png_error(png_ptr, "Invalid number of colors in palette");
{ }
png_error(png_ptr, "Invalid number of colors in palette"); else
} {
else png_warning(png_ptr, "Invalid number of colors in palette");
{ return;
png_warning(png_ptr, "Invalid number of colors in palette"); }
return; }
}
if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR))
{
png_warning(png_ptr,
"Ignoring request to write a PLTE chunk in grayscale PNG");
return;
} }
png_ptr->num_palette = (png_uint_16)num_pal; png_ptr->num_palette = (png_uint_16)num_pal;
@@ -1020,7 +1029,7 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
{ {
if ( if (
#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ #if defined(PNG_MNG_FEATURES_SUPPORTED) || \
defined (PNG_WRITE_EMPTY_PLTE_SUPPORTED) defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
(png_ptr->num_palette || (png_ptr->num_palette ||
(!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) && (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) &&
#endif #endif
@@ -1417,9 +1426,9 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); png_warning(png_ptr, "Unrecognized equation type for pCAL chunk");
purpose_len = png_check_keyword(png_ptr, purpose, &new_purpose) + 1; purpose_len = png_check_keyword(png_ptr, purpose, &new_purpose) + 1;
png_debug1(3, "pCAL purpose length = %d\n", purpose_len); png_debug1(3, "pCAL purpose length = %d\n", (int)purpose_len);
units_len = png_strlen(units) + (nparams == 0 ? 0 : 1); units_len = png_strlen(units) + (nparams == 0 ? 0 : 1);
png_debug1(3, "pCAL units length = %d\n", units_len); png_debug1(3, "pCAL units length = %d\n", (int)units_len);
total_len = purpose_len + units_len + 10; total_len = purpose_len + units_len + 10;
params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams
@@ -1434,7 +1443,7 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
total_len += (png_size_t)params_len[i]; total_len += (png_size_t)params_len[i];
} }
png_debug1(3, "pCAL total length = %d\n", total_len); png_debug1(3, "pCAL total length = %d\n", (int)total_len);
png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len); png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len);
png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len); png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len);
png_save_int_32(buf, X0); png_save_int_32(buf, X0);
@@ -1486,7 +1495,7 @@ png_write_sCAL(png_structp png_ptr, int unit, double width,double height)
#endif #endif
total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf); total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf);
png_debug1(3, "sCAL total length = %d\n", total_len); png_debug1(3, "sCAL total length = %d\n", (int)total_len);
png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len); png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len);
png_write_chunk_data(png_ptr, (png_bytep)&unit, 1); png_write_chunk_data(png_ptr, (png_bytep)&unit, 1);
png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1); png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1);

5
zlib.h
View File

@@ -35,6 +35,11 @@
* *
* The switch statement in inflate.c was rearranged so that case BLOCKS is * The switch statement in inflate.c was rearranged so that case BLOCKS is
* checked first. Glenn Randers-Pehrson, April 2001. * checked first. Glenn Randers-Pehrson, April 2001.
*
* Added tests for Windows platforms at line 136 in zutil.h, since some
* emulators will use MSC compiler on other platforms. Glenn Randers-Pehrson,
* May 2001. Suggested by Emmanuel Blot.
*
*/ */
#ifndef _ZLIB_H #ifndef _ZLIB_H

View File

@@ -8,6 +8,8 @@
subject to change. Applications should only use zlib.h. subject to change. Applications should only use zlib.h.
*/ */
/* Added tests for Windows platforms at line 136. glennrp, May 2001 */
/* @(#) $Id$ */ /* @(#) $Id$ */
#ifndef _Z_UTIL_H #ifndef _Z_UTIL_H
@@ -133,7 +135,9 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
# define fdopen(fd,mode) NULL /* No fdopen() */ # define fdopen(fd,mode) NULL /* No fdopen() */
#endif #endif
#if (defined(_MSC_VER) && (_MSC_VER > 600)) #if (defined(_MSC_VER) && (_MSC_VER > 600)) && (defined(WIN32) || \
defined(_Windows) || defined(_WINDOWS) || defined(_WIN32) || \
defined(__WIN32__))
# define fdopen(fd,type) _fdopen(fd,type) # define fdopen(fd,type) _fdopen(fd,type)
#endif #endif