diff options
author | Glenn Randers-Pehrson <glennrp at users.sourceforge.net> | 2000-03-12 07:31:31 -0600 |
---|---|---|
committer | Glenn Randers-Pehrson <glennrp at users.sourceforge.net> | 2009-04-16 10:46:41 -0500 |
commit | 66e6b07dfd77d0ab61961f2b93e107cfa71e3581 (patch) | |
tree | de4bae9c2cf10b2734bbc4b9ad1d6cfe6585f918 | |
parent | 601daa7a76cc5375118683607a9c384c5131c72e (diff) | |
download | libpng-1.3.6.tar.gz |
Imported from pngcrush-1.3.6.tarv1.3.6
-rw-r--r-- | png.c | 25 | ||||
-rw-r--r-- | png.h | 69 | ||||
-rw-r--r-- | pngasmrd.h | 2 | ||||
-rw-r--r-- | pngconf.h | 16 | ||||
-rw-r--r-- | pngcrush.c | 93 | ||||
-rw-r--r-- | pngcrush.h | 6 | ||||
-rw-r--r-- | pngerror.c | 2 | ||||
-rw-r--r-- | pnggccrd.c | 2 | ||||
-rw-r--r-- | pngget.c | 4 | ||||
-rw-r--r-- | pngmem.c | 2 | ||||
-rw-r--r-- | pngpread.c | 10 | ||||
-rw-r--r-- | pngread.c | 13 | ||||
-rw-r--r-- | pngrio.c | 2 | ||||
-rw-r--r-- | pngrtran.c | 69 | ||||
-rw-r--r-- | pngrutil.c | 22 | ||||
-rw-r--r-- | pngset.c | 27 | ||||
-rw-r--r-- | pngtrans.c | 2 | ||||
-rw-r--r-- | pngtypes.h | 2 | ||||
-rw-r--r-- | pngvcrd.c | 2 | ||||
-rw-r--r-- | pngwio.c | 2 | ||||
-rw-r--r-- | pngwrite.c | 8 | ||||
-rw-r--r-- | pngwtran.c | 2 | ||||
-rw-r--r-- | pngwutil.c | 12 |
23 files changed, 218 insertions, 176 deletions
@@ -1,7 +1,7 @@ /* png.c - location for general purpose libpng functions * - * libpng version 1.0.5s - February 18, 2000 + * libpng version 1.0.5v - March 11, 2000 * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson @@ -13,13 +13,15 @@ #include <assert.h> #include "png.h" +/* Generate a compiler error if there is an old png.h in the search path. */ +typedef version_1_0_5v Your_png_h_is_not_version_1_0_5v; + /* 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 /* png_libpng_ver was changed to a function in version 1.0.5c */ -char png_libpng_ver[12] = "1.0.5s"; +char png_libpng_ver[12] = "1.0.5v"; /* png_sig was changed to a function in version 1.0.5c */ /* Place to hold the signature string for a PNG file. */ @@ -543,7 +545,7 @@ png_charp png_get_copyright(png_structp png_ptr) { if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */ - return ("\n libpng version 1.0.5s - February 18, 2000\n\ + return ("\n libpng version 1.0.5v - March 11, 2000\n\ Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\ Copyright (c) 1996, 1997 Andreas Dilger\n\ Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson\n"); @@ -561,8 +563,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("1.0.5s"); - return("1.0.5s"); + return("1.0.5v"); + return("1.0.5v"); } png_charp @@ -583,15 +585,6 @@ png_get_header_version(png_structp png_ptr) return(PNG_HEADER_VERSION_STRING); } -/* Generate a compiler error if there is an old png.h in the search path. */ -void -png_check_version - (version_1_0_5s png_h_is_not_version_1_0_5s) -{ - if(png_h_is_not_version_1_0_5s == NULL) - return; -} - #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED int png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.0.5s - February 18, 2000 + * libpng version 1.0.5v - March 11, 2000 * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson @@ -9,19 +9,19 @@ * Authors and maintainers: * libpng versions 0.71, May 1995, through 0.89c, May 1996: Guy Schalnat * libpng versions 0.90, December 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.0.5s - February 18, 2000: Glenn + * libpng versions 0.97, January 1998, through 1.0.5v - March 11, 2000: Glenn * See also "Contributing Authors", below. * * Y2K compliance in libpng: * ========================= * - * February 18, 2000 + * March 11, 2000 * * 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.0.5s are Y2K compliant. It is my belief that earlier + * upward through 1.0.5v 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 @@ -99,7 +99,8 @@ * 1.0.5 1.0.5 10005 2.1.0.5 * 1.0.5a-d 1.0.5a-d 10006 2.1.0.5a-d * 1.0.5e-r 1.0.5e-r 10100 2.1.0.5e-r (not compatible) - * 1.0.5s 1.0.5s 10006 2.1.0.5s (compatible) + * 1.0.5s-v 1.0.5s-v 10006 2.1.0.5s-v (compatible) + * 1.0.6 1.0.6 10006 2.1.0.6 * 1.3.0 1.3.0 10300 3.1.3.0 * * Henceforth the source version will match the shared-library minor @@ -124,7 +125,7 @@ * Copyright (c) 1996, 1997 Andreas Dilger * (libpng versions 0.90, December 1996, through 0.96, May 1997) * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson - * (libpng versions 0.97, January 1998, through 1.0.5s, February 18, 2000) + * (libpng versions 0.97, January 1998, through 1.0.5v, March 11, 2000) * * For the purposes of this copyright and license, "Contributing Authors" * is defined as the following set of individuals: @@ -157,16 +158,13 @@ * source code, or portions hereof, for any purpose, without fee, subject * to the following restrictions: * - * 1. The origin of this source code must not be - * misrepresented. + * 1. The origin of this source code must not be misrepresented. * - * 2. Altered versions must be plainly marked as such - * and must not be misrepresented as being the - * original source. + * 2. Altered versions must be plainly marked as such and must not + * be misrepresented as being the original source. * - * 3. This Copyright notice may not be removed or - * altered from any source or altered source - * distribution. + * 3. This Copyright notice may not be removed or altered from any + * source or altered source distribution. * * The Contributing Authors and Group 42, Inc. specifically permit, without * fee, and encourage the use of this source code as a component to @@ -230,7 +228,7 @@ extern "C" { */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.0.5s" +#define PNG_LIBPNG_VER_STRING "1.0.5v" /* Careful here. At one time, Guy wanted to use 082, but that would be octal. * We must not include leading zeros. @@ -310,26 +308,26 @@ typedef png_color_8 FAR * FAR * png_color_8pp; * The following two structures are used for the in-core representation * of sPLT chunks. */ -typedef struct png_spalette_entry_struct +typedef struct png_sPLT_entry_struct { png_uint_16 red; png_uint_16 green; png_uint_16 blue; png_uint_16 alpha; png_uint_16 frequency; -} png_spalette_entry; -typedef png_spalette_entry FAR * png_spalette_entryp; -typedef png_spalette_entry FAR * FAR * png_spalette_entrypp; +} png_sPLT_entry; +typedef png_sPLT_entry FAR * png_sPLT_entryp; +typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp; -typedef struct png_spalette_struct +typedef struct png_sPLT_struct { png_charp name; /* palette name */ png_byte depth; /* depth of palette samples */ - png_spalette_entryp entries; /* palette entries */ + png_sPLT_entryp entries; /* palette entries */ png_int_32 nentries; /* number of palette entries */ -} png_spalette; -typedef png_spalette FAR * png_spalette_p; -typedef png_spalette FAR * FAR * png_spalette_pp; +} png_sPLT_t; +typedef png_sPLT_t FAR * png_sPLT_tp; +typedef png_sPLT_t FAR * FAR * png_sPLT_tpp; #ifdef PNG_TEXT_SUPPORTED /* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, @@ -635,7 +633,7 @@ defined(PNG_READ_BACKGROUND_SUPPORTED) #if defined(PNG_sPLT_SUPPORTED) /* data on sPLT chunks (there may be more than one). */ - png_spalette_p splt_palettes; + png_sPLT_tp splt_palettes; png_uint_32 splt_palettes_num; #endif @@ -1039,9 +1037,9 @@ struct png_struct_def #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) png_byte rgb_to_gray_status; - png_byte rgb_to_gray_red_coeff; - png_byte rgb_to_gray_green_coeff; - png_byte rgb_to_gray_blue_coeff; + png_uint_16 rgb_to_gray_red_coeff; + png_uint_16 rgb_to_gray_green_coeff; + png_uint_16 rgb_to_gray_blue_coeff; #endif #if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ @@ -1056,9 +1054,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.0.5s +and png.h are both at * version 1.0.5v */ -typedef png_structp version_1_0_5s; +typedef png_structp version_1_0_5v; typedef png_struct FAR * FAR * png_structpp; @@ -1179,6 +1177,8 @@ extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr, int error_action, double red, double green )); #endif +extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr, + int error_action, png_fixed_point red, png_fixed_point green )); extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp png_ptr)); #endif @@ -1887,12 +1887,12 @@ extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr, #if defined(PNG_READ_sPLT_SUPPORTED) extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_spalette_pp entries)); + png_infop info_ptr, png_sPLT_tpp entries)); #endif #if defined(PNG_sPLT_SUPPORTED) extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_spalette_p entries, int nentries)); + png_infop info_ptr, png_sPLT_tp entries, int nentries)); #endif #if defined(PNG_TEXT_SUPPORTED) @@ -2029,7 +2029,7 @@ extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr) extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); #define PNG_HEADER_VERSION_STRING \ - " libpng version 1.0.5s - February 18, 2000 (header)\n" + " libpng version 1.0.5v - March 11, 2000 (header)\n" #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED /* With these routines we avoid an integer divide, which will be slower on @@ -2083,7 +2083,6 @@ extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); /* Various modes of operation. Note that after an init, mode is set to * zero automatically when the structure is created. */ -#define PNG_BEFORE_IHDR 0x00 #define PNG_HAVE_IHDR 0x01 #define PNG_HAVE_PLTE 0x02 #define PNG_HAVE_IDAT 0x04 @@ -2404,7 +2403,7 @@ PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, #if defined(PNG_WRITE_sPLT_SUPPORTED) PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, - png_spalette_p palette)); + png_sPLT_tp palette)); #endif #if defined(PNG_WRITE_tRNS_SUPPORTED) diff --git a/pngasmrd.h b/pngasmrd.h index 63b4aefe8..9a62bf616 100644 --- a/pngasmrd.h +++ b/pngasmrd.h @@ -1,6 +1,6 @@ /* pngasmrd.h - assembler version of utilities to read a PNG file * - * libpng 1.0.5s - February 18, 2000 + * libpng 1.0.5v - March 11, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1999, 2000 Glenn Randers-Pehrson * @@ -1,7 +1,7 @@ /* pngconf.h - machine configurable file for libpng * - * libpng 1.0.5s - February 18, 2000 + * libpng 1.0.5v - March 11, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger @@ -443,9 +443,14 @@ * but might be required for some pre-1.0.5c applications. */ #ifdef PNG_NO_GLOBAL_ARRAYS -#define PNG_USE_LOCAL_ARRAYS +# define PNG_USE_LOCAL_ARRAYS #else -#define PNG_USE_GLOBAL_ARRAYS +# if defined(__GNUC__) && defined(WIN32) +# define PNG_NO_GLOBAL_ARRAYS +# define PNG_USE_LOCAL_ARRAYS +# else +# define PNG_USE_GLOBAL_ARRAYS +# endif #endif /* These are currently experimental features, define them if you want */ @@ -915,7 +920,10 @@ typedef z_stream FAR * png_zstreamp; #endif #ifdef PNG_SETJMP_SUPPORTED -# define png_jmp_env(png_ptr) png_ptr->jmpbuf +# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +#else +# define png_jmpbuf(png_ptr) \ + (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED) #endif #if defined(USE_FAR_KEYWORD) /* memory model independent fns */ diff --git a/pngcrush.c b/pngcrush.c index 184e899fc..b75f8b469 100644 --- a/pngcrush.c +++ b/pngcrush.c @@ -15,12 +15,12 @@ * occasionally creating Linux executables. */ -#define PNGCRUSH_VERSION "1.3.5" +#define PNGCRUSH_VERSION "1.3.6" /* * COPYRIGHT NOTICE, DISCLAIMER, AND LICENSE: * - * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson (randeg@alum.rpi.edu) + * Copyright (C) 1998, 1999, 2000 Glenn Randers-Pehrson (randeg@alum.rpi.edu) * * The pngcrush program is supplied "AS IS". The Author disclaims all * warranties, expressed or implied, including, without limitation, the @@ -45,15 +45,35 @@ /* To do: * * Version 1.3.*: check for unused alpha channel and ok-to-reduce-depth. - * Rearrange palette to put most-used color first and - * transparent color second. Finish pplt (partial palette) feature. + * Rearrange palette to put most-used color first and transparent color + * second (see ImageMagick 5.1.1 and later). + * Finish pplt (partial palette) feature. * * Version 1.3.*: Use an alternate write function for the trial passes, that * simply counts bytes rather than actually writing to a file, to save wear * and tear on disk drives. * + * Version 1.4.*: Allow in-place file replacement or as a filter, as in + * "pngcrush -overwrite file.png" + * "pngcreator | pngcrush > output.png" + * + * Version 1.4.*: Remove text-handling and color-handling features and put + * those in a separate program or programs, to avoid unnecessary + * recompressing. + * * Change log: * + * Version 1.3.6 (built with libpng-1.0.5v) + * + * RGB to Grayscale conversion is more accurate (15-bit instead of 8-bit) + * and now uses only integer arithmetic. + * + * #ifdef'ed out PNG_READ_DITHER + * + * Changed "Compressed" to "Uncompressed" in help for -itxt. + * + * Stifled some compiler warnings + * * Version 1.3.5 (built with libpng-1.0.5s) * * Add test on stat_buf.st_size to verify fpin==fpout, because stat in @@ -180,6 +200,7 @@ #define EXTENSION_MODE 2 #define FOPEN(file, how) fopen(file, how) #define FCLOSE(file) {fclose(file); file=NULL;--number_of_open_files;}; +#define P1 if(verbose > 1)printf #define P2 if(verbose > 2)printf /* we don't need the extra libpng tranformations @@ -188,6 +209,11 @@ #define PNG_INTERNAL #include "png.h" +/* so we can load pngcrush with pre-1.0.6 versions of libpng */ +#ifndef png_jmpbuf +# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +#endif + #ifdef __TURBOC__ #include <mem.h> #endif @@ -422,7 +448,7 @@ void png_crush_pause(void) fprintf(STDERR, "Press [ENTER] key to continue.\n"); keystroke=(char)getc(stdin); if (keystroke) - /* stifle compiler warning */ ; + /* stifle compiler warning */ return; } } #define PNG_CRUSH_CLEANUP \ @@ -438,7 +464,7 @@ void png_crush_pause(void) png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); \ FCLOSE(fpin); \ if(verbose > 1) \ - fprintf(STDERR, "returning after longjump\n"); + fprintf(STDERR, "returning after longjump\n"); int keep_chunk(png_const_charp name, char *argv[]); @@ -1067,7 +1093,7 @@ main(int argc, char *argv[]) fprintf(STDERR, " | Copyright (C) 1998, 1999, 2000 Glenn Randers-Pehrson,\n"); fprintf(STDERR, - " | and zlib version %s, Copyright (c) 1998,\n", + " | and zlib version %s, Copyright (C) 1998,\n", ZLIB_VERSION); fprintf(STDERR, " | Jean-loup Gailly and Mark Adler.\n"); @@ -1077,12 +1103,12 @@ main(int argc, char *argv[]) __VERSION__, "2.81"); /* is there a macro for "as" versions? */ fprintf(STDERR, - " | under DJGPP %d.%d, Copyright (c) 1995, D. J. Delorie\n", + " | under DJGPP %d.%d, Copyright (C) 1995, D. J. Delorie\n", __DJGPP__,__DJGPP_MINOR__); fprintf(STDERR, " | and loaded with PMODE/DJ, by Thomas Pytel and Matthias Grimrath\n"); fprintf(STDERR, - " | Copyright (c) 1996, Matthias Grimrath.\n"); + " | Copyright (C) 1996, Matthias Grimrath.\n"); #endif fprintf(STDERR,"\n"); } @@ -1158,6 +1184,8 @@ main(int argc, char *argv[]) fprintf(STDERR, " the input file does not have alpha information.\n"); fprintf(STDERR, + " You can use 0 or 4 to convert color to grayscale.\n"); + fprintf(STDERR, " Use 0 or 2 to delete an unwanted alpha channel.\n"); fprintf(STDERR, " Default is to use same color type as the input file.\n\n"); @@ -1234,7 +1262,7 @@ main(int argc, char *argv[]) " -itxt b[efore_IDAT]|a[fter_IDAT] \"keyword\" \"text\"\n"); if(verbose > 1) fprintf(STDERR, - "\n Compressed iTXt chunk to insert (see -text).\n\n"); + "\n Uncompressed iTXt chunk to insert (see -text).\n\n"); fprintf(STDERR, " -l zlib_compression_level [0-9]\n"); if(verbose > 1) @@ -1689,7 +1717,9 @@ main(int argc, char *argv[]) it is possible that we will erroneously reject the attempt when inputsize and outputsize are equal, for different files */ - fprintf(STDERR, "Cannot overwrite input file %s\n", inname); + fprintf(STDERR, "\n Cannot overwrite input file %s\n", inname); + P1(" st_ino=%d, st_size=%d\n\n", (int)stat_in.st_ino, + (int)stat_in.st_size); FCLOSE(fpin); return 1; } @@ -1757,7 +1787,7 @@ main(int argc, char *argv[]) # else # ifdef PNG_JMPBUF_SUPPORTED /* New setjmp interface */ - if (setjmp(png_jmp_env(read_ptr))) + if (setjmp(png_jmpbuf(read_ptr))) # else /* old interface */ if (setjmp(read_ptr->jmpbuf)) @@ -1769,7 +1799,7 @@ main(int argc, char *argv[]) } #if defined(USE_FAR_KEYWORD) - png_memcpy(png_jmp_env(read_ptr),jmpbuf,sizeof(jmp_buf)); + png_memcpy(png_jmpbuf(read_ptr),jmpbuf,sizeof(jmp_buf)); #endif if(nosave == 0) # ifdef USE_FAR_KEYWORD @@ -1777,7 +1807,7 @@ main(int argc, char *argv[]) # else # ifdef PNG_JMPBUF_SUPPORTED /* New setjmp interface */ - if (setjmp(png_jmp_env(write_ptr))) + if (setjmp(png_jmpbuf(write_ptr))) # else /* Old interface */ if (setjmp(write_ptr->jmpbuf)) @@ -1788,7 +1818,7 @@ main(int argc, char *argv[]) continue; } #if defined(USE_FAR_KEYWORD) - png_memcpy(png_jmp_env(write_ptr),jmpbuf,sizeof(jmp_buf)); + png_memcpy(png_jmpbuf(write_ptr),jmpbuf,sizeof(jmp_buf)); #endif P2("jmp_buf has been set.\n"); png_crush_pause(); @@ -1910,8 +1940,13 @@ main(int argc, char *argv[]) #endif #else /* !PNG_UINT_IHDR */ +#if !defined(PNG_cHRM_SUPPORTED) || !defined(PNG_hIST_SUPPORTED) || \ + !defined(PNG_iCCP_SUPPORTED) || !defined(PNG_sCAL_SUPPORTED) || \ + !defined(PNG_pCAL_SUPPORTED) || !defined(PNG_sPLT_SUPPORTED) || \ + !defined(PNG_tIME_SUPPORTED) png_byte chunk_name[5]; chunk_name[4]='\0'; +#endif png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_IF_SAFE, NULL, 0); @@ -1965,7 +2000,7 @@ main(int argc, char *argv[]) if (png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, &compression_type, &filter_type)) { - int compression_window=default_compression_window; + int compression_window; int need_expand = 0; input_color_type=color_type; input_bit_depth=bit_depth; @@ -1995,15 +2030,10 @@ main(int argc, char *argv[]) if((color_type == 2 || color_type == 6 || color_type == 3) && (output_color_type == 0 || output_color_type == 4)) { -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) && \ - defined(PNG_FLOATING_POINT_SUPPORTED) - png_set_rgb_to_gray(read_ptr, 1, 54./255., 183./255.); +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + png_set_rgb_to_gray_fixed(read_ptr, 1, -1, -1); if(output_bit_depth < 8)output_bit_depth=8; if(color_type == 3) need_expand = 1; -#else - printf(" Cannot reduce color image to grayscale unless\n"); - printf(" pngcrush is rebuilt with floating point support \n"); - output_color_type=input_color_type; #endif } @@ -2416,7 +2446,7 @@ main(int argc, char *argv[]) } else { - for (i=0 ; ia<256; ia++) + for (ia=0 ; ia<256; ia++) trns_array[ia]=255; } if (verbose > 1 && first_trial) @@ -2494,12 +2524,12 @@ main(int argc, char *argv[]) png_sPLT_tp entries; int num_entries; - num_entries = (int)png_get_spalettes(read_ptr, read_info_ptr, &entries); + num_entries = (int)png_get_sPLT(read_ptr, read_info_ptr, &entries); if (num_entries) { if(keep_chunk("sPLT",argv)) - png_set_spalettes(write_ptr, write_info_ptr, entries, num_entries); - png_free_spalettes(read_ptr, read_info_ptr, num_entries); + png_set_sPLT(write_ptr, write_info_ptr, entries, num_entries); + png_free_data(read_ptr, read_info_ptr, PNG_FREE_SPLT, num_entries); } } #endif @@ -2737,13 +2767,13 @@ main(int argc, char *argv[]) png_debug(0, "\nBegin Pass\n"); for (y = 0; y < height; y++) { - png_read_rows(read_ptr, (png_bytepp)&row_buf, (png_bytepp)NULL, 1); + png_read_row(read_ptr, row_buf, (png_bytep)NULL); if(nosave == 0) { t_stop = (float)clock(); t_decode += (t_stop - t_start); t_start = t_stop; - png_write_rows(write_ptr, (png_bytepp)&row_buf, 1); + png_write_row(write_ptr, row_buf); t_stop = (float)clock(); t_encode += (t_stop - t_start); t_start = t_stop; @@ -3044,7 +3074,7 @@ measure_idats(FILE *fpin) # else # ifdef PNG_JMPBUF_SUPPORTED /* New setjmp interface */ - if (setjmp(png_jmp_env(read_ptr))) + if (setjmp(png_jmpbuf(read_ptr))) # else /* old interface */ if (setjmp(read_ptr->jmpbuf)) @@ -3057,7 +3087,7 @@ measure_idats(FILE *fpin) } # if defined(USE_FAR_KEYWORD) - png_memcpy(png_jmp_env(read_ptr),jmpbuf,sizeof(jmp_buf)); + png_memcpy(png_jmpbuf(read_ptr),jmpbuf,sizeof(jmp_buf)); # endif #endif @@ -3067,7 +3097,6 @@ measure_idats(FILE *fpin) png_set_read_fn(read_ptr, (png_voidp)fpin, png_default_read_data); #endif - measured_idat_length=0; read_ptr->sig_bytes=0; measured_idat_length=png_measure_idat(read_ptr, read_info_ptr); P2("measure_idats: IDAT length=%lu\n",measured_idat_length); diff --git a/pngcrush.h b/pngcrush.h index 3e464c7d2..d4b3a412c 100644 --- a/pngcrush.h +++ b/pngcrush.h @@ -3,9 +3,6 @@ /* Special defines for pngcrush, mostly just to reduce the size of the static executable. */ -#ifndef PNG_FLOATING_POINT_SUPPORTED /* define this if you want to be */ -# define PNG_NO_FLOATING_POINT_SUPPORTED /* able to reduce color to gray */ -#endif #define PNG_NO_READ_cHRM #define PNG_NO_WRITE_cHRM #define PNG_NO_READ_hIST @@ -24,6 +21,7 @@ #define PNG_NO_INFO_IMAGE #define PNG_NO_READ_USER_CHUNKS #define PNG_NO_EASY_ACCESS +#define PNG_NO_READ_DITHER #define PNG_NO_READ_EMPTY_PLTE #define PNG_NO_WRITE_TRANSFORMS #define PNG_NO_PROGRESSIVE_READ @@ -32,9 +30,9 @@ #define PNG_READ_STRIP_ALPHA_SUPPORTED #define PNG_READ_EXPAND_SUPPORTED #define PNG_READ_FILLER_SUPPORTED +#define PNG_READ_RGB_TO_GRAY_SUPPORTED #ifndef PNG_NO_FLOATING_POINT_SUPPORTED # define PNG_READ_GRAY_TO_RGB_SUPPORTED -# define PNG_READ_RGB_TO_GRAY_SUPPORTED # define PNG_READ_BACKGROUND_SUPPORTED # define PNG_READ_GAMMA_SUPPORTED #else diff --git a/pngerror.c b/pngerror.c index 512aeb2fe..dd2a43097 100644 --- a/pngerror.c +++ b/pngerror.c @@ -1,7 +1,7 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * libpng 1.0.5s - February 18, 2000 + * libpng 1.0.5v - March 11, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger diff --git a/pnggccrd.c b/pnggccrd.c index 504111caf..532b58c33 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 1.0.5s - February 18, 2000 + * libpng 1.0.5v - March 11, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998, Intel Corporation * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson @@ -1,7 +1,7 @@ /* pngget.c - retrieval of values from info struct * - * libpng 1.0.5s - February 18, 2000 + * libpng 1.0.5v - March 11, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger @@ -489,7 +489,7 @@ png_get_iCCP(png_structp png_ptr, png_infop info_ptr, #if defined(PNG_READ_sPLT_SUPPORTED) png_uint_32 png_get_sPLT(png_structp png_ptr, png_infop info_ptr, - png_spalette_pp spalettes) + png_sPLT_tpp spalettes) { if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) *spalettes = info_ptr->splt_palettes; @@ -1,7 +1,7 @@ /* pngmem.c - stub functions for memory allocation * - * libpng 1.0.5s - February 18, 2000 + * libpng 1.0.5v - March 11, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger diff --git a/pngpread.c b/pngpread.c index 9da074346..6c7be7f34 100644 --- a/pngpread.c +++ b/pngpread.c @@ -1,7 +1,7 @@ /* pngpread.c - read a png file in push mode * - * libpng 1.0.5s - February 18, 2000 + * libpng 1.0.5v - March 11, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger @@ -952,7 +952,7 @@ png_read_push_finish_row(png_structp png_ptr) void png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - if (png_ptr->mode == PNG_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND) + if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) { png_error(png_ptr, "Out of place tEXt"); /* to quiet some compiler warnings */ @@ -1040,7 +1040,7 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr) void png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - if (png_ptr->mode == PNG_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND) + if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) { png_error(png_ptr, "Out of place zTXt"); /* to quiet some compiler warnings */ @@ -1221,7 +1221,7 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) void png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - if (png_ptr->mode == PNG_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND) + if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) { png_error(png_ptr, "Out of place iTXt"); /* to quiet some compiler warnings */ @@ -1268,7 +1268,7 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr) { png_textp text_ptr; png_charp key; - int comp_flag = 0; + int comp_flag; png_charp lang; png_charp lang_key; png_charp text; @@ -1,7 +1,7 @@ /* pngread.c - read a PNG file * - * libpng 1.0.5s - February 18, 2000 + * libpng 1.0.5v - March 11, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger @@ -641,7 +641,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.0.5s. + * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5v. */ void @@ -690,7 +690,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.0.5s. + * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5v. */ void png_read_image(png_structp png_ptr, png_bytepp image) @@ -1113,9 +1113,6 @@ void png_read_png(png_structp png_ptr, png_infop info_ptr, { int row; - if(transforms == 0 || params == (voidp)NULL) - /* quiet compiler warnings */ ; - #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) /* invert the alpha channel from opacity to transparency */ if (transforms & PNG_TRANSFORM_INVERT_ALPHA) @@ -1237,5 +1234,9 @@ void png_read_png(png_structp png_ptr, png_infop info_ptr, /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ png_read_end(png_ptr, info_ptr); + + if(transforms == 0 || params == (voidp)NULL) + /* quiet compiler warnings */ return; + } #endif @@ -1,7 +1,7 @@ /* pngrio.c - functions for data input * - * libpng 1.0.5s - February 18, 2000 + * libpng 1.0.5v - March 11, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger diff --git a/pngrtran.c b/pngrtran.c index 6037574c0..066bcf942 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -1,7 +1,7 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * libpng 1.0.5s - February 18, 2000 + * libpng 1.0.5v - March 11, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger @@ -582,14 +582,25 @@ png_set_gray_to_rgb(png_structp png_ptr) } #endif -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) && \ - defined(PNG_FLOATING_POINT_SUPPORTED) +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +#if defined(PNG_FLOATING_POINT_SUPPORTED) /* Convert a RGB image to a grayscale of the same width. This allows us, * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image. */ + void png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red, - double green) + double green) +{ + int red_fixed = (int)((float)red*100000.0 + 0.5); + int green_fixed = (int)((float)green*100000.0 + 0.5); + png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed); +} +#endif + +void +png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, + png_fixed_point red, png_fixed_point green) { png_debug(1, "in png_set_rgb_to_gray\n"); switch(error_action) @@ -610,22 +621,26 @@ png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red, } #endif { - png_byte red_byte = (png_byte)((float)red*255.0 + 0.5); - png_byte green_byte = (png_byte)((float)green*255.0 + 0.5); - if(red < 0.0 || green < 0.0) + png_uint_16 red_int, green_int; + if(red > 0 && green > 0) { - red_byte = 54; - green_byte = 183; + red_int = 6968; /* .212671 * 32768 + .5 */ + green_int = 23434; /* .715160 * 32768 + .5 */ } - else if(red_byte + green_byte > 255) + else if(red + green < 100000L) + { + red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L); + green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L); + } + else { png_warning(png_ptr, "ignoring out of range rgb_to_gray coefficients"); - red_byte = 54; - green_byte = 183; + red_int = 6968; + green_int = 23434; } - png_ptr->rgb_to_gray_red_coeff = red_byte; - png_ptr->rgb_to_gray_green_coeff = green_byte; - png_ptr->rgb_to_gray_blue_coeff = (png_byte)(255-red_byte-green_byte); + png_ptr->rgb_to_gray_red_coeff = red_int; + png_ptr->rgb_to_gray_green_coeff = green_int; + png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(32768-red_int-green_int); } } #endif @@ -2021,11 +2036,11 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) * * We approximate this with * - * Y = 0.211 * R + 0.715 * G + 0.074 * B + * Y = 0.21268 * R + 0.7151 * G + 0.07217 * B * * which can be expressed with integers as * - * Y = (54 * R + 183 * G + 19 * B)/256 + * Y = (6969 * R + 23434 * G + 2365 * B)/32768 * * The calculation is to be done in a linear colorspace. * @@ -2047,9 +2062,9 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) #endif (row_info->color_type & PNG_COLOR_MASK_COLOR)) { - png_byte rc = png_ptr->rgb_to_gray_red_coeff; - png_byte gc = png_ptr->rgb_to_gray_green_coeff; - png_byte bc = png_ptr->rgb_to_gray_blue_coeff; + png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; + png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; + png_uint_32 bc = png_ptr->rgb_to_gray_blue_coeff; if (row_info->color_type == PNG_COLOR_TYPE_RGB) { @@ -2070,7 +2085,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) { rgb_error |= 1; *(dp++) = png_ptr->gamma_from_1[ - (rc*red+gc*green+bc*blue)>>8]; + (rc*red+gc*green+bc*blue)>>15]; } else *(dp++) = *(sp-1); @@ -2089,7 +2104,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) if(red != green || red != blue) { rgb_error |= 1; - *(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>8); + *(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>15); } else *(dp++) = *(sp-1); @@ -2124,7 +2139,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> png_ptr->gamma_shift][blue>>8]; png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1 - + bc*blue_1)>>8); + + bc*blue_1)>>15); w = png_ptr->gamma_16_from_1[(gray16&0xff) >> png_ptr->gamma_shift][gray16 >> 8]; rgb_error |= 1; @@ -2149,7 +2164,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) if(red != green || red != blue) rgb_error |= 1; - gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>8); + gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); *(dp++) = (png_byte)((gray16>>8) & 0xff); *(dp++) = (png_byte)(gray16 & 0xff); } @@ -2173,7 +2188,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) if(red != green || red != blue) rgb_error |= 1; *(dp++) = png_ptr->gamma_from_1 - [(rc*red + gc*green + bc*blue)>>8]; + [(rc*red + gc*green + bc*blue)>>15]; *(dp++) = *(sp++); /* alpha */ } } @@ -2221,7 +2236,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> png_ptr->gamma_shift][blue>>8]; png_uint_16 gray16 = (png_uint_16)((rc * red_1 - + gc * green_1 + bc * blue_1)>>8); + + gc * green_1 + bc * blue_1)>>15); w = png_ptr->gamma_16_from_1[(gray16&0xff) >> png_ptr->gamma_shift][gray16 >> 8]; rgb_error |= 1; @@ -2246,7 +2261,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; if(red != green || red != blue) rgb_error |= 1; - gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>8); + gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); *(dp++) = (png_byte)((gray16>>8) & 0xff); *(dp++) = (png_byte)(gray16 & 0xff); *(dp++) = *(sp++); /* alpha */ diff --git a/pngrutil.c b/pngrutil.c index 9da17fa43..15b7197aa 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -1,7 +1,7 @@ /* pngrutil.c - utilities to read a PNG file * - * libpng 1.0.5s - February 18, 2000 + * libpng 1.0.5v - March 11, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger @@ -147,7 +147,7 @@ png_charp png_decompress_chunk(png_structp png_ptr, int comp_type, { static char msg[] = "Error decoding compressed text"; png_charp text = NULL; - png_size_t text_size = (chunklength - prefix_size); + png_size_t text_size; if (comp_type == PNG_TEXT_COMPRESSION_zTXt) { @@ -262,7 +262,7 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_debug(1, "in png_handle_IHDR\n"); - if (png_ptr->mode != PNG_BEFORE_IHDR) + if (png_ptr->mode & PNG_HAVE_IHDR) png_error(png_ptr, "Out of place IHDR"); /* check the length */ @@ -968,7 +968,7 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_bytep chunkdata; png_bytep entry_start; - png_spalette new_palette; + png_sPLT_t new_palette; int data_length, entry_size, i; png_uint_32 skip = 0; png_size_t slength; @@ -1028,12 +1028,12 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) } new_palette.nentries = data_length / entry_size; - new_palette.entries = (png_spalette_entryp)png_malloc( - png_ptr, new_palette.nentries * sizeof(png_spalette_entry)); + new_palette.entries = (png_sPLT_entryp)png_malloc( + png_ptr, new_palette.nentries * sizeof(png_sPLT_entry)); for (i = 0; i < new_palette.nentries; i++) { - png_spalette_entryp pp = new_palette.entries + i; + png_sPLT_entryp pp = new_palette.entries + i; if (new_palette.depth == 8) { @@ -1090,7 +1090,7 @@ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) /* Should be an error, but we can cope with it */ png_warning(png_ptr, "Missing PLTE before tRNS"); } - else if (length > png_ptr->num_palette) + else if (length > (png_uint_32)png_ptr->num_palette) { png_warning(png_ptr, "Incorrect tRNS chunk length"); png_crc_finish(png_ptr, length); @@ -1510,7 +1510,7 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_charp buffer, ep; #ifdef PNG_FLOATING_POINT_SUPPORTED - double width=0., height=0.; + double width, height; png_charp vp; #else #ifdef PNG_FIXED_POINT_SUPPORTED @@ -1723,7 +1723,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_textp text_ptr; png_charp chunkdata; png_charp text; - int comp_type = PNG_TEXT_COMPRESSION_NONE; + int comp_type; png_size_t slength, prefix_len; png_debug(1, "in png_handle_zTXt\n"); @@ -1798,7 +1798,7 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_textp text_ptr; png_charp chunkdata; png_charp key, lang, text, lang_key; - int comp_flag = PNG_TEXT_COMPRESSION_NONE; + int comp_flag; int comp_type = 0; png_size_t slength, prefix_len; @@ -1,7 +1,7 @@ /* pngset.c - storage of image information into info struct * - * libpng 1.0.5s - February 18, 2000 + * libpng 1.0.5v - March 11, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger @@ -312,8 +312,6 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr, if (png_ptr == NULL || info_ptr == NULL) return; - png_debug1(3, "allocating PLTE for info (%d bytes)\n", length); - info_ptr->palette = palette; info_ptr->num_palette = (png_uint_16)num_palette; @@ -613,30 +611,30 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr, #if defined(PNG_sPLT_SUPPORTED) void png_set_sPLT(png_structp png_ptr, - png_infop info_ptr, png_spalette_p entries, int nentries) + png_infop info_ptr, png_sPLT_tp entries, int nentries) { - png_spalette_p np; + png_sPLT_tp np; int i; - np = (png_spalette_p)png_malloc(png_ptr, - (info_ptr->splt_palettes_num + nentries) * sizeof(png_spalette)); + np = (png_sPLT_tp)png_malloc(png_ptr, + (info_ptr->splt_palettes_num + nentries) * sizeof(png_sPLT_t)); png_memcpy(np, info_ptr->splt_palettes, - info_ptr->splt_palettes_num * sizeof(png_spalette)); + info_ptr->splt_palettes_num * sizeof(png_sPLT_t)); png_free(png_ptr, info_ptr->splt_palettes); for (i = 0; i < nentries; i++) { - png_spalette_p to = np + info_ptr->splt_palettes_num + i; - png_spalette_p from = entries + i; + png_sPLT_tp to = np + info_ptr->splt_palettes_num + i; + png_sPLT_tp from = entries + i; to->name = (png_charp)png_malloc(png_ptr, png_strlen(from->name) + 1); png_strcpy(to->name, from->name); - to->entries = (png_spalette_entryp)png_malloc(png_ptr, - from->nentries * sizeof(png_spalette)); + to->entries = (png_sPLT_entryp)png_malloc(png_ptr, + from->nentries * sizeof(png_sPLT_t)); png_memcpy(to->entries, from->entries, - from->nentries * sizeof(png_spalette)); + from->nentries * sizeof(png_sPLT_t)); to->nentries = from->nentries; to->depth = from->depth; } @@ -687,7 +685,8 @@ png_set_unknown_chunks(png_structp png_ptr, } #endif -#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) +#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) void png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted) { diff --git a/pngtrans.c b/pngtrans.c index 86c0dfd99..ce998a360 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.0.5s - February 18, 2000 + * libpng 1.0.5v - March 11, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger diff --git a/pngtypes.h b/pngtypes.h index 756d8e2fb..f787156ab 100644 --- a/pngtypes.h +++ b/pngtypes.h @@ -1,6 +1,6 @@ /* pngtypes.h - array of chunk-types for libpng * - * libpng 1.0.5s - February 18, 2000 + * libpng 1.0.5u - March 4, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger @@ -2,7 +2,7 @@ * * For Intel x86 CPU and Microsoft Visual C++ compiler * - * libpng 1.0.5s - February 18, 2000 + * libpng 1.0.5v - March 11, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998, Intel Corporation * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson @@ -1,7 +1,7 @@ /* pngwio.c - functions for data output * - * libpng 1.0.5s - February 18, 2000 + * libpng 1.0.5v - March 11, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger diff --git a/pngwrite.c b/pngwrite.c index ab68a1e44..432e37195 100644 --- a/pngwrite.c +++ b/pngwrite.c @@ -1,7 +1,7 @@ /* pngwrite.c - general routines to write a PNG file * - * libpng 1.0.5s - February 18, 2000 + * libpng 1.0.5v - March 11, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger @@ -1187,9 +1187,6 @@ void png_write_png(png_structp png_ptr, png_infop info_ptr, int transforms, voidp params) { - if(transforms == 0 || params == (voidp)NULL) - /* quiet compiler warnings */ ; - #if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) /* invert the alpha channel from opacity to transparency */ if (transforms & PNG_TRANSFORM_INVERT_ALPHA) @@ -1262,5 +1259,8 @@ void png_write_png(png_structp png_ptr, png_infop info_ptr, /* It is REQUIRED to call this to finish writing the rest of the file */ png_write_end(png_ptr, info_ptr); + + if(transforms == 0 || params == (voidp)NULL) + /* quiet compiler warnings */ return; } #endif diff --git a/pngwtran.c b/pngwtran.c index 4092834ed..6bf2b3347 100644 --- a/pngwtran.c +++ b/pngwtran.c @@ -1,7 +1,7 @@ /* pngwtran.c - transforms the data in a row for PNG writers * - * libpng 1.0.5s - February 18, 2000 + * libpng 1.0.5v - March 11, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger diff --git a/pngwutil.c b/pngwutil.c index 437a53503..c4fe193d0 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -1,7 +1,7 @@ /* pngwutil.c - utilities to write a PNG file * - * libpng 1.0.5s - February 18, 2000 + * libpng 1.0.5v - March 11, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger @@ -179,7 +179,6 @@ png_text_compress(png_structp png_ptr, #else png_warning(png_ptr, "Unknown compression type"); #endif - compression = PNG_TEXT_COMPRESSION_zTXt; } /* We can't write the chunk until we find out how much data we have, @@ -642,7 +641,7 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, } if (compression_type) - /* ignore */ ; + png_warning(png_ptr, "Unknown compression type in iCCP chunk"); if (profile == NULL || *profile == '\0') profile_len = 0; @@ -667,7 +666,7 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, #if defined(PNG_WRITE_sPLT_SUPPORTED) /* write a sPLT chunk */ void -png_write_sPLT(png_structp png_ptr, png_spalette_p spalette) +png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette) { #ifdef PNG_USE_LOCAL_ARRAYS PNG_sPLT; @@ -677,10 +676,11 @@ png_write_sPLT(png_structp png_ptr, png_spalette_p spalette) png_byte entrybuf[10]; int entry_size = (spalette->depth == 8 ? 6 : 10); int palette_size = entry_size * spalette->nentries; - png_spalette_entryp ep; + png_sPLT_entryp ep; png_debug(1, "in png_write_sPLT\n"); - if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr, spalette->name, &new_name))==0) + if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr, + spalette->name, &new_name))==0) { png_warning(png_ptr, "Empty keyword in sPLT chunk"); return; |