summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2000-01-12 22:56:38 -0600
committerGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2009-04-16 10:46:39 -0500
commit10ecaa7a20ce62a49a20f4dc9dfb6d5046658127 (patch)
treeb53ec861a763819786fd89ac908b2f19838352e2
parentc3e8db9e59d63d431aca628ea036b17fe5934596 (diff)
downloadlibpng-10ecaa7a20ce62a49a20f4dc9dfb6d5046658127.tar.gz
Imported from pngcrush-1.3.3.tarv1.3.3
-rw-r--r--png.c40
-rw-r--r--png.h84
-rw-r--r--pngasmrd.h6
-rw-r--r--pngconf.h24
-rw-r--r--pngcrush.c68
-rw-r--r--pngcrush.h4
-rw-r--r--pngerror.c4
-rw-r--r--pngget.c15
-rw-r--r--pngmem.c4
-rw-r--r--pngpread.c35
-rw-r--r--pngread.c138
-rw-r--r--pngrio.c4
-rw-r--r--pngrtran.c4
-rw-r--r--pngrutil.c36
-rw-r--r--pngset.c34
-rw-r--r--pngtrans.c4
-rw-r--r--pngtypes.h5
-rw-r--r--pngvcrd.c4
-rw-r--r--pngwio.c4
-rw-r--r--pngwrite.c91
-rw-r--r--pngwtran.c4
-rw-r--r--pngwutil.c4
22 files changed, 509 insertions, 107 deletions
diff --git a/png.c b/png.c
index 4a5f998da..20dae0415 100644
--- a/png.c
+++ b/png.c
@@ -1,10 +1,10 @@
/* png.c - location for general purpose libpng functions
*
- * libpng version 1.0.5k - December 27, 1999
+ * libpng version 1.0.5m - January 7, 2000
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*
*/
@@ -19,7 +19,7 @@
#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.5k";
+char png_libpng_ver[12] = "1.0.5m";
/* png_sig was changed to a function in version 1.0.5c */
/* Place to hold the signature string for a PNG file. */
@@ -448,6 +448,25 @@ png_free_hIST(png_structp png_ptr, png_infop info_ptr)
}
#endif
+#if defined(PNG_INFO_IMAGE_SUPPORTED)
+/* free any image bits attached to the info structure */
+void
+png_free_pixels(png_structp png_ptr, png_infop info_ptr)
+{
+ if (png_ptr == NULL || info_ptr == NULL)
+ return;
+ if (info_ptr->valid & PNG_INFO_IDAT)
+ {
+ int row;
+
+ for (row = 0; row < (int)info_ptr->height; row++)
+ png_free(png_ptr, info_ptr->row_pointers[row]);
+ png_free(png_ptr, info_ptr->row_pointers);
+ info_ptr->valid &= ~PNG_INFO_IDAT;
+ }
+}
+#endif
+
/* This is an internal routine to free any memory that the info struct is
* pointing to before re-using it or freeing the struct itself. Recall
* that png_free() checks for NULL pointers for us.
@@ -481,6 +500,9 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_hIST_SUPPORTED)
png_free_hIST(png_ptr, info_ptr);
#endif
+#if defined(PNG_INFO_IMAGE_SUPPORTED)
+ png_free_pixels(png_ptr, info_ptr);
+#endif
png_info_init(info_ptr);
}
@@ -558,10 +580,10 @@ 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.5k - December 27, 1999\n\
+ return ("\n libpng version 1.0.5m - January 7, 2000\n\
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\
Copyright (c) 1996, 1997 Andreas Dilger\n\
- Copyright (c) 1998, 1999 Glenn Randers-Pehrson\n");
+ Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson\n");
return ("");
}
@@ -576,8 +598,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.5k");
- return("1.0.5k");
+ return("1.0.5m");
+ return("1.0.5m");
}
png_charp
@@ -601,9 +623,9 @@ png_get_header_version(png_structp png_ptr)
/* Generate a compiler error if there is an old png.h in the search path. */
void
png_check_version
- (version_1_0_5k png_h_is_not_version_1_0_5k)
+ (version_1_0_5m png_h_is_not_version_1_0_5m)
{
- if(png_h_is_not_version_1_0_5k == NULL)
+ if(png_h_is_not_version_1_0_5m == NULL)
return;
}
diff --git a/png.h b/png.h
index d6c6c34bf..5dba0466f 100644
--- a/png.h
+++ b/png.h
@@ -1,27 +1,27 @@
/* png.h - header file for PNG reference library
*
- * libpng version 1.0.5k - December 27, 1999
+ * libpng version 1.0.5m - January 7, 2000
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*
* 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.5k - December 27, 1999: Glenn
+ * libpng versions 0.97, January 1998, through 1.0.5m - January 7, 2000: Glenn
* See also "Contributing Authors", below.
*
* Y2K compliance in libpng:
* =========================
*
- * December 27, 1999
+ * January 7, 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.5k are Y2K compliant. It is my belief that earlier
+ * upward through 1.0.5m 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
@@ -98,7 +98,7 @@
* 1.0.4a-f 1.0.4a-f 10005 2.1.0.4a-f
* 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-k 1.0.5e-k 10100 2.1.0.5e-k
+ * 1.0.5e-m 1.0.5e-m 10100 2.1.0.5e-m
* 1.1.0 1.1.0 10100 3.1.0.0
*
* Henceforth the source version will match the shared-library minor
@@ -122,8 +122,8 @@
* (libpng versions 0.5, May 1995, through 0.89c, May 1996)
* Copyright (c) 1996, 1997 Andreas Dilger
* (libpng versions 0.90, December 1996, through 0.96, May 1997)
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
- * (libpng versions 0.97, January 1998, through 1.0.5k, December 27, 1999)
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
+ * (libpng versions 0.97, January 1998, through 1.0.5m, January 7, 2000)
*
* For the purposes of this copyright and license, "Contributing Authors"
* is defined as the following set of individuals:
@@ -224,7 +224,7 @@ extern "C" {
*/
/* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.0.5k"
+#define PNG_LIBPNG_VER_STRING "1.0.5m"
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
* We must not include leading zeros.
@@ -418,9 +418,9 @@ typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;
* The following members may have allocated storage attached that should be
* cleaned up before the structure is discarded: palette, trans, text,
* pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
- * splt_palettes, and scal_unit. Of these, the text, pcal_*, hist, iccp_*,
- * splt_*, and scal_unit members are automatically freed when the info
- * structure is deallocated. The palette member is not.
+ * splt_palettes, scal_unit, and row_pointers. Of these, the text, pcal_*,
+ * hist, iccp_*, splt_*, scal_unit, and row_pointers members are automatically
+ * freed when the info structure is deallocated. The palette member is not.
*
* More allocation details: all the chunk-reading functions that change these
* members go through the corresponding png_set_* functions. Functions to
@@ -655,6 +655,11 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
png_unknown_chunkp unknown_chunks;
png_size_t unknown_chunks_num;
#endif
+
+#if defined(PNG_INFO_IMAGE_SUPPORTED)
+ /* Data valid if (valid & PNG_INFO_IDAT) non-zero */
+ png_bytepp row_pointers; /* the image bits */
+#endif
} png_info;
typedef png_info FAR * png_infop;
@@ -743,6 +748,7 @@ typedef png_info FAR * FAR * png_infopp;
#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */
#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */
#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */
+#define PNG_INFO_IDAT 0x8000 /* ESR, 1.0.6 */
/* This is used for the transformation routines, as some of them
* change these values for the row. It also should enable using
@@ -789,6 +795,28 @@ typedef void (*png_user_transform_ptr) PNGARG((png_structp,
png_row_infop, png_bytep));
#endif
+#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
+typedef int (*png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp));
+#endif
+#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
+typedef void (*png_unknown_chunk_ptr) PNGARG((png_structp));
+#endif
+
+/* Transform masks for the high-level interface */
+#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */
+#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */
+#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */
+#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */
+#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */
+#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */
+#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */
+#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */
+#define PNG_TRANSFORM_BGR 0x0080 /* read and write */
+#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */
+#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */
+#define PNG_TRANSFORM_INVERT_ALPHA 0x0200 /* read and write */
+#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */
+
typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t));
typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp));
@@ -825,6 +853,11 @@ struct png_struct_def
png_byte user_transform_channels; /* channels in user transformed pixels */
#endif
+#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
+ png_voidp user_chunk_ptr;
+ png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
+#endif
+
png_uint_32 mode; /* tells us where we are in the PNG file */
png_uint_32 flags; /* flags indicating various things to libpng */
png_uint_32 transformations; /* which transformations to perform */
@@ -1011,9 +1044,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.5k
+and png.h are both at * version 1.0.5m
*/
-typedef png_structp version_1_0_5k;
+typedef png_structp version_1_0_5m;
typedef png_struct FAR * FAR * png_structpp;
@@ -1506,6 +1539,13 @@ extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr)
PNGARG((png_structp png_ptr));
#endif
+#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
+extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr,
+ png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));
+extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp
+ png_ptr));
+#endif
+
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
/* Sets the function callbacks for the push reader, and a pointer to a
* user-defined structure available to the callback functions.
@@ -1925,6 +1965,19 @@ extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp
extern PNG_EXPORT(void,png_free_chunk_list) PNGARG((png_structp png_ptr));
#endif
+#if defined(PNG_INFO_IMAGE_SUPPORTED)
+extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr,
+ png_infop info_ptr,
+ int transforms,
+ voidp params));
+extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr,
+ png_infop info_ptr,
+ int transforms,
+ voidp params));
+extern PNG_EXPORT(void, png_free_pixels) PNGARG((png_structp png_ptr,
+ png_infop info_ptr));
+#endif
+
/* Define PNG_DEBUG at compile time for debugging information. Higher
* numbers for PNG_DEBUG mean more debugging information. This has
* only been added since version 0.95 so it is not implemented throughout
@@ -1964,7 +2017,8 @@ extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr));
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.5k - December 27, 1999 (header)\n"
+#define PNG_HEADER_VERSION_STRING \
+ " libpng version 1.0.5m - January 7, 2000 (header)\n"
#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
/* With these routines we avoid an integer divide, which will be slower on
diff --git a/pngasmrd.h b/pngasmrd.h
index c9aa882bd..07a8d736e 100644
--- a/pngasmrd.h
+++ b/pngasmrd.h
@@ -1,8 +1,8 @@
/* pngasmrd.h - assembler version of utilities to read a PNG file
*
- * libpng 1.0.5k - December 27, 1999
+ * libpng 1.0.5m - January 7, 2000
* For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1999, 2000 Glenn Randers-Pehrson
*
*/
@@ -21,7 +21,7 @@
/* Set this in the makefile for gcc on Pentium, not in pngconf.h */
#ifdef PNG_USE_PNGGCCRD
/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c
- * (not available in libpng 1.0.5k).
+ * (not available in libpng 1.0.5m).
* MMX will be detected at run time and used if present.
*/
#define PNG_HAVE_ASSEMBLER_COMBINE_ROW
diff --git a/pngconf.h b/pngconf.h
index 6886566f8..5b2ab13da 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,11 +1,11 @@
/* pngconf.h - machine configurable file for libpng
*
- * libpng 1.0.5k - December 27, 1999
+ * libpng 1.0.5m - January 7, 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
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*/
/* Any machine specific code is near the front of this file, so if you
@@ -551,6 +551,16 @@ __dont__ include it again
# define PNG_READ_zTXt_SUPPORTED
# define PNG_zTXt_SUPPORTED
#endif
+#ifndef PNG_NO_READ_USER_CHUNKS
+# define PNG_READ_USER_CHUNKS_SUPPORTED
+# define PNG_USER_CHUNKS_SUPPORTED
+# ifdef PNG_NO_READ_UNKNOWN_CHUNKS
+# undef PNG_NO_READ_UNKNOWN_CHUNKS
+# endif
+# ifdef PNG_NO_HANDLE_AS_UNKNOWN
+# undef PNG_NO_HANDLE_AS_UNKNOWN
+# endif
+#endif
#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
@@ -696,8 +706,16 @@ __dont__ include it again
#endif
#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
+/* Turn this off to disable png_read_png() and
+ * png_write_png() and leave the image_bits member
+ * out of the info structure.
+ */
+#ifndef PNG_NO_INFO_IMAGE
+# define PNG_INFO_IMAGE_SUPPORTED
+#endif
+
/* need the time information for reading tIME chunks */
-#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
+#if defined(PNG_tIME_SUPPORTED)
# include <time.h>
#endif
diff --git a/pngcrush.c b/pngcrush.c
index 82c4595b8..8a9f97d70 100644
--- a/pngcrush.c
+++ b/pngcrush.c
@@ -15,7 +15,7 @@
* occasionally creating Linux executables.
*/
-#define PNGCRUSH_VERSION "1.3.2"
+#define PNGCRUSH_VERSION "1.3.3"
/*
* COPYRIGHT NOTICE, DISCLAIMER, AND LICENSE:
@@ -54,6 +54,11 @@
*
* Change log:
*
+ * Version 1.3.3 (built with libpng-1.0.5m)
+ *
+ * Restored ability to enter gamma as a float even when floating point
+ * arithmetic is not enabled.
+ *
* Version 1.3.2 (built with libpng-1.0.5k)
*
* Renamed "dirname" to "directory_name" to avoid conflict with "dirname"
@@ -741,7 +746,30 @@ main(int argc, char *argv[])
{
names++;
i++;
- if (intent < 0) specified_gamma=atoi(argv[i]);
+ if (intent < 0)
+ {
+ int c;
+ char number[16];
+ char *n=number;
+ int nzeroes=-1;
+ int length=strlen(argv[i]);
+ for (c=0; c<length; c++)
+ {
+ if( *(argv[i]+c) == '.')
+ {
+ nzeroes=5;
+ }
+ else if (nzeroes != 0)
+ {
+ *n++=*(argv[i]+c);
+ nzeroes--;
+ }
+ }
+ for (c=0; c<nzeroes; c++)
+ *n++='0';
+ *n='\0';
+ specified_gamma=atoi(number);
+ }
}
#endif
else if(!strncmp(argv[i],"-h",2))
@@ -852,7 +880,6 @@ main(int argc, char *argv[])
{
text_compression[text_inputs] = PNG_ITXT_COMPRESSION_NONE;
names+=2;
- printf("Adding an iTXt chunk.\n");
}
names+=3;
if( !strncmp(argv[++i],"b",1))
@@ -1043,7 +1070,7 @@ main(int argc, char *argv[])
else
fprintf(STDERR, "options:\n");
fprintf(STDERR,
- " -brute (Use brute-force, try 114 different methods)\n");
+ " -brute (Use brute-force, try 114 different methods [11-124])\n");
if(verbose > 1)
{
fprintf(STDERR,
@@ -1131,7 +1158,7 @@ main(int argc, char *argv[])
" additions, removals, or changes were requested.\n\n");
}
fprintf(STDERR,
- " -g gamma_value (float, e.g., 0.45455)\n");
+ " -g gamma (float or fixed*100000, e.g., 0.45455 or 45455)\n");
if(verbose > 1)
fprintf(STDERR,
"\n Value to insert in gAMA chunk, only if the input\n");
@@ -1143,7 +1170,7 @@ main(int argc, char *argv[])
" gAMA chunk, use the '-replace_gamma' option.\n\n");
png_crush_pause();
fprintf(STDERR,
- " -itxt b[efore_IDAT]|a[fter_IDAT] \"keyword\" \"text\"\n");
+ " -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");
@@ -1296,11 +1323,15 @@ main(int argc, char *argv[])
}
fprintf(STDERR,
- " -verbose (write more detailed information)\n");
+ " -v (display more detailed information)\n");
if(verbose > 1)
fprintf(STDERR,
"\n Repeat the option (use \"-v -v\") for even more.\n\n");
fprintf(STDERR,
+ " -version (display the pngcrush version)\n");
+ if(verbose > 1)
+ fprintf(STDERR,"\n");
+ fprintf(STDERR,
" -w compression_window_size [32, 16, 8, 4, 2, 1, 512]\n");
if(verbose > 1)
{
@@ -1324,7 +1355,7 @@ main(int argc, char *argv[])
" '-m method' argument.\n\n");
}
fprintf(STDERR,
- " -zitxt b[efore_IDAT]|a[fter_IDAT] \"keyword\" \"text\"\n");
+ " -zitxt b[efore_IDAT]|a[fter_IDAT] \"keyword\" \"text\"\n");
if(verbose > 1)
fprintf(STDERR,
"\n Compressed iTXt chunk to insert (see -text).\n\n");
@@ -2382,13 +2413,13 @@ main(int argc, char *argv[])
png_set_text(write_ptr, write_info_ptr, added_text, 1);
png_free(write_ptr,added_text);
if(added_text[0].compression < 0)
- printf("Added a tEXt chunk.\n");
+ printf(" Added a tEXt chunk.\n");
else if(added_text[0].compression == 0)
- printf("Added a zTXt chunk.\n");
+ printf(" Added a zTXt chunk.\n");
else if(added_text[0].compression == 1)
- printf("Added an uncompressed iTXt chunk.\n");
+ printf(" Added an uncompressed iTXt chunk.\n");
else
- printf("Added a compressed iTXt chunk.\n");
+ printf(" Added a compressed iTXt chunk.\n");
}
}
}
@@ -2453,8 +2484,8 @@ main(int argc, char *argv[])
if(output_bit_depth < input_bit_depth)
{
png_color_8 true_bits;
- write_ptr->bit_depth=output_bit_depth;
- true_bits.gray = 8 - (input_bit_depth - output_bit_depth);
+ write_ptr->bit_depth=(png_byte)output_bit_depth;
+ true_bits.gray = (png_byte)(8 - (input_bit_depth - output_bit_depth));
png_set_shift(read_ptr, &true_bits);
png_set_packing(write_ptr);
}
@@ -2626,13 +2657,14 @@ main(int argc, char *argv[])
png_set_text(write_ptr, write_end_info_ptr, added_text, 1);
png_free(write_ptr,added_text);
if(added_text[0].compression < 0)
- printf("Added a tEXt chunk after IDAT.\n");
+ printf(" Added a tEXt chunk after IDAT.\n");
else if(added_text[0].compression == 0)
- printf("Added a zTXt chunk after IDAT.\n");
+ printf(" Added a zTXt chunk after IDAT.\n");
else if(added_text[0].compression == 1)
- printf("Added an uncompressed iTXt chunk after IDAT.\n");
+ printf(
+ " Added an uncompressed iTXt chunk after IDAT.\n");
else
- printf("Added a compressed iTXt chunk after IDAT.\n");
+ printf(" Added a compressed iTXt chunk after IDAT.\n");
}
}
}
diff --git a/pngcrush.h b/pngcrush.h
index 77f0dbdf4..d063f7356 100644
--- a/pngcrush.h
+++ b/pngcrush.h
@@ -20,6 +20,8 @@
#define PNG_NO_READ_tIME
#define PNG_NO_WRITE_tIME
+#define PNG_NO_INFO_IMAGE
+#define PNG_NO_READ_USER_CHUNKS
#define PNG_NO_EASY_ACCESS
#define PNG_NO_READ_EMPTY_PLTE
#define PNG_NO_WRITE_TRANSFORMS
@@ -38,7 +40,5 @@
# define PNG_NO_READ_RGB_TO_GRAY
#endif
#define PNG_ZBUF_SIZE 524288 /* increases the IDAT size */
-/*
#define PNG_NO_GLOBAL_ARRAYS
-*/
#define TOO_FAR 32767 /* Improves zlib/deflate compression */
diff --git a/pngerror.c b/pngerror.c
index 1449a9dbd..b7d87bcaf 100644
--- a/pngerror.c
+++ b/pngerror.c
@@ -1,11 +1,11 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
- * libpng 1.0.5k - December 27, 1999
+ * libpng 1.0.5m - January 7, 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
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*
* This file provides a location for all error handling. Users who
* need special error handling are expected to write replacement functions
diff --git a/pngget.c b/pngget.c
index dee47e8d7..4ab606f79 100644
--- a/pngget.c
+++ b/pngget.c
@@ -1,11 +1,11 @@
/* pngget.c - retrieval of values from info struct
*
- * libpng 1.0.5k - December 27, 1999
+ * libpng 1.0.5m - January 7, 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
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*/
#define PNG_INTERNAL
@@ -304,7 +304,7 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
return (retval);
}
#endif /* PNG_READ_pHYs_SUPPORTED */
-#endif /* PNG_INCH_CONVERSIONS $$ PNG_FLOATING_POINT_SUPPORTED */
+#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
/* png_get_channels really belongs in here, too, but it's been around longer */
@@ -779,3 +779,12 @@ png_get_rgb_to_gray_status (png_structp png_ptr)
return png_ptr->rgb_to_gray_status;
}
#endif
+
+#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
+png_voidp
+png_get_user_chunk_ptr(png_structp png_ptr)
+{
+ return (png_ptr->user_chunk_ptr);
+}
+#endif
+
diff --git a/pngmem.c b/pngmem.c
index 10df79f9a..d9ebb4b4f 100644
--- a/pngmem.c
+++ b/pngmem.c
@@ -1,11 +1,11 @@
/* pngmem.c - stub functions for memory allocation
*
- * libpng 1.0.5k - December 27, 1999
+ * libpng 1.0.5m - January 7, 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
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*
* This file provides a location for all memory allocation. Users who
* need special memory handling are expected to supply replacement
diff --git a/pngpread.c b/pngpread.c
index 070ab76a8..bf7e3b2b2 100644
--- a/pngpread.c
+++ b/pngpread.c
@@ -1,11 +1,11 @@
/* pngpread.c - read a png file in push mode
*
- * libpng 1.0.5k - December 27, 1999
+ * libpng 1.0.5m - January 7, 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
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*/
#define PNG_INTERNAL
@@ -1338,9 +1338,17 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 len
if (!(png_ptr->chunk_name[0] & 0x20))
{
- png_chunk_error(png_ptr, "unknown critical chunk");
- /* to quiet some compiler warnings */
- if(info_ptr == NULL) return;
+ if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
+ HANDLE_CHUNK_ALWAYS
+#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
+ && png_ptr->read_user_chunk_fn == (png_user_chunk_ptr)NULL
+#endif
+ )
+ png_chunk_error(png_ptr, "unknown critical chunk");
+
+ /* to quiet compiler warnings about unused info_ptr */
+ if (info_ptr == NULL)
+ return;
}
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
@@ -1361,7 +1369,22 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 len
chunk.data = (png_bytep)png_malloc(png_ptr, length);
png_crc_read(png_ptr, chunk.data, length);
chunk.size = length;
- png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
+#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
+ if(png_ptr->read_user_chunk_fn != (png_user_chunk_ptr)NULL)
+ {
+ /* callback to user unknown chunk handler */
+ if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0)
+ {
+ if (!(png_ptr->chunk_name[0] & 0x20))
+ if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
+ HANDLE_CHUNK_ALWAYS)
+ png_chunk_error(png_ptr, "unknown critical chunk");
+ }
+ png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
+ }
+ else
+#endif
+ png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
png_free(png_ptr, chunk.data);
}
else
diff --git a/pngread.c b/pngread.c
index fd401e863..967e56f8e 100644
--- a/pngread.c
+++ b/pngread.c
@@ -1,11 +1,11 @@
/* pngread.c - read a PNG file
*
- * libpng 1.0.5k - December 27, 1999
+ * libpng 1.0.5m - January 7, 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
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*
* This file contains routines that an application calls directly to
* read a PNG file or stream.
@@ -627,7 +627,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.5k.
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5m.
*/
void
@@ -676,7 +676,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.5k.
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5m.
*/
void
png_read_image(png_structp png_ptr, png_bytepp image)
@@ -802,8 +802,10 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
{
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
+ {
if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT)
png_error(png_ptr, "Too many IDAT's found");
+ }
else
png_ptr->mode |= PNG_AFTER_IDAT;
png_handle_unknown(png_ptr, info_ptr, length);
@@ -1079,3 +1081,131 @@ png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)
{
png_ptr->read_row_fn = read_row_fn;
}
+
+#if defined(PNG_INFO_IMAGE_SUPPORTED)
+void png_read_png(png_structp png_ptr, png_infop info_ptr,
+ int transforms,
+ voidp params)
+{
+ 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)
+ png_set_invert_alpha(png_ptr);
+#endif
+
+ /* The call to png_read_info() gives us all of the information from the
+ * PNG file before the first IDAT (image data chunk).
+ */
+ png_read_info(png_ptr, info_ptr);
+
+ /* -------------- image transformations start here ------------------- */
+
+#if defined(PNG_READ_16_TO_8_SUPPORTED)
+ /* tell libpng to strip 16 bit/color files down to 8 bits/color */
+ if (transforms & PNG_TRANSFORM_STRIP_16)
+ png_set_strip_16(png_ptr);
+#endif
+
+#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
+ /* Strip alpha bytes from the input data without combining with the
+ * background (not recommended).
+ */
+ if (transforms & PNG_TRANSFORM_STRIP_ALPHA)
+ png_set_strip_alpha(png_ptr);
+#endif
+
+#if defined(PNG_READ_PACK_SUPPORTED)
+ /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single
+ * byte into separate bytes (useful for paletted and grayscale images).
+ */
+ if (transforms & PNG_TRANSFORM_PACKING)
+ png_set_packing(png_ptr);
+#endif
+
+#if defined(PNG_READ_PACKSWAP_SUPPORTED)
+ /* Change the order of packed pixels to least significant bit first
+ * (not useful if you are using png_set_packing). */
+ if (transforms & PNG_TRANSFORM_PACKSWAP)
+ png_set_packswap(png_ptr);
+#endif
+
+#if defined(PNG_READ_EXPAND_SUPPORTED)
+ /* Expand paletted colors into true RGB triplets
+ * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel
+ * Expand paletted or RGB images with transparency to full alpha
+ * channels so the data will be available as RGBA quartets.
+ */
+ if (transforms & PNG_TRANSFORM_EXPAND)
+ if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
+ png_set_expand(png_ptr);
+#endif
+
+ /* We don't handle background color or gamma transformation or dithering. */
+
+#if defined(PNG_READ_INVERT_SUPPORTED)
+ /* invert monochrome files to have 0 as white and 1 as black */
+ if (transforms & PNG_TRANSFORM_INVERT_MONO)
+ png_set_invert_mono(png_ptr);
+#endif
+
+#if defined(PNG_READ_SHIFT_SUPPORTED)
+ /* If you want to shift the pixel values from the range [0,255] or
+ * [0,65535] to the original [0,7] or [0,31], or whatever range the
+ * colors were originally in:
+ */
+ if ((transforms & PNG_TRANSFORM_SHIFT)
+ && png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT))
+ {
+ png_color_8p sig_bit;
+
+ png_get_sBIT(png_ptr, info_ptr, &sig_bit);
+ png_set_shift(png_ptr, sig_bit);
+ }
+#endif
+
+#if defined(PNG_READ_BGR_SUPPORTED)
+ /* flip the RGB pixels to BGR (or RGBA to BGRA) */
+ if (transforms & PNG_TRANSFORM_BGR)
+ png_set_bgr(png_ptr);
+#endif
+
+#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
+ /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
+ if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
+ png_set_swap_alpha(png_ptr);
+#endif
+
+#if defined(PNG_READ_SWAP_SUPPORTED)
+ /* swap bytes of 16 bit files to least significant byte first */
+ if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
+ png_set_swap(png_ptr);
+#endif
+
+ /* We don't handle adding filler bytes */
+
+ /* Optional call to gamma correct and add the background to the palette
+ * and update info structure. REQUIRED if you are expecting libpng to
+ * update the palette for you (ie you selected such a transform above).
+ */
+ png_read_update_info(png_ptr, info_ptr);
+
+ /* -------------- image transformations end here ------------------- */
+
+ info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
+ info_ptr->height * sizeof(png_bytep));
+ for (row = 0; row < (int)info_ptr->height; row++)
+ info_ptr->row_pointers[row] = png_malloc(png_ptr,
+ png_get_rowbytes(png_ptr, info_ptr));
+
+ png_read_image(png_ptr, info_ptr->row_pointers);
+ info_ptr->valid |= PNG_INFO_IDAT;
+
+ /* read rest of file, and get additional chunks in info_ptr - REQUIRED */
+ png_read_end(png_ptr, info_ptr);
+}
+#endif
diff --git a/pngrio.c b/pngrio.c
index a8390c0cb..d24473d2f 100644
--- a/pngrio.c
+++ b/pngrio.c
@@ -1,11 +1,11 @@
/* pngrio.c - functions for data input
*
- * libpng 1.0.5k - December 27, 1999
+ * libpng 1.0.5m - January 7, 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
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*
* This file provides a location for all input. Users who need
* special handling are expected to write a function that has the same
diff --git a/pngrtran.c b/pngrtran.c
index ec9a311e6..111454736 100644
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -1,11 +1,11 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
- * libpng 1.0.5k - December 27, 1999
+ * libpng 1.0.5m - January 7, 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
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*
* This file contains functions optionally called by an application
* in order to tell libpng how to handle data when reading a PNG.
diff --git a/pngrutil.c b/pngrutil.c
index 8b6afe8bd..fc353d150 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1,11 +1,11 @@
/* pngrutil.c - utilities to read a PNG file
*
- * libpng 1.0.5k - December 27, 1999
+ * libpng 1.0.5m - January 7, 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
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*
* This file contains routines that are only called from within
* libpng itself during the course of reading an image.
@@ -1907,20 +1907,19 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
- /* In the future we can have code here that calls user-supplied
- * callback functions for unknown chunks before they are ignored or
- * cause an error.
- */
-
if (!(png_ptr->chunk_name[0] & 0x20))
{
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
- HANDLE_CHUNK_ALWAYS)
- png_chunk_error(png_ptr, "unknown critical chunk");
+ HANDLE_CHUNK_ALWAYS
+#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
+ && png_ptr->read_user_chunk_fn == (png_user_chunk_ptr)NULL
+#endif
+ )
+ png_chunk_error(png_ptr, "unknown critical chunk");
/* to quiet compiler warnings about unused info_ptr */
if (info_ptr == NULL)
- return;
+ return;
}
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
@@ -1941,7 +1940,22 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
chunk.data = (png_bytep)png_malloc(png_ptr, length);
png_crc_read(png_ptr, chunk.data, length);
chunk.size = length;
- png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
+#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
+ if(png_ptr->read_user_chunk_fn != (png_user_chunk_ptr)NULL)
+ {
+ /* callback to user unknown chunk handler */
+ if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0)
+ {
+ if (!(png_ptr->chunk_name[0] & 0x20))
+ if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
+ HANDLE_CHUNK_ALWAYS)
+ png_chunk_error(png_ptr, "unknown critical chunk");
+ png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
+ }
+ }
+ else
+#endif
+ png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
png_free(png_ptr, chunk.data);
}
else
diff --git a/pngset.c b/pngset.c
index b4202eab7..5d7fa6610 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1,11 +1,11 @@
/* pngset.c - storage of image information into info struct
*
- * libpng 1.0.5k - December 27, 1999
+ * libpng 1.0.5m - January 7, 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
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*
* The functions here are used during reads to store data from the file
* into the info struct, and during writes to store application data
@@ -81,14 +81,14 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
info_ptr->int_x_blue = blue_x;
info_ptr->int_y_blue = blue_y;
#ifdef PNG_FLOATING_POINT_SUPPORTED
- info_ptr->x_white = (float)white_x/100000.;
- info_ptr->y_white = (float)white_y/100000.;
- info_ptr->x_red = (float)red_x/100000.;
- info_ptr->y_red = (float)red_y/100000.;
- info_ptr->x_green = (float)green_x/100000.;
- info_ptr->y_green = (float)green_y/100000.;
- info_ptr->x_blue = (float)blue_x/100000.;
- info_ptr->y_blue = (float)blue_y/100000.;
+ info_ptr->x_white = (float)(white_x/100000.);
+ info_ptr->y_white = (float)(white_y/100000.);
+ info_ptr->x_red = (float)(red_x/100000.);
+ info_ptr->y_red = (float)(red_y/100000.);
+ info_ptr->x_green = (float)(green_x/100000.);
+ info_ptr->y_green = (float)(green_y/100000.);
+ info_ptr->x_blue = (float)(blue_x/100000.);
+ info_ptr->y_blue = (float)(blue_y/100000.);
#endif
info_ptr->valid |= PNG_INFO_cHRM;
}
@@ -121,7 +121,7 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
return;
#ifdef PNG_FLOATING_POINT_SUPPORTED
- info_ptr->gamma = (float)int_gamma/100000.;
+ info_ptr->gamma = (float)(int_gamma/100000.);
#endif
info_ptr->int_gamma = int_gamma;
info_ptr->valid |= PNG_INFO_gAMA;
@@ -733,3 +733,15 @@ png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep
png_ptr->chunk_list=new_list;
}
#endif
+
+#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
+void
+png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,
+ png_user_chunk_ptr read_user_chunk_fn)
+{
+ png_debug(1, "in png_set_read_user_chunk_fn\n");
+ png_ptr->read_user_chunk_fn = read_user_chunk_fn;
+ png_ptr->user_chunk_ptr = user_chunk_ptr;
+}
+#endif
+
diff --git a/pngtrans.c b/pngtrans.c
index 53cdbc89d..1818ace32 100644
--- a/pngtrans.c
+++ b/pngtrans.c
@@ -1,11 +1,11 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
- * libpng 1.0.5k - December 27, 1999
+ * libpng 1.0.5m - January 7, 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
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*/
#define PNG_INTERNAL
diff --git a/pngtypes.h b/pngtypes.h
index 3725d3d4f..f79120299 100644
--- a/pngtypes.h
+++ b/pngtypes.h
@@ -1,10 +1,10 @@
/* pngtypes.h - array of chunk-types for libpng
*
- * libpng 1.0.5k - December 27, 1999
+ * libpng 1.0.5m - January 7, 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
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*/
/* Constant strings for known chunk types. If you need to add a chunk,
@@ -25,6 +25,7 @@ PNG_oFFs;
PNG_pCAL;
PNG_pHYs;
PNG_sBIT;
+PNG_sCAL;
PNG_sPLT;
PNG_sRGB;
PNG_tEXt;
diff --git a/pngvcrd.c b/pngvcrd.c
index ee204e482..87dd306ca 100644
--- a/pngvcrd.c
+++ b/pngvcrd.c
@@ -2,10 +2,10 @@
*
* For Intel x86 CPU and Microsoft Visual C++ compiler
*
- * libpng 1.0.5k - December 27, 1999
+ * libpng 1.0.5m - January 7, 2000
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998, Intel Corporation
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*
* Contributed by Nirav Chhatrapati, Intel Corporation, 1998
* Interface to libpng contributed by Gilles Vollant, 1999
diff --git a/pngwio.c b/pngwio.c
index e063c8dc9..a1f8102a3 100644
--- a/pngwio.c
+++ b/pngwio.c
@@ -1,11 +1,11 @@
/* pngwio.c - functions for data output
*
- * libpng 1.0.5k - December 27, 1999
+ * libpng 1.0.5m - January 7, 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
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*
* This file provides a location for all output. Users who need
* special handling are expected to write functions that have the same
diff --git a/pngwrite.c b/pngwrite.c
index dd55c0e07..f6925e490 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -1,11 +1,11 @@
/* pngwrite.c - general routines to write a PNG file
*
- * libpng 1.0.5k - December 27, 1999
+ * libpng 1.0.5m - January 7, 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
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*/
/* get internal access to png.h */
@@ -812,6 +812,9 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
#if defined(PNG_hIST_SUPPORTED)
png_free_hIST(png_ptr, info_ptr);
#endif
+#if defined(PNG_INFO_IMAGE_SUPPORTED)
+ png_free_pixels(png_ptr, info_ptr);
+#endif
#ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)info_ptr, free_fn);
@@ -1180,3 +1183,87 @@ png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
png_ptr->write_user_transform_fn = write_user_transform_fn;
}
#endif
+
+
+#if defined(PNG_INFO_IMAGE_SUPPORTED)
+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)
+ png_set_invert_alpha(png_ptr);
+#endif
+
+ /* Write the file header information. */
+ png_write_info(png_ptr, info_ptr);
+
+ /* ------ these transformations don't touch the info structure ------- */
+
+#if defined(PNG_WRITE_INVERT_SUPPORTED)
+ /* invert monochrome pixels */
+ if (transforms & PNG_TRANSFORM_INVERT_MONO)
+ png_set_invert_mono(png_ptr);
+#endif
+
+#if defined(PNG_WRITE_SHIFT_SUPPORTED)
+ /* Shift the pixels up to a legal bit depth and fill in
+ * as appropriate to correctly scale the image.
+ */
+ if ((transforms & PNG_TRANSFORM_SHIFT)
+ && (info_ptr->valid & PNG_INFO_sBIT))
+ png_set_shift(png_ptr, &info_ptr->sig_bit);
+#endif
+
+#if defined(PNG_WRITE_PACK_SUPPORTED)
+ /* pack pixels into bytes */
+ if (transforms & PNG_TRANSFORM_PACKING)
+ png_set_packing(png_ptr);
+#endif
+
+#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
+ /* swap location of alpha bytes from ARGB to RGBA */
+ if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
+ png_set_swap_alpha(png_ptr);
+#endif
+
+#if defined(PNG_WRITE_FILLER_SUPPORTED)
+ /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into
+ * RGB (4 channels -> 3 channels). The second parameter is not used.
+ */
+ if (transforms & PNG_TRANSFORM_STRIP_FILLER)
+ png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
+#endif
+
+#if defined(PNG_WRITE_BGR_SUPPORTED)
+ /* flip BGR pixels to RGB */
+ if (transforms & PNG_TRANSFORM_BGR)
+ png_set_bgr(png_ptr);
+#endif
+
+#if defined(PNG_WRITE_SWAP_SUPPORTED)
+ /* swap bytes of 16-bit files to most significant byte first */
+ if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
+ png_set_swap(png_ptr);
+#endif
+
+#if defined(PNG_WRITE_PACKSWAP_SUPPORTED)
+ /* swap bits of 1, 2, 4 bit packed pixel formats */
+ if (transforms & PNG_TRANSFORM_PACKSWAP)
+ png_set_packswap(png_ptr);
+#endif
+
+ /* ----------------------- end of transformations ------------------- */
+
+ /* write the bits */
+ if (info_ptr->valid & PNG_INFO_IDAT)
+ png_write_image(png_ptr, info_ptr->row_pointers);
+
+ /* It is REQUIRED to call this to finish writing the rest of the file */
+ png_write_end(png_ptr, info_ptr);
+}
+#endif
diff --git a/pngwtran.c b/pngwtran.c
index 15798a1a6..ff5fd2e9c 100644
--- a/pngwtran.c
+++ b/pngwtran.c
@@ -1,11 +1,11 @@
/* pngwtran.c - transforms the data in a row for PNG writers
*
- * libpng 1.0.5k - December 27, 1999
+ * libpng 1.0.5m - January 7, 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
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*/
#define PNG_INTERNAL
diff --git a/pngwutil.c b/pngwutil.c
index afd3f8bf8..0cdb90edd 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -1,11 +1,11 @@
/* pngwutil.c - utilities to write a PNG file
*
- * libpng 1.0.5k - December 27, 1999
+ * libpng 1.0.5m - January 7, 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
- * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
+ * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*/
#define PNG_INTERNAL