diff options
author | Glenn Randers-Pehrson <glennrp at users.sourceforge.net> | 2001-12-12 18:01:38 -0600 |
---|---|---|
committer | Glenn Randers-Pehrson <glennrp at users.sourceforge.net> | 2009-04-16 10:46:56 -0500 |
commit | 2eb0852fd6993b7d25a0e942231bf4d7ddbd04e6 (patch) | |
tree | 50125d31d3ee0d99d137b792a47531cdfe93df2e | |
parent | f671d863fe45e837a8fa58be506a733213c49d7d (diff) | |
download | libpng-2eb0852fd6993b7d25a0e942231bf4d7ddbd04e6.tar.gz |
Imported from pngcrush-1.5.8.tarv1.5.8
-rw-r--r-- | README.txt | 28 | ||||
-rw-r--r-- | png.c | 27 | ||||
-rw-r--r-- | png.h | 74 | ||||
-rw-r--r-- | pngasmrd.h | 2 | ||||
-rw-r--r-- | pngconf.h | 21 | ||||
-rw-r--r-- | pngcrush.c | 116 | ||||
-rw-r--r-- | pngerror.c | 2 | ||||
-rw-r--r-- | pnggccrd.c | 4 | ||||
-rw-r--r-- | pngget.c | 2 | ||||
-rw-r--r-- | pngmem.c | 56 | ||||
-rw-r--r-- | pngpread.c | 32 | ||||
-rw-r--r-- | pngread.c | 42 | ||||
-rw-r--r-- | pngrio.c | 2 | ||||
-rw-r--r-- | pngrtran.c | 46 | ||||
-rw-r--r-- | pngrutil.c | 4 | ||||
-rw-r--r-- | pngset.c | 16 | ||||
-rw-r--r-- | pngtrans.c | 2 | ||||
-rw-r--r-- | pngvcrd.c | 5 | ||||
-rw-r--r-- | pngwio.c | 2 | ||||
-rw-r--r-- | pngwrite.c | 41 | ||||
-rw-r--r-- | pngwtran.c | 2 | ||||
-rw-r--r-- | pngwutil.c | 5 |
22 files changed, 323 insertions, 208 deletions
diff --git a/README.txt b/README.txt index d8015aefc..8fd1ca2fb 100644 --- a/README.txt +++ b/README.txt @@ -41,13 +41,14 @@ case of any discrepancy, the copy in pngcrush.c shall prevail): This is the output of "pngcrush" and "pngcrush -help": - | pngcrush 1.5.7, Copyright (C) 1998-2001 Glenn Randers-Pehrson + + | pngcrush 1.5.8, Copyright (C) 1998-2001 Glenn Randers-Pehrson | This is a free, open-source program. Permission is irrevocably | granted to everyone to use this version of pngcrush without | payment of any fee. | Executable name is pngcrush - | It was built with libpng version 1.2.0, and is - | running with libpng version 1.2.0 - September 1, 2001 (header) + | It was built with libpng version 1.2.1, and is + | running with libpng version 1.2.1 - December 12, 2001 (header) | Copyright (C) 1998-2001 Glenn Randers-Pehrson, | Copyright (C) 1996, 1997 Andreas Dilger, | Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc., @@ -63,7 +64,6 @@ options: -bit_depth depth (bit_depth to use in output file) -brute (Use brute-force, try 114 different methods [11-124]) -c color_type of output file [0, 2, 4, or 6] - -cc (do color counting) -d directory_name (where output files will go) -double_gamma (used for fixing gamma in PhotoShop 5.0/5.02 files) -e extension (used for creating output filename) @@ -77,7 +77,6 @@ options: -loco ("loco crush" truecolor PNGs) -m method [0 through 200] -max maximum_IDAT_size [default 8192] - -no_cc (no color counting) -nofilecheck (do not check for infile.png == outfile.png) -n (no save; does not do compression or write output PNG) -plte_len n (truncate PLTE) @@ -89,6 +88,7 @@ options: -save (keep all copy-unsafe chunks) -srgb [0, 1, 2, or 3] -text b[efore_IDAT]|a[fter_IDAT] "keyword" "text" + -trns_array n trns[0] trns[1] .. trns[n-1] -trns index red green blue gray -v (display more detailed information) -version (display the pngcrush version) @@ -101,13 +101,13 @@ options: -p (pause) - | pngcrush 1.5.7, Copyright (C) 1998-2001 Glenn Randers-Pehrson + | pngcrush 1.5.8, Copyright (C) 1998-2001 Glenn Randers-Pehrson | This is a free, open-source program. Permission is irrevocably | granted to everyone to use this version of pngcrush without | payment of any fee. | Executable name is pngcrush - | It was built with libpng version 1.2.0, and is - | running with libpng version 1.2.0 - September 1, 2001 (header) + | It was built with libpng version 1.2.1, and is + | running with libpng version 1.2.1 - December 12, 2001 (header) | Copyright (C) 1998-2001 Glenn Randers-Pehrson, | Copyright (C) 1996, 1997 Andreas Dilger, | Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc., @@ -152,8 +152,6 @@ options (Note: any option can be spelled out for clarity, e.g., Use 0 or 2 to delete an unwanted alpha channel. Default is to use same color type as the input file. - -cc (do color counting) - -d directory_name (where output files will go) If a directory name is given, then the output @@ -227,8 +225,6 @@ options (Note: any option can be spelled out for clarity, e.g., -max maximum_IDAT_size [default 8192] - -no_cc (no color counting) - -nofilecheck (do not check for infile.png == outfile.png) To avoid false hits from MSVC-compiled code. Note @@ -289,6 +285,11 @@ options (Note: any option can be spelled out for clarity, e.g., text < 2048 chars. For now, you can only add ten tEXt, iTXt, or zTXt chunks per pngcrush run. + -trns_array n trns[0] trns[1] .. trns[n-1] + + Insert a tRNS chunk, if no tRNS chunk found in file. + Values are for the tRNS array in indexed-color PNG. + -trns index red green blue gray Insert a tRNS chunk, if no tRNS chunk found in file. @@ -302,7 +303,7 @@ options (Note: any option can be spelled out for clarity, e.g., -version (display the pngcrush version) Look for the most recent version of pngcrush at - http://pmt.sourceforge.net + http://pmt.sf.net -w compression_window_size [32, 16, 8, 4, 2, 1, 512] @@ -336,3 +337,4 @@ options (Note: any option can be spelled out for clarity, e.g., Wait for [enter] key before continuing display. e.g., type 'pngcrush -pause -help', if the help screen scrolls out of sight. + @@ -1,7 +1,7 @@ /* png.c - location for general purpose libpng functions * - * libpng version 1.2.0 - September 1, 2001 + * libpng version 1.2.1 - December 12, 2001 * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -13,14 +13,14 @@ #include "png.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_2_0 Your_png_h_is_not_version_1_2_0; +typedef version_1_2_1 Your_png_h_is_not_version_1_2_1; /* Version information for C files. This had better match the version * string defined in png.h. */ #ifdef PNG_USE_GLOBAL_ARRAYS /* png_libpng_ver was changed to a function in version 1.0.5c */ -const char png_libpng_ver[18] = "1.2.0"; +const char png_libpng_ver[18] = "1.2.1"; /* png_sig was changed to a function in version 1.0.5c */ /* Place to hold the signature string for a PNG file. */ @@ -212,14 +212,13 @@ png_create_info_struct(png_structp png_ptr) png_debug(1, "in png_create_info_struct\n"); if(png_ptr == NULL) return (NULL); #ifdef PNG_USER_MEM_SUPPORTED - if ((info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, - png_ptr->malloc_fn, png_ptr->mem_ptr)) != NULL) + info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, + png_ptr->malloc_fn, png_ptr->mem_ptr); #else - if ((info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO)) != NULL) + info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); #endif - { + if (info_ptr != NULL) png_info_init_3(&info_ptr, sizeof(png_info)); - } return (info_ptr); } @@ -248,7 +247,7 @@ png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) #else png_destroy_struct((png_voidp)info_ptr); #endif - *info_ptr_ptr = (png_infop)NULL; + *info_ptr_ptr = NULL; } } @@ -551,7 +550,7 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr) if (png_ptr->num_chunk_list) { png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=(png_bytep)NULL; + png_ptr->chunk_list=NULL; png_ptr->num_chunk_list=0; } #endif @@ -646,7 +645,7 @@ png_charp PNGAPI png_get_copyright(png_structp png_ptr) { if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */ - return ((png_charp) "\n libpng version 1.2.0 - September 1, 2001\n\ + return ((png_charp) "\n libpng version 1.2.1 - December 12, 2001\n\ Copyright (c) 1998-2001 Glenn Randers-Pehrson\n\ Copyright (c) 1996, 1997 Andreas Dilger\n\ Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n"); @@ -664,8 +663,8 @@ png_get_libpng_ver(png_structp png_ptr) { /* Version of *.c files used when building libpng */ if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return((png_charp) "1.2.0"); - return((png_charp) "1.2.0"); + return((png_charp) "1.2.1"); + return((png_charp) "1.2.1"); } png_charp PNGAPI @@ -715,7 +714,7 @@ png_uint_32 PNGAPI png_access_version_number(void) { /* Version of *.c files used when building libpng */ - return((png_uint_32) 10200L); + return((png_uint_32) 10201L); } @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.2.0 - September 1, 2001 + * libpng version 1.2.1 - December 12, 2001 * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -9,7 +9,7 @@ * Authors and maintainers: * 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.97, January 1998, through 1.2.0 - September 1, 2001: Glenn + * libpng versions 0.97, January 1998, through 1.2.1 - December 12, 2001: Glenn * See also "Contributing Authors", below. * * Note about libpng version numbers: @@ -75,7 +75,12 @@ * 1.0.12 2 10012 2.1.0.12 * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned) * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 - * 1.2.0beta3-4 3 10200 3.1.2.0beta3-4 + * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 + * 1.2.0rc1 3 10200 3.1.2.0rc1 + * 1.2.0 3 10200 3.1.2.0 + * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4 + * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 + * 1.2.1 3 10201 3.1.2.1 * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be @@ -105,7 +110,7 @@ * If you modify libpng you may insert additional notices immediately following * this sentence. * - * libpng versions 1.0.7, July 1, 2000, through 1.2.0, September 1, 2001, are + * libpng versions 1.0.7, July 1, 2000, through 1.2.1, December 12, 2001, are * Copyright (c) 2000, 2001 Glenn Randers-Pehrson, and are * distributed according to the same disclaimer and license as libpng-1.0.6 * with the following individuals added to the list of Contributing Authors @@ -210,13 +215,13 @@ * Y2K compliance in libpng: * ========================= * - * September 1, 2001 + * December 12, 2001 * * Since the PNG Development group is an ad-hoc body, we can't make * an official declaration. * * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.2.0 are Y2K compliant. It is my belief that earlier + * upward through 1.2.1 are Y2K compliant. It is my belief that earlier * versions were also Y2K compliant. * * Libpng only has three year fields. One is a 2-byte unsigned integer @@ -272,7 +277,7 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.2.0" +#define PNG_LIBPNG_VER_STRING "1.2.1" #define PNG_LIBPNG_VER_SONUM 3 #define PNG_LIBPNG_VER_DLLNUM %DLLNUM% @@ -280,7 +285,7 @@ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ #define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MINOR 2 -#define PNG_LIBPNG_VER_RELEASE 0 +#define PNG_LIBPNG_VER_RELEASE 1 /* This should match the numeric part of the final component of * PNG_LIBPNG_VER_STRING, omitting any leading zero: */ @@ -299,7 +304,7 @@ * 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.1 it's xxyyzz, where x=major, y=minor, z=release */ -#define PNG_LIBPNG_VER 10200 /* 1.2.0 */ +#define PNG_LIBPNG_VER 10201 /* 1.2.1 */ #ifndef PNG_VERSION_INFO_ONLY @@ -320,6 +325,40 @@ extern "C" { * which applications aren't expected to use directly. */ +#ifndef PNG_NO_TYPECAST_NULL +#define int_p_NULL (int *)NULL +#define png_bytep_NULL (png_bytep)NULL +#define png_bytepp_NULL (png_bytepp)NULL +#define png_doublep_NULL (png_doublep)NULL +#define png_error_ptr_NULL (png_error_ptr)NULL +#define png_flush_ptr_NULL (png_flush_ptr)NULL +#define png_free_ptr_NULL (png_free_ptr)NULL +#define png_infopp_NULL (png_infopp)NULL +#define png_malloc_ptr_NULL (png_malloc_ptr)NULL +#define png_read_status_ptr_NULL (png_read_status_ptr)NULL +#define png_rw_ptr_NULL (png_rw_ptr)NULL +#define png_structp_NULL (png_structp)NULL +#define png_uint_16p_NULL (png_uint_16p)NULL +#define png_voidp_NULL (png_voidp)NULL +#define png_write_status_ptr_NULL (png_write_status_ptr)NULL +#else +#define int_p_NULL NULL +#define png_bytep_NULL NULL +#define png_bytepp_NULL NULL +#define png_doublep_NULL NULL +#define png_error_ptr_NULL NULL +#define png_flush_ptr_NULL NULL +#define png_free_ptr_NULL NULL +#define png_infopp_NULL NULL +#define png_malloc_ptr_NULL NULL +#define png_read_status_ptr_NULL NULL +#define png_rw_ptr_NULL NULL +#define png_structp_NULL NULL +#define png_uint_16p_NULL NULL +#define png_voidp_NULL NULL +#define png_write_status_ptr_NULL NULL +#endif + /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) /* Version information for C files, stored in png.c. This had better match @@ -1044,9 +1083,9 @@ struct png_struct_def float background_gamma; # endif png_color_16 background; /* background color in screen gamma space */ -# if defined(PNG_READ_GAMMA_SUPPORTED) - png_color_16 background_1; /* background normalized to gamma 1.0 */ -# endif /* PNG_READ_GAMMA && PNG_bKGD_SUPPORTED */ +#if defined(PNG_READ_GAMMA_SUPPORTED) + png_color_16 background_1; /* background normalized to gamma 1.0 */ +#endif #endif /* PNG_bKGD_SUPPORTED */ #if defined(PNG_WRITE_FLUSH_SUPPORTED) @@ -1214,9 +1253,9 @@ struct png_struct_def /* This prevents a compiler error in png_get_copyright() in png.c if png.c - and png.h are both at version 1.2.0 + and png.h are both at version 1.2.1 */ -typedef png_structp version_1_2_0; +typedef png_structp version_1_2_1; typedef png_struct FAR * FAR * png_structpp; @@ -2333,7 +2372,7 @@ extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp /* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ #define PNG_HEADER_VERSION_STRING \ - " libpng version 1.2.0 - September 1, 2001 (header)\n" + " libpng version 1.2.1 - December 12, 2001 (header)\n" #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED /* With these routines we avoid an integer divide, which will be slower on @@ -2946,12 +2985,17 @@ PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, #endif #if defined(PNG_READ_BACKGROUND_SUPPORTED) +#if defined(PNG_READ_GAMMA_SUPPORTED) PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, png_color_16p trans_values, png_color_16p background, png_color_16p background_1, png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, png_uint_16pp gamma_16_to_1, int gamma_shift)); +#else +PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, + png_color_16p trans_values, png_color_16p background)); +#endif #endif #if defined(PNG_READ_GAMMA_SUPPORTED) diff --git a/pngasmrd.h b/pngasmrd.h index 420f5fed7..b96a46417 100644 --- a/pngasmrd.h +++ b/pngasmrd.h @@ -1,6 +1,6 @@ /* pngasmrd.h - assembler version of utilities to read a PNG file * - * libpng 1.2.0 - September 1, 2001 + * libpng 1.2.1 - December 12, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 2001 Glenn Randers-Pehrson * @@ -1,6 +1,6 @@ /* pngconf.h - machine configurable file for libpng * - * libpng 1.2.0 - September 1, 2001 + * libpng 1.2.1 - December 12, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -204,6 +204,9 @@ #ifdef _NO_PROTO # define PNGARG(arglist) () +# ifndef PNG_TYPECAST_NULL +# define PNG_TYPECAST_NULL +# endif #else # define PNGARG(arglist) arglist #endif /* _NO_PROTO */ @@ -401,10 +404,10 @@ */ #ifndef PNG_iTXt_SUPPORTED -# ifndef PNG_READ_iTXt_SUPPORTED +# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt) # define PNG_NO_READ_iTXt # endif -# ifndef PNG_WRITE_iTXt_SUPPORTED +# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt) # define PNG_NO_WRITE_iTXt # endif #endif @@ -728,8 +731,12 @@ # define PNG_iCCP_SUPPORTED #endif #ifndef PNG_NO_READ_iTXt -# define PNG_READ_iTXt_SUPPORTED -# define PNG_iTXt_SUPPORTED +# ifndef PNG_READ_iTXt_SUPPORTED +# define PNG_READ_iTXt_SUPPORTED +# endif +# ifndef PNG_iTXt_SUPPORTED +# define PNG_iTXt_SUPPORTED +# endif #endif #ifndef PNG_NO_READ_oFFs # define PNG_READ_oFFs_SUPPORTED @@ -844,7 +851,9 @@ # endif #endif #ifndef PNG_NO_WRITE_iTXt -# define PNG_WRITE_iTXt_SUPPORTED +# ifndef PNG_WRITE_iTXt_SUPPORTED +# define PNG_WRITE_iTXt_SUPPORTED +# endif # ifndef PNG_iTXt_SUPPORTED # define PNG_iTXt_SUPPORTED # endif diff --git a/pngcrush.c b/pngcrush.c index 06256641b..22c87c43a 100644 --- a/pngcrush.c +++ b/pngcrush.c @@ -1,8 +1,8 @@ /* pngcrush.c - recompresses png files * Copyright (C) 1998-2001 Glenn Randers-Pehrson (randeg@alum.rpi.edu) * - * The most recent version of pngcrush can be found at - * http://pmt.sourceforge.net/pngcrush/ + * The most recent version of pngcrush can be found at SourceForge in + * http://pmt.sf.net/pngcrush/ * * This program reads in a PNG image, and writes it out again, with the * optimum filter_method and zlib_level. It uses brute force (trying @@ -25,7 +25,7 @@ * */ -#define PNGCRUSH_VERSION "1.5.7" +#define PNGCRUSH_VERSION "1.5.8" /* #define PNGCRUSH_COUNT_COLORS @@ -67,6 +67,10 @@ /* Change log: * + * Version 1.5.8 (built with libpng-1.2.1) + * + * Added -trns_a option for entering a tRNS array. + * * Version 1.5.7 (built with libpng-1.2.0) * * Added setargv.obj to Makefile.msc to expand wildcards, e.g., *.png @@ -239,7 +243,7 @@ * Version 1.4.1 (built with libpng-1.0.6e and cexcept-0.6.0) * * Uses cexcept.h for error handling instead of libpng's built-in - * setjmp/longjmp mechanism. See http://cexcept.sourceforge.net/ + * setjmp/longjmp mechanism. See http://cexcept.sf.net/ * * Pngcrush.c will now run when compiled with old versions of libpng back * to version 0.96, although some features will not be available. @@ -659,6 +663,8 @@ static png_uint_16 trns_blue=0; static png_uint_16 trns_gray=0; #endif static png_byte trns_array[256]; +static png_byte trans_in[256]; +static png_uint_16 num_trans_in; static int have_bkgd=0; static png_uint_16 bkgd_red=0; static png_uint_16 bkgd_green=0; @@ -1645,6 +1651,15 @@ main(int argc, char *argv[]) } } #ifdef PNG_tRNS_SUPPORTED + else if( !strncmp(argv[i],"-trns_a",7) || + !strncmp(argv[i],"-tRNS_a",7)) + { + num_trans_in=(png_uint_16)atoi(argv[++i]); + have_trns=1; + for (ia=0; ia<num_trans_in; ia++) + trans_in[ia]=(png_byte)atoi(argv[++i]); + names+=1+num_trans_in; + } else if( !strncmp(argv[i],"-trns",5) || !strncmp(argv[i],"-tRNS",5)) { @@ -1665,7 +1680,7 @@ main(int argc, char *argv[]) fprintf(STDERR, PNG_LIBPNG_VER_STRING ); fprintf(STDERR,"and zlib "); fprintf(STDERR, ZLIB_VERSION ); - fprintf(STDERR, "\n Check http://pmt.sourceforge.net\n"); + fprintf(STDERR, "\n Check http://pmt.sf.net\n"); fprintf(STDERR, " for the most recent version.\n"); } else if(!strncmp(argv[i],"-v",2)) @@ -2154,6 +2169,15 @@ main(int argc, char *argv[]) } #ifdef PNG_tRNS_SUPPORTED fprintf(STDERR, + " -trns_array n trns[0] trns[1] .. trns[n-1]\n"); + if(verbose > 1) + { + fprintf(STDERR, + "\n Insert a tRNS chunk, if no tRNS chunk found in file.\n"); + fprintf(STDERR, + " Values are for the tRNS array in indexed-color PNG.\n\n"); + } + fprintf(STDERR, " -trns index red green blue gray\n"); if(verbose > 1) { @@ -2177,7 +2201,7 @@ main(int argc, char *argv[]) fprintf(STDERR, "\n Look for the most recent version of pngcrush at\n"); fprintf(STDERR, - " http://pmt.sourceforge.net\n\n"); + " http://pmt.sf.net\n\n"); } fprintf(STDERR, " -w compression_window_size [32, 16, 8, 4, 2, 1, 512]\n"); @@ -2291,7 +2315,7 @@ main(int argc, char *argv[]) } for (ia=0; ia<256; ia++) - trns_array[ia]=255; + trans_in[ia]=trns_array[ia]=255; for(;;) /* loop on input files */ @@ -2417,8 +2441,10 @@ main(int argc, char *argv[]) if(verbose > 0) { - fprintf(STDERR," %s IDAT length in input file = %8lu\n", - inname,idat_length[0]); + fprintf(STDERR," Recompressing %s\n",inname); + fprintf(STDERR, + " Total length of data found in IDAT chunks = %8lu\n", + idat_length[0]); fflush(STDERR); } @@ -3395,35 +3421,6 @@ main(int argc, char *argv[]) } #endif - if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette)) - { - if (plte_len > 0) - num_palette=plte_len; - if (do_pplt) - { - printf("PPLT: %s\n",pplt_string); - } - if(output_color_type == 3) - png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette); - else if(keep_chunk("PLTE",argv)) - png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette); - if(verbose > 1 && first_trial) - { - int i; - png_colorp p = palette; - fprintf(STDERR, " Palette:\n"); - fprintf(STDERR, " I R G B ( color ) A\n"); - for (i=0; i<num_palette; i++) - { - fprintf(STDERR, " %4d %4d %4d %4d (#%2.2x%2.2x%2.2x) %4d\n", - i, p->red, p->green, p->blue, - p->red, p->green, p->blue, - trns_array[i]); - p++; - } - } - } - #if defined(PNG_READ_hIST_SUPPORTED) && defined(PNG_WRITE_hIST_SUPPORTED) { png_uint_16p hist; @@ -3490,6 +3487,16 @@ main(int argc, char *argv[]) num_trans = index_data+1; if(verbose > 1) fprintf(STDERR,"Have_tRNS, num_trans=%d\n",num_trans); + if (output_color_type == 3) + { + trans_values=NULL; + for (ia=0;ia<num_trans;ia++) + trns_array[ia]=trans_in[ia]; + for ( ; ia<256; ia++) + trns_array[ia]=255; + } + else + { for (ia=0;ia<256;ia++) trns_array[ia]=255; trns_array[index_data]=0; @@ -3500,6 +3507,7 @@ main(int argc, char *argv[]) trans_data.blue = trns_blue; trans_data.gray = trns_gray; trans_values = &trans_data; + } P0 (" Adding a tRNS chunk\n"); png_set_tRNS(write_ptr, write_info_ptr, trns_array, num_trans, @@ -3533,6 +3541,38 @@ main(int argc, char *argv[]) } #endif + if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette)) + { + if (plte_len > 0) + num_palette=plte_len; + if (do_pplt) + { + printf("PPLT: %s\n",pplt_string); + printf("Sorry, PPLT is not implemented yet.\n"); + } + if(output_color_type == 3) + png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette); + else if(keep_chunk("PLTE",argv)) + png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette); + if(verbose > 1 && first_trial) + { + int i; + png_colorp p = palette; + fprintf(STDERR, " Palette:\n"); + fprintf(STDERR, " I R G B ( color ) A\n"); + for (i=0; i<num_palette; i++) + { + fprintf(STDERR, " %4d %4d %4d %4d (#%2.2x%2.2x%2.2x) %4d\n", + i, p->red, p->green, p->blue, + p->red, p->green, p->blue, + trns_array[i]); + p++; + } + } + } + + + #if defined(PNG_READ_sBIT_SUPPORTED) && defined(PNG_WRITE_sBIT_SUPPORTED) { png_color_8p sig_bit; diff --git a/pngerror.c b/pngerror.c index cf04c9157..b6ad8d866 100644 --- a/pngerror.c +++ b/pngerror.c @@ -1,7 +1,7 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * libpng 1.2.0 - September 1, 2001 + * libpng 1.2.1 - December 12, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pnggccrd.c b/pnggccrd.c index ce519c51e..e4540c511 100644 --- a/pnggccrd.c +++ b/pnggccrd.c @@ -6,7 +6,7 @@ * and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm * for Intel's performance analysis of the MMX vs. non-MMX code. * - * libpng version 1.2.0 - September 1, 2001 + * libpng version 1.2.1 - December 12, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * Copyright (c) 1998, Intel Corporation @@ -5287,6 +5287,8 @@ png_mmx_support(void) "popfl \n\t" // restore modified value to Eflag reg "pushfl \n\t" // save Eflag to stack "popl %%eax \n\t" // get Eflag from stack + "pushl %%ecx \n\t" // save original Eflag to stack + "popfl \n\t" // restore original Eflag "xorl %%ecx, %%eax \n\t" // compare new Eflag with original Eflag "jz .NOT_SUPPORTED \n\t" // if same, CPUID instr. is not supported @@ -1,7 +1,7 @@ /* pngget.c - retrieval of values from info struct * - * libpng 1.2.0 - September 1, 2001 + * libpng 1.2.1 - December 12, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -1,7 +1,7 @@ /* pngmem.c - stub functions for memory allocation * - * libpng 1.2.0 - September 1, 2001 + * libpng 1.2.1 - December 12, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -27,7 +27,7 @@ png_voidp /* PRIVATE */ png_create_struct(int type) { #ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, NULL, NULL)); + return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); } /* Alternate version of png_create_struct, for use with user-defined malloc. */ @@ -43,39 +43,30 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) else if (type == PNG_STRUCT_PNG) size = sizeof(png_struct); else - return ((png_voidp)NULL); + return (NULL); #ifdef PNG_USER_MEM_SUPPORTED if(malloc_fn != 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); - return (struct_ptr); + png_struct dummy_struct; + png_structp png_ptr = &dummy_struct; + png_ptr->mem_ptr=mem_ptr; + struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size); } + else #endif /* PNG_USER_MEM_SUPPORTED */ - if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL) - { + struct_ptr = (png_voidp)farmalloc(size)); + if (struct_ptr != NULL) png_memset(struct_ptr, 0, size); - } return (struct_ptr); } - /* Free memory allocated by a png_create_struct() call */ void /* PRIVATE */ png_destroy_struct(png_voidp struct_ptr) { #ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL, (png_voidp)NULL); + png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); } /* Free memory allocated by a png_create_struct() call */ @@ -126,12 +117,12 @@ png_malloc(png_structp png_ptr, png_uint_32 size) png_voidp ret; #endif if (png_ptr == NULL || size == 0) - return ((png_voidp)NULL); + return (NULL); #ifdef PNG_USER_MEM_SUPPORTED if(png_ptr->malloc_fn != NULL) { - ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size)); + ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); if (ret == NULL) png_error(png_ptr, "Out of memory!"); return (ret); @@ -297,7 +288,7 @@ png_voidp /* PRIVATE */ png_create_struct(int type) { #ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, NULL, NULL)); + return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); } /* Allocate memory for a png_struct or a png_info. The malloc and @@ -315,20 +306,15 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) else if (type == PNG_STRUCT_PNG) size = sizeof(png_struct); else - return ((png_voidp)NULL); + return (NULL); #ifdef PNG_USER_MEM_SUPPORTED if(malloc_fn != 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); + png_struct dummy_struct; + png_structp png_ptr = &dummy_struct; + png_ptr->mem_ptr=mem_ptr; + struct_ptr = (*(malloc_fn))(png_ptr, size); if (struct_ptr != NULL) png_memset(struct_ptr, 0, size); return (struct_ptr); @@ -357,7 +343,7 @@ void /* PRIVATE */ png_destroy_struct(png_voidp struct_ptr) { #ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL, (png_voidp)NULL); + png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); } /* Free memory allocated by a png_create_struct() call */ @@ -402,7 +388,7 @@ png_malloc(png_structp png_ptr, png_uint_32 size) { png_voidp ret; if (png_ptr == NULL || size == 0) - return ((png_voidp)NULL); + return (NULL); #ifdef PNG_USER_MEM_SUPPORTED if(png_ptr->malloc_fn != NULL) diff --git a/pngpread.c b/pngpread.c index 4f7baf66c..9207cbd4e 100644 --- a/pngpread.c +++ b/pngpread.c @@ -1,7 +1,7 @@ /* pngpread.c - read a png file in push mode * - * libpng 1.2.0 - September 1, 2001 + * libpng 1.2.1 - December 12, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -792,7 +792,7 @@ png_push_process_row(png_structp png_ptr) { for (i = 0; i < 4 && png_ptr->pass == 2; i++) { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } } @@ -800,13 +800,13 @@ png_push_process_row(png_structp png_ptr) { for (i = 0; i < 2 && png_ptr->pass == 4; i++) { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } } if (png_ptr->pass == 6 && png_ptr->height <= 4) { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } break; @@ -823,7 +823,7 @@ png_push_process_row(png_structp png_ptr) { for (i = 0; i < 4 && png_ptr->pass == 2; i++) { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } } @@ -839,14 +839,14 @@ png_push_process_row(png_structp png_ptr) } for (i = 0; i < 4 && png_ptr->pass == 2; i++) { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } if (png_ptr->pass == 4) /* pass 3 might be empty */ { for (i = 0; i < 2 && png_ptr->pass == 4; i++) { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } } @@ -864,7 +864,7 @@ png_push_process_row(png_structp png_ptr) { for (i = 0; i < 2 && png_ptr->pass == 4; i++) { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } } @@ -880,12 +880,12 @@ png_push_process_row(png_structp png_ptr) } for (i = 0; i < 2 && png_ptr->pass == 4; i++) { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } if (png_ptr->pass == 6) /* pass 5 might be empty */ { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } break; @@ -900,7 +900,7 @@ png_push_process_row(png_structp png_ptr) } if (png_ptr->pass == 6) /* skip top generated row */ { - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } break; @@ -911,7 +911,7 @@ png_push_process_row(png_structp png_ptr) png_read_push_finish_row(png_ptr); if (png_ptr->pass != 6) break; - png_push_have_row(png_ptr, NULL); + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } } @@ -1072,8 +1072,8 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr) text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; text_ptr->key = key; #ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = (char *)NULL; - text_ptr->lang_key = (char *)NULL; + text_ptr->lang = NULL; + text_ptr->lang_key = NULL; #endif text_ptr->text = text; @@ -1257,8 +1257,8 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt; text_ptr->key = key; #ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = (char *)NULL; - text_ptr->lang_key = (char *)NULL; + text_ptr->lang = NULL; + text_ptr->lang_key = NULL; #endif text_ptr->text = text; @@ -1,7 +1,7 @@ /* pngread.c - read a PNG file * - * libpng 1.2.0 - September 1, 2001 + * libpng 1.2.1 - December 12, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -22,7 +22,7 @@ png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, #ifdef PNG_USER_MEM_SUPPORTED return (png_create_read_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, NULL, NULL, NULL)); + warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); } /* Alternate create PNG structure for reading, and allocate any memory needed. */ @@ -50,9 +50,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, #else if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL) #endif - { - return (png_structp)NULL; - } + return (NULL); #ifdef PNG_ASSEMBLER_CODE_SUPPORTED png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ @@ -68,7 +66,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, png_free(png_ptr, png_ptr->zbuf); png_ptr->zbuf=NULL; png_destroy_struct(png_ptr); - return (png_structp)NULL; + return (NULL); } #ifdef USE_FAR_KEYWORD png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf)); @@ -107,7 +105,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, user_png_ver); png_warning(png_ptr, msg); } - sprintf(msg, "Application is running with png.c from libpng-%.20s", + sprintf(msg, "Application is running with png.c from libpng-%.20s", png_libpng_ver); png_warning(png_ptr, msg); #endif @@ -139,7 +137,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_set_read_fn(png_ptr, NULL, NULL); + png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); return (png_ptr); } @@ -165,21 +163,21 @@ png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver, if(sizeof(png_struct) > png_struct_size || sizeof(png_info) > png_info_size) { char msg[80]; - png_ptr->warning_fn=(png_error_ptr)NULL; + png_ptr->warning_fn=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", + 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; + png_ptr->error_fn=NULL; #ifdef PNG_ERROR_NUMBERS_SUPPORTED png_ptr->flags=0; #endif @@ -188,7 +186,7 @@ png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver, } if(sizeof(png_info) > png_info_size) { - png_ptr->error_fn=(png_error_ptr)NULL; + png_ptr->error_fn=NULL; #ifdef PNG_ERROR_NUMBERS_SUPPORTED png_ptr->flags=0; #endif @@ -217,7 +215,7 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, #ifdef PNG_LEGACY_SUPPORTED png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; #else - png_ptr->warning_fn=(png_error_ptr)NULL; + png_ptr->warning_fn=NULL; png_warning(png_ptr, "Application uses deprecated png_read_init() and should be recompiled."); break; @@ -267,7 +265,7 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_set_read_fn(png_ptr, NULL, NULL); + png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); } /* Read the information before the actual image data. This has been @@ -769,7 +767,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 * be ignored, so pass NULL to it. * - * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.0 + * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.1 */ void PNGAPI @@ -796,14 +794,14 @@ png_read_rows(png_structp png_ptr, png_bytepp row, for (i = 0; i < num_rows; i++) { png_bytep rptr = *rp; - png_read_row(png_ptr, rptr, NULL); + png_read_row(png_ptr, rptr, png_bytep_NULL); rp++; } else if(dp != NULL) for (i = 0; i < num_rows; i++) { png_bytep dptr = *dp; - png_read_row(png_ptr, NULL, dptr); + png_read_row(png_ptr, png_bytep_NULL, dptr); dp++; } } @@ -818,7 +816,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row, * only call this function once. If you desire to have an image for * each pass of a interlaced image, use png_read_rows() instead. * - * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.0 + * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.1 */ void PNGAPI png_read_image(png_structp png_ptr, png_bytepp image) @@ -848,7 +846,7 @@ png_read_image(png_structp png_ptr, png_bytepp image) rp = image; for (i = 0; i < image_height; i++) { - png_read_row(png_ptr, *rp, NULL); + png_read_row(png_ptr, *rp, png_bytep_NULL); rp++; } } @@ -1081,7 +1079,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, #else png_destroy_struct((png_voidp)info_ptr); #endif - *info_ptr_ptr = (png_infop)NULL; + *info_ptr_ptr = NULL; } if (end_info_ptr != NULL) @@ -1095,7 +1093,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, #else png_destroy_struct((png_voidp)end_info_ptr); #endif - *end_info_ptr_ptr = (png_infop)NULL; + *end_info_ptr_ptr = NULL; } if (png_ptr != NULL) @@ -1106,7 +1104,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, #else png_destroy_struct((png_voidp)png_ptr); #endif - *png_ptr_ptr = (png_structp)NULL; + *png_ptr_ptr = NULL; } } @@ -1,7 +1,7 @@ /* pngrio.c - functions for data input * - * libpng 1.2.0 - September 1, 2001 + * libpng 1.2.1 - December 12, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngrtran.c b/pngrtran.c index e045c94cb..2d62779cf 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -1,7 +1,7 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * libpng 1.2.0 - September 1, 2001 + * libpng 1.2.1 - December 12, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -742,7 +742,7 @@ png_init_read_transformations(png_structp png_ptr) } #endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) png_ptr->background_1 = png_ptr->background; #endif #if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) @@ -901,7 +901,7 @@ png_init_read_transformations(png_structp png_ptr) } else /* transformation does not include PNG_BACKGROUND */ -#endif +#endif /* PNG_READ_BACKGROUND_SUPPORTED */ if (color_type == PNG_COLOR_TYPE_PALETTE) { png_colorp palette = png_ptr->palette; @@ -919,7 +919,7 @@ png_init_read_transformations(png_structp png_ptr) #if defined(PNG_READ_BACKGROUND_SUPPORTED) else #endif -#endif +#endif /* PNG_READ_GAMMA_SUPPORTED && PNG_FLOATING_POINT_SUPPORTED */ #if defined(PNG_READ_BACKGROUND_SUPPORTED) /* No GAMMA transformation */ if ((png_ptr->transformations & PNG_BACKGROUND) && @@ -952,7 +952,7 @@ png_init_read_transformations(png_structp png_ptr) } } } -#endif +#endif /* PNG_READ_BACKGROUND_SUPPORTED */ #if defined(PNG_READ_SHIFT_SUPPORTED) if ((png_ptr->transformations & PNG_SHIFT) && @@ -977,7 +977,7 @@ png_init_read_transformations(png_structp png_ptr) png_ptr->palette[i].blue >>= sb; } } -#endif +#endif /* PNG_READ_SHIFT_SUPPORTED */ } #if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \ && !defined(PNG_READ_BACKGROUND_SUPPORTED) @@ -1227,12 +1227,15 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998: ((png_ptr->num_trans != 0 ) || (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) png_do_background(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->trans_values), &(png_ptr->background), - &(png_ptr->background_1), + &(png_ptr->trans_values), &(png_ptr->background) +#if defined(PNG_READ_GAMMA_SUPPORTED) + , &(png_ptr->background_1), png_ptr->gamma_table, png_ptr->gamma_from_1, png_ptr->gamma_to_1, png_ptr->gamma_16_table, png_ptr->gamma_16_from_1, png_ptr->gamma_16_to_1, - png_ptr->gamma_shift); + png_ptr->gamma_shift +#endif +); #endif #if defined(PNG_READ_GAMMA_SUPPORTED) @@ -2545,11 +2548,14 @@ png_correct_palette(png_structp png_ptr, png_colorp palette, */ void /* PRIVATE */ png_do_background(png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background, - png_color_16p background_1, + png_color_16p trans_values, png_color_16p background +#if defined(PNG_READ_GAMMA_SUPPORTED) + , png_color_16p background_1, png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, - png_uint_16pp gamma_16_to_1, int gamma_shift) + png_uint_16pp gamma_16_to_1, int gamma_shift +#endif + ) { png_bytep sp, dp; png_uint_32 i; @@ -2932,6 +2938,7 @@ png_do_background(png_row_infop row_info, png_bytep row, { *dp = *sp; } +#if defined(PNG_READ_GAMMA_SUPPORTED) else if (a == 0) { *dp = (png_byte)background->gray; @@ -2940,6 +2947,9 @@ png_do_background(png_row_infop row_info, png_bytep row, { png_composite(*dp, *sp, a, background_1->gray); } +#else + *dp = (png_byte)background->gray; +#endif } } } @@ -2963,12 +2973,17 @@ png_do_background(png_row_infop row_info, png_bytep row, *dp = (png_byte)((v >> 8) & 0xff); *(dp + 1) = (png_byte)(v & 0xff); } +#if defined(PNG_READ_GAMMA_SUPPORTED) else if (a == 0) +#else + else +#endif { /* background is already in screen gamma */ *dp = (png_byte)((background->gray >> 8) & 0xff); *(dp + 1) = (png_byte)(background->gray & 0xff); } +#if defined(PNG_READ_GAMMA_SUPPORTED) else { png_uint_16 g, v, w; @@ -2979,6 +2994,7 @@ png_do_background(png_row_infop row_info, png_bytep row, *dp = (png_byte)((w >> 8) & 0xff); *(dp + 1) = (png_byte)(w & 0xff); } +#endif } } else @@ -2993,11 +3009,16 @@ png_do_background(png_row_infop row_info, png_bytep row, { png_memcpy(dp, sp, 2); } +#if defined(PNG_READ_GAMMA_SUPPORTED) else if (a == 0) +#else + else +#endif { *dp = (png_byte)((background->gray >> 8) & 0xff); *(dp + 1) = (png_byte)(background->gray & 0xff); } +#if defined(PNG_READ_GAMMA_SUPPORTED) else { png_uint_16 g, v; @@ -3007,6 +3028,7 @@ png_do_background(png_row_infop row_info, png_bytep row, *dp = (png_byte)((v >> 8) & 0xff); *(dp + 1) = (png_byte)(v & 0xff); } +#endif } } } diff --git a/pngrutil.c b/pngrutil.c index 1977783fb..dca7c655d 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -1,7 +1,7 @@ /* pngrutil.c - utilities to read a PNG file * - * libpng 1.2.0 - September 1, 2001 + * libpng 1.2.1 - December 12, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -1029,7 +1029,7 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) profile_length = data_length - prefix_length; - if ( profile_length < 4) + if ( prefix_length > data_length || profile_length < 4) { png_free(png_ptr, chunkdata); png_warning(png_ptr, "Profile size field missing from iCCP chunk"); @@ -1,7 +1,7 @@ /* pngset.c - storage of image information into info struct * - * libpng 1.2.0 - September 1, 2001 + * libpng 1.2.1 - December 12, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -152,8 +152,9 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) #ifdef PNG_FREE_ME_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); #endif + /* Changed from info->num_palette to 256 in version 1.2.1 */ png_ptr->hist = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(info_ptr->num_palette * sizeof (png_uint_16))); + (png_uint_32)(256 * sizeof (png_uint_16))); for (i = 0; i < info_ptr->num_palette; i++) png_ptr->hist[i] = hist[i]; @@ -410,7 +411,9 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr, #ifdef PNG_FREE_ME_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0); #endif - png_ptr->palette = (png_colorp)png_zalloc(png_ptr, (uInt)num_palette, + /* Changed in libpng-1.2.1 to allocate 256 instead of num_palette entries, + in case of an invalid PNG file that has too-large sample values. */ + png_ptr->palette = (png_colorp)png_zalloc(png_ptr, (uInt)256, sizeof (png_color)); png_memcpy(png_ptr->palette, palette, num_palette * sizeof (png_color)); info_ptr->palette = png_ptr->palette; @@ -676,8 +679,8 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, #endif { #ifdef PNG_iTXt_SUPPORTED - textp->lang=(png_charp)NULL; - textp->lang_key=(png_charp)NULL; + textp->lang=NULL; + textp->lang_key=NULL; #endif textp->text=textp->key + key_len + 1; } @@ -740,8 +743,9 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr, #ifdef PNG_FREE_ME_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); #endif + /* Changed from num_trans to 256 in version 1.2.1 */ png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr, - (png_uint_32)num_trans); + (png_uint_32)256); png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans); #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_TRNS; diff --git a/pngtrans.c b/pngtrans.c index 6398dcf34..6eee9fb1e 100644 --- a/pngtrans.c +++ b/pngtrans.c @@ -1,7 +1,7 @@ /* pngtrans.c - transforms the data in a row (used by both readers and writers) * - * libpng 1.2.0 - September 1, 2001 + * libpng 1.2.1 - December 12, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -2,7 +2,7 @@ * * For Intel x86 CPU and Microsoft Visual C++ compiler * - * libpng 1.2.0 - September 1, 2001 + * libpng version 1.2.1 - December 12, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * Copyright (c) 1998, Intel Corporation @@ -39,6 +39,7 @@ png_mmx_support(void) push ebx //CPUID will trash these push ecx push edx + pushfd //Save Eflag to stack pop eax //Get Eflag from stack into eax mov ecx, eax //Make another copy of Eflag in ecx @@ -48,6 +49,8 @@ png_mmx_support(void) popfd //Restored modified value back to Eflag reg pushfd //Save Eflag to stack pop eax //Get Eflag from stack + push ecx // save original Eflag to stack + popfd // restore original Eflag xor eax, ecx //Compare the new Eflag with the original Eflag jz NOT_SUPPORTED //If the same, CPUID instruction is not supported, //skip following instructions and jump to @@ -1,7 +1,7 @@ /* pngwio.c - functions for data output * - * libpng 1.2.0 - September 1, 2001 + * libpng 1.2.1 - December 12, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngwrite.c b/pngwrite.c index afec136cb..f46ce0f6b 100644 --- a/pngwrite.c +++ b/pngwrite.c @@ -1,7 +1,7 @@ /* pngwrite.c - general routines to write a PNG file * - * libpng 1.2.0 - September 1, 2001 + * libpng 1.2.1 - December 12, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -424,7 +424,7 @@ png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr, { #ifdef PNG_USER_MEM_SUPPORTED return (png_create_write_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, NULL, NULL, NULL)); + warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); } /* Alternate initialize png_ptr structure, and allocate any memory needed */ @@ -448,9 +448,7 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, #else if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL) #endif /* PNG_USER_MEM_SUPPORTED */ - { - return ((png_structp)NULL); - } + return (NULL); #ifdef PNG_ASSEMBLER_CODE_SUPPORTED png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ @@ -466,7 +464,7 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, png_free(png_ptr, png_ptr->zbuf); png_ptr->zbuf=NULL; png_destroy_struct(png_ptr); - return ((png_structp)NULL); + return (NULL); } #ifdef USE_FAR_KEYWORD png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf)); @@ -504,7 +502,7 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, user_png_ver); png_warning(png_ptr, msg); } - sprintf(msg, "Application is running with png.c from libpng-%.20s", + sprintf(msg, "Application is running with png.c from libpng-%.20s", png_libpng_ver); png_warning(png_ptr, msg); #endif @@ -521,11 +519,12 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); - png_set_write_fn(png_ptr, NULL, NULL, NULL); + png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, + png_flush_ptr_NULL); #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, - 1, NULL, NULL); + 1, png_doublep_NULL, png_doublep_NULL); #endif return ((png_structp)png_ptr); @@ -550,21 +549,21 @@ png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver, if(sizeof(png_struct) > png_struct_size || sizeof(png_info) > png_info_size) { char msg[80]; - png_ptr->warning_fn=(png_error_ptr)NULL; + png_ptr->warning_fn=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", + 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; + png_ptr->error_fn=NULL; #ifdef PNG_ERROR_NUMBERS_SUPPORTED png_ptr->flags=0; #endif @@ -573,7 +572,7 @@ png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver, } if(sizeof(png_info) > png_info_size) { - png_ptr->error_fn=(png_error_ptr)NULL; + png_ptr->error_fn=NULL; #ifdef PNG_ERROR_NUMBERS_SUPPORTED png_ptr->flags=0; #endif @@ -600,7 +599,7 @@ png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, #ifdef PNG_LEGACY_SUPPORTED png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; #else - png_ptr->warning_fn=(png_error_ptr)NULL; + png_ptr->warning_fn=NULL; png_warning(png_ptr, "Application uses deprecated png_write_init() and should be recompiled."); break; @@ -634,7 +633,8 @@ png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf)); #endif - png_set_write_fn(png_ptr, NULL, NULL, NULL); + png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, + png_flush_ptr_NULL); /* initialize zbuf - compression buffer */ png_ptr->zbuf_size = PNG_ZBUF_SIZE; @@ -643,7 +643,7 @@ png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, - 1, NULL, NULL); + 1, png_doublep_NULL, png_doublep_NULL); #endif } @@ -705,6 +705,11 @@ png_write_row(png_structp png_ptr, png_bytep row) /* initialize transformations and other stuff if first time */ if (png_ptr->row_number == 0 && png_ptr->pass == 0) { + /* make sure we wrote the header info */ + if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) + png_error(png_ptr, + "png_write_info was never called before png_write_row."); + /* check for transforms that have been set but were defined out */ #if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED) if (png_ptr->transformations & PNG_INVERT_MONO) @@ -968,7 +973,7 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) #else png_destroy_struct((png_voidp)info_ptr); #endif - *info_ptr_ptr = (png_infop)NULL; + *info_ptr_ptr = NULL; } if (png_ptr != NULL) @@ -980,7 +985,7 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) #else png_destroy_struct((png_voidp)png_ptr); #endif - *png_ptr_ptr = (png_structp)NULL; + *png_ptr_ptr = NULL; } } diff --git a/pngwtran.c b/pngwtran.c index 7a38b9c41..55e691d28 100644 --- a/pngwtran.c +++ b/pngwtran.c @@ -1,7 +1,7 @@ /* pngwtran.c - transforms the data in a row for PNG writers * - * libpng 1.2.0 - September 1, 2001 + * libpng 1.2.1 - December 12, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngwutil.c b/pngwutil.c index 5613a1f17..1f2d72442 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -1,7 +1,7 @@ /* pngwutil.c - utilities to write a PNG file * - * libpng 1.2.0 - September 1, 2001 + * libpng 1.2.1 - December 12, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -608,7 +608,8 @@ png_write_IEND(png_structp png_ptr) PNG_IEND; #endif png_debug(1, "in png_write_IEND\n"); - png_write_chunk(png_ptr, (png_bytep)png_IEND, NULL, (png_size_t)0); + png_write_chunk(png_ptr, (png_bytep)png_IEND, png_bytep_NULL, + (png_size_t)0); png_ptr->mode |= PNG_HAVE_IEND; } |