[libpng10] Imported from libpng-1.0.16.tar
diff --git a/ANNOUNCE b/ANNOUNCE
index 7e1871a..dd85cbc 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,28 +1,116 @@
 
-Libpng 1.0.15 - October 3, 2002
+Libpng 1.0.16 - August 15, 2004
 
 This is a public release of libpng, intended for use in production codes.
 
-Changes since the last public release (1.0.14):
+Changes since the last public release (1.0.15):
 
-  Added code to contrib/gregbook/readpng2.c to ignore unused chunks.
-  Replaced toucan.png in contrib/gregbook (it has been corrupt since 1.0.11)
-  Removed some stray *.o files from contrib/gregbook.
-  Changed png_error() to png_warning() about "Too much data" in pngpread.c
-    and about "Extra compressed data" in pngrutil.c.
-  Prevent png_ptr->pass from exceeding 7 in png_push_finish_row().
-  Updated makefile.hggcc
-  Updated png.c and pnggccrd.c handling of return from png_mmx_support()
-  Only issue png_warning() about "Too much data" in pngpread.c when avail_in
-    is nonzero.
-  Updated makefiles to install a separate libpng.so.2 with its own rpath.
-  Revised makefiles to not remove previous minor versions of shared libraries.
-  Revised 13 makefiles to remove "-lz" and "-L$(ZLIBLIB)", etc., from shared
-    library loader directive.
-  Revised libpng-config script.
-  Relocated two misplaced PNGAPI lines in pngtest.c
+  Commented out warning about uninitialized mmx_support in pnggccrd.c.
+  Changed "IBMCPP__" flag to "__IBMCPP__" in pngconf.h.
+  Relocated two more misplaced PNGAPI lines in pngtest.c
+  Fixed memory overrun bug in png_do_read_filler() with 16-bit datastreams,
+    introduced in version 1.0.2.
+  Fixed potential overrun in pngerror.c by using strncpy instead of memcpy.
+  Revised makefile.macosx, makefile.dec, makefile.aix, and makefile.32sunu.
+  Changed the one instance of "ln -sf" to "ln -f -s" in each Sun makefile.
+  Fixed potential overrun in pngerror.c by using strncpy instead of memcpy.
+  Added "#!/bin/sh" at the top of configure, for recognition of the
+    'x' flag under Cygwin (Cosmin).
+  Optimized vacuous tests that silence compiler warnings, in png.c (Cosmin).
+  Added support for PNG_USER_CONFIG, in pngconf.h (Cosmin).
+  Fixed the special memory handler for Borland C under DOS, in pngmem.c
+    (Cosmin).
+  Removed some spurious assignments in pngrutil.c (Cosmin).
+  Replaced 65536 with 65536L, and 0xffff with 0xffffL, to silence warnings
+    on 16-bit platforms (Cosmin).
+  Enclosed shift op expressions in parentheses, to silence warnings (Cosmin).
+  Used proper type png_fixed_point, to avoid problems on 16-bit platforms,
+    in png_handle_sRGB() (Cosmin).
+  Added compression_type to png_struct, and optimized the window size
+    inside the deflate stream (Cosmin).
+  Fixed definition of isnonalpha(), in pngerror.c and pngrutil.c (Cosmin).
+  Fixed handling of unknown chunks that come after IDAT (Cosmin).
+  Allowed png_error() and png_warning() to work even if png_ptr == NULL
+    (Cosmin).
+  Replaced row_info->rowbytes with row_bytes in png_write_find_filter()
+    (Cosmin).
+  Fixed definition of PNG_LIBPNG_VER_DLLNUM (Simon-Pierre).
+  Used PNG_LIBPNG_VER and PNG_LIBPNG_VER_STRING instead of the hardcoded
+    values in png.c (Simon-Pierre, Cosmin).
+  Initialized png_libpng_ver[] with PNG_LIBPNG_VER_STRING (Simon-Pierre).
+  Replaced PNG_LIBPNG_VER_MAJOR with PNG_LIBPNG_VER_DLLNUM in png.rc
+    (Simon-Pierre).
+  Moved the definition of PNG_HEADER_VERSION_STRING near the definitions
+    of the other PNG_LIBPNG_VER_... symbols in png.h (Cosmin).
+  Relocated #ifndef PNGAPI guards in pngconf.h (Simon-Pierre, Cosmin).
+  Updated scripts/makefile.vc(a)win32 (Cosmin).
+  Updated the MSVC project (Simon-Pierre, Cosmin).
+  Updated the Borland C++ Builder project (Cosmin).
+  Avoided access to asm_flags in pngvcrd.c, if PNG_1_0_X is defined (Cosmin).
+  Commented out warning about uninitialized mmx_support in pngvcrd.c (Cosmin).
+  Removed scripts/makefile.bd32 and scripts/pngdef.pas (Cosmin).
+  Added extra guard around inclusion of Turbo C memory headers, in pngconf.h
+    (Cosmin).
+  Renamed projects/msvc/ to projects/visualc6/, and projects/borland/ to
+    projects/cbuilder5/ (Cosmin).
+  Moved projects/visualc6/png32ms.def to scripts/pngw32.def,
+    and projects/visualc6/png.rc to scripts/pngw32.rc (Cosmin).
+  Added projects/visualc6/pngtest.dsp; removed contrib/msvctest/ (Cosmin).
+  Updated contrib/visupng/VisualPng.dsp (Cosmin).
+  Updated contrib/visupng/cexcept.h to version 2.0.0 (Cosmin).
+  Added a separate distribution with "configure" and supporting files (Junichi).
+  Added user ability to change png_size_t via a PNG_SIZE_T macro.
+  Added png_sizeof() and png_convert_size() functions.
+  Added PNG_SIZE_MAX (maximum value of a png_size_t variable.
+  Added check in png_malloc_default() for (size_t)size != (png_uint_32)size
+    which would indicate an overflow.
+  Changed sPLT failure action from png_error to png_warning and abandon chunk.
+  Changed sCAL and iCCP failures from png_error to png_warning and abandon.
+  Added png_get_uint_31(png_ptr, buf) function.
+  Added PNG_UINT_32_MAX macro.
+  Renamed PNG_MAX_UINT to PNG_UINT_31_MAX.
+  Made png_zalloc() issue a png_warning and return NULL on potential
+    overflow.
+  Turn on PNG_NO_ZALLOC_ZERO by default in version 1.2.x
+  Revised "clobber list" in pnggccrd.c so it will compile under gcc-3.4.
+  Revised Borland portion of png_malloc() to return NULL or issue
+    png_error() according to setting of PNG_FLAG_MALLOC_NULL_MEM_OK.
+  Added PNG_NO_SEQUENTIAL_READ_SUPPORTED macro to conditionally remove
+    sequential read support.
+  Added some "#if PNG_WRITE_SUPPORTED" blocks.
+  #ifdef'ed out some redundancy in png_malloc_default().
+  Use png_malloc instead of png_zalloc to allocate the pallete.
+  Rearranged order of processing of color types in png_handle_tRNS().
+  Added PNG_ROWBYTES macro to calculate rowbytes without integer overflow.
+  Updated makefile.darwin and removed makefile.macosx from scripts directory.
+  Imposed default one million column, one-million row limits on the image
+    dimensions, and added png_set_user_limits() function and
+    PNG_SET_USER_LIMITS_SUPPORTED macro to override them.
+  Fixed wrong cast of returns from png_get_user_width|height_max().
+  Fixed buffer overflow vulnerability in png_handle_tRNS()
+  Fixed integer arithmetic overflow vulnerability in png_read_png().
+  Fixed some harmless bugs in png_handle_sBIT, etc, that would cause
+    duplicate chunk types to go undetected.
+  Changed some "keep the compiler happy" from empty statements to returns,
+  Revised makefile.darwin and makefile.solaris.  Removed makefile.macosx.
+  Revised pngtest's png_debug_malloc() to use png_malloc() instead of
+     png_malloc_default() which is not supposed to be exported.
+  Fixed old bug in RGB to Gray transformation.
+  Fixed problem with 64-bit compilers by casting arguments to abs()
+    to png_int_32.
+  Changed "ln -sf" to "ln -f -s" in three makefiles (solaris, sco, so9).
+  Changed "HANDLE_CHUNK_*" to "PNG_HANDLE_CHUNK_*" (Cosmin)
+  Added "-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)" to 15 *NIX makefiles.
+  Added code to update the row_info->colortype in png_do_read_filler() (MSB).
+  Eliminated use of "abs()" in testing cHRM and gAMA values, to avoid
+    trouble with some 64-bit compilers.  Created PNG_OUT_OF_RANGE() macro.
+  Revised documentation of png_set_keep_unknown_chunks().
+  Check handle_as_unknown status in pngpread.c, as in pngread.c previously.
+  Moved  "PNG_HANDLE_CHUNK_*" macros out of PNG_INTERNAL section of png.h
+  Added "rim" definitions for CONST4 and CONST6 in pnggccrd.c
+  Revised pngtest so memory allocation testing is only done when PNG_DEBUG==1.
 
 Send comments/corrections/commendations to
-png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
+png-implement@ccrc.wustl.edu or to glennrp@users.sourceforge.net
 
 Glenn R-P
diff --git a/CHANGES b/CHANGES
index d151a41..980538c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1177,8 +1177,137 @@
   Revised makefile.macosx, makefile.darwin, makefile.hpgcc, and makefile.hpux,
     and makefile.aix.
   Relocated two misplaced PNGAPI lines in pngtest.c
+version 1.2.6beta1 [October 22, 2002]
+  Commented out warning about uninitialized mmx_support in pnggccrd.c.
+  Changed "IBMCPP__" flag to "__IBMCPP__" in pngconf.h.
+  Relocated two more misplaced PNGAPI lines in pngtest.c
+  Fixed memory overrun bug in png_do_read_filler() with 16-bit datastreams,
+    introduced in version 1.0.2.
+  Revised makefile.macosx, makefile.dec, makefile.aix, and makefile.32sunu.
+version 1.2.6beta2 [November 1, 2002]
+  Added libpng-config "--ldopts" output.
+  Added "AR=ar" and "ARFLAGS=rc" and changed "ar rc" to "$(AR) $(ARFLAGS)"
+    in makefiles.
+version 1.2.6beta3 [July 18, 2004]
+  Reverted makefile changes from version 1.2.6beta2 and some of the changes
+    from version 1.2.6beta1; these will be postponed until version 1.2.7.
+    Version 1.2.6 is going to be a simple bugfix release.
+  Changed the one instance of "ln -sf" to "ln -f -s" in each Sun makefile.
+  Fixed potential overrun in pngerror.c by using strncpy instead of memcpy.
+  Added "#!/bin/sh" at the top of configure, for recognition of the
+    'x' flag under Cygwin (Cosmin).
+  Optimized vacuous tests that silence compiler warnings, in png.c (Cosmin).
+  Added support for PNG_USER_CONFIG, in pngconf.h (Cosmin).
+  Fixed the special memory handler for Borland C under DOS, in pngmem.c
+    (Cosmin).
+  Removed some spurious assignments in pngrutil.c (Cosmin).
+  Replaced 65536 with 65536L, and 0xffff with 0xffffL, to silence warnings
+    on 16-bit platforms (Cosmin).
+  Enclosed shift op expressions in parentheses, to silence warnings (Cosmin).
+  Used proper type png_fixed_point, to avoid problems on 16-bit platforms,
+    in png_handle_sRGB() (Cosmin).
+  Added compression_type to png_struct, and optimized the window size
+    inside the deflate stream (Cosmin).
+  Fixed definition of isnonalpha(), in pngerror.c and pngrutil.c (Cosmin).
+  Fixed handling of unknown chunks that come after IDAT (Cosmin).
+  Allowed png_error() and png_warning() to work even if png_ptr == NULL
+    (Cosmin).
+  Replaced row_info->rowbytes with row_bytes in png_write_find_filter()
+    (Cosmin).
+  Fixed definition of PNG_LIBPNG_VER_DLLNUM (Simon-Pierre).
+  Used PNG_LIBPNG_VER and PNG_LIBPNG_VER_STRING instead of the hardcoded
+    values in png.c (Simon-Pierre, Cosmin).
+  Initialized png_libpng_ver[] with PNG_LIBPNG_VER_STRING (Simon-Pierre).
+  Replaced PNG_LIBPNG_VER_MAJOR with PNG_LIBPNG_VER_DLLNUM in png.rc
+    (Simon-Pierre).
+  Moved the definition of PNG_HEADER_VERSION_STRING near the definitions
+    of the other PNG_LIBPNG_VER_... symbols in png.h (Cosmin).
+  Relocated #ifndef PNGAPI guards in pngconf.h (Simon-Pierre, Cosmin).
+  Updated scripts/makefile.vc(a)win32 (Cosmin).
+  Updated the MSVC project (Simon-Pierre, Cosmin).
+  Updated the Borland C++ Builder project (Cosmin).
+  Avoided access to asm_flags in pngvcrd.c, if PNG_1_0_X is defined (Cosmin).
+  Commented out warning about uninitialized mmx_support in pngvcrd.c (Cosmin).
+  Removed scripts/makefile.bd32 and scripts/pngdef.pas (Cosmin).
+  Added extra guard around inclusion of Turbo C memory headers, in pngconf.h
+    (Cosmin).
+  Renamed projects/msvc/ to projects/visualc6/, and projects/borland/ to
+    projects/cbuilder5/ (Cosmin).
+  Moved projects/visualc6/png32ms.def to scripts/pngw32.def,
+    and projects/visualc6/png.rc to scripts/pngw32.rc (Cosmin).
+  Added projects/visualc6/pngtest.dsp; removed contrib/msvctest/ (Cosmin).
+  Changed line endings to DOS style in cbuilder5 and visualc6 files, even
+    in the tar.* distributions (Cosmin).
+  Updated contrib/visupng/VisualPng.dsp (Cosmin).
+  Updated contrib/visupng/cexcept.h to version 2.0.0 (Cosmin).
+  Added a separate distribution with "configure" and supporting files (Junichi).
+version 1.2.6beta4 [July 28, 2004]
+  Added user ability to change png_size_t via a PNG_SIZE_T macro.
+  Added png_sizeof() and png_convert_size() functions.
+  Added PNG_SIZE_MAX (maximum value of a png_size_t variable.
+  Added check in png_malloc_default() for (size_t)size != (png_uint_32)size
+    which would indicate an overflow.
+  Changed sPLT failure action from png_error to png_warning and abandon chunk.
+  Changed sCAL and iCCP failures from png_error to png_warning and abandon.
+  Added png_get_uint_31(png_ptr, buf) function.
+  Added PNG_UINT_32_MAX macro.
+  Renamed PNG_MAX_UINT to PNG_UINT_31_MAX.
+  Made png_zalloc() issue a png_warning and return NULL on potential
+    overflow.
+  Turn on PNG_NO_ZALLOC_ZERO by default in version 1.2.x
+  Revised "clobber list" in pnggccrd.c so it will compile under gcc-3.4.
+  Revised Borland portion of png_malloc() to return NULL or issue
+    png_error() according to setting of PNG_FLAG_MALLOC_NULL_MEM_OK.
+  Added PNG_NO_SEQUENTIAL_READ_SUPPORTED macro to conditionally remove
+    sequential read support.
+  Added some "#if PNG_WRITE_SUPPORTED" blocks.
+  #ifdef'ed out some redundancy in png_malloc_default().
+  Use png_malloc instead of png_zalloc to allocate the pallete.
+version 1.2.6rc1 [August 4, 2004]
+  Fixed buffer overflow vulnerability in png_handle_tRNS()
+  Fixed integer arithmetic overflow vulnerability in png_read_png().
+  Fixed some harmless bugs in png_handle_sBIT, etc, that would cause
+    duplicate chunk types to go undetected.
+  Fixed some timestamps in the -config version
+  Rearranged order of processing of color types in png_handle_tRNS().
+  Added ROWBYTES macro to calculate rowbytes without integer overflow.
+  Updated makefile.darwin and removed makefile.macosx from scripts directory.
+  Imposed default one million column, one-million row limits on the image
+    dimensions, and added png_set_user_limits() function to override them.
+  Revised use of PNG_SET_USER_LIMITS_SUPPORTED macro.
+  Fixed wrong cast of returns from png_get_user_width|height_max().
+  Changed some "keep the compiler happy" from empty statements to returns,
+version 1.2.6rc2 [August 7, 2004]
+  Revised makefile.darwin and makefile.solaris.  Removed makefile.macosx.
+  Revised pngtest's png_debug_malloc() to use png_malloc() instead of
+    png_malloc_default() which is not supposed to be exported.
+  Fixed off-by-one error in one of the conversions to PNG_ROWBYTES() in
+    pngpread.c.  Bug was introduced in 1.2.6rc1.
+  Fixed bug in RGB to RGBX transformation introduced in 1.2.6rc1.
+  Fixed old bug in RGB to Gray transformation.
+  Fixed problem with 64-bit compilers by casting arguments to abs()
+    to png_int_32.
+  Changed "ln -sf" to "ln -f -s" in three makefiles (solaris, sco, so9).
+  Changed "HANDLE_CHUNK_*" to "PNG_HANDLE_CHUNK_*" (Cosmin)
+  Added "-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)" to 15 *NIX makefiles.
+  Added code to update the row_info->colortype in png_do_read_filler() (MSB).
+version 1.2.6rc3 [August 9, 2004]
+  Eliminated use of "abs()" in testing cHRM and gAMA values, to avoid
+    trouble with some 64-bit compilers.  Created PNG_OUT_OF_RANGE() macro.
+  Revised documentation of png_set_keep_unknown_chunks().
+  Check handle_as_unknown status in pngpread.c, as in pngread.c previously.
+  Moved  "PNG_HANDLE_CHUNK_*" macros out of PNG_INTERNAL section of png.h
+  Added "rim" definitions for CONST4 and CONST6 in pnggccrd.c
+version 1.2.6rc4 [August 10, 2004]
+  Fixed mistake in pngtest.c introduced in 1.2.6rc2 (declaration of
+    "pinfo" was out of place).
+version 1.2.6rc5 [August 10, 2004]
+  Moved  "PNG_HANDLE_CHUNK_*" macros out of PNG_ASSEMBLER_CODE_SUPPORTED
+     section of png.h where they were inadvertently placed in version rc3.
+version 1.2.6rc6 [August 15, 2004]
+  Revised pngtest so memory allocation testing is only done when PNG_DEBUG==1.
 
 Send comments/corrections/commendations to
-png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
+png-implement@ccrc.wustl.edu or to glennrp@users.sourceforge.net
 
 Glenn R-P
diff --git a/INSTALL b/INSTALL
index 425cc30..02895f8 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
 
-Installing libpng version 1.0.15 - October 3, 2002
+Installing libpng version 1.0.16 - August 15, 2004
 
 Before installing libpng, you must first install zlib.  zlib
 can usually be found wherever you got libpng.  zlib can be
@@ -10,8 +10,8 @@
 version of zlib that's installed.
 
 You can rename the directories that you downloaded (they
-might be called "libpng-1.0.15" or "lpng109" and "zlib-1.1.4"
-or "zlib114") so that you have directories called "zlib" and "libpng".
+might be called "libpng-1.0.16" or "lpng109" and "zlib-1.1.3"
+or "zlib113") so that you have directories called "zlib" and "libpng".
 
 Your directory structure should look like this:
 
@@ -35,7 +35,6 @@
              wince.txt
           scripts
              makefile.*
-             libpng*.in
           pngtest.png
           etc.
       zlib
@@ -65,8 +64,8 @@
 include
 
  makefile.std      =>  Generic UNIX makefile (cc, creates static libpng.a)
- makefile.linux    =>  Linux/ELF makefile (gcc, creates libpng10.so.0.1.0.15)
- makefile.gcmmx    =>  Linux/ELF makefile (gcc, creates libpng10.so.0.1.0.15,
+ makefile.linux    =>  Linux/ELF makefile (gcc, creates libpng10.so.0.1.0.16)
+ makefile.gcmmx    =>  Linux/ELF makefile (gcc, creates libpng10.so.0.1.0.16,
                        uses assembler code tuned for Intel MMX platform)
  makefile.gcc      =>  Generic makefile (gcc, creates static libpng.a)
  makefile.knr      =>  Archaic UNIX Makefile that converts files with
@@ -74,7 +73,7 @@
                        ftp://ftp.cs.wisc.edu/ghost)
  makefile.aix      =>  AIX/gcc makefile
  makefile.cygwin   =>  Cygwin/gcc makefile
- makefile.darwin   =>  Darwin makefile
+ makefile.darwin   =>  Darwin makefile, can use on MacosX
  makefile.dec      =>  DEC Alpha UNIX makefile
  makefile.hpgcc    =>  FreeBSD makefile
  makefile.hpgcc    =>  HPUX makefile using gcc
@@ -82,15 +81,14 @@
  makefile.ibmc     =>  IBM C/C++ version 3.x for Win32 and OS/2 (static)
  makefile.intel    =>  Intel C/C++ version 4.0 and later
  libpng.icc        =>  Project file for IBM VisualAge/C++ version 4.0 or later
- makefile.macosx   =>  MACOS X Makefile
  makefile.netbsd   =>  NetBSD/cc makefile, uses PNGGCCRD, makes libpng.so.
  makefile.ne0bsd  =>  NetBSD/cc makefile, uses PNGGCCRD, makes libpng0.so
  makefile.openbsd  =>  OpenBSD makefile
  makefile.sgi      =>  Silicon Graphics IRIX makefile (cc, creates static lib)
- makefile.sggcc    =>  Silicon Graphics (gcc, creates libpng10.so.0.1.0.15)
+ makefile.sggcc    =>  Silicon Graphics (gcc, creates libpng10.so.0.1.0.16)
  makefile.sunos    =>  Sun makefile
- makefile.solaris  =>  Solaris 2.X makefile (gcc, creates libpng10.so.0.1.0.15)
- makefile.so9      =>  Solaris 9 makefile (gcc, creates libpng10.so.0.1.0.15)
+ makefile.solaris  =>  Solaris 2.X makefile (gcc, creates libpng10.so.0.1.0.16)
+ makefile.so9      =>  Solaris 9 makefile (gcc, creates libpng10.so.0.1.0.16)
  makefile.32sunu   =>  Sun Ultra 32-bit makefile
  makefile.64sunu   =>  Sun Ultra 64-bit makefile
  makefile.sco      =>  For SCO OSr5  ELF and Unixware 7 with Native cc
@@ -146,6 +144,17 @@
 Some also allow you to run "make test-installed" after you have
 run "make install".
 
+If you encounter a compiler error message complaining about the
+lines
+      __png.h__ already includes setjmp.h;
+      __dont__ include it again.;
+This means you have compiled another module that includes setjmp.h,
+which is hazardous because the two modules might not include exactly
+the same setjmp.h.  If you are sure that you know what you are doing
+and that they are exactly the same, then you can comment out or
+delete the two lines.  Better yet, use the cexcept interface
+instead, as demonstrated in contrib/visupng of the libpng distribution.
+
 Further information can be found in the README and libpng.txt
-files, in the individual makefiles, in png.h, in the README files in
-subdirectories of the LIB directory, and the manual pages libpng.3 and png.5.
+files, in the individual makefiles, in png.h, and the manual pages
+libpng.3 and png.5.
diff --git a/KNOWNBUG b/KNOWNBUG
index f6ca02b..9a2778d 100644
--- a/KNOWNBUG
+++ b/KNOWNBUG
@@ -1,5 +1,5 @@
 
-Known bugs in libpng version 1.0.15
+Known bugs in libpng version 1.0.16
 
 1. April 22, 2001: pnggccrd.c has been reported to crash on NetBSD when
    reading interlaced PNG files, when assembler code is enabled but running
diff --git a/LICENSE b/LICENSE
index 89e553d..65c9d46 100644
--- a/LICENSE
+++ b/LICENSE
@@ -8,9 +8,16 @@
 If you modify libpng you may insert additional notices immediately following
 this sentence.
 
-libpng versions 1.0.7, July 1, 2000, through 1.0.15, October 3, 2002, are
-Copyright (c) 2000-2002 Glenn Randers-Pehrson
-and are distributed according to the same disclaimer and license as libpng-1.0.6
+libpng version 1.2.6, August 15, 2004, is
+Copyright (c) 2004 Glenn Randers-Pehrson, and is
+distributed according to the same disclaimer and license as libpng-1.2.5
+with the following individual added to the list of Contributing Authors
+
+   Cosmin Truta
+
+libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
+Copyright (c) 2000-2002 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
 
    Simon-Pierre Cadieux
@@ -98,5 +105,5 @@
 certification mark of the Open Source Initiative.
 
 Glenn Randers-Pehrson
-randeg@alum.rpi.edu
-October 3, 2002
+glennrp@users.sourceforge.net
+August 15, 2004
diff --git a/README b/README
index d1e9ad8..32e4100 100644
--- a/README
+++ b/README
@@ -1,11 +1,11 @@
-README for libpng 1.0.15 - October 3, 2002 (shared library 2.1)
+README for libpng version 1.0.16 - August 15, 2004 (shared library 12.0)
 See the note about version numbers near the top of png.h
 
 See INSTALL for instructions on how to install libpng.
 
-Libpng comes in two distribution formats.  Get libpng-*.tar.gz if you
-want UNIX-style line endings in the text files, or lpng*.zip if you want
-DOS-style line endings.
+Libpng comes in several distribution formats.  Get libpng-*.tar.gz
+or libpng-*.tar.bz2 if you want UNIX-style line endings in the text
+files, or lpng*.zip if you want DOS-style line endings.
 
 Version 0.89 was the first official release of libpng.  Don't let the
 fact that it's the first release fool you.  The libpng library has been in
@@ -104,7 +104,7 @@
 This release was created and will be supported by myself (of course
 based in a large way on Guy's and Andreas' earlier work), and the PNG group.
 
-randeg@alum.rpi.edu
+glennrp@users.sourceforge.net
 png-implement@ccrc.wustl.edu
 
 You can't reach Guy, the original libpng author, at the addresses
@@ -187,9 +187,9 @@
        descrip.mms      =>  VMS makefile for MMS or MMK
        makefile.std     =>  Generic UNIX makefile (cc, creates static libpng.a)
        makefile.linux   =>  Linux/ELF makefile
-                            (gcc, creates libpng10.so.0.1.0.15)
+                            (gcc, creates libpng12.so.0.1.2.5)
        makefile.gcmmx   =>  Linux/ELF makefile (gcc, creates
-                            libpng10.so.0.1.0.15, uses assembler code
+                            libpng12.so.0.1.2.5, uses assembler code
                             tuned for Intel MMX platform)
        makefile.gcc     =>  Generic makefile (gcc, creates static libpng.a)
        makefile.knr     =>  Archaic UNIX Makefile that converts files with
@@ -210,12 +210,12 @@
        makefile.ne0bsd =>  NetBSD/cc makefile, PNGGCCRD, makes libpng0.so
        makefile.openbsd =>  OpenBSD makefile
        makefile.sgi     =>  Silicon Graphics IRIX (cc, creates static lib)
-       makefile.sggcc   =>  Silicon Graphics (gcc, creates libpng10.so.0.1.0.15)
+       makefile.sggcc   =>  Silicon Graphics (gcc, creates libpng12.so.0.1.2.5)
        makefile.sunos   =>  Sun makefile
        makefile.solaris =>  Solaris 2.X makefile
-                            (gcc, creates libpng10.so.0.1.0.15)
+                            (gcc, creates libpng12.so.0.1.2.5)
        makefile.so9     =>  Solaris 9 makefile
-                            (gcc, creates libpng10.so.0.1.0.15)
+                            (gcc, creates libpng12.so.0.1.2.5)
        makefile.32sunu  =>  Sun Ultra 32-bit makefile
        makefile.64sunu  =>  Sun Ultra 64-bit makefile
        makefile.sco     =>  For SCO OSr5  ELF and Unixware 7 with Native cc
@@ -244,6 +244,16 @@
        makevms.com      =>  VMS build script
        pngdef.pas       =>  Defines for a png32bd.dll with Borland C++ 4.5
        SCOPTIONS.ppc    =>  Used with smakefile.ppc
+      mangle        =>  Directory containing scripts to build libpng12m.so:
+       mangle.in        =>  Function-decoration macros added to png.h by the
+                            makefiles.
+       makefile.linux   =>  Linux/ELF makefile
+                            (gcc, creates libpng12m.so.0.1.2.5)
+       makefile.gcmmx   =>  Linux/ELF makefile (gcc, creates
+                            libpng12.so.0m.1.2.5, uses assembler code
+                            tuned for Intel MMX platform)
+       makefile.sgi     =>  Silicon Graphics (cc, creates libpng12m.so)
+       makefile.sggcc   =>  Silicon Graphics (gcc, creates libpng12m.so)
 
 Good luck, and happy coding.
 
diff --git a/Y2KINFO b/Y2KINFO
index 09c709f..2d38f31 100644
--- a/Y2KINFO
+++ b/Y2KINFO
@@ -1,13 +1,13 @@
    Y2K compliance in libpng:
    =========================
 
-      October 3, 2002
+      August 15, 2004
 
       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.15 are Y2K compliant.  It is my belief that earlier
+      upward through 1.0.16 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
diff --git a/configure b/configure
index 51cf554..5925b6e 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,13 @@
+#!/bin/sh
 echo "
-  There is no \"configure\" script for Libpng-1.0.15.  Instead, please
-  copy the appropriate makefile for your system from the \"scripts\"
-  directory.  Read the INSTALL file for more details.
+  There is no \"configure\" script in this distribution of
+  libpng-1.0.16.
+
+  Instead, please copy the appropriate makefile for your system from the
+  \"scripts\" directory.  Read the INSTALL file for more details.
+
+  Update, July 2004: you can get a "configure" based distribution
+  from the libpng distribution sites.  Download the file
+  libpng-1.0.16-config.tar.gz
 "
 
diff --git a/contrib/gregbook/Makefile.sgi b/contrib/gregbook/Makefile.sgi
index f824a96..e3ca6ce 100644
--- a/contrib/gregbook/Makefile.sgi
+++ b/contrib/gregbook/Makefile.sgi
@@ -23,9 +23,9 @@
 
 # macros --------------------------------------------------------------------
 
-PNGINC = -I/usr/local/include/libpng10
-PNGLIB = -L/usr/local/lib -lpng10	  # dynamically linked against libpng
-#PNGLIB = /usr/local/lib/libpng10.a # statically linked against libpng
+PNGINC = -I/usr/local/include/libpng12
+PNGLIB = -L/usr/local/lib -lpng12	  # dynamically linked against libpng
+#PNGLIB = /usr/local/lib/libpng12.a # statically linked against libpng
 # or:
 #PNGINC = -I../..
 #PNGLIB = -L../.. -lpng
@@ -52,8 +52,10 @@
 CC = cc
 LD = cc
 RM = rm -f
-CFLAGS = -O -fullwarn $(INCS)
-LDFLAGS =
+# ABI must be the same as that used to build libpng.
+ABI=
+CFLAGS = $(ABI) -O -fullwarn $(INCS)
+LDFLAGS = $(ABI)
 O = .o
 E =
 
diff --git a/contrib/gregbook/Makefile.unx b/contrib/gregbook/Makefile.unx
index 89018ae..c0c3fb1 100644
--- a/contrib/gregbook/Makefile.unx
+++ b/contrib/gregbook/Makefile.unx
@@ -23,9 +23,9 @@
 
 # macros --------------------------------------------------------------------
 
-PNGINC = -I/usr/local/include/libpng10
-#PNGLIB = -L/usr/local/lib -lpng10 # dynamically linked against libpng
-PNGLIB = /usr/local/lib/libpng10.a # statically linked against libpng
+PNGINC = -I/usr/local/include/libpng12
+#PNGLIB = -L/usr/local/lib -lpng12 # dynamically linked against libpng
+PNGLIB = /usr/local/lib/libpng12.a # statically linked against libpng
 # or:
 #PNGINC = -I../libpng
 #PNGLIB = -L../libpng -lpng
diff --git a/contrib/gregbook/readpng2.c b/contrib/gregbook/readpng2.c
index 87f1350..9e66a0b 100644
--- a/contrib/gregbook/readpng2.c
+++ b/contrib/gregbook/readpng2.c
@@ -4,7 +4,13 @@
 
   ---------------------------------------------------------------------------
 
-      Copyright (c) 1998-2001 Greg Roelofs.  All rights reserved.
+   Changelog:
+    - 1.01:  initial public release
+    - 1.02:  added code to skip unused chunks (GR-P)
+
+  ---------------------------------------------------------------------------
+
+      Copyright (c) 1998-2002 Greg Roelofs.  All rights reserved.
 
       This software is provided "as is," without warranty of any kind,
       express or implied.  In no event shall the author or contributors
@@ -173,6 +179,40 @@
         return 2;
     }
 
+    /* prepare the reader to ignore all recognized chunks whose data isn't
+     * going to be used, i.e., all chunks recognized by libpng except for
+     * IHDR, PLTE, IDAT, IEND, tRNS, bKGD, gAMA, and sRGB : */
+
+#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
+    {
+#ifndef HANDLE_CHUNK_NEVER
+/* prior to libpng-1.2.5, this macro was internal, so we define it here. */
+# define HANDLE_CHUNK_NEVER 1
+#endif
+       /* these byte strings were copied from png.h.
+        * If a future libpng version recognizes more chunks, add them
+        * to this list.  If a future version of readpng2.c recognizes
+        * more chunks, delete them from this list. */
+       png_byte png_chunk_types_to_ignore[]=
+          { 99,  72,  82,  77, '\0', /* cHRM */
+           104,  73,  83,  84, '\0', /* hIST */
+           105,  67,  67,  80, '\0', /* iCCP */
+           105,  84,  88, 116, '\0', /* iTXt */
+           111,  70,  70, 115, '\0', /* oFFs */
+           112,  67,  65,  76, '\0', /* pCAL */
+           115,  67,  65,  76, '\0', /* sCAL */
+           112,  72,  89, 115, '\0', /* pHYs */
+           115,  66,  73,  84, '\0', /* sBIT */
+           115,  80,  76,  84, '\0', /* sPLT */
+           116,  69,  88, 116, '\0', /* tEXt */
+           116,  73,  77,  69, '\0', /* tIME */
+           122,  84,  88, 116, '\0'}; /* zTXt */
+#define NUM_PNG_CHUNK_TYPES_TO_IGNORE 13
+
+    png_set_keep_unknown_chunks(png_ptr, HANDLE_CHUNK_NEVER,
+        png_chunk_types_to_ignore, NUM_PNG_CHUNK_TYPES_TO_IGNORE);
+    }
+#endif
 
     /* instead of doing png_init_io() here, now we set up our callback
      * functions for progressive decoding */
diff --git a/contrib/gregbook/rpng2-x.c b/contrib/gregbook/rpng2-x.c
index 1c61283..5fc29ea 100644
--- a/contrib/gregbook/rpng2-x.c
+++ b/contrib/gregbook/rpng2-x.c
@@ -594,6 +594,7 @@
          * If we/it segfault instead, seems like a libpng bug... */
 
         /* we're here via libpng callback, so if window fails, clean and bail */
+printf("readpng2_cleanup.\n");
         readpng2_cleanup(&rpng2_info);
         rpng2_x_cleanup();
         exit(2);
diff --git a/contrib/msvctest/README.txt b/contrib/msvctest/README.txt
deleted file mode 100644
index 09bffd3..0000000
--- a/contrib/msvctest/README.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-Microsoft Developer Studio Build File, Format Version 6.00 for
-msvctest
-
-Assumes that libpng DLLs and LIBs are in ..\..\projects\msvc\win32\libpng
-Assumes that zlib DLLs and LIBs are in ..\..\projects\msvc\win32\zlib
-
-To build:
-
-1) On the main menu Select "Build|Set Active configuration".
-   Choose the configuration that corresponds to the library you want to test.
-   This library must have been built using the libpng MS project located in
-   the "mscv" subdirectory.
-
-2) Select "Build|Clean"
-
-3) Select "Build|Rebuild All"
-
-4) The test results should appear in the "Build" pane of the Output Window.
-
-
-Simon-Pierre Cadieux
-Methodex Computer Systems Inc.
diff --git a/contrib/msvctest/msvctest.dsp b/contrib/msvctest/msvctest.dsp
deleted file mode 100644
index ea81cb0..0000000
--- a/contrib/msvctest/msvctest.dsp
+++ /dev/null
@@ -1,247 +0,0 @@
-# Microsoft Developer Studio Project File - Name="msvctest" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=msvctest - Win32 Debug DLL
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "msvctest.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "msvctest.mak" CFG="msvctest - Win32 Debug DLL"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "msvctest - Win32 DLL" (based on "Win32 (x86) Console Application")
-!MESSAGE "msvctest - Win32 Debug DLL" (based on "Win32 (x86) Console Application")
-!MESSAGE "msvctest - Win32 ASM DLL" (based on "Win32 (x86) Console Application")
-!MESSAGE "msvctest - Win32 Debug ASM DLL" (based on "Win32 (x86) Console Application")
-!MESSAGE "msvctest - Win32 LIB" (based on "Win32 (x86) Console Application")
-!MESSAGE "msvctest - Win32 Debug LIB" (based on "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "msvctest - Win32 DLL"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "dll"
-# PROP BASE Intermediate_Dir "dll"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "dll"
-# PROP Intermediate_Dir "dll"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FD /c
-# ADD CPP /nologo /MD /W3 /O1 /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /subsystem:console /machine:I386
-# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll\libpng10.lib /nologo /subsystem:console /machine:I386
-# Begin Special Build Tool
-OutDir=.\dll
-SOURCE="$(InputPath)"
-PostBuild_Desc=[Run Test]
-PostBuild_Cmds=set path=..\..\projects\msvc\win32\libpng\dll;..\..\projects\msvc\win32\zlib\dll;	$(outdir)\msvctest.exe ..\..\pngtest.png
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "msvctest - Win32 Debug DLL"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "dll_dbg"
-# PROP BASE Intermediate_Dir "dll_dbg"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "dll_dbg"
-# PROP Intermediate_Dir "dll_dbg"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Zi /Od /I "..\..\..\zlib" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll_dbg\libpng10d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# Begin Special Build Tool
-OutDir=.\dll_dbg
-SOURCE="$(InputPath)"
-PostBuild_Desc=[Run Test]
-PostBuild_Cmds=set path=..\..\projects\msvc\win32\libpng\dll_dbg;..\..\projects\msvc\win32\zlib\dll_dbg;	$(outdir)\msvctest.exe ..\..\pngtest.png
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "msvctest - Win32 ASM DLL"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "dll_asm"
-# PROP BASE Intermediate_Dir "dll_asm"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "dll_asm"
-# PROP Intermediate_Dir "dll_asm"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FD /c
-# ADD CPP /nologo /MD /W3 /O1 /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /subsystem:console /machine:I386
-# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll_asm\libpng10a.lib /nologo /subsystem:console /machine:I386
-# Begin Special Build Tool
-OutDir=.\dll_asm
-SOURCE="$(InputPath)"
-PostBuild_Desc=[Run Test]
-PostBuild_Cmds=set path=..\..\projects\msvc\win32\libpng\dll_asm;..\..\projects\msvc\win32\zlib\dll_asm;	$(outdir)\msvctest.exe ..\..\pngtest.png
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "msvctest - Win32 Debug ASM DLL"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "dll_dbga"
-# PROP BASE Intermediate_Dir "dll_dbga"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "dll_dbga"
-# PROP Intermediate_Dir "dll_dbga"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Zi /Od /I "..\..\..\zlib" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll_dbga\libpng10b.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# Begin Special Build Tool
-OutDir=.\dll_dbga
-SOURCE="$(InputPath)"
-PostBuild_Desc=[Run Test]
-PostBuild_Cmds=set path=..\..\projects\msvc\win32\libpng\dll_dbga;..\..\projects\msvc\win32\zlib\dll_dbga;	$(outdir)\msvctest.exe ..\..\pngtest.png
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "msvctest - Win32 LIB"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "lib"
-# PROP BASE Intermediate_Dir "lib"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "lib"
-# PROP Intermediate_Dir "lib"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FD /c
-# ADD CPP /nologo /W3 /O1 /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /subsystem:console /machine:I386
-# ADD LINK32 ..\..\projects\msvc\win32\libpng\lib\libpng.lib /nologo /subsystem:console /machine:I386
-# Begin Special Build Tool
-OutDir=.\lib
-SOURCE="$(InputPath)"
-PostBuild_Desc=[Run Test]
-PostBuild_Cmds=$(outdir)\msvctest.exe ..\..\pngtest.png
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "msvctest - Win32 Debug LIB"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "lib_dbg"
-# PROP BASE Intermediate_Dir "lib_dbg"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "lib_dbg"
-# PROP Intermediate_Dir "lib_dbg"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Zi /Od /I "..\..\..\zlib" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 ..\..\projects\msvc\win32\libpng\lib_dbg\libpng.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# Begin Special Build Tool
-OutDir=.\lib_dbg
-SOURCE="$(InputPath)"
-PostBuild_Desc=[Run Test]
-PostBuild_Cmds=$(outdir)\msvctest.exe ..\..\pngtest.png
-# End Special Build Tool
-
-!ENDIF 
-
-# Begin Target
-
-# Name "msvctest - Win32 DLL"
-# Name "msvctest - Win32 Debug DLL"
-# Name "msvctest - Win32 ASM DLL"
-# Name "msvctest - Win32 Debug ASM DLL"
-# Name "msvctest - Win32 LIB"
-# Name "msvctest - Win32 Debug LIB"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\..\pngtest.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\README.txt
-# PROP Exclude_From_Build 1
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/contrib/msvctest/msvctest.dsw b/contrib/msvctest/msvctest.dsw
deleted file mode 100644
index a2bb056..0000000
--- a/contrib/msvctest/msvctest.dsw
+++ /dev/null
@@ -1,29 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "msvctest"=.\msvctest.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/contrib/pngminus/makefile.std b/contrib/pngminus/makefile.std
index b33b022..2fb061b 100644
--- a/contrib/pngminus/makefile.std
+++ b/contrib/pngminus/makefile.std
@@ -8,9 +8,9 @@
 RM=rm -f
 
 #PNGPATH = /usr/local
-#PNGINC = -I$(PNGPATH)/include/libpng10
-#PNGLIB = -L$(PNGPATH)/lib -lpng10
-#PNGLIBS = $(PNGPATH)/lib/libpng10.a
+#PNGINC = -I$(PNGPATH)/include/libpng12
+#PNGLIB = -L$(PNGPATH)/lib -lpng12
+#PNGLIBS = $(PNGPATH)/lib/libpng12.a
 PNGINC = -I../..
 PNGLIB = -L../.. -lpng
 PNGLIBS = ../../libpng.a
diff --git a/contrib/visupng/VisualPng.dsp b/contrib/visupng/VisualPng.dsp
index 24402ca..53ef5a2 100644
--- a/contrib/visupng/VisualPng.dsp
+++ b/contrib/visupng/VisualPng.dsp
@@ -1,223 +1,147 @@
-# Microsoft Developer Studio Project File - Name="VisualPng" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-
-# Copyright 2000, Willem van Schaik.  For conditions of distribution and
-# use, see the copyright/license/disclaimer notice in png.h
-
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Application" 0x0101
-
-CFG=VisualPng - Win32 Debug LIB
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "VisualPng.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "VisualPng.mak" CFG="VisualPng - Win32 Debug LIB"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "VisualPng - Win32 DLL" (based on "Win32 (x86) Application")
-!MESSAGE "VisualPng - Win32 Debug DLL" (based on "Win32 (x86) Application")
-!MESSAGE "VisualPng - Win32 LIB" (based on "Win32 (x86) Application")
-!MESSAGE "VisualPng - Win32 Debug LIB" (based on "Win32 (x86) Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "VisualPng - Win32 DLL"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "VisualPng___Win32_DLL"
-# PROP BASE Intermediate_Dir "VisualPng___Win32_DLL"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "dll"
-# PROP Intermediate_Dir "dll"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /I "libpng" /I "zlib" /D "PNG_USE_DLL" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\libpng" /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "PNG_USE_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 libpng10.lib zlibd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"libpng" /libpath:"zlib"
-# ADD LINK32 libpng10.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"..\..\projects\msvc\win32\libpng\dll"
-# Begin Special Build Tool
-OutDir=.\dll
-SOURCE="$(InputPath)"
-PostBuild_Cmds=set path=..\..\projects\msvc\win32\libpng\dll;..\..\projects\msvc\win32\zlib\dll;	$(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "VisualPng - Win32 Debug DLL"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "VisualPng___Win32_Debug_DLL"
-# PROP BASE Intermediate_Dir "VisualPng___Win32_Debug_DLL"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "dll_dbg"
-# PROP Intermediate_Dir "dll_dbg"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "libpng" /I "zlib" /D "PNG_USE_DLL" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\libpng" /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "PNG_USE_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c
-# SUBTRACT CPP /YX
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 libpng10.lib zlibd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"libpng" /libpath:"zlib"
-# SUBTRACT BASE LINK32 /nodefaultlib
-# ADD LINK32 libpng10d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"..\..\projects\msvc\win32\libpng\dll_dbg"
-# SUBTRACT LINK32 /nodefaultlib
-# Begin Special Build Tool
-OutDir=.\dll_dbg
-SOURCE="$(InputPath)"
-PostBuild_Cmds=set path=..\..\projects\msvc\win32\libpng\dll_dbg;..\..\projects\msvc\win32\zlib\dll_dbg;	$(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "VisualPng - Win32 LIB"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "VisualPng___Win32_LIB"
-# PROP BASE Intermediate_Dir "VisualPng___Win32_LIB"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "lib"
-# PROP Intermediate_Dir "lib"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /I "..\..\..\libpng" /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "PNG_USE_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c
-# SUBTRACT BASE CPP /YX
-# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\libpng" /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 libpng10.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"..\..\projects\msvc\win32\libpng\dll"
-# ADD LINK32 libpng.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"..\..\projects\msvc\win32\libpng\lib"
-# Begin Special Build Tool
-OutDir=.\lib
-SOURCE="$(InputPath)"
-PostBuild_Cmds=$(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "VisualPng - Win32 Debug LIB"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "VisualPng___Win32_Debug_LIB"
-# PROP BASE Intermediate_Dir "VisualPng___Win32_Debug_LIB"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "lib_dbg"
-# PROP Intermediate_Dir "lib_dbg"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\libpng" /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "PNG_USE_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\libpng" /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c
-# SUBTRACT CPP /YX
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 libpng10d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"..\..\projects\msvc\win32\libpng\dll_dbg"
-# SUBTRACT BASE LINK32 /nodefaultlib
-# ADD LINK32 libpng.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"..\..\projects\msvc\win32\libpng\lib_dbg"
-# SUBTRACT LINK32 /nodefaultlib
-# Begin Special Build Tool
-OutDir=.\lib_dbg
-SOURCE="$(InputPath)"
-PostBuild_Cmds=$(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png
-# End Special Build Tool
-
-!ENDIF 
-
-# Begin Target
-
-# Name "VisualPng - Win32 DLL"
-# Name "VisualPng - Win32 Debug DLL"
-# Name "VisualPng - Win32 LIB"
-# Name "VisualPng - Win32 Debug LIB"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\PngFile.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\VisualPng.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\cexcept.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\PngFile.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\resource.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# Begin Source File
-
-SOURCE=.\VisualPng.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\VisualPng.rc
-# End Source File
-# End Group
-# End Target
-# End Project
+# Microsoft Developer Studio Project File - Name="VisualPng" - Package Owner=<4>

+# Microsoft Developer Studio Generated Build File, Format Version 6.00

+# ** DO NOT EDIT **

+

+# TARGTYPE "Win32 (x86) Application" 0x0101

+

+CFG=VisualPng - Win32 Debug

+!MESSAGE This is not a valid makefile. To build this project using NMAKE,

+!MESSAGE use the Export Makefile command and run

+!MESSAGE 

+!MESSAGE NMAKE /f "VisualPng.mak".

+!MESSAGE 

+!MESSAGE You can specify a configuration when running NMAKE

+!MESSAGE by defining the macro CFG on the command line. For example:

+!MESSAGE 

+!MESSAGE NMAKE /f "VisualPng.mak" CFG="VisualPng - Win32 Debug"

+!MESSAGE 

+!MESSAGE Possible choices for configuration are:

+!MESSAGE 

+!MESSAGE "VisualPng - Win32 Release" (based on "Win32 (x86) Application")

+!MESSAGE "VisualPng - Win32 Debug" (based on "Win32 (x86) Application")

+!MESSAGE 

+

+# Begin Project

+# PROP AllowPerConfigDependencies 0

+# PROP Scc_ProjName ""

+# PROP Scc_LocalPath ""

+CPP=cl.exe

+MTL=midl.exe

+RSC=rc.exe

+

+!IF  "$(CFG)" == "VisualPng - Win32 Release"

+

+# PROP BASE Use_MFC 0

+# PROP BASE Use_Debug_Libraries 0

+# PROP BASE Output_Dir "Release"

+# PROP BASE Intermediate_Dir "Release"

+# PROP BASE Ignore_Export_Lib 0

+# PROP BASE Target_Dir ""

+# PROP Use_MFC 0

+# PROP Use_Debug_Libraries 0

+# PROP Output_Dir "Release"

+# PROP Intermediate_Dir "Release"

+# PROP Ignore_Export_Lib 0

+# PROP Target_Dir ""

+# ADD BASE CPP /nologo /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c

+# SUBTRACT BASE CPP /YX

+# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c

+# SUBTRACT CPP /YX

+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32

+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32

+# ADD BASE RSC /l 0x409 /d "NDEBUG"

+# ADD RSC /l 0x409 /d "NDEBUG"

+BSC32=bscmake.exe

+# ADD BASE BSC32 /nologo

+# ADD BSC32 /nologo

+LINK32=link.exe

+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386

+# ADD LINK32 ..\..\projects\visualc6\Win32_LIB_Release\libpng.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_Release\zlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386

+# Begin Special Build Tool

+OutDir=.\Release

+SOURCE="$(InputPath)"

+PostBuild_Cmds=$(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png

+# End Special Build Tool

+

+!ELSEIF  "$(CFG)" == "VisualPng - Win32 Debug"

+

+# PROP BASE Use_MFC 0

+# PROP BASE Use_Debug_Libraries 1

+# PROP BASE Output_Dir "Debug"

+# PROP BASE Intermediate_Dir "Debug"

+# PROP BASE Ignore_Export_Lib 0

+# PROP BASE Target_Dir ""

+# PROP Use_MFC 0

+# PROP Use_Debug_Libraries 1

+# PROP Output_Dir "Debug"

+# PROP Intermediate_Dir "Debug"

+# PROP Ignore_Export_Lib 0

+# PROP Target_Dir ""

+# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c

+# SUBTRACT BASE CPP /YX

+# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c

+# SUBTRACT CPP /YX

+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32

+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32

+# ADD BASE RSC /l 0x409 /d "_DEBUG"

+# ADD RSC /l 0x409 /d "_DEBUG"

+BSC32=bscmake.exe

+# ADD BASE BSC32 /nologo

+# ADD BSC32 /nologo

+LINK32=link.exe

+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept

+# ADD LINK32 ..\..\projects\visualc6\Win32_LIB_Release\libpng.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_Release\zlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"msvcrt.lib" /pdbtype:sept

+# Begin Special Build Tool

+OutDir=.\Debug

+SOURCE="$(InputPath)"

+PostBuild_Cmds=$(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png

+# End Special Build Tool

+

+!ENDIF 

+

+# Begin Target

+

+# Name "VisualPng - Win32 Release"

+# Name "VisualPng - Win32 Debug"

+# Begin Group "Source Files"

+

+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"

+# Begin Source File

+

+SOURCE=.\PngFile.c

+# End Source File

+# Begin Source File

+

+SOURCE=.\VisualPng.c

+# End Source File

+# End Group

+# Begin Group "Header Files"

+

+# PROP Default_Filter "h;hpp;hxx;hm;inl"

+# Begin Source File

+

+SOURCE=.\cexcept.h

+# End Source File

+# Begin Source File

+

+SOURCE=.\PngFile.h

+# End Source File

+# Begin Source File

+

+SOURCE=.\resource.h

+# End Source File

+# End Group

+# Begin Group "Resource Files"

+

+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"

+# Begin Source File

+

+SOURCE=.\VisualPng.ico

+# End Source File

+# Begin Source File

+

+SOURCE=.\VisualPng.rc

+# End Source File

+# End Group

+# End Target

+# End Project

diff --git a/contrib/visupng/VisualPng.dsw b/contrib/visupng/VisualPng.dsw
index 17ad83a..a30e1cc 100644
--- a/contrib/visupng/VisualPng.dsw
+++ b/contrib/visupng/VisualPng.dsw
@@ -1,29 +1,29 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "VisualPng"=.\VisualPng.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
+Microsoft Developer Studio Workspace File, Format Version 6.00

+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!

+

+###############################################################################

+

+Project: "VisualPng"=.\VisualPng.dsp - Package Owner=<4>

+

+Package=<5>

+{{{

+}}}

+

+Package=<4>

+{{{

+}}}

+

+###############################################################################

+

+Global:

+

+Package=<5>

+{{{

+}}}

+

+Package=<3>

+{{{

+}}}

+

+###############################################################################

+

diff --git a/contrib/visupng/cexcept.h b/contrib/visupng/cexcept.h
index 532b23d..dbea51e 100644
--- a/contrib/visupng/cexcept.h
+++ b/contrib/visupng/cexcept.h
@@ -1,17 +1,20 @@
 /*===
-cexcept.h 1.0.0 (2000-Jun-21-Wed)
+cexcept.h 2.0.0 (2001-Jul-12-Thu)
 Adam M. Costello <amc@cs.berkeley.edu>
 
-An interface for exception-handling in ANSI C, developed jointly with
-Cosmin Truta <cosmin@cs.toronto.edu>.
+An interface for exception-handling in ANSI C (C89 and subsequent ISO
+standards), developed jointly with Cosmin Truta <cosmin@cs.toronto.edu>.
 
-    Copyright (c) 2000 Adam M. Costello and Cosmin Truta.  Everyone
+    Copyright (c) 2001 Adam M. Costello and Cosmin Truta.  Everyone
     is hereby granted permission to do whatever they like with this
     file, provided that if they modify it they take reasonable steps to
     avoid confusing or misleading people about the authors, version,
     and terms of use of the derived file.  The copyright holders make
-    no guarantees about the correctness of this file, and are not
-    responsible for any damage resulting from its use.
+    no guarantees regarding this file, and are not responsible for any
+    damage resulting from its use.
+
+Only user-defined exceptions are supported, not "real" exceptions like
+division by zero or memory segmentation violations.
 
 If this interface is used by multiple .c files, they shouldn't include
 this header file directly.  Instead, create a wrapper header file that
@@ -37,6 +40,10 @@
         struct exception { int code; const char *msg; };
         define_exception_type(struct exception);
 
+    Because throwing an exception causes the object to be copied (not
+    just once, but twice), programmers may wish to consider size when
+    choosing the exception type.
+
 
 struct exception_context;
 
@@ -62,7 +69,7 @@
     application may declare a variable of this name anywhere it likes
     (inside a function, in a parameter list, or externally), and may
     use whatever storage class specifiers (static, extern, etc) or type
-    qualifiers (const, volatile) it likes.  Examples:
+    qualifiers (const, volatile, etc) it likes.  Examples:
 
         static struct exception_context
           * const the_exception_context = &foo;
@@ -107,15 +114,15 @@
     confusion with the C++ keywords, which have subtly different
     semantics.
 
-    A Try/Catch statement has a syntax similar to an if/else
-    statement, except that the parenthesized expression goes after
-    the second keyword rather than the first.  As with if/else,
-    there are two clauses, each of which may be a simple statement
-    ending with a semicolon or a brace-enclosed compound statement.
-    But whereas the else clause is optional, the Catch clause is
-    required.  The expression must be a modifiable lvalue (something
-    capable of being assigned to) of the exact same type passed to
-    define_exception_type().
+    A Try/Catch statement has a syntax similar to an if/else statement,
+    except that the parenthesized expression goes after the second
+    keyword rather than the first.  As with if/else, there are two
+    clauses, each of which may be a simple statement ending with a
+    semicolon or a brace-enclosed compound statement.  But whereas
+    the else clause is optional, the Catch clause is required.  The
+    expression must be a modifiable lvalue (something capable of being
+    assigned to) of the same type (disregarding type qualifiers) that
+    was passed to define_exception_type().
 
     If a Throw that uses the same exception context as the Try/Catch is
     executed within the Try clause (typically within a function called
@@ -125,9 +132,8 @@
     such Throw is executed, then the assignment is not performed, and
     the Catch clause is not executed.
 
-    Regardless of whether an exception is caught, the expression is
-    always evaluated exactly once, which is significant if it has side
-    effects, for example:
+    The expression is not evaluated unless and until the exception is
+    caught, which is significant if it has side effects, for example:
 
         Try foo();
         Catch (p[++i].e) { ... }
@@ -183,62 +189,55 @@
 #include <setjmp.h>
 
 #define define_exception_type(etype) \
-struct exception__state { \
-  etype *exception; \
-  jmp_buf env; \
+struct exception_context { \
+  jmp_buf *penv; \
+  int caught; \
+  volatile struct { etype etmp; } v; \
 }
 
-struct exception_context { \
-  struct exception__state *last; \
-  int caught; \
-};
+/* etmp must be volatile because the application might use automatic */
+/* storage for the_exception_context, and etmp is modified between   */
+/* the calls to setjmp() and longjmp().  A wrapper struct is used to */
+/* avoid warnings about a duplicate volatile qualifier in case etype */
+/* already includes it.                                              */
 
-#define init_exception_context(ec) ((void)((ec)->last = 0))
-
-#define Catch(e) exception__catch(&(e))
-#define Catch_anonymous exception__catch(0)
+#define init_exception_context(ec) ((void)((ec)->penv = 0))
 
 #define Try \
   { \
-    struct exception__state *exception__p, exception__s; \
-    int exception__i; \
-    exception__p = the_exception_context->last; \
-    the_exception_context->last = &exception__s; \
-    for (exception__i = 0; ; exception__i = 1) \
-      if (exception__i) { \
-        if (setjmp(exception__s.env) == 0) { \
-          if (&exception__s)
+    jmp_buf *exception__prev, exception__env; \
+    exception__prev = the_exception_context->penv; \
+    the_exception_context->penv = &exception__env; \
+    if (setjmp(exception__env) == 0) { \
+      if (&exception__prev)
 
-#define exception__catch(e_addr) \
-          else { } \
-          the_exception_context->caught = 0; \
-        } \
-        else the_exception_context->caught = 1; \
-        the_exception_context->last = exception__p; \
-        break; \
-      } \
-      else exception__s.exception = e_addr; \
+#define exception__catch(action) \
+      else { } \
+      the_exception_context->caught = 0; \
+    } \
+    else { \
+      the_exception_context->caught = 1; \
+    } \
+    the_exception_context->penv = exception__prev; \
   } \
-  if (!the_exception_context->caught) { } \
+  if (!the_exception_context->caught || action) { } \
   else
 
+#define Catch(e) exception__catch(((e) = the_exception_context->v.etmp, 0))
+#define Catch_anonymous exception__catch(0)
+
 /* Try ends with if(), and Catch begins and ends with else.  This     */
 /* ensures that the Try/Catch syntax is really the same as the        */
 /* if/else syntax.                                                    */
 /*                                                                    */
-/* We use &exception__s instead of 1 to appease compilers that        */
+/* We use &exception__prev instead of 1 to appease compilers that     */
 /* warn about constant expressions inside if().  Most compilers       */
-/* should still recognize that &exception__s is never zero and avoid  */
-/* generating test code.                                              */
-/*                                                                    */
-/* We use the variable exception__i to start the loop at the bottom,  */
-/* rather than jump into the loop using a switch statement, to        */
-/* appease compilers that warn about jumping into loops.              */
+/* should still recognize that &exception__prev is never zero and     */
+/* avoid generating test code.                                        */
 
 #define Throw \
-  for (;; longjmp(the_exception_context->last->env, 1)) \
-    if (the_exception_context->last->exception) \
-      *the_exception_context->last->exception =
+  for (;; longjmp(*the_exception_context->penv, 1)) \
+    the_exception_context->v.etmp =
 
 
 #endif /* CEXCEPT_H */
diff --git a/example.c b/example.c
index 7956cf7..fb1f5ed 100644
--- a/example.c
+++ b/example.c
@@ -631,7 +631,7 @@
 
    /* set the palette if there is one.  REQUIRED for indexed-color images */
    palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
-             * sizeof (png_color));
+             * png_sizeof (png_color));
    /* ... set palette colors ... */
    png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
    /* You must not free palette here, because png_set_PLTE only makes a link to
@@ -741,6 +741,7 @@
    png_uint_32 k, height, width;
    png_byte image[height][width*bytes_per_pixel];
    png_bytep row_pointers[height];
+
    for (k = 0; k < height; k++)
      row_pointers[k] = image + k*width*bytes_per_pixel;
 
diff --git a/libpng.3 b/libpng.3
index 38fda99..a27be76 100644
--- a/libpng.3
+++ b/libpng.3
@@ -1,6 +1,6 @@
-.TH LIBPNG 3 "October 3, 2002"
+.TH LIBPNG 3 "August 15, 2004"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.0.15
+libpng \- Portable Network Graphics (PNG) Reference Library 1.0.16
 .SH SYNOPSIS
 \fI\fB
 
@@ -266,10 +266,18 @@
 
 \fI\fB
 
+\fBpng_uint_32 png_get_user_height_max( png_structp \fIpng_ptr\fP\fB);\fP
+
+\fI\fB
+
 \fBpng_voidp png_get_user_transform_ptr (png_structp \fIpng_ptr\fP\fB);\fP
 
 \fI\fB
 
+\fBpng_uint_32 png_get_user_width_max (png_structp \fIpng_ptr\fP\fB);\fP
+
+\fI\fB
+
 \fBpng_uint_32 png_get_valid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIflag\fP\fB);\fP
 
 \fI\fB
@@ -650,6 +658,10 @@
 
 \fI\fB
 
+\fBvoid png_set_user_limits (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIuser_width_max\fP\fB, png_uint_32 \fIuser_height_max\fP\fB);\fP
+
+\fI\fB
+
 \fBvoid png_set_user_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIuser_transform_ptr\fP\fB, int \fP\fIuser_transform_depth\fP\fB, int \fIuser_transform_channels\fP\fB);\fP
 
 \fI\fB
@@ -761,10 +773,10 @@
 .SH LIBPNG.TXT
 libpng.txt - A description on how to use and modify libpng
 
- libpng version 1.0.15 - October 3, 2002
+ libpng version 1.0.16 - August 15, 2004
  Updated and distributed by Glenn Randers-Pehrson
- <randeg@alum.rpi.edu>
- Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ <glennrp@users.sourceforge.net>
+ Copyright (c) 1998-2004 Glenn Randers-Pehrson
  For conditions of distribution and use, see copyright
  notice in png.h.
 
@@ -1061,6 +1073,28 @@
 
     png_set_read_status_fn(png_ptr, read_row_callback);
 
+%-%.SS Width and height limits
+%-%
+%-%The PNG specification allows the width and height of an image to be as
+%-%large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns.
+%-%Since very few applications really need to process such large images,
+%-%we have imposed an arbitrary 1-million limit on rows and columns.
+%-%Larger images will be rejected immediately with a png_error() call. If
+%-%you wish to override this limit, you can use
+%-%
+%-%   png_set_user_limits(png_ptr, width_max, height_max);
+%-%
+%-%to set your own limits, or use width_max = height_max = 0x7fffffffL
+%-%to allow all valid dimensions (libpng may reject some very large images
+%-%anyway because of potential buffer overflow conditions).
+%-%
+%-%You should put this statement after you create the PNG structure and
+%-%before calling png_read_info(), png_read_png(), or png_process_data().
+%-%If you need to retrieve the limits that are being applied, use
+%-%
+%-%   width_max = png_get_user_width_max(png_ptr);
+%-%   height_max = png_get_user_height_max(png_ptr);
+%-%
 .SS Unknown-chunk handling
 
 Now you get to set the way the library processes unknown chunks in the
@@ -1069,23 +1103,31 @@
 various info_ptr members; unknown chunks will be discarded. To change
 this, you can call:
 
-    png_set_keep_unknown_chunks(png_ptr, info_ptr, keep,
+    png_set_keep_unknown_chunks(png_ptr, keep,
         chunk_list, num_chunks);
-    keep       - 0: do not keep
-                 1: keep only if safe-to-copy
-                 2: keep even if unsafe-to-copy
+    keep       - 0: do not handle as unknown
+                 1: do not keep
+                 2: keep only if safe-to-copy
+                 3: keep even if unsafe-to-copy
+               You can use these definitions:
+                 PNG_HANDLE_CHUNK_AS_DEFAULT   0
+                 PNG_HANDLE_CHUNK_NEVER        1
+                 PNG_HANDLE_CHUNK_IF_SAFE      2
+                 PNG_HANDLE_CHUNK_ALWAYS       3
     chunk_list - list of chunks affected (a byte string,
                  five bytes per chunk, NULL or '\0' if
                  num_chunks is 0)
     num_chunks - number of chunks affected; if 0, all
-                 unknown chunks are affected
+                 unknown chunks are affected.  If nonzero,
+                 only the chunks in the list are affected
 
 Unknown chunks declared in this way will be saved as raw data onto a
 list of png_unknown_chunk structures.  If a chunk that is normally
 known to libpng is named in the list, it will be handled as unknown,
 according to the "keep" directive.  If a chunk is named in successive
 instances of png_set_keep_unknown_chunks(), the final instance will
-take precedence.
+take precedence.  The IHDR and IEND chunks should not be named in
+chunk_list; if they are, libpng will process them normally anyway.
 
 .SS The high-level read interface
 
@@ -1140,8 +1182,14 @@
 If you know your image size and pixel size ahead of time, you can allocate
 row_pointers prior to calling png_read_png() with
 
+   if (height > PNG_UINT_32_MAX/png_sizeof(png_byte))
+      png_error (png_ptr,
+         "Image is too tall to process in memory");
+   if (width > PNG_UINT_32_MAX/pixel_size)
+      png_error (png_ptr,
+         "Image is too wide to process in memory");
    row_pointers = png_malloc(png_ptr,
-      height*sizeof(png_bytep));
+      height*png_sizeof(png_bytep));
    for (int i=0; i<height, i++)
       row_pointers[i]=png_malloc(png_ptr,
          width*pixel_size);
@@ -3081,9 +3129,9 @@
        png_size_t size);
     void free_fn(png_structp png_ptr, png_voidp ptr);
 
-Your malloc_fn() should return NULL in case of failure.  The png_malloc()
-function will call png_error() if it receives a NULL from the system
-memory allocator or from your replacement malloc_fn().
+Your malloc_fn() must return NULL in case of failure.  The png_malloc()
+function will normally call png_error() if it receives a NULL from the
+system memory allocator or from your replacement malloc_fn().
 
 Input/Output in libpng is done through png_read() and png_write(),
 which currently just call fread() and fwrite().  The FILE * is stored in
@@ -3414,6 +3462,125 @@
 having level = 0 will be printed.  There aren't any such statements in
 this version of libpng, but if you insert some they will be printed.
 
+%-%.SH VI.  Runtime optimization
+%-%
+%-%A new feature in libpng 1.2.0 is the ability to dynamically switch between
+%-%standard and optimized versions of some routines.  Currently these are
+%-%limited to three computationally intensive tasks when reading PNG files:
+%-%decoding row filters, expanding interlacing, and combining interlaced or
+%-%transparent row data with previous row data.  Currently the optimized
+%-%versions are available only for x86 (Intel, AMD, etc.) platforms with
+%-%MMX support, though this may change in future versions.  (For example,
+%-%the non-MMX assembler optimizations for zlib might become similarly
+%-%runtime-selectable in future releases, in which case libpng could be
+%-%extended to support them.  Alternatively, the compile-time choice of
+%-%floating-point versus integer routines for gamma correction might become
+%-%runtime-selectable.)
+%-%
+%-%Because such optimizations tend to be very platform- and compiler-dependent,
+%-%both in how they are written and in how they perform, the new runtime code
+%-%in libpng has been written to allow programs to query, enable, and disable
+%-%either specific optimizations or all such optimizations.  For example, to
+%-%enable all possible optimizations (bearing in mind that some "optimizations"
+%-%may actually run more slowly in rare cases):
+%-%
+%-%    #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
+%-%       png_uint_32 mask, flags;
+%-%
+%-%       flags = png_get_asm_flags(png_ptr);
+%-%       mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE);
+%-%       png_set_asm_flags(png_ptr, flags | mask);
+%-%    #endif
+%-%
+%-%To enable only optimizations relevant to reading PNGs, use PNG_SELECT_READ
+%-%by itself when calling png_get_asm_flagmask(); similarly for optimizing
+%-%only writing.  To disable all optimizations:
+%-%
+%-%    #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
+%-%       flags = png_get_asm_flags(png_ptr);
+%-%       mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE);
+%-%       png_set_asm_flags(png_ptr, flags & ~mask);
+%-%    #endif
+%-%
+%-%To enable or disable only MMX-related features, use png_get_mmx_flagmask()
+%-%in place of png_get_asm_flagmask().  The mmx version takes one additional
+%-%parameter:
+%-%
+%-%    #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
+%-%       int selection = PNG_SELECT_READ | PNG_SELECT_WRITE;
+%-%       int compilerID;
+%-%
+%-%       mask = png_get_mmx_flagmask(selection, &compilerID);
+%-%    #endif
+%-%
+%-%On return, compilerID will indicate which version of the MMX assembler
+%-%optimizations was compiled.  Currently two flavors exist:  Microsoft
+%-%Visual C++ (compilerID == 1) and GNU C (a.k.a. gcc/gas, compilerID == 2).
+%-%On non-x86 platforms or on systems compiled without MMX optimizations, a
+%-%value of -1 is used.
+%-%
+%-%Note that both png_get_asm_flagmask() and png_get_mmx_flagmask() return
+%-%all valid, settable optimization bits for the version of the library that's
+%-%currently in use.  In the case of shared (dynamically linked) libraries,
+%-%this may include optimizations that did not exist at the time the code was
+%-%written and compiled.  It is also possible, of course, to enable only known,
+%-%specific optimizations; for example:
+%-%
+%-%    #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
+%-%       flags = PNG_ASM_FLAG_MMX_READ_COMBINE_ROW  \
+%-%             | PNG_ASM_FLAG_MMX_READ_INTERLACE    \
+%-%             | PNG_ASM_FLAG_MMX_READ_FILTER_SUB   \
+%-%             | PNG_ASM_FLAG_MMX_READ_FILTER_UP    \
+%-%             | PNG_ASM_FLAG_MMX_READ_FILTER_AVG   \
+%-%             | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
+%-%       png_set_asm_flags(png_ptr, flags);
+%-%    #endif
+%-%
+%-%This method would enable only the MMX read-optimizations available at the
+%-%time of libpng 1.2.0's release, regardless of whether a later version of
+%-%the DLL were actually being used.  (Also note that these functions did not
+%-%exist in versions older than 1.2.0, so any attempt to run a dynamically
+%-%linked app on such an older version would fail.)
+%-%
+%-%To determine whether the processor supports MMX instructions at all, use
+%-%the png_mmx_support() function:
+%-%
+%-%    #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
+%-%       mmxsupport = png_mmx_support();
+%-%    #endif
+%-%
+%-%It returns -1 if MMX support is not compiled into libpng, 0 if MMX code
+%-%is compiled but MMX is not supported by the processor, or 1 if MMX support
+%-%is fully available.  Note that png_mmx_support(), png_get_mmx_flagmask(),
+%-%and png_get_asm_flagmask() all may be called without allocating and ini-
+%-%tializing any PNG structures (for example, as part of a usage screen or
+%-%"about" box).
+%-%
+%-%The following code can be used to prevent an application from using the
+%-%thread_unsafe features, even if libpng was built with PNG_THREAD_UNSAFE_OK
+%-%defined:
+%-%
+%-%#if defined(PNG_USE_PNGGCCRD) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) \
+%-%  && defined(PNG_THREAD_UNSAFE_OK)
+%-%    /* Disable thread-unsafe features of pnggccrd */
+%-%    if (png_access_version() >= 10200)
+%-%    {
+%-%      png_uint_32 mmx_disable_mask = 0;
+%-%      png_uint_32 asm_flags;
+%-%
+%-%      mmx_disable_mask |= ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW  \
+%-%                          | PNG_ASM_FLAG_MMX_READ_FILTER_SUB   \
+%-%                          | PNG_ASM_FLAG_MMX_READ_FILTER_AVG   \
+%-%                          | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH );
+%-%      asm_flags = png_get_asm_flags(png_ptr);
+%-%      png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask);
+%-%    }
+%-%#endif
+%-%
+%-%For more extensive examples of runtime querying, enabling and disabling
+%-%of optimized features, see contrib/gregbook/readpng2.c in the libpng
+%-%source-code distribution.
+%-%
 .SH VI.  MNG support
 
 The MNG specification (available at http://www.libpng.org/pub/mng) allows
@@ -3427,7 +3594,7 @@
         PNG_FLAG_MNG_EMPTY_PLTE
         PNG_FLAG_MNG_FILTER_64
         PNG_ALL_MNG_FEATURES
-   feature_set is a png_byte that is the logical AND of
+   feature_set is a png_uint_32 that is the logical AND of
       your mask with the set of MNG features that is
       supported by the version of libpng that you are using.
 
@@ -3490,13 +3657,13 @@
 
 .SH VII. Y2K Compliance in libpng
 
-October 3, 2002
+August 15, 2004
 
 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.15 are Y2K compliant.  It is my belief that earlier
+upward through 1.0.16 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 that
@@ -3632,10 +3799,13 @@
  1.0.14              10    10014  10.so.0.1.0.14
  1.2.4               13    10204  12.so.0.1.2.4
  1.2.5beta1-2        13    10205  12.so.0.1.2.5beta1-2
- 1.0.15rc1-3         10    10015  10.so.0.1.0.15rc1-3
- 1.2.5rc1-3          13    10205  12.so.0.1.2.5rc1-3
+ 1.0.15rc1           10    10015  10.so.0.1.0.15rc1
  1.0.15              10    10015  10.so.0.1.0.15
  1.2.5               13    10205  12.so.0.1.2.5
+ 1.2.6beta1-4        13    10206  12.so.0.1.2.6beta1-4
+ 1.2.6rc1-5          13    10206  12.so.0.1.2.6rc1-5
+ 1.0.16              10    10016  10.so.0.1.0.16
+ 1.2.6               13    10206  12.so.0.1.2.6
 
 Henceforth the source version will match the shared-library minor
 and patch numbers; the shared-library major version number will be
@@ -3685,7 +3855,7 @@
 
 .SH AUTHORS
 This man page: Glenn Randers-Pehrson
-<randeg@alum.rpi.edu>
+<glennrp@users.sourceforge.net>
 
 The contributing authors would like to thank all those who helped
 with testing, bug fixes, and patience.  This wouldn't have been
@@ -3693,9 +3863,9 @@
 
 Thanks to Frank J. T. Wojcik for helping with the documentation.
 
-Libpng version 1.0.15 - October 3, 2002:
+Libpng version 1.0.16 - August 15, 2004:
 Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
-Currently maintained by Glenn Randers-Pehrson (randeg@alum.rpi.edu).
+Currently maintained by Glenn Randers-Pehrson (glennrp@users.sourceforge.net).
 
 Supported by the PNG development group
 .br
@@ -3710,7 +3880,14 @@
 If you modify libpng you may insert additional notices immediately following
 this sentence.
 
-libpng versions 1.0.7, July 1, 2000, through 1.0.15, October 3, 2002, are
+libpng version 1.2.6, August 15, 2004, is
+Copyright (c) 2004 Glenn Randers-Pehrson, and is
+distributed according to the same disclaimer and license as libpng-1.2.5
+with the following individual added to the list of Contributing Authors
+
+   Cosmin Truta
+
+libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
 Copyright (c) 2000-2002 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
@@ -3801,8 +3978,8 @@
 certification mark of the Open Source Initiative.
 
 Glenn Randers-Pehrson
-randeg@alum.rpi.edu
-October 3, 2002
+glennrp@users.sourceforge.net
+August 15, 2004
 
 .\" end of man page
 
diff --git a/libpng.txt b/libpng.txt
index e264f68..d1d3742 100644
--- a/libpng.txt
+++ b/libpng.txt
@@ -1,9 +1,9 @@
 libpng.txt - A description on how to use and modify libpng
 
- libpng version 1.0.15 - October 3, 2002
+ libpng version 1.0.16 - August 15, 2004
  Updated and distributed by Glenn Randers-Pehrson
- <randeg@alum.rpi.edu>
- Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ <glennrp@users.sourceforge.net>
+ Copyright (c) 1998-2004 Glenn Randers-Pehrson
  For conditions of distribution and use, see copyright
  notice in png.h.
 
@@ -308,23 +308,31 @@
 various info_ptr members; unknown chunks will be discarded. To change
 this, you can call:
 
-    png_set_keep_unknown_chunks(png_ptr, info_ptr, keep,
+    png_set_keep_unknown_chunks(png_ptr, keep,
         chunk_list, num_chunks);
-    keep       - 0: do not keep
-                 1: keep only if safe-to-copy
-                 2: keep even if unsafe-to-copy
+    keep       - 0: do not handle as unknown
+                 1: do not keep
+                 2: keep only if safe-to-copy
+                 3: keep even if unsafe-to-copy
+               You can use these definitions:
+                 PNG_HANDLE_CHUNK_AS_DEFAULT   0
+                 PNG_HANDLE_CHUNK_NEVER        1
+                 PNG_HANDLE_CHUNK_IF_SAFE      2
+                 PNG_HANDLE_CHUNK_ALWAYS       3
     chunk_list - list of chunks affected (a byte string,
                  five bytes per chunk, NULL or '\0' if
                  num_chunks is 0)
     num_chunks - number of chunks affected; if 0, all
-                 unknown chunks are affected
+                 unknown chunks are affected.  If nonzero,
+                 only the chunks in the list are affected
 
 Unknown chunks declared in this way will be saved as raw data onto a
 list of png_unknown_chunk structures.  If a chunk that is normally
 known to libpng is named in the list, it will be handled as unknown,
 according to the "keep" directive.  If a chunk is named in successive
 instances of png_set_keep_unknown_chunks(), the final instance will
-take precedence.
+take precedence.  The IHDR and IEND chunks should not be named in
+chunk_list; if they are, libpng will process them normally anyway.
 
 The high-level read interface
 
@@ -379,8 +387,14 @@
 If you know your image size and pixel size ahead of time, you can allocate
 row_pointers prior to calling png_read_png() with
 
+   if (height > PNG_UINT_32_MAX/png_sizeof(png_byte))
+      png_error (png_ptr,
+         "Image is too tall to process in memory");
+   if (width > PNG_UINT_32_MAX/pixel_size)
+      png_error (png_ptr,
+         "Image is too wide to process in memory");
    row_pointers = png_malloc(png_ptr,
-      height*sizeof(png_bytep));
+      height*png_sizeof(png_bytep));
    for (int i=0; i<height, i++)
       row_pointers[i]=png_malloc(png_ptr,
          width*pixel_size);
@@ -2320,9 +2334,9 @@
        png_size_t size);
     void free_fn(png_structp png_ptr, png_voidp ptr);
 
-Your malloc_fn() should return NULL in case of failure.  The png_malloc()
-function will call png_error() if it receives a NULL from the system
-memory allocator or from your replacement malloc_fn().
+Your malloc_fn() must return NULL in case of failure.  The png_malloc()
+function will normally call png_error() if it receives a NULL from the
+system memory allocator or from your replacement malloc_fn().
 
 Input/Output in libpng is done through png_read() and png_write(),
 which currently just call fread() and fwrite().  The FILE * is stored in
@@ -2666,7 +2680,7 @@
         PNG_FLAG_MNG_EMPTY_PLTE
         PNG_FLAG_MNG_FILTER_64
         PNG_ALL_MNG_FEATURES
-   feature_set is a png_byte that is the logical AND of
+   feature_set is a png_uint_32 that is the logical AND of
       your mask with the set of MNG features that is
       supported by the version of libpng that you are using.
 
@@ -2729,13 +2743,13 @@
 
 VII. Y2K Compliance in libpng
 
-October 3, 2002
+August 15, 2004
 
 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.15 are Y2K compliant.  It is my belief that earlier
+upward through 1.0.16 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 that
diff --git a/libpngpf.3 b/libpngpf.3
index eed12e7..6ca45c5 100644
--- a/libpngpf.3
+++ b/libpngpf.3
@@ -1,529 +1,1085 @@
-.TH LIBPNGPF 3 "October 3, 2002"
+.TH LIBPNGPF 3 "August 15, 2004"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.0.15
+libpng \- Portable Network Graphics (PNG) Reference Library 1.0.16
 (private functions)
 .SH SYNOPSIS
-\fB#include <png.h>\fP
+\fB\fB#include <png.h>\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_build_gamma_table (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_build_grayscale_palette (int \fP\fI\fP\fIbit_depth\fP\fB\fP\fB, png_colorp \fI\fIpalette\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_calculate_crc (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIptr\fP\fB\fP\fB, png_size_t \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_check_chunk_name (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_bytep \fI\fIchunk_name\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBpng_size_t png_check_keyword (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_charp \fP\fI\fP\fIkey\fP\fB\fP\fB, png_charpp \fI\fInew_key\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_combine_row (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIrow\fP\fB\fP\fB, int \fI\fImask\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_correct_palette (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_colorp \fP\fI\fP\fIpalette\fP\fB\fP\fB, int \fI\fInum_palette\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBint png_crc_error (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBint png_crc_finish (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIskip\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_crc_read (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIbuf\fP\fB\fP\fB, png_size_t \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBpng_voidp png_create_struct (int \fI\fItype\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBpng_voidp png_create_struct_2 (int \fP\fI\fP\fItype\fP\fB\fP\fB, png_malloc_ptr \fP\fI\fP\fImalloc_fn\fP\fB\fP\fB, png_voidp \fI\fImem_ptr\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBpng_charp png_decompress_chunk (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, int \fP\fI\fP\fIcomp_type\fP\fB\fP\fB, png_charp \fP\fI\fP\fIchunkdata\fP\fB\fP\fB, png_size_t \fP\fI\fP\fIchunklength\fP\fB\fP\fB, png_size_t \fP\fI\fP\fIprefix_length\fP\fB\fP\fB, png_size_t \fI\fI*data_length\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_destroy_struct (png_voidp \fI\fIstruct_ptr\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_destroy_struct_2 (png_voidp \fP\fI\fP\fIstruct_ptr\fP\fB\fP\fB, png_free_ptr \fP\fI\fP\fIfree_fn\fP\fB\fP\fB, png_voidp \fI\fImem_ptr\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_background (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIrow\fP\fB\fP\fB, png_color_16p \fP\fI\fP\fItrans_values\fP\fB\fP\fB, png_color_16p \fP\fI\fP\fIbackground\fP\fB\fP\fB, png_color_16p \fP\fI\fP\fIbackground_1\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIgamma_table\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIgamma_from_1\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIgamma_to_1\fP\fB\fP\fB, png_uint_16pp \fP\fI\fP\fIgamma_16\fP\fB\fP\fB, png_uint_16pp \fP\fI\fP\fIgamma_16_from_1\fP\fB\fP\fB, png_uint_16pp \fP\fI\fP\fIgamma_16_to_1\fP\fB\fP\fB, int \fI\fIgamma_shift\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_bgr (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fI\fIrow\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_chop (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fI\fIrow\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_dither (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIrow\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIpalette_lookup\fP\fB\fP\fB, png_bytep \fI\fIdither_lookup\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_expand (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIrow\fP\fB\fP\fB, png_color_16p \fI\fItrans_value\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_expand_palette (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIrow\fP\fB\fP\fB, png_colorp \fP\fI\fP\fIpalette\fP\fB\fP\fB, png_bytep \fP\fI\fP\fItrans\fP\fB\fP\fB, int \fI\fInum_trans\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_gamma (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIrow\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIgamma_table\fP\fB\fP\fB, png_uint_16pp \fP\fI\fP\fIgamma_16_table\fP\fB\fP\fB, int \fI\fIgamma_shift\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_gray_to_rgb (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fI\fIrow\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_invert (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fI\fIrow\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_pack (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIrow\fP\fB\fP\fB, png_uint_32 \fI\fIbit_depth\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_packswap (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fI\fIrow\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_read_filler (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIrow\fP\fB\fP\fB, png_uint_32 \fP\fI\fP\fIfiller\fP\fB\fP\fB, png_uint_32 \fI\fIflags\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_read_interlace (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIrow\fP\fB\fP\fB, int \fP\fI\fP\fIpass\fP\fB\fP\fB, png_uint_32 \fI\fItransformations\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_read_invert_alpha (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fI\fIrow\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_read_swap_alpha (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fI\fIrow\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_read_transformations (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBint png_do_rgb_to_gray (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fI\fIrow\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_shift (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIrow\fP\fB\fP\fB, png_color_8p \fI\fIbit_depth\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_strip_filler (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIrow\fP\fB\fP\fB, png_uint_32 \fI\fIflags\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_swap (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fI\fIrow\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_unpack (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fI\fIrow\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_unshift (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIrow\fP\fB\fP\fB, png_color_8p \fI\fIsig_bits\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_write_interlace (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIrow\fP\fB\fP\fB, int \fI\fIpass\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_write_invert_alpha (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fI\fIrow\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_write_swap_alpha (png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fI\fIrow\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_do_write_transformations (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid *png_far_to_near (png_structp png_ptr,png_voidp \fP\fI\fP\fIptr\fP\fB\fP\fB, int \fI\fIcheck\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_flush (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBpng_int_32 png_get_int_32 (png_bytep \fI\fIbuf\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBpng_uint_16 png_get_uint_16 (png_bytep \fI\fIbuf\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBpng_uint_32 png_get_uint_31 (png_bytep \fI\fIbuf\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBpng_uint_32 png_get_uint_32 (png_bytep \fI\fIbuf\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_bKGD (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_cHRM (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_gAMA (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_hIST (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_IEND (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_IHDR (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_iCCP (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_iTXt (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_oFFs (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_pCAL (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_pHYs (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_PLTE (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_sBIT (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_sCAL (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_sPLT (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_sRGB (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_tEXt (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_tIME (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_tRNS (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_unknown (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_handle_zTXt (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
+
+\fI\fB
+
+\fB\fBvoid png_info_destroy (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fI\fIinfo_ptr\fP\fB\fP\fB);\fP\fP
+
+\fI\fB
+
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_build_gamma_table (png_structp \fIpng_ptr\fP\fB);\fP
+\fB\fBvoid png_init_mmx_flags (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_build_grayscale_palette (int \fP\fIbit_depth\fP\fB, png_colorp \fIpalette\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_calculate_crc (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIptr\fP\fB, png_size_t \fIlength\fP\fB);\fP
+\fB\fBvoid png_init_read_transformations (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_check_chunk_name (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBpng_size_t png_check_keyword (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charpp \fInew_key\fP\fB);\fP
+\fB\fBvoid png_process_IDAT_data (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIbuffer\fP\fB\fP\fB, png_size_t \fI\fIbuffer_length\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_combine_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fImask\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_correct_palette (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fInum_palette\fP\fB);\fP
+\fB\fBvoid png_process_some_data (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fI\fIinfo_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBint png_crc_error (png_structp \fIpng_ptr\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBint png_crc_finish (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIskip\fP\fB);\fP
+\fB\fBvoid png_push_check_crc (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_crc_read (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuf\fP\fB, png_size_t \fIlength\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBpng_voidp png_create_struct (int \fItype\fP\fB);\fP
+\fB\fBvoid png_push_crc_finish (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBpng_voidp png_create_struct_2 (int \fP\fItype\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_voidp \fImem_ptr\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBpng_charp png_decompress_chunk (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcomp_type\fP\fB, png_charp \fP\fIchunkdata\fP\fB, png_size_t \fP\fIchunklength\fP\fB, png_size_t \fP\fIprefix_length\fP\fB, png_size_t \fI*data_length\fP\fB);\fP
+\fB\fBvoid png_push_crc_skip (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_destroy_struct (png_voidp \fIstruct_ptr\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_destroy_struct_2 (png_voidp \fP\fIstruct_ptr\fP\fB, png_free_ptr \fP\fIfree_fn\fP\fB, png_voidp \fImem_ptr\fP\fB);\fP
+\fB\fBvoid png_push_fill_buffer (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIbuffer\fP\fB\fP\fB, png_size_t \fI\fIlength\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_do_background (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_16p \fP\fItrans_values\fP\fB, png_color_16p \fP\fIbackground\fP\fB, png_color_16p \fP\fIbackground_1\fP\fB, png_bytep \fP\fIgamma_table\fP\fB, png_bytep \fP\fIgamma_from_1\fP\fB, png_bytep \fP\fIgamma_to_1\fP\fB, png_uint_16pp \fP\fIgamma_16\fP\fB, png_uint_16pp \fP\fIgamma_16_from_1\fP\fB, png_uint_16pp \fP\fIgamma_16_to_1\fP\fB, int \fIgamma_shift\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_do_bgr (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
+\fB\fBvoid png_push_handle_tEXt (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_do_chop (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_do_dither (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIpalette_lookup\fP\fB, png_bytep \fIdither_lookup\fP\fB);\fP
+\fB\fBvoid png_push_handle_unknown (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_do_expand (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_16p \fItrans_value\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_do_expand_palette (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_colorp \fP\fIpalette\fP\fB, png_bytep \fP\fItrans\fP\fB, int \fInum_trans\fP\fB);\fP
+\fB\fBvoid png_push_handle_zTXt (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIlength\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_do_gamma (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIgamma_table\fP\fB, png_uint_16pp \fP\fIgamma_16_table\fP\fB, int \fIgamma_shift\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_do_gray_to_rgb (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
+\fB\fBvoid png_push_have_end (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fI\fIinfo_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_do_invert (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_do_pack (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fIbit_depth\fP\fB);\fP
+\fB\fBvoid png_push_have_info (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fI\fIinfo_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_do_packswap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_do_read_filler (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, png_uint_32 \fIflags\fP\fB);\fP
+\fB\fBvoid png_push_have_row (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_bytep \fI\fIrow\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_do_read_interlace (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fP\fIpass\fP\fB, png_uint_32 \fItransformations\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_do_read_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
+\fB\fBvoid png_push_process_row (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_do_read_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_do_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP
+\fB\fBvoid png_push_read_chunk (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fI\fIinfo_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBint png_do_rgb_to_gray (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_do_shift (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_8p \fIbit_depth\fP\fB);\fP
+\fB\fBvoid png_push_read_end (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fI\fIinfo_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_do_strip_filler (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fIflags\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_do_swap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
+\fB\fBvoid png_push_read_IDAT (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_do_unpack (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_do_unshift (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_8p \fIsig_bits\fP\fB);\fP
+\fB\fBvoid png_push_read_sig (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fI\fIinfo_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_do_write_interlace (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fIpass\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_do_write_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
+\fB\fBvoid png_push_read_tEXt (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fI\fIinfo_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_do_write_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_do_write_transformations (png_structp \fIpng_ptr\fP\fB);\fP
+\fB\fBvoid png_push_read_zTXt (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fI\fIinfo_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid *png_far_to_near (png_structp png_ptr,png_voidp \fP\fIptr\fP\fB, int \fIcheck\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_flush (png_structp \fIpng_ptr\fP\fB);\fP
+\fB\fBvoid png_push_restore_buffer (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIbuffer\fP\fB\fP\fB, png_size_t \fI\fIbuffer_length\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBpng_int_32 png_get_int_32 (png_bytep \fIbuf\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBpng_uint_16 png_get_uint_16 (png_bytep \fIbuf\fP\fB);\fP
+\fB\fBvoid png_push_save_buffer (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBpng_uint_32 png_get_uint_32 (png_bytep \fIbuf\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_handle_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fB\fBvoid png_read_data (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIdata\fP\fB\fP\fB, png_size_t \fI\fIlength\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_handle_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_handle_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fB\fBvoid png_read_filter_row (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_row_infop \fP\fI\fP\fIrow_info\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIrow\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIprev_row\fP\fB\fP\fB, int \fI\fIfilter\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_handle_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_handle_IEND (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fB\fBvoid png_read_finish_row (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_handle_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_handle_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fB\fBvoid png_read_push_finish_row (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_handle_iTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_handle_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fB\fBvoid png_read_start_row (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_handle_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_handle_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fB\fBvoid png_read_transform_info (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fI\fIinfo_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_handle_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_handle_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fB\fBvoid png_reset_crc (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_handle_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_handle_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fB\fBvoid png_save_int_32 (png_bytep \fP\fI\fP\fIbuf\fP\fB\fP\fB, png_int_32 \fI\fIi\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_handle_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_handle_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fB\fBvoid png_save_uint_16 (png_bytep \fP\fI\fP\fIbuf\fP\fB\fP\fB, unsigned int \fI\fIi\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_handle_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_handle_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fB\fBvoid png_save_uint_32 (png_bytep \fP\fI\fP\fIbuf\fP\fB\fP\fB, png_uint_32 \fI\fIi\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_handle_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_handle_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fB\fBint png_set_text_2 (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_infop \fP\fI\fP\fIinfo_ptr\fP\fB\fP\fB, png_textp \fP\fI\fP\fItext_ptr\fP\fB\fP\fB, int \fI\fInum_text)\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_info_destroy (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_init_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP
+\fB\fBvoid png_write_cHRM (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, double \fP\fI\fP\fIwhite_x\fP\fB\fP\fB, double \fP\fI\fP\fIwhite_y\fP\fB\fP\fB, double \fP\fI\fP\fIred_x\fP\fB\fP\fB, double \fP\fI\fP\fIred_y\fP\fB\fP\fB, double \fP\fI\fP\fIgreen_x\fP\fB\fP\fB, double \fP\fI\fP\fIgreen_y\fP\fB\fP\fB, double \fP\fI\fP\fIblue_x\fP\fB\fP\fB, double \fI\fIblue_y\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_process_IDAT_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_length\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_process_some_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
+\fB\fBvoid png_write_cHRM_fixed (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_uint_32 \fP\fI\fP\fIwhite_x\fP\fB\fP\fB, png_uint_32 \fP\fI\fP\fIwhite_y\fP\fB\fP\fB, png_uint_32 \fP\fI\fP\fIred_x\fP\fB\fP\fB, png_uint_32 \fP\fI\fP\fIred_y\fP\fB\fP\fB, png_uint_32 \fP\fI\fP\fIgreen_x\fP\fB\fP\fB, png_uint_32 \fP\fI\fP\fIgreen_y\fP\fB\fP\fB, png_uint_32 \fP\fI\fP\fIblue_x\fP\fB\fP\fB, png_uint_32 \fI\fIblue_y\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_push_check_crc (png_structp \fIpng_ptr\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_push_crc_finish (png_structp \fIpng_ptr\fP\fB);\fP
+\fB\fBvoid png_write_data (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIdata\fP\fB\fP\fB, png_size_t \fI\fIlength\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_push_crc_skip (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_push_fill_buffer (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIlength\fP\fB);\fP
+\fB\fBvoid png_write_filtered_row (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_bytep \fI\fIfiltered_row\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_push_handle_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_push_handle_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fB\fBvoid png_write_find_filter (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_row_infop \fI\fIrow_info\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_push_handle_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_push_have_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
+\fB\fBvoid png_write_finish_row (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_push_have_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_push_have_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP
+\fB\fBvoid png_write_gAMA (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, double \fI\fIfile_gamma\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_push_process_row (png_structp \fIpng_ptr\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_push_read_chunk (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
+\fB\fBvoid png_write_gAMA_fixed (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_uint_32 \fI\fIint_file_gamma\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_push_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_push_read_IDAT (png_structp \fIpng_ptr\fP\fB);\fP
+\fB\fBvoid png_write_hIST (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_uint_16p \fP\fI\fP\fIhist\fP\fB\fP\fB, int \fI\fInum_hist\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_push_read_sig (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_push_read_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
+\fB\fBvoid png_write_iCCP (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_charp \fP\fI\fP\fIname\fP\fB\fP\fB, int \fP\fI\fP\fIcompression_type\fP\fB\fP\fB, png_charp \fP\fI\fP\fIprofile\fP\fB\fP\fB, int \fI\fIproflen\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_push_read_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_push_restore_buffer (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_length\fP\fB);\fP
+\fB\fBvoid png_write_IDAT (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_bytep \fP\fI\fP\fIdata\fP\fB\fP\fB, png_size_t \fI\fIlength\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_push_save_buffer (png_structp \fIpng_ptr\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_read_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP
+\fB\fBvoid png_write_IEND (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_read_filter_row (png_structp \fP\fIpng_ptr\fP\fB, png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIprev_row\fP\fB, int \fIfilter\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_read_finish_row (png_structp \fIpng_ptr\fP\fB);\fP
+\fB\fBvoid png_write_IHDR (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_uint_32 \fP\fI\fP\fIwidth\fP\fB\fP\fB, png_uint_32 \fP\fI\fP\fIheight\fP\fB\fP\fB, int \fP\fI\fP\fIbit_depth\fP\fB\fP\fB, int \fP\fI\fP\fIcolor_type\fP\fB\fP\fB, int \fP\fI\fP\fIcompression_type\fP\fB\fP\fB, int \fP\fI\fP\fIfilter_type\fP\fB\fP\fB, int \fI\fIinterlace_type\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_read_push_finish_row (png_structp \fIpng_ptr\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_read_start_row (png_structp \fIpng_ptr\fP\fB);\fP
+\fB\fBvoid png_write_iTXt (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, int \fP\fI\fP\fIcompression\fP\fB\fP\fB, png_charp \fP\fI\fP\fIkey\fP\fB\fP\fB, png_charp \fP\fI\fP\fIlang\fP\fB\fP\fB, png_charp \fP\fI\fP\fItranslated_key\fP\fB\fP\fB, png_charp \fI\fItext)\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_read_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_reset_crc (png_structp \fIpng_ptr\fP\fB);\fP
+\fB\fBvoid png_write_oFFs (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_uint_32 \fP\fI\fP\fIx_offset\fP\fB\fP\fB, png_uint_32 \fP\fI\fP\fIy_offset\fP\fB\fP\fB, int \fI\fIunit_type\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_save_int_32 (png_bytep \fP\fIbuf\fP\fB, png_int_32 \fIi\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_save_uint_16 (png_bytep \fP\fIbuf\fP\fB, unsigned int \fIi\fP\fB);\fP
+\fB\fBvoid png_write_pCAL (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_charp \fP\fI\fP\fIpurpose\fP\fB\fP\fB, png_int_32 \fP\fI\fP\fIX0\fP\fB\fP\fB, png_int_32 \fP\fI\fP\fIX1\fP\fB\fP\fB, int \fP\fI\fP\fItype\fP\fB\fP\fB, int \fP\fI\fP\fInparams\fP\fB\fP\fB, png_charp \fP\fI\fP\fIunits\fP\fB\fP\fB, png_charpp \fI\fIparams\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_save_uint_32 (png_bytep \fP\fIbuf\fP\fB, png_uint_32 \fIi\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_write_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_color_16p \fP\fIvalues\fP\fB, int \fIcolor_type\fP\fB);\fP
+\fB\fBvoid png_write_pHYs (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_uint_32 \fP\fI\fP\fIx_pixels_per_unit\fP\fB\fP\fB, png_uint_32 \fP\fI\fP\fIy_pixels_per_unit\fP\fB\fP\fB, int \fI\fIunit_type\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_write_cHRM (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_write_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIwhite_x\fP\fB, png_uint_32 \fP\fIwhite_y\fP\fB, png_uint_32 \fP\fIred_x\fP\fB, png_uint_32 \fP\fIred_y\fP\fB, png_uint_32 \fP\fIgreen_x\fP\fB, png_uint_32 \fP\fIgreen_y\fP\fB, png_uint_32 \fP\fIblue_x\fP\fB, png_uint_32 \fIblue_y\fP\fB);\fP
+\fB\fBvoid png_write_PLTE (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_colorp \fP\fI\fP\fIpalette\fP\fB\fP\fB, png_uint_32 \fI\fInum_pal\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_write_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_write_filtered_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIfiltered_row\fP\fB);\fP
+\fB\fBvoid png_write_sBIT (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_color_8p \fP\fI\fP\fIsbit\fP\fB\fP\fB, int \fI\fIcolor_type\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_write_find_filter (png_structp \fP\fIpng_ptr\fP\fB, png_row_infop \fIrow_info\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_write_finish_row (png_structp \fIpng_ptr\fP\fB);\fP
+\fB\fBvoid png_write_sCAL (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_charp \fP\fI\fP\fIunit\fP\fB\fP\fB, double \fP\fI\fP\fIwidth\fP\fB\fP\fB, double \fI\fIheight\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_write_gAMA (png_structp \fP\fIpng_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_write_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIint_file_gamma\fP\fB);\fP
+\fB\fBvoid png_write_sCAL_s (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_charp \fP\fI\fP\fIunit\fP\fB\fP\fB, png_charp \fP\fI\fP\fIwidth\fP\fB\fP\fB, png_charp \fI\fIheight\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_write_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_uint_16p \fP\fIhist\fP\fB, int \fInum_hist\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_write_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_charp \fP\fIprofile\fP\fB, int \fIproflen\fP\fB);\fP
+\fB\fBvoid png_write_sig (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_write_IDAT (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_write_IEND (png_structp \fIpng_ptr\fP\fB);\fP
+\fB\fBvoid png_write_sRGB (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, int \fI\fIintent\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_write_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIwidth\fP\fB, png_uint_32 \fP\fIheight\fP\fB, int \fP\fIbit_depth\fP\fB, int \fP\fIcolor_type\fP\fB, int \fP\fIcompression_type\fP\fB, int \fP\fIfilter_type\fP\fB, int \fIinterlace_type\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_write_iTXt (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcompression\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fIlang\fP\fB, png_charp \fP\fItranslated_key\fP\fB, png_charp \fItext)\fP\fB);\fP
+\fB\fBvoid png_write_sPLT (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_spalette_p \fI\fIpalette\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_write_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIx_offset\fP\fB, png_uint_32 \fP\fIy_offset\fP\fB, int \fIunit_type\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_write_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIpurpose\fP\fB, png_int_32 \fP\fIX0\fP\fB, png_int_32 \fP\fIX1\fP\fB, int \fP\fItype\fP\fB, int \fP\fInparams\fP\fB, png_charp \fP\fIunits\fP\fB, png_charpp \fIparams\fP\fB);\fP
+\fB\fBvoid png_write_start_row (png_structp \fI\fIpng_ptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_write_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIx_pixels_per_unit\fP\fB, png_uint_32 \fP\fIy_pixels_per_unit\fP\fB, int \fIunit_type\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_write_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, png_uint_32 \fInum_pal\fP\fB);\fP
+\fB\fBvoid png_write_tEXt (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_charp \fP\fI\fP\fIkey\fP\fB\fP\fB, png_charp \fP\fI\fP\fItext\fP\fB\fP\fB, png_size_t \fI\fItext_len\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_write_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fP\fIsbit\fP\fB, int \fIcolor_type\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_write_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP
+\fB\fBvoid png_write_tIME (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_timep \fI\fImod_time\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_write_sCAL_s (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, png_charp \fP\fIwidth\fP\fB, png_charp \fIheight\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_write_sig (png_structp \fIpng_ptr\fP\fB);\fP
+\fB\fBvoid png_write_tRNS (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_bytep \fP\fI\fP\fItrans\fP\fB\fP\fB, png_color_16p \fP\fI\fP\fIvalues\fP\fB\fP\fB, int \fP\fI\fP\fInumber\fP\fB\fP\fB, int \fI\fIcolor_type\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_write_sRGB (png_structp \fP\fIpng_ptr\fP\fB, int \fIintent\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_write_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_spalette_p \fIpalette\fP\fB);\fP
+\fB\fBvoid png_write_zTXt (png_structp \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, png_charp \fP\fI\fP\fIkey\fP\fB\fP\fB, png_charp \fP\fI\fP\fItext\fP\fB\fP\fB, png_size_t \fP\fI\fP\fItext_len\fP\fB\fP\fB, int \fI\fIcompression\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_write_start_row (png_structp \fIpng_ptr\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_write_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fItext\fP\fB, png_size_t \fItext_len\fP\fB);\fP
+\fB\fBvoidpf png_zalloc (voidpf \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, uInt \fP\fI\fP\fIitems\fP\fB\fP\fB, uInt \fI\fIsize\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_write_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fImod_time\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
-\fBvoid png_write_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fItrans\fP\fB, png_color_16p \fP\fIvalues\fP\fB, int \fP\fInumber\fP\fB, int \fIcolor_type\fP\fB);\fP
+\fB\fBvoid png_zfree (voidpf \fP\fI\fP\fIpng_ptr\fP\fB\fP\fB, voidpf \fI\fIptr\fP\fB\fP\fB);\fP\fP
 
 \fI\fB
 
-\fBvoid png_write_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fItext\fP\fB, png_size_t \fP\fItext_len\fP\fB, int \fIcompression\fP\fB);\fP
+\fI\fB\fI\fB
 
 \fI\fB
 
diff --git a/png.5 b/png.5
index d555d81..e9e9bc7 100644
--- a/png.5
+++ b/png.5
@@ -1,4 +1,4 @@
-.TH PNG 5 "October 3, 2002"
+.TH PNG 5 "August 15, 2004"
 .SH NAME
 png \- Portable Network Graphics (PNG) format
 .SH DESCRIPTION
@@ -53,7 +53,7 @@
 The PNG-1.2 specification is copyright (c) 1999 Glenn Randers-Pehrson.
 See the specification for conditions of use and distribution.
 .LP
-The PNG-1.0 specification is copyright (c) 1996 Massachussets Institute of
+The PNG-1.0 specification is copyright (c) 1996 Massachusetts Institute of
 Technology.  See the specification for conditions of use and distribution.
 .LP
 .\" end of man page
diff --git a/png.c b/png.c
index 93cfd32..1404181 100644
--- a/png.c
+++ b/png.c
@@ -1,11 +1,11 @@
 
 /* png.c - location for general purpose libpng functions
  *
- * libpng version 1.0.15 - October 3, 2002
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * libpng version 1.0.16 - August 15, 2004
+ * For conditions of distribution and use, see copyright notice in png.h
+ * Copyright (c) 1998-2004 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.)
- *
  */
 
 #define PNG_INTERNAL
@@ -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_0_15 Your_png_h_is_not_version_1_0_15;
+typedef version_1_0_16 Your_png_h_is_not_version_1_0_16;
 
 /* 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.0.15";
+const char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING;
 
 /* png_sig was changed to a function in version 1.0.5c */
 /* Place to hold the signature string for a PNG file. */
@@ -142,16 +142,23 @@
 #endif
 png_zalloc(voidpf png_ptr, uInt items, uInt size)
 {
-   png_uint_32 num_bytes = (png_uint_32)items * size;
    png_voidp ptr;
    png_structp p=png_ptr;
    png_uint_32 save_flags=p->flags;
+   png_uint_32 num_bytes;
+
+   if (items > PNG_UINT_32_MAX/size)
+   {
+     png_warning (png_ptr, "Potential overflow in png_zalloc()");
+     return (NULL);
+   }
+   num_bytes = (png_uint_32)items * size;
 
    p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
    ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);
    p->flags=save_flags;
 
-#ifndef PNG_NO_ZALLOC_ZERO
+#if defined(PNG_1_0_X) && !defined(PNG_NO_ZALLOC_ZERO)
    if (ptr == NULL)
        return ((voidpf)ptr);
 
@@ -217,7 +224,7 @@
 
 /* Allocate the memory for an info_struct for the application.  We don't
  * really need the png_ptr, but it could potentially be useful in the
- * future.  This should be used in favour of malloc(sizeof(png_info))
+ * future.  This should be used in favour of malloc(png_sizeof(png_info))
  * and png_info_init() so that applications that want to use a shared
  * libpng don't have to be recompiled if png_info changes size.
  */
@@ -235,7 +242,7 @@
    info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO);
 #endif
    if (info_ptr != NULL)
-      png_info_init_3(&info_ptr, sizeof(png_info));
+      png_info_init_3(&info_ptr, png_sizeof(png_info));
 
    return (info_ptr);
 }
@@ -287,7 +294,7 @@
 
    png_debug(1, "in png_info_init_3\n");
 
-   if(sizeof(png_info) > png_info_struct_size)
+   if(png_sizeof(png_info) > png_info_struct_size)
      {
        png_destroy_struct(info_ptr);
        info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO);
@@ -295,7 +302,7 @@
      }
 
    /* set everything to 0 */
-   png_memset(info_ptr, 0, sizeof (png_info));
+   png_memset(info_ptr, 0, png_sizeof (png_info));
 }
 
 #ifdef PNG_FREE_ME_SUPPORTED
@@ -581,7 +588,7 @@
    }
 #endif
 
-   png_info_init_3(&info_ptr, sizeof(png_info));
+   png_info_init_3(&info_ptr, png_sizeof(png_info));
 }
 
 /* This function returns a pointer to the io_ptr associated with the user
@@ -623,7 +630,7 @@
    if (png_ptr->time_buffer == NULL)
    {
       png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29*
-         sizeof(char)));
+         png_sizeof(char)));
    }
 
 #if defined(_WIN32_WCE)
@@ -645,7 +652,7 @@
           ptime->year, ptime->hour % 24, ptime->minute % 60,
           ptime->second % 61);
       png_memcpy(png_ptr->time_buffer, near_time_buf,
-          29*sizeof(char));
+          29*png_sizeof(char));
    }
 #else
    sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000",
@@ -670,45 +677,47 @@
 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.0.15 - October 3, 2002\n\
-   Copyright (c) 1998-2002 Glenn Randers-Pehrson\n\
+   if (&png_ptr != NULL)  /* silence compiler warning about unused png_ptr */
+   return ((png_charp) "\n libpng version 1.0.16 - August 15, 2004\n\
+   Copyright (c) 1998-2004 Glenn Randers-Pehrson\n\
    Copyright (c) 1996-1997 Andreas Dilger\n\
    Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
    return ((png_charp) "");
 }
 
 /* The following return the library version as a short string in the
- * format 1.0.0 through 99.99.99zz.  To get the version of *.h files used
- * with your application, print out PNG_LIBPNG_VER_STRING, which is defined
- * in png.h.
+ * format 1.0.0 through 99.99.99zz.  To get the version of *.h files
+ * used with your application, print out PNG_LIBPNG_VER_STRING, which
+ * is defined in png.h.
+ * Note: now there is no difference between png_get_libpng_ver() and
+ * png_get_header_ver().  Due to the version_nn_nn_nn typedef guard,
+ * it is guaranteed that png.c uses the correct version of png.h.
  */
-
 png_charp PNGAPI
 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.0.15");
-   return((png_charp) "1.0.15");
+   if (&png_ptr != NULL)  /* silence compiler warning about unused png_ptr */
+      return ((png_charp) PNG_LIBPNG_VER_STRING);
+   return ((png_charp) "");
 }
 
 png_charp PNGAPI
 png_get_header_ver(png_structp png_ptr)
 {
    /* Version of *.h files used when building libpng */
-   if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
-      return((png_charp) PNG_LIBPNG_VER_STRING);
-   return((png_charp) PNG_LIBPNG_VER_STRING);
+   if (&png_ptr != NULL)  /* silence compiler warning about unused png_ptr */
+      return ((png_charp) PNG_LIBPNG_VER_STRING);
+   return ((png_charp) "");
 }
 
 png_charp PNGAPI
 png_get_header_version(png_structp png_ptr)
 {
    /* Returns longer string containing both version and date */
-   if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
-      return((png_charp) PNG_HEADER_VERSION_STRING);
-   return((png_charp) PNG_HEADER_VERSION_STRING);
+   if (&png_ptr != NULL)  /* silence compiler warning about unused png_ptr */
+      return ((png_charp) PNG_HEADER_VERSION_STRING);
+   return ((png_charp) "");
 }
 
 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
@@ -740,7 +749,7 @@
 png_access_version_number(void)
 {
    /* Version of *.c files used when building libpng */
-   return((png_uint_32) 10015L);
+   return((png_uint_32) PNG_LIBPNG_VER);
 }
 
 
@@ -803,3 +812,15 @@
 }
 #endif
 #endif /* PNG_1_0_X */
+
+#ifdef PNG_SIZE_T
+/* Added at libpng version 1.2.6 */
+   PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size));
+png_size_t PNGAPI
+png_convert_size(size_t size)
+{
+  if (size > (png_size_t)-1)
+     PNG_ABORT();  /* We haven't got access to png_ptr, so no png_error() */
+  return ((png_size_t)size);
+}
+#endif /* PNG_SIZE_T */
diff --git a/png.h b/png.h
index e6aa0ab..648aa7e 100644
--- a/png.h
+++ b/png.h
@@ -1,14 +1,14 @@
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.0.15 - October 3, 2002
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * libpng version 1.0.16 - August 15, 2004
+ * Copyright (c) 1998-2004 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.)
  *
  * 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.0.15 - October 3, 2002: Glenn
+ *  libpng versions 0.97, January 1998, through 1.0.16 - August 15, 2004: Glenn
  *  See also "Contributing Authors", below.
  *
  * Note about libpng version numbers:
@@ -98,6 +98,9 @@
  *    1.2.5rc1-3              13    10205  12.so.0.1.2.5rc1-3
  *    1.0.15                  10    10015  10.so.0.1.0.15
  *    1.2.5                   13    10205  12.so.0.1.2.5
+ *    1.2.6beta1-4            13    10206  12.so.0.1.2.6beta1-4
+ *    1.0.16                  10    10016  10.so.0.1.0.16
+ *    1.2.6                   13    10206  12.so.0.1.2.6
  *
  *    Henceforth the source version will match the shared-library major
  *    and minor numbers; the shared-library major version number will be
@@ -127,7 +130,14 @@
  * If you modify libpng you may insert additional notices immediately following
  * this sentence.
  *
- * libpng versions 1.0.7, July 1, 2000, through 1.0.15, October 3, 2002, are
+ * libpng version 1.2.6, August 15, 2004, is
+ * Copyright (c) 2004 Glenn Randers-Pehrson, and is
+ * distributed according to the same disclaimer and license as libpng-1.2.5
+ * with the following individual added to the list of Contributing Authors
+ *
+ *    Cosmin Truta
+ *
+ * libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
  * Copyright (c) 2000-2002 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
@@ -232,13 +242,13 @@
  * Y2K compliance in libpng:
  * =========================
  *
- *    October 3, 2002
+ *    August 15, 2004
  *
  *    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.15 are Y2K compliant.  It is my belief that earlier
+ *    upward through 1.0.16 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
@@ -294,7 +304,9 @@
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.0.15"
+#define PNG_LIBPNG_VER_STRING "1.0.16"
+#define PNG_HEADER_VERSION_STRING \
+   " libpng version 1.0.16 - August 15, 2004 (header)\n"
 
 #define PNG_LIBPNG_VER_SONUM   0
 #define PNG_LIBPNG_VER_DLLNUM  %DLLNUM%
@@ -302,7 +314,7 @@
 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
 #define PNG_LIBPNG_VER_MAJOR   1
 #define PNG_LIBPNG_VER_MINOR   0
-#define PNG_LIBPNG_VER_RELEASE 15
+#define PNG_LIBPNG_VER_RELEASE 16
 /* This should match the numeric part of the final component of
  * PNG_LIBPNG_VER_STRING, omitting any leading zero: */
 
@@ -321,7 +333,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 10015 /* 1.0.15 */
+#define PNG_LIBPNG_VER 10016 /* 1.0.16 */
 
 #ifndef PNG_VERSION_INFO_ONLY
 
@@ -833,7 +845,11 @@
 typedef png_info FAR * FAR * png_infopp;
 
 /* Maximum positive integer used in PNG is (2^31)-1 */
-#define PNG_MAX_UINT ((png_uint_32)0x7fffffffL)
+#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)
+#define PNG_UINT_32_MAX (~((png_uint_32)0))
+#define PNG_SIZE_MAX (~((png_size_t)0))
+/* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */
+#define PNG_MAX_UINT PNG_UINT_31_MAX
 
 /* These describe the color_type field in png_info. */
 /* color type masks */
@@ -1280,13 +1296,21 @@
                                      /* palette color */
 #endif
 
+/* New members added in libpng-1.0.16 and 1.2.6 */
+   png_byte compression_type;
+
+#ifdef PNG_SET_USER_LIMITS_SUPPORTED
+   png_uint_32 user_width_max;
+   png_uint_32 user_height_max;
+#endif
+
 };
 
 
-/* This prevents a compiler error in png.c if png.c and png.h are both at
-   version 1.0.15
+/* This triggers a compiler error in png.c, if png.c and png.h
+ * do not agree upon the version number.
  */
-typedef png_structp version_1_0_15;
+typedef png_structp version_1_0_16;
 
 typedef png_struct FAR * FAR * png_structpp;
 
@@ -1328,11 +1352,15 @@
    PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
    png_error_ptr error_fn, png_error_ptr warn_fn));
 
+#ifdef PNG_WRITE_SUPPORTED
 extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size)
    PNGARG((png_structp png_ptr));
+#endif
 
+#ifdef PNG_WRITE_SUPPORTED
 extern PNG_EXPORT(void,png_set_compression_buffer_size)
    PNGARG((png_structp png_ptr, png_uint_32 size));
+#endif
 
 /* Reset the compression stream */
 extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr));
@@ -1371,7 +1399,8 @@
 /* Initialize the info structure (old interface - DEPRECATED) */
 extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr));
 #undef png_info_init
-#define png_info_init(info_ptr) png_info_init_3(&info_ptr, sizeof(png_info));
+#define png_info_init(info_ptr) png_info_init_3(&info_ptr,\
+    png_sizeof(png_info));
 extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr,
     png_size_t png_info_struct_size));
 
@@ -1381,9 +1410,11 @@
 extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr,
    png_infop info_ptr));
 
+#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
 /* read the information before the actual image data. */
 extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr,
    png_infop info_ptr));
+#endif
 
 #if defined(PNG_TIME_RFC1123_SUPPORTED)
 extern PNG_EXPORT(png_charp,png_convert_to_rfc1123)
@@ -1546,18 +1577,24 @@
 extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr,
    png_infop info_ptr));
 
+#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
 /* read one or more rows of image data. */
 extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr,
    png_bytepp row, png_bytepp display_row, png_uint_32 num_rows));
+#endif
 
+#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
 /* read a row of data. */
 extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr,
    png_bytep row,
    png_bytep display_row));
+#endif
 
+#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
 /* read the whole image into memory at once. */
 extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr,
    png_bytepp image));
+#endif
 
 /* write a row of image data */
 extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr,
@@ -1575,9 +1612,11 @@
 extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr,
    png_infop info_ptr));
 
+#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
 /* read the end of the PNG file. */
 extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr,
    png_infop info_ptr));
+#endif
 
 /* free any memory associated with the png_info_struct */
 extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr,
@@ -2349,6 +2388,12 @@
    png_ptr, png_uint_32 mng_features_permitted));
 #endif
 
+/* For use in png_set_keep_unknown, added to version 1.2.6 */
+#define PNG_HANDLE_CHUNK_AS_DEFAULT   0
+#define PNG_HANDLE_CHUNK_NEVER        1
+#define PNG_HANDLE_CHUNK_IF_SAFE      2
+#define PNG_HANDLE_CHUNK_ALWAYS       3
+
 /* Added to version 1.2.0 */
 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
 #define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED  0x01  /* not user-settable */
@@ -2377,7 +2422,6 @@
 #define PNG_SELECT_READ   1
 #define PNG_SELECT_WRITE  2
 
-
 #if !defined(PNG_1_0_X)
 /* pngget.c */
 extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask)
@@ -2421,12 +2465,20 @@
 extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp
    png_ptr, png_uint_32 strip_mode));
 #endif
+
 #endif /* PNG_1_0_X */
 
-/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */
+/* Added at libpng-1.2.6 */
+#ifdef PNG_SET_USER_LIMITS_SUPPORTED
+extern PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp
+   png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max));
+extern PNG_EXPORT(png_uint_32,png_get_user_width_max) PNGARG((png_structp
+   png_ptr));
+extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp
+   png_ptr));
+#endif
 
-#define PNG_HEADER_VERSION_STRING \
-   " libpng version 1.0.15 - October 3, 2002 (header)\n"
+/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */
 
 #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
 /* With these routines we avoid an integer divide, which will be slower on
@@ -2553,12 +2605,6 @@
 #define PNG_FLAG_STRIP_ERROR_TEXT         0x80000L
 #define PNG_FLAG_MALLOC_NULL_MEM_OK       0x100000L
 
-/* For use in png_set_keep_unknown, png_handle_as_unknown */
-#define HANDLE_CHUNK_AS_DEFAULT   0
-#define HANDLE_CHUNK_NEVER        1
-#define HANDLE_CHUNK_IF_SAFE      2
-#define HANDLE_CHUNK_ALWAYS       3
-
 #define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
                                      PNG_FLAG_CRC_ANCILLARY_NOWARN)
 
@@ -2569,10 +2615,24 @@
                                      PNG_FLAG_CRC_CRITICAL_MASK)
 
 /* save typing and make code easier to understand */
+
 #define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \
    abs((int)((c1).green) - (int)((c2).green)) + \
    abs((int)((c1).blue) - (int)((c2).blue)))
 
+/* Added to libpng-1.2.6 JB */
+#define PNG_ROWBYTES(pixel_bits, width) \
+    ((pixel_bits) >= 8 ? \
+    ((width) * (((png_uint_32)(pixel_bits)) >> 3)) : \
+    (( ((width) * ((png_uint_32)(pixel_bits))) + 7) >> 3) )
+
+/* PNG_OUT_OF_RANGE returns true if value is outside the range
+   ideal-delta..ideal+delta.  Each argument is evaluated twice.
+   "ideal" and "delta" should be constants, normally simple
+   integers, "value" a variable. Added to libpng-1.2.6 JB */
+#define PNG_OUT_OF_RANGE(value, ideal, delta) \
+        ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) )
+
 /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
 #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
 /* place to hold the signature string for a PNG file. */
@@ -2655,6 +2715,8 @@
 PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf));
 PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf));
 #endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */
+PNG_EXTERN png_uint_32 png_get_uint_31 PNGARG((png_structp png_ptr,
+  png_bytep buf));
 
 /* Initialize png_ptr struct for reading, and allocate any other memory.
  * (old interface - DEPRECATED - use png_create_read_struct instead).
@@ -2662,7 +2724,7 @@
 extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr));
 #undef png_read_init
 #define png_read_init(png_ptr) png_read_init_3(&png_ptr, \
-    PNG_LIBPNG_VER_STRING,  sizeof(png_struct));
+    PNG_LIBPNG_VER_STRING,  png_sizeof(png_struct));
 extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr,
     png_const_charp user_png_ver, png_size_t png_struct_size));
 extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr,
@@ -2675,7 +2737,7 @@
 extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr));
 #undef png_write_init
 #define png_write_init(png_ptr) png_write_init_3(&png_ptr, \
-    PNG_LIBPNG_VER_STRING, sizeof(png_struct));
+    PNG_LIBPNG_VER_STRING, png_sizeof(png_struct));
 extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr,
     png_const_charp user_png_ver, png_size_t png_struct_size));
 extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr,
@@ -2704,6 +2766,11 @@
 /* Function to free memory for zlib */
 PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr));
 
+#ifdef PNG_SIZE_T
+/* Function to convert a sizeof an item to png_sizeof item */
+   PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size));
+#endif
+
 /* Next four functions are used internally as callbacks.  PNGAPI is required
  * but not PNG_EXPORT.  PNGAPI added at libpng version 1.2.3. */
 
diff --git a/pngasmrd.h b/pngasmrd.h
index 3574374..335a682 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.15 - October 3, 2002
+ * libpng 1.0.16 - August 15, 2004
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 2002 Glenn Randers-Pehrson
+ * Copyright (c) 2002-2004 Glenn Randers-Pehrson
  *
  */
 
diff --git a/pngconf.h b/pngconf.h
index 32adc45..c81b87c 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,8 +1,9 @@
+
 /* pngconf.h - machine configurable file for libpng
  *
- * libpng 1.0.15 - October 3, 2002
+ * libpng version 1.0.16 - August 15, 2004
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 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.)
  */
@@ -16,7 +17,9 @@
 #ifndef PNGCONF_H
 #define PNGCONF_H
 
-#define PNG_1_0_X
+#ifdef PNG_USER_CONFIG
+#include "pngusr.h"
+#endif
 
 /* This is the size of the compression buffer, and thus the size of
  * an IDAT chunk.  Make this whatever size you feel is best for your
@@ -254,8 +257,11 @@
 #      undef _BSD_SOURCE
 #    endif
 #    ifdef _SETJMP_H
-      __png.h__ already includes setjmp.h;
-      __dont__ include it again.;
+     /* If you encounter a compiler error here, see the explanation
+      * near the end of INSTALL.
+      */
+         __png.h__ already includes setjmp.h;
+         __dont__ include it again.;
 #    endif
 #  endif /* __linux__ */
 
@@ -319,15 +325,13 @@
 #  define PNG_ALWAYS_EXTERN
 #endif
 
-/* For some reason, Borland C++ defines memcmp, etc. in mem.h, not
- * stdlib.h like it should (I think).  Or perhaps this is a C++
- * "feature"?
- */
-#ifdef __TURBOC__
+/* This provides the non-ANSI (far) memory allocation routines. */
+#if defined(__TURBOC__) && defined(__MSDOS__)
 #  include <mem.h>
-#  include "alloc.h"
+#  include <alloc.h>
 #endif
 
+/* I have no idea why is this necessary... */
 #if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \
     defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__))
 #  include <malloc.h>
@@ -665,6 +669,25 @@
 #endif
 #endif /* PNG_1_0_X */
 
+/* Added at libpng-1.2.6 */
+#if !defined(PNG_1_0_X)
+#ifndef PNG_SET_USER_LIMITS_SUPPORTED
+#if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED)
+#  define PNG_SET_USER_LIMITS_SUPPORTED
+#endif
+#endif
+#endif /* PNG_1_0_X */
+
+/* Added at libpng-1.0.16 and 1.2.6.  To accept all valid PNGS no matter
+ * how large, set these limits to 0x7fffffffL
+ */
+#ifndef PNG_USER_WIDTH_MAX
+#  define PNG_USER_WIDTH_MAX 1000000L
+#endif
+#ifndef PNG_USER_HEIGHT_MAX
+#  define PNG_USER_HEIGHT_MAX 1000000L
+#endif
+
 /* These are currently experimental features, define them if you want */
 
 /* very little testing */
@@ -679,10 +702,8 @@
 /* This is only for PowerPC big-endian and 680x0 systems */
 /* some testing */
 /*
-#ifdef PNG_READ_SUPPORTED
-#  ifndef PNG_PNG_READ_BIG_ENDIAN_SUPPORTED
-#    define PNG_READ_BIG_ENDIAN_SUPPORTED
-#  endif
+#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED
+#  define PNG_READ_BIG_ENDIAN_SUPPORTED
 #endif
 */
 
@@ -990,7 +1011,13 @@
 
 /* This is usually size_t.  It is typedef'ed just in case you need it to
    change (I'm not sure if you will or not, so I thought I'd be safe) */
-typedef size_t png_size_t;
+#ifdef PNG_SIZE_T
+   typedef PNG_SIZE_T png_size_t;
+#  define png_sizeof(x) png_convert_size(sizeof (x))
+#else
+   typedef size_t png_size_t;
+#  define png_sizeof(x) sizeof (x)
+#endif
 
 /* The following is needed for medium model support.  It cannot be in the
  * PNG_INTERNAL section.  Needs modification for other compilers besides
@@ -1173,8 +1200,6 @@
  * zlib and your applications the same way you build libpng.
  */
 
-#ifndef PNGAPI
-
 #if defined(__MINGW32__) && !defined(PNG_MODULEDEF)
 #  ifndef PNG_NO_MODULEDEF
 #    define PNG_NO_MODULEDEF
@@ -1189,10 +1214,12 @@
     (( defined(_Windows) || defined(_WINDOWS) || \
        defined(WIN32) || defined(_WIN32) || defined(__WIN32__) ))
 
-#  if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
-#    define PNGAPI __cdecl
-#  else
-#    define PNGAPI _cdecl
+#  ifndef PNGAPI
+#     if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
+#        define PNGAPI __cdecl
+#     else
+#        define PNGAPI _cdecl
+#     endif
 #  endif
 
 #  if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \
@@ -1230,17 +1257,14 @@
 #     endif
 #  endif  /* PNG_IMPEXP */
 #else /* !(DLL || non-cygwin WINDOWS) */
-#    if (defined(__IBMC__) || defined(IBMCPP__)) && defined(__OS2__)
-#      define PNGAPI _System
-#      define PNG_IMPEXP
-#    else
-#      if 0 /* ... other platforms, with other meanings */
-#      else
-#        define PNGAPI
-#        define PNG_IMPEXP
+#   if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
+#      ifndef PNGAPI
+#         define PNGAPI _System
 #      endif
-#    endif
-#endif
+#   else
+#      if 0 /* ... other platforms, with other meanings */
+#      endif
+#   endif
 #endif
 
 #ifndef PNGAPI
@@ -1281,28 +1305,30 @@
 #  define NOCHECK 0
 #  define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
 #  define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
-#  define png_strcpy _fstrcpy
-#  define png_strlen _fstrlen
-#  define png_memcmp _fmemcmp      /* SJT: added */
-#  define png_memcpy _fmemcpy
-#  define png_memset _fmemset
+#  define png_strcpy  _fstrcpy
+#  define png_strncpy _fstrncpy   /* Added to v 1.2.6 */
+#  define png_strlen  _fstrlen
+#  define png_memcmp  _fmemcmp    /* SJT: added */
+#  define png_memcpy  _fmemcpy
+#  define png_memset  _fmemset
 #else /* use the usual functions */
 #  define CVT_PTR(ptr)         (ptr)
 #  define CVT_PTR_NOCHECK(ptr) (ptr)
-#  define png_strcpy strcpy
-#  define png_strlen strlen
-#  define png_memcmp memcmp     /* SJT: added */
-#  define png_memcpy memcpy
-#  define png_memset memset
+#  define png_strcpy  strcpy
+#  define png_strncpy strncpy     /* Added to v 1.2.6 */
+#  define png_strlen  strlen
+#  define png_memcmp  memcmp      /* SJT: added */
+#  define png_memcpy  memcpy
+#  define png_memset  memset
 #endif
 /* End of memory model independent support */
 
 /* Just a little check that someone hasn't tried to define something
  * contradictory.
  */
-#if (PNG_ZBUF_SIZE > 65536) && defined(PNG_MAX_MALLOC_64K)
+#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)
 #  undef PNG_ZBUF_SIZE
-#  define PNG_ZBUF_SIZE 65536
+#  define PNG_ZBUF_SIZE 65536L
 #endif
 
 #ifdef PNG_READ_SUPPORTED
diff --git a/pngerror.c b/pngerror.c
index 5eeefe7..da7453a 100644
--- a/pngerror.c
+++ b/pngerror.c
@@ -1,9 +1,9 @@
 
 /* pngerror.c - stub functions for i/o and memory allocation
  *
- * libpng 1.0.15 - October 3, 2002
+ * libpng version 1.0.16 - August 15, 2004
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 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.)
  *
@@ -35,9 +35,9 @@
    char msg[16];
    if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
    {
-     int offset = 0;
      if (*error_message == '#')
      {
+         int offset;
          for (offset=1; offset<15; offset++)
             if (*(error_message+offset) == ' ')
                 break;
@@ -63,11 +63,11 @@
      }
    }
 #endif
-   if (png_ptr->error_fn != NULL)
+   if (png_ptr != NULL && png_ptr->error_fn != NULL)
       (*(png_ptr->error_fn))(png_ptr, error_message);
 
-   /* if the following returns or doesn't exist, use the default function,
-      which will not return */
+   /* If the custom handler doesn't exist, or if it returns,
+      use the default handler, which will not return. */
    png_default_error(png_ptr, error_message);
 }
 
@@ -79,7 +79,7 @@
 void PNGAPI
 png_warning(png_structp png_ptr, png_const_charp warning_message)
 {
-     int offset = 0;
+   int offset = 0;
 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
    if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
 #endif
@@ -91,11 +91,10 @@
                 break;
      }
    }
-   if (png_ptr->warning_fn != NULL)
-      (*(png_ptr->warning_fn))(png_ptr,
-         (png_const_charp)(warning_message+offset));
+   if (png_ptr != NULL && png_ptr->warning_fn != NULL)
+      (*(png_ptr->warning_fn))(png_ptr, warning_message+offset);
    else
-      png_default_warning(png_ptr, (png_const_charp)(warning_message+offset));
+      png_default_warning(png_ptr, warning_message+offset);
 }
 
 /* These utilities are used internally to build an error message that relates
@@ -104,10 +103,11 @@
  * to 63 bytes, the name characters are output as hex digits wrapped in []
  * if the character is invalid.
  */
-#define isnonalpha(c) ((c) < 41 || (c) > 122 || ((c) > 90 && (c) < 97))
+#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
 static PNG_CONST char png_digit[16] = {
-   '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
-   'F' };
+   '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+   'A', 'B', 'C', 'D', 'E', 'F'
+};
 
 static void /* PRIVATE */
 png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
@@ -137,7 +137,7 @@
    {
       buffer[iout++] = ':';
       buffer[iout++] = ' ';
-      png_memcpy(buffer+iout, error_message, 64);
+      png_strncpy(buffer+iout, error_message, 63);
       buffer[iout+63] = 0;
    }
 }
@@ -190,26 +190,28 @@
    else
 #endif
    fprintf(stderr, "libpng error: %s\n", error_message);
-#else
-   if (error_message)
-     /* make compiler happy */ ;
 #endif
 
 #ifdef PNG_SETJMP_SUPPORTED
 #  ifdef USE_FAR_KEYWORD
    {
       jmp_buf jmpbuf;
-      png_memcpy(jmpbuf,png_ptr->jmpbuf,sizeof(jmp_buf));
+      png_memcpy(jmpbuf,png_ptr->jmpbuf,png_sizeof(jmp_buf));
       longjmp(jmpbuf, 1);
    }
 #  else
    longjmp(png_ptr->jmpbuf, 1);
 # endif
 #else
+   /* make compiler happy */ ;
    if (png_ptr)
-     /* make compiler happy */ ;
    PNG_ABORT();
 #endif
+#ifdef PNG_NO_CONSOLE_IO
+   /* make compiler happy */ ;
+   if (&error_message != NULL)
+      return;
+#endif
 }
 
 /* This function is called when there is a warning, but the library thinks
@@ -245,9 +247,11 @@
 #  endif
      fprintf(stderr, "libpng warning: %s\n", warning_message);
 #else
+   /* make compiler happy */ ;
    if (warning_message)
-     /* appease compiler */ ;
+     return;
 #endif
+   /* make compiler happy */ ;
    if (png_ptr)
       return;
 }
diff --git a/pnggccrd.c b/pnggccrd.c
index e9547dc..2edf06a 100644
--- a/pnggccrd.c
+++ b/pnggccrd.c
@@ -6,9 +6,9 @@
  *     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.0.15 - October 3, 2002
+ * libpng version 1.0.16 - August 15, 2004
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 Glenn Randers-Pehrson
  * Copyright (c) 1998, Intel Corporation
  *
  * Based on MSVC code contributed by Nirav Chhatrapati, Intel Corp., 1998.
@@ -223,6 +223,10 @@
  * 20020304:
  *  - eliminated incorrect use of width_mmx in pixel_bytes == 8 case
  *
+ * 20040724:
+ *   - more tinkering with clobber list at lines 4529 and 5033, to get
+ *     it to compile on gcc-3.4.
+ *
  * STILL TO DO:
  *     - test png_do_read_interlace() 64-bit case (pixel_bytes == 8)
  *     - write MMX code for 48-bit case (pixel_bytes == 6)
@@ -412,8 +416,10 @@
 
 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
    if (_mmx_supported == 2) {
+#if !defined(PNG_1_0_X)
        /* this should have happened in png_init_mmx_flags() already */
        png_warning(png_ptr, "asm_flags may not have been initialized");
+#endif
        png_mmx_support();
    }
 #endif
@@ -422,7 +428,7 @@
    {
       png_debug(2,"mask == 0xff:  doing single png_memcpy()\n");
       png_memcpy(row, png_ptr->row_buf + 1,
-       (png_size_t)((png_ptr->width * png_ptr->row_info.pixel_depth + 7) >> 3));
+       (png_size_t)PNG_ROWBYTES(png_ptr->row_info.pixel_depth,png_ptr->width));
    }
    else   /* (png_combine_row() is never called with mask == 0) */
    {
@@ -1767,8 +1773,8 @@
 
                         : "1" (sptr),      // esi      // input regs
                           "2" (dp),        // edi
-                          "0" (width)      // ecx
-// doesn't work           "i" (0x0000000000FFFFFFLL)   // %1 (a.k.a. _const4)
+                          "0" (width),     // ecx
+                          "rim" (_const4)  // %1(?)  (0x0000000000FFFFFFLL)
 
 #if 0  /* %mm0, ..., %mm4 not supported by gcc 2.7.2.3 or egcs 1.1 */
                         : "%mm0", "%mm1", "%mm2"       // clobber list
@@ -1811,7 +1817,8 @@
 
                         : "1" (sptr),      // esi      // input regs
                           "2" (dp),        // edi
-                          "0" (width)      // ecx
+                          "0" (width),     // ecx
+                          "rim" (_const4)  // (0x0000000000FFFFFFLL)
 
 #if 0  /* %mm0, ..., %mm2 not supported by gcc 2.7.2.3 or egcs 1.1 */
                         : "%mm0", "%mm1", "%mm2"       // clobber list
@@ -1865,7 +1872,9 @@
 
                            : "1" (sptr),      // esi      // input regs
                              "2" (dp),        // edi
-                             "0" (width_mmx)  // ecx
+                             "0" (width_mmx), // ecx
+                             "rim" (_const4), // 0x0000000000FFFFFFLL
+                             "rim" (_const6)  // 0x00000000000000FFLL
 
 #if 0  /* %mm0, ..., %mm3 not supported by gcc 2.7.2.3 or egcs 1.1 */
                            : "%mm0", "%mm1"               // clobber list
@@ -2727,8 +2736,8 @@
       } /* end switch (row_info->pixel_depth) */
 
       row_info->width = final_width;
-      row_info->rowbytes = ((final_width *
-         (png_uint_32)row_info->pixel_depth + 7) >> 3);
+
+      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width);
    }
 
 } /* end png_do_read_interlace() */
@@ -4529,8 +4538,7 @@
       : "0" (bpp),              // eax    // input regs
         "1" (row)               // edi
 
-      : "%ebx", "%ecx", "%edx"            // clobber list
-      , "%esi"
+      : "%esi", "%ecx", "%edx"            // clobber list
 
 #if 0  /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */
       , "%mm0", "%mm1", "%mm2", "%mm3"
@@ -5034,7 +5042,10 @@
         "1" (prev_row),         // esi
         "2" (row)               // edi
 
-      : "%eax", "%ebx", "%ecx"            // clobber list (no input regs!)
+      : "%eax", "%ecx"            // clobber list (no input regs!)
+#ifndef __PIC__
+      , "%ebx"
+#endif
 
 #if 0  /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */
       , "%mm0", "%mm1", "%mm2", "%mm3"
diff --git a/pngget.c b/pngget.c
index 108afc7..db937f8 100644
--- a/pngget.c
+++ b/pngget.c
@@ -1,9 +1,9 @@
 
 /* pngget.c - retrieval of values from info struct
  *
- * libpng 1.0.15 - October 3, 2002
+ * libpng 1.0.16 - August 15, 2004
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 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.)
  */
@@ -540,9 +540,6 @@
    if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
       bit_depth != NULL && color_type != NULL)
    {
-      int pixel_depth, channels;
-      png_uint_32 rowbytes_per_pixel;
-
       png_debug1(1, "in %s retrieval function\n", "IHDR");
       *width = info_ptr->width;
       *height = info_ptr->height;
@@ -560,23 +557,18 @@
          *interlace_type = info_ptr->interlace_type;
 
       /* check for potential overflow of rowbytes */
-      if (*color_type == PNG_COLOR_TYPE_PALETTE)
-         channels = 1;
-      else if (*color_type & PNG_COLOR_MASK_COLOR)
-         channels = 3;
-      else
-         channels = 1;
-      if (*color_type & PNG_COLOR_MASK_ALPHA)
-         channels++;
-      pixel_depth = *bit_depth * channels;
-      rowbytes_per_pixel = (pixel_depth + 7) >> 3;
-      if (width == 0 || *width > PNG_MAX_UINT)
+      if (width == 0 || *width > PNG_UINT_31_MAX)
         png_error(png_ptr, "Invalid image width");
-      if (height == 0 || *height > PNG_MAX_UINT)
+      if (height == 0 || *height > PNG_UINT_31_MAX)
         png_error(png_ptr, "Invalid image height");
-      if (*width > PNG_MAX_UINT/rowbytes_per_pixel - 64)
+      if (info_ptr->width > (PNG_UINT_32_MAX
+                 >> 3)      /* 8-byte RGBA pixels */
+                 - 64       /* bigrowbuf hack */
+                 - 1        /* filter byte */
+                 - 7*8      /* rounding of width to multiple of 8 pixels */
+                 - 8)       /* extra max_pixel_depth pad */
       {
-         png_error(png_ptr,
+         png_warning(png_ptr,
             "Width too large for libpng to process image data.");
       }
       return (1);
@@ -827,13 +819,13 @@
 }
 #endif
 
-
+#ifdef PNG_WRITE_SUPPORTED
 png_uint_32 PNGAPI
 png_get_compression_buffer_size(png_structp png_ptr)
 {
    return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L);
 }
-
+#endif
 
 #ifndef PNG_1_0_X
 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
@@ -923,5 +915,20 @@
 {
     return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L);
 }
-#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
-#endif /* PNG_1_0_X */
+#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
+
+#ifdef PNG_SET_USER_LIMITS_SUPPORTED
+/* these functions were added to libpng 1.2.6 */
+png_uint_32 PNGAPI
+png_get_user_width_max (png_structp png_ptr)
+{
+    return (png_ptr? png_ptr->user_width_max : 0);
+}
+png_uint_32 PNGAPI
+png_get_user_height_max (png_structp png_ptr)
+{
+    return (png_ptr? png_ptr->user_height_max : 0);
+}
+#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
+
+#endif /* ?PNG_1_0_X */
diff --git a/pngmem.c b/pngmem.c
index 62f5f85..1be5157 100644
--- a/pngmem.c
+++ b/pngmem.c
@@ -1,9 +1,9 @@
 
 /* pngmem.c - stub functions for memory allocation
  *
- * libpng 1.0.15 - October 3, 2002
+ * libpng version 1.0.16 - August 15, 2004
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 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.)
  *
@@ -39,11 +39,11 @@
    png_voidp struct_ptr;
 
    if (type == PNG_STRUCT_INFO)
-     size = sizeof(png_info);
+     size = png_sizeof(png_info);
    else if (type == PNG_STRUCT_PNG)
-     size = sizeof(png_struct);
+     size = png_sizeof(png_struct);
    else
-     return (png_get_copyright());
+     return (png_get_copyright(NULL));
 
 #ifdef PNG_USER_MEM_SUPPORTED
    if(malloc_fn != NULL)
@@ -55,7 +55,7 @@
    }
    else
 #endif /* PNG_USER_MEM_SUPPORTED */
-      struct_ptr = (png_voidp)farmalloc(size));
+      struct_ptr = (png_voidp)farmalloc(size);
    if (struct_ptr != NULL)
       png_memset(struct_ptr, 0, size);
    return (struct_ptr);
@@ -121,14 +121,12 @@
 
 #ifdef PNG_USER_MEM_SUPPORTED
    if(png_ptr->malloc_fn != NULL)
-   {
        ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
-       if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
-          png_error(png_ptr, "Out of memory!");
-       return (ret);
-   }
    else
-       return png_malloc_default(png_ptr, size);
+       ret = (png_malloc_default(png_ptr, size));
+   if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
+       png_error(png_ptr, "Out of memory!");
+   return (ret);
 }
 
 png_voidp PNGAPI
@@ -139,10 +137,16 @@
 
 #ifdef PNG_MAX_MALLOC_64K
    if (size > (png_uint_32)65536L)
-      png_error(png_ptr, "Cannot Allocate > 64K");
+   {
+      png_warning(png_ptr, "Cannot Allocate > 64K");
+      ret = NULL;
+   }
+   else
 #endif
 
-   if (size == (png_uint_32)65536L)
+   if (size != (size_t)size)
+     ret = NULL;
+   else if (size == (png_uint_32)65536L)
    {
       if (png_ptr->offset_table == NULL)
       {
@@ -177,34 +181,40 @@
 
             if (table == NULL)
             {
-               if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
+#ifndef PNG_USER_MEM_SUPPORTED
+               if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
                   png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */
                else
                   png_warning(png_ptr, "Out Of Memory.");
+#endif
                return (NULL);
             }
 
             if ((png_size_t)table & 0xfff0)
             {
-               if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
+#ifndef PNG_USER_MEM_SUPPORTED
+               if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
                   png_error(png_ptr,
                     "Farmalloc didn't return normalized pointer");
                else
                   png_warning(png_ptr,
                     "Farmalloc didn't return normalized pointer");
+#endif
                return (NULL);
             }
 
             png_ptr->offset_table = table;
             png_ptr->offset_table_ptr = farmalloc(num_blocks *
-               sizeof (png_bytep));
+               png_sizeof (png_bytep));
 
             if (png_ptr->offset_table_ptr == NULL)
             {
-               if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
+#ifndef PNG_USER_MEM_SUPPORTED
+               if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
                   png_error(png_ptr, "Out Of memory."); /* Note "O" and "M" */
                else
                   png_warning(png_ptr, "Out Of memory.");
+#endif
                return (NULL);
             }
 
@@ -228,10 +238,12 @@
 
       if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
       {
-         if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
+#ifndef PNG_USER_MEM_SUPPORTED
+         if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
             png_error(png_ptr, "Out of Memory."); /* Note "o" and "M" */
          else
             png_warning(png_ptr, "Out of Memory.");
+#endif
          return (NULL);
       }
 
@@ -240,13 +252,15 @@
    else
       ret = farmalloc(size);
 
+#ifndef PNG_USER_MEM_SUPPORTED
    if (ret == NULL)
    {
-      if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
+      if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
          png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */
       else
          png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */
    }
+#endif
 
    return (ret);
 }
@@ -325,9 +339,9 @@
    png_voidp struct_ptr;
 
    if (type == PNG_STRUCT_INFO)
-      size = sizeof(png_info);
+      size = png_sizeof(png_info);
    else if (type == PNG_STRUCT_PNG)
-      size = sizeof(png_struct);
+      size = png_sizeof(png_struct);
    else
       return (NULL);
 
@@ -345,17 +359,16 @@
 #endif /* PNG_USER_MEM_SUPPORTED */
 
 #if defined(__TURBOC__) && !defined(__FLAT__)
-   if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL)
+   struct_ptr = (png_voidp)farmalloc(size);
 #else
 # if defined(_MSC_VER) && defined(MAXSEG_64K)
-   if ((struct_ptr = (png_voidp)halloc(size,1)) != NULL)
+   struct_ptr = (png_voidp)halloc(size,1);
 # else
-   if ((struct_ptr = (png_voidp)malloc(size)) != NULL)
+   struct_ptr = (png_voidp)malloc(size);
 # endif
 #endif
-   {
+   if (struct_ptr != NULL)
       png_memset(struct_ptr, 0, size);
-   }
 
    return (struct_ptr);
 }
@@ -410,19 +423,17 @@
 {
    png_voidp ret;
 
+#ifdef PNG_USER_MEM_SUPPORTED
    if (png_ptr == NULL || size == 0)
       return (NULL);
 
-#ifdef PNG_USER_MEM_SUPPORTED
    if(png_ptr->malloc_fn != NULL)
-   {
        ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
-       if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
-          png_error(png_ptr, "Out of Memory!");
-       return (ret);
-   }
    else
-       return (png_malloc_default(png_ptr, size));
+       ret = (png_malloc_default(png_ptr, size));
+   if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
+       png_error(png_ptr, "Out of Memory!");
+   return (ret);
 }
 
 png_voidp PNGAPI
@@ -431,28 +442,45 @@
    png_voidp ret;
 #endif /* PNG_USER_MEM_SUPPORTED */
 
+   if (png_ptr == NULL || size == 0)
+      return (NULL);
+
 #ifdef PNG_MAX_MALLOC_64K
    if (size > (png_uint_32)65536L)
    {
+#ifndef PNG_USER_MEM_SUPPORTED
       if(png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
          png_error(png_ptr, "Cannot Allocate > 64K");
       else
+#endif
          return NULL;
    }
 #endif
 
+ /* Check for overflow */
 #if defined(__TURBOC__) && !defined(__FLAT__)
+ if (size != (unsigned long)size)
+   ret = NULL;
+ else
    ret = farmalloc(size);
 #else
 # if defined(_MSC_VER) && defined(MAXSEG_64K)
+ if (size != (unsigned long)size)
+   ret = NULL;
+ else
    ret = halloc(size, 1);
 # else
+ if (size != (size_t)size)
+   ret = NULL;
+ else
    ret = malloc((size_t)size);
 # endif
 #endif
 
+#ifndef PNG_USER_MEM_SUPPORTED
    if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
       png_error(png_ptr, "Out of Memory");
+#endif
 
    return (ret);
 }
@@ -498,8 +526,9 @@
 #  define png_malloc_warn png_malloc
 #else
 /* This function was added at libpng version 1.2.3.  The png_malloc_warn()
- * function will issue a png_warning and return NULL instead of issuing a
- * png_error, if it fails to allocate the requested memory.
+ * function will set up png_malloc() to issue a png_warning and return NULL
+ * instead of issuing a png_error, if it fails to allocate the requested
+ * memory.
  */
 png_voidp PNGAPI
 png_malloc_warn(png_structp png_ptr, png_uint_32 size)
diff --git a/pngpread.c b/pngpread.c
index 7b8d37b..923df63 100644
--- a/pngpread.c
+++ b/pngpread.c
@@ -1,9 +1,9 @@
 
 /* pngpread.c - read a png file in push mode
  *
- * libpng 1.0.15 - October 3, 2002
+ * libpng version 1.0.16 - August 15, 2004
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 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.)
  */
@@ -208,7 +208,7 @@
       }
 
       png_push_fill_buffer(png_ptr, chunk_length, 4);
-      png_ptr->push_length = png_get_uint_32(chunk_length);
+      png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length);
       png_reset_crc(png_ptr);
       png_crc_read(png_ptr, png_ptr->chunk_name, 4);
       png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
@@ -223,6 +223,41 @@
       }
       png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length);
    }
+   else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
+   {
+      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
+      {
+         png_push_save_buffer(png_ptr);
+         return;
+      }
+      png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length);
+
+      png_ptr->process_mode = PNG_READ_DONE_MODE;
+      png_push_have_end(png_ptr, info_ptr);
+   }
+#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
+   else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
+   {
+      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
+      {
+         png_push_save_buffer(png_ptr);
+         return;
+      }
+      if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
+         png_ptr->mode |= PNG_HAVE_IDAT;
+      png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
+      if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
+         png_ptr->mode |= PNG_HAVE_PLTE;
+      else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
+      {
+         if (!(png_ptr->mode & PNG_HAVE_IHDR))
+            png_error(png_ptr, "Missing IHDR before IDAT");
+         else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
+                  !(png_ptr->mode & PNG_HAVE_PLTE))
+            png_error(png_ptr, "Missing PLTE before IDAT");
+      }
+   }
+#endif
    else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
@@ -261,18 +296,6 @@
       png_ptr->zstream.next_out = png_ptr->row_buf;
       return;
    }
-   else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
-   {
-      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
-      {
-         png_push_save_buffer(png_ptr);
-         return;
-      }
-      png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length);
-
-      png_ptr->process_mode = PNG_READ_DONE_MODE;
-      png_push_have_end(png_ptr, info_ptr);
-   }
 #if defined(PNG_READ_gAMA_SUPPORTED)
    else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4))
    {
@@ -591,6 +614,11 @@
       png_size_t new_max;
       png_bytep old_buffer;
 
+      if (png_ptr->save_buffer_size > PNG_SIZE_MAX - 
+         (png_ptr->current_buffer_size + 256))
+      {
+        png_error(png_ptr, "Potential overflow of save_buffer");
+      }
       new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256;
       old_buffer = png_ptr->save_buffer;
       png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr,
@@ -637,8 +665,7 @@
       }
 
       png_push_fill_buffer(png_ptr, chunk_length, 4);
-      png_ptr->push_length = png_get_uint_32(chunk_length);
-
+      png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length);
       png_reset_crc(png_ptr);
       png_crc_read(png_ptr, png_ptr->chunk_name, 4);
       png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
@@ -753,7 +780,7 @@
              png_ptr->interlaced && png_ptr->pass > 6) ||
              (!png_ptr->interlaced &&
 #endif
-             png_ptr->row_number == png_ptr->num_rows-1))
+             png_ptr->row_number == png_ptr->num_rows))
          {
            if (png_ptr->zstream.avail_in)
              png_warning(png_ptr, "Too much data in IDAT chunks");
@@ -778,8 +805,8 @@
    png_ptr->row_info.bit_depth = png_ptr->bit_depth;
    png_ptr->row_info.pixel_depth = png_ptr->pixel_depth;
 
-   png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
-      (png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
+   png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
+       png_ptr->row_info.width);
 
    png_read_filter_row(png_ptr, &(png_ptr->row_info),
       png_ptr->row_buf + 1, png_ptr->prev_row + 1,
@@ -1004,8 +1031,8 @@
             png_pass_start[png_ptr->pass]) /
             png_pass_inc[png_ptr->pass];
 
-         png_ptr->irowbytes = ((png_ptr->iwidth *
-            png_ptr->pixel_depth + 7) >> 3) + 1;
+         png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,
+            png_ptr->iwidth) + 1;
 
          if (png_ptr->transformations & PNG_INTERLACE)
             break;
@@ -1094,7 +1121,8 @@
       if (text != key + png_ptr->current_text_size)
          text++;
 
-      text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
+      text_ptr = (png_textp)png_malloc(png_ptr,
+         (png_uint_32)png_sizeof(png_text));
       text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
       text_ptr->key = key;
 #ifdef PNG_iTXt_SUPPORTED
@@ -1287,7 +1315,8 @@
       key = text;
       text += key_size;
 
-      text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
+      text_ptr = (png_textp)png_malloc(png_ptr,
+          (png_uint_32)png_sizeof(png_text));
       text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt;
       text_ptr->key = key;
 #ifdef PNG_iTXt_SUPPORTED
@@ -1399,7 +1428,8 @@
       if (text != key + png_ptr->current_text_size)
          text++;
 
-      text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
+      text_ptr = (png_textp)png_malloc(png_ptr,
+         (png_uint_32)png_sizeof(png_text));
       text_ptr->compression = comp_flag + 2;
       text_ptr->key = key;
       text_ptr->lang = lang;
@@ -1434,7 +1464,7 @@
    {
 #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
       if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
-           HANDLE_CHUNK_ALWAYS
+           PNG_HANDLE_CHUNK_ALWAYS
 #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
            && png_ptr->read_user_chunk_fn == NULL
 #endif
@@ -1473,7 +1503,7 @@
           {
              if (!(png_ptr->chunk_name[0] & 0x20))
                 if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
-                     HANDLE_CHUNK_ALWAYS)
+                     PNG_HANDLE_CHUNK_ALWAYS)
                    png_chunk_error(png_ptr, "unknown critical chunk");
           }
              png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
diff --git a/pngread.c b/pngread.c
index 42813c3..123bfce 100644
--- a/pngread.c
+++ b/pngread.c
@@ -1,9 +1,9 @@
 
 /* pngread.c - read a PNG file
  *
- * libpng 1.0.15 - October 3, 2002
+ * libpng 1.0.16 - August 15, 2004
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 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.)
  *
@@ -59,6 +59,12 @@
 #endif
 #endif /* PNG_1_0_X */
 
+   /* added at libpng-1.2.6 */
+#ifdef PNG_SET_USER_LIMITS_SUPPORTED
+   png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
+   png_ptr->user_height_max=PNG_USER_HEIGHT_MAX;
+#endif
+
 #ifdef PNG_SETJMP_SUPPORTED
 #ifdef USE_FAR_KEYWORD
    if (setjmp(jmpbuf))
@@ -77,7 +83,7 @@
       return (NULL);
    }
 #ifdef USE_FAR_KEYWORD
-   png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
+   png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf));
 #endif
 #endif
 
@@ -154,7 +160,7 @@
 #ifdef USE_FAR_KEYWORD
    if (setjmp(jmpbuf))
       PNG_ABORT();
-   png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
+   png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf));
 #else
    if (setjmp(png_ptr->jmpbuf))
       PNG_ABORT();
@@ -180,7 +186,8 @@
 {
    /* We only come here via pre-1.0.12-compiled applications */
 #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
-   if(sizeof(png_struct) > png_struct_size || sizeof(png_info) > png_info_size)
+   if(png_sizeof(png_struct) > png_struct_size || 
+      png_sizeof(png_info) > png_info_size)
    {
       char msg[80];
       png_ptr->warning_fn=NULL;
@@ -195,7 +202,7 @@
       png_warning(png_ptr, msg);
    }
 #endif
-   if(sizeof(png_struct) > png_struct_size)
+   if(png_sizeof(png_struct) > png_struct_size)
      {
        png_ptr->error_fn=NULL;
 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
@@ -204,7 +211,7 @@
        png_error(png_ptr,
        "The png struct allocated by the application for reading is too small.");
      }
-   if(sizeof(png_info) > png_info_size)
+   if(png_sizeof(png_info) > png_info_size)
      {
        png_ptr->error_fn=NULL;
 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
@@ -247,10 +254,10 @@
 
 #ifdef PNG_SETJMP_SUPPORTED
    /* save jump buffer and error functions */
-   png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
+   png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf));
 #endif
 
-   if(sizeof(png_struct) > png_struct_size)
+   if(png_sizeof(png_struct) > png_struct_size)
      {
        png_destroy_struct(png_ptr);
        *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
@@ -258,11 +265,17 @@
      }
 
    /* reset all variables to 0 */
-   png_memset(png_ptr, 0, sizeof (png_struct));
+   png_memset(png_ptr, 0, png_sizeof (png_struct));
 
 #ifdef PNG_SETJMP_SUPPORTED
    /* restore jump buffer */
-   png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
+   png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf));
+#endif
+
+   /* added at libpng-1.2.6 */
+#ifdef PNG_SET_USER_LIMITS_SUPPORTED
+   png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
+   png_ptr->user_height_max=PNG_USER_HEIGHT_MAX;
 #endif
 
    /* initialize zbuf - compression buffer */
@@ -288,6 +301,7 @@
    png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL);
 }
 
+#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
 /* Read the information before the actual image data.  This has been
  * changed in v0.90 to allow reading a file that already has the magic
  * bytes read from the stream.  You can tell libpng how many bytes have
@@ -384,7 +398,7 @@
       png_uint_32 length;
 
       png_read_data(png_ptr, chunk_length, 4);
-      length = png_get_uint_32(chunk_length);
+      length = png_get_uint_31(png_ptr,chunk_length);
 
       png_reset_crc(png_ptr);
       png_crc_read(png_ptr, png_ptr->chunk_name, 4);
@@ -392,9 +406,6 @@
       png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name,
          length);
 
-      if (length > PNG_MAX_UINT)
-         png_error(png_ptr, "Invalid chunk length.");
-
       /* This should be a binary subdivision search or a hash for
        * matching the chunk name rather than a linear search.
        */
@@ -507,6 +518,7 @@
          png_handle_unknown(png_ptr, info_ptr, length);
    }
 }
+#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
 
 /* optional call to update the users info_ptr structure */
 void PNGAPI
@@ -521,6 +533,7 @@
    png_read_transform_info(png_ptr, info_ptr);
 }
 
+#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
 /* Initialize palette, background, etc, after transformations
  * are set, but before any reading takes place.  This allows
  * the user to obtain a gamma-corrected palette, for example.
@@ -533,7 +546,9 @@
    if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
       png_read_start_row(png_ptr);
 }
+#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
 
+#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
 void PNGAPI
 png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
 {
@@ -673,10 +688,7 @@
             png_crc_finish(png_ptr, 0);
 
             png_read_data(png_ptr, chunk_length, 4);
-            png_ptr->idat_size = png_get_uint_32(chunk_length);
-
-            if (png_ptr->idat_size > PNG_MAX_UINT)
-              png_error(png_ptr, "Invalid chunk length.");
+            png_ptr->idat_size = png_get_uint_31(png_ptr,chunk_length);
 
             png_reset_crc(png_ptr);
             png_crc_read(png_ptr, png_ptr->chunk_name, 4);
@@ -712,8 +724,8 @@
    png_ptr->row_info.channels = png_ptr->channels;
    png_ptr->row_info.bit_depth = png_ptr->bit_depth;
    png_ptr->row_info.pixel_depth = png_ptr->pixel_depth;
-   png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
-      (png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
+   png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
+       png_ptr->row_info.width);
 
    if(png_ptr->row_buf[0])
    png_read_filter_row(png_ptr, &(png_ptr->row_info),
@@ -767,7 +779,9 @@
    if (png_ptr->read_row_fn != NULL)
       (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
 }
+#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
 
+#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
 /* Read one or more rows of image data.  If the image is interlaced,
  * and png_set_interlace_handling() has been called, the rows need to
  * contain the contents of the rows from the previous pass.  If the
@@ -789,7 +803,7 @@
  * 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.15
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.16
  */
 
 void PNGAPI
@@ -826,7 +840,9 @@
          dp++;
       }
 }
+#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
 
+#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
 /* Read the entire image.  If the image has an alpha channel or a tRNS
  * chunk, and you have called png_handle_alpha()[*], you will need to
  * initialize the image to the current image that PNG will be overlaying.
@@ -837,7 +853,7 @@
  * 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.15
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.16
  */
 void PNGAPI
 png_read_image(png_structp png_ptr, png_bytepp image)
@@ -871,7 +887,9 @@
       }
    }
 }
+#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
 
+#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
 /* Read the end of the PNG file.  Will not read past the end of the
  * file, will verify the end is accurate, and will read any comments
  * or time information at the end of the file, if info is not NULL.
@@ -946,16 +964,13 @@
 #endif /* PNG_GLOBAL_ARRAYS */
 
       png_read_data(png_ptr, chunk_length, 4);
-      length = png_get_uint_32(chunk_length);
+      length = png_get_uint_31(png_ptr,chunk_length);
 
       png_reset_crc(png_ptr);
       png_crc_read(png_ptr, png_ptr->chunk_name, 4);
 
       png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name);
 
-      if (length > PNG_MAX_UINT)
-         png_error(png_ptr, "Invalid chunk length.");
-
       if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
          png_handle_IHDR(png_ptr, info_ptr, length);
       else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
@@ -1058,6 +1073,7 @@
          png_handle_unknown(png_ptr, info_ptr, length);
    } while (!(png_ptr->mode & PNG_HAVE_IEND));
 }
+#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
 
 /* free all memory used by the read */
 void PNGAPI
@@ -1067,8 +1083,8 @@
    png_structp png_ptr = NULL;
    png_infop info_ptr = NULL, end_info_ptr = NULL;
 #ifdef PNG_USER_MEM_SUPPORTED
-   png_free_ptr free_fn = NULL;
-   png_voidp mem_ptr = NULL;
+   png_free_ptr free_fn;
+   png_voidp mem_ptr;
 #endif
 
    png_debug(1, "in png_destroy_read_struct\n");
@@ -1249,7 +1265,7 @@
     * being used again.
     */
 #ifdef PNG_SETJMP_SUPPORTED
-   png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
+   png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf));
 #endif
 
    error_fn = png_ptr->error_fn;
@@ -1259,7 +1275,7 @@
    free_fn = png_ptr->free_fn;
 #endif
 
-   png_memset(png_ptr, 0, sizeof (png_struct));
+   png_memset(png_ptr, 0, png_sizeof (png_struct));
 
    png_ptr->error_fn = error_fn;
    png_ptr->warning_fn = warning_fn;
@@ -1269,7 +1285,7 @@
 #endif
 
 #ifdef PNG_SETJMP_SUPPORTED
-   png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
+   png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf));
 #endif
 
 }
@@ -1280,6 +1296,8 @@
    png_ptr->read_row_fn = read_row_fn;
 }
 
+
+#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
 #if defined(PNG_INFO_IMAGE_SUPPORTED)
 void PNGAPI
 png_read_png(png_structp png_ptr, png_infop info_ptr,
@@ -1289,34 +1307,38 @@
    int row;
 
 #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
-   /* invert the alpha channel from opacity to transparency */
+   /* 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_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);
+   if (info_ptr->height > PNG_UINT_32_MAX/png_sizeof(png_bytep))
+      png_error(png_ptr,"Image is too high to process with png_read_png()");
 
    /* -------------- 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 */
+   /* tell libpng to strip 16 bit/color files down to 8 bits per 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).
+   /* 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) && !defined(PNG_READ_EXPAND_SUPPORTED)
-   /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single
+   /* Extract multiple pixels with bit depths of 1, 2, or 4 from a single
     * byte into separate bytes (useful for paletted and grayscale images).
     */
    if (transforms & PNG_TRANSFORM_PACKING)
@@ -1325,7 +1347,8 @@
 
 #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). */
+    * (not useful if you are using png_set_packing).
+    */
    if (transforms & PNG_TRANSFORM_PACKSWAP)
        png_set_packswap(png_ptr);
 #endif
@@ -1343,10 +1366,12 @@
          png_set_expand(png_ptr);
 #endif
 
-   /* We don't handle background color or gamma transformation or dithering. */
+   /* 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 */
+   /* 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
@@ -1367,19 +1392,22 @@
 #endif
 
 #if defined(PNG_READ_BGR_SUPPORTED)
-   /* flip the RGB pixels to BGR (or RGBA to BGRA) */
+   /* 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) */
+   /* 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 */
+   /* swap bytes of 16 bit files to least significant byte first
+    */
    if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
        png_set_swap(png_ptr);
 #endif
@@ -1400,7 +1428,7 @@
    if(info_ptr->row_pointers == NULL)
    {
       info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
-         info_ptr->height * sizeof(png_bytep));
+         info_ptr->height * png_sizeof(png_bytep));
 #ifdef PNG_FREE_ME_SUPPORTED
       info_ptr->free_me |= PNG_FREE_ROWS;
 #endif
@@ -1422,3 +1450,4 @@
 
 }
 #endif
+#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
diff --git a/pngrio.c b/pngrio.c
index e24b5af..7669ac2 100644
--- a/pngrio.c
+++ b/pngrio.c
@@ -1,9 +1,9 @@
 
 /* pngrio.c - functions for data input
  *
- * libpng 1.0.15 - October 3, 2002
+ * libpng 1.0.16 - August 15, 2004
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 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.)
  *
diff --git a/pngrtran.c b/pngrtran.c
index c590074..7894e39 100644
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -1,9 +1,9 @@
 
 /* pngrtran.c - transforms the data in a row for PNG readers
  *
- * libpng 1.0.15 - October 3, 2002
+ * libpng version 1.0.16 - August 15, 2004
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 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.)
  *
@@ -85,7 +85,8 @@
    }
 
    png_ptr->transformations |= PNG_BACKGROUND;
-   png_memcpy(&(png_ptr->background), background_color, sizeof(png_color_16));
+   png_memcpy(&(png_ptr->background), background_color,
+      png_sizeof(png_color_16));
    png_ptr->background_gamma = (float)background_gamma;
    png_ptr->background_gamma_type = (png_byte)(background_gamma_code);
    png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0);
@@ -154,7 +155,7 @@
       int i;
 
       png_ptr->dither_index = (png_bytep)png_malloc(png_ptr,
-         (png_uint_32)(num_palette * sizeof (png_byte)));
+         (png_uint_32)(num_palette * png_sizeof (png_byte)));
       for (i = 0; i < num_palette; i++)
          png_ptr->dither_index[i] = (png_byte)i;
    }
@@ -170,7 +171,7 @@
 
          /* initialize an array to sort colors */
          png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr,
-            (png_uint_32)(num_palette * sizeof (png_byte)));
+            (png_uint_32)(num_palette * png_sizeof (png_byte)));
 
          /* initialize the dither_sort array */
          for (i = 0; i < num_palette; i++)
@@ -299,9 +300,9 @@
 
          /* initialize palette index arrays */
          png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
-            (png_uint_32)(num_palette * sizeof (png_byte)));
+            (png_uint_32)(num_palette * png_sizeof (png_byte)));
          png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
-            (png_uint_32)(num_palette * sizeof (png_byte)));
+            (png_uint_32)(num_palette * png_sizeof (png_byte)));
 
          /* initialize the sort array */
          for (i = 0; i < num_palette; i++)
@@ -311,10 +312,10 @@
          }
 
          hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 *
-            sizeof (png_dsortp)));
+            png_sizeof (png_dsortp)));
          for (i = 0; i < 769; i++)
             hash[i] = NULL;
-/*         png_memset(hash, 0, 769 * sizeof (png_dsortp)); */
+/*         png_memset(hash, 0, 769 * png_sizeof (png_dsortp)); */
 
          num_new_palette = num_palette;
 
@@ -344,7 +345,7 @@
                   {
 
                      t = (png_dsortp)png_malloc_warn(png_ptr,
-                         (png_uint_32)(sizeof(png_dsort)));
+                         (png_uint_32)(png_sizeof(png_dsort)));
                      if (t == NULL)
                          break;
                      t->next = hash[d];
@@ -462,14 +463,15 @@
       png_size_t num_entries = ((png_size_t)1 << total_bits);
 
       png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr,
-         (png_uint_32)(num_entries * sizeof (png_byte)));
+         (png_uint_32)(num_entries * png_sizeof (png_byte)));
 
-      png_memset(png_ptr->palette_lookup, 0, num_entries * sizeof (png_byte));
+      png_memset(png_ptr->palette_lookup, 0, num_entries *
+         png_sizeof (png_byte));
 
       distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *
-         sizeof(png_byte)));
+         png_sizeof(png_byte)));
 
-      png_memset(distance, 0xff, num_entries * sizeof(png_byte));
+      png_memset(distance, 0xff, num_entries * png_sizeof(png_byte));
 
       for (i = 0; i < num_palette; i++)
       {
@@ -480,12 +482,14 @@
 
          for (ir = 0; ir < num_red; ir++)
          {
-            int dr = abs(ir - r);
+            /* int dr = abs(ir - r); */
+            int dr = ((ir > r) ? ir - r : r - ir);
             int index_r = (ir << (PNG_DITHER_BLUE_BITS + PNG_DITHER_GREEN_BITS));
 
             for (ig = 0; ig < num_green; ig++)
             {
-               int dg = abs(ig - g);
+               /* int dg = abs(ig - g); */
+               int dg = ((ig > g) ? ig - g : g - ig);
                int dt = dr + dg;
                int dm = ((dr > dg) ? dr : dg);
                int index_g = index_r | (ig << PNG_DITHER_BLUE_BITS);
@@ -493,7 +497,8 @@
                for (ib = 0; ib < num_blue; ib++)
                {
                   int d_index = index_g | ib;
-                  int db = abs(ib - b);
+                  /* int db = abs(ib - b); */
+                  int db = ((ib > b) ? ib - b : b - ib);
                   int dmax = ((dm > db) ? dm : db);
                   int d = dmax + dt + db;
 
@@ -1149,7 +1154,8 @@
 
    info_ptr->pixel_depth = (png_byte)(info_ptr->channels *
       info_ptr->bit_depth);
-   info_ptr->rowbytes = ((info_ptr->width * info_ptr->pixel_depth + 7) >> 3);
+
+   info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,info_ptr->width);
 
 #if !defined(PNG_READ_EXPAND_SUPPORTED)
    if(png_ptr)
@@ -1380,8 +1386,8 @@
 #endif
       png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
          png_ptr->row_info.channels);
-      png_ptr->row_info.rowbytes = (png_ptr->row_info.width *
-         png_ptr->row_info.pixel_depth+7)>>3;
+      png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
+         png_ptr->row_info.width);
    }
 #endif
 
@@ -1889,8 +1895,8 @@
          /* This changes the data from GG to GGXX */
          if (flags & PNG_FLAG_FILLER_AFTER)
          {
-            png_bytep sp = row + (png_size_t)row_width;
-            png_bytep dp = sp  + (png_size_t)row_width;
+            png_bytep sp = row + (png_size_t)row_width * 2;
+            png_bytep dp = sp  + (png_size_t)row_width * 2;
             for (i = 1; i < row_width; i++)
             {
                *(--dp) = hi_filler;
@@ -1907,8 +1913,8 @@
          /* This changes the data from GG to XXGG */
          else
          {
-            png_bytep sp = row + (png_size_t)row_width;
-            png_bytep dp = sp  + (png_size_t)row_width;
+            png_bytep sp = row + (png_size_t)row_width * 2;
+            png_bytep dp = sp  + (png_size_t)row_width * 2;
             for (i = 0; i < row_width; i++)
             {
                *(--dp) = *(--sp);
@@ -1921,6 +1927,7 @@
             row_info->rowbytes = row_width * 4;
          }
       }
+      row_info->color_type |= PNG_COLOR_MASK_ALPHA;
    } /* COLOR_TYPE == GRAY */
    else if (row_info->color_type == PNG_COLOR_TYPE_RGB)
    {
@@ -1965,8 +1972,8 @@
          /* This changes the data from RRGGBB to RRGGBBXX */
          if (flags & PNG_FLAG_FILLER_AFTER)
          {
-            png_bytep sp = row + (png_size_t)row_width * 3;
-            png_bytep dp = sp  + (png_size_t)row_width;
+            png_bytep sp = row + (png_size_t)row_width * 6;
+            png_bytep dp = sp  + (png_size_t)row_width * 2;
             for (i = 1; i < row_width; i++)
             {
                *(--dp) = hi_filler;
@@ -1987,8 +1994,8 @@
          /* This changes the data from RRGGBB to XXRRGGBB */
          else
          {
-            png_bytep sp = row + (png_size_t)row_width * 3;
-            png_bytep dp = sp  + (png_size_t)row_width;
+            png_bytep sp = row + (png_size_t)row_width * 6;
+            png_bytep dp = sp  + (png_size_t)row_width * 2;
             for (i = 0; i < row_width; i++)
             {
                *(--dp) = *(--sp);
@@ -2005,6 +2012,7 @@
             row_info->rowbytes = row_width * 8;
          }
       }
+      row_info->color_type |= PNG_COLOR_MASK_ALPHA;
    } /* COLOR_TYPE == RGB */
 }
 #endif
@@ -2087,8 +2095,7 @@
       row_info->color_type |= PNG_COLOR_MASK_COLOR;
       row_info->pixel_depth = (png_byte)(row_info->channels *
          row_info->bit_depth);
-      row_info->rowbytes = ((row_width *
-         row_info->pixel_depth + 7) >> 3);
+      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width);
    }
 }
 #endif
@@ -2271,7 +2278,7 @@
                   png_byte blue  = *(sp++);
                   if(red != green || red != blue)
                      rgb_error |= 1;
-                  *(dp++) =  (png_byte)((gc*red + gc*green + bc*blue)>>8);
+                  *(dp++) =  (png_byte)((rc*red + gc*green + bc*blue)>>15);
                   *(dp++) = *(sp++);  /* alpha */
                }
             }
@@ -2341,8 +2348,7 @@
       row_info->color_type &= ~PNG_COLOR_MASK_COLOR;
       row_info->pixel_depth = (png_byte)(row_info->channels *
          row_info->bit_depth);
-      row_info->rowbytes = ((row_width *
-         row_info->pixel_depth + 7) >> 3);
+      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width);
    }
    return rgb_error;
 }
@@ -3260,8 +3266,7 @@
          row_info->channels--;
          row_info->pixel_depth = (png_byte)(row_info->channels *
             row_info->bit_depth);
-         row_info->rowbytes = ((row_width *
-            row_info->pixel_depth + 7) >> 3);
+         row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width);
       }
    }
 }
@@ -3735,8 +3740,8 @@
             row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
             row_info->channels = 2;
             row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1);
-            row_info->rowbytes =
-               ((row_width * row_info->pixel_depth) >> 3);
+            row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
+               row_width);
          }
       }
       else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_value)
@@ -3790,8 +3795,7 @@
          row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
          row_info->channels = 4;
          row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2);
-         row_info->rowbytes =
-            ((row_width * row_info->pixel_depth) >> 3);
+         row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width);
       }
    }
 }
@@ -3844,8 +3848,7 @@
          row_info->color_type = PNG_COLOR_TYPE_PALETTE;
          row_info->channels = 1;
          row_info->pixel_depth = row_info->bit_depth;
-         row_info->rowbytes =
-             ((row_width * row_info->pixel_depth + 7) >> 3);
+         row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width);
       }
       else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
          palette_lookup != NULL && row_info->bit_depth == 8)
@@ -3874,8 +3877,7 @@
          row_info->color_type = PNG_COLOR_TYPE_PALETTE;
          row_info->channels = 1;
          row_info->pixel_depth = row_info->bit_depth;
-         row_info->rowbytes =
-            ((row_width * row_info->pixel_depth + 7) >> 3);
+         row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width);
       }
       else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE &&
          dither_lookup && row_info->bit_depth == 8)
@@ -4005,7 +4007,7 @@
          g = 1.0;
 
       png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr,
-         (png_uint_32)(num * sizeof (png_uint_16p)));
+         (png_uint_32)(num * png_sizeof (png_uint_16p)));
 
       if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND))
       {
@@ -4015,7 +4017,7 @@
          for (i = 0; i < num; i++)
          {
             png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
-               (png_uint_32)(256 * sizeof (png_uint_16)));
+               (png_uint_32)(256 * png_sizeof (png_uint_16)));
          }
 
          g = 1.0 / g;
@@ -4045,7 +4047,7 @@
          for (i = 0; i < num; i++)
          {
             png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
-               (png_uint_32)(256 * sizeof (png_uint_16)));
+               (png_uint_32)(256 * png_sizeof (png_uint_16)));
 
             ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4);
             for (j = 0; j < 256; j++)
@@ -4065,12 +4067,12 @@
          g = 1.0 / (png_ptr->gamma);
 
          png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr,
-            (png_uint_32)(num * sizeof (png_uint_16p )));
+            (png_uint_32)(num * png_sizeof (png_uint_16p )));
 
          for (i = 0; i < num; i++)
          {
             png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr,
-               (png_uint_32)(256 * sizeof (png_uint_16)));
+               (png_uint_32)(256 * png_sizeof (png_uint_16)));
 
             ig = (((png_uint_32)i *
                (png_uint_32)png_gamma_shift[shift]) >> 4);
@@ -4088,12 +4090,12 @@
             g = png_ptr->gamma;   /* probably doing rgb_to_gray */
 
          png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr,
-            (png_uint_32)(num * sizeof (png_uint_16p)));
+            (png_uint_32)(num * png_sizeof (png_uint_16p)));
 
          for (i = 0; i < num; i++)
          {
             png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr,
-               (png_uint_32)(256 * sizeof (png_uint_16)));
+               (png_uint_32)(256 * png_sizeof (png_uint_16)));
 
             ig = (((png_uint_32)i *
                (png_uint_32)png_gamma_shift[shift]) >> 4);
@@ -4159,15 +4161,15 @@
 
          for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
          {
-            png_uint_32 s0=*(rp  )<<8 | *(rp+1);
-            png_uint_32 s1=*(rp+2)<<8 | *(rp+3);
-            png_uint_32 s2=*(rp+4)<<8 | *(rp+5);
-            png_uint_32 red=(65536+s0+s1)&0xffff;
-            png_uint_32 blue=(65536+s2+s1)&0xffff;
-            *(rp  ) = (png_byte)((red>>8)&0xff);
-            *(rp+1) = (png_byte)(red&0xff);
-            *(rp+4) = (png_byte)((blue>>8)&0xff);
-            *(rp+5) = (png_byte)(blue&0xff);
+            png_uint_32 s0   = (*(rp  ) << 8) | *(rp+1);
+            png_uint_32 s1   = (*(rp+2) << 8) | *(rp+3);
+            png_uint_32 s2   = (*(rp+4) << 8) | *(rp+5);
+            png_uint_32 red  = (png_uint_32)((s0+s1+65536L) & 0xffffL);
+            png_uint_32 blue = (png_uint_32)((s2+s1+65536L) & 0xffffL);
+            *(rp  ) = (png_byte)((red >> 8) & 0xff);
+            *(rp+1) = (png_byte)(red & 0xff);
+            *(rp+4) = (png_byte)((blue >> 8) & 0xff);
+            *(rp+5) = (png_byte)(blue & 0xff);
          }
       }
    }
diff --git a/pngrutil.c b/pngrutil.c
index e4d23c8..158f17a 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1,9 +1,8 @@
-
 /* pngrutil.c - utilities to read a PNG file
  *
- * libpng 1.0.15 - October 3, 2002
+ * libpng version 1.0.16 - August 15, 2004
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 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.)
  *
@@ -38,6 +37,14 @@
 #  endif
 #endif
 
+png_uint_32 /* PRIVATE */
+png_get_uint_31(png_structp png_ptr, png_bytep buf)
+{
+   png_uint_32 i = png_get_uint_32(buf);
+   if (i > PNG_UINT_31_MAX)
+     png_error(png_ptr, "PNG unsigned integer out of range.\n");
+   return (i);
+}
 #ifndef PNG_READ_BIG_ENDIAN_SUPPORTED
 /* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
 png_uint_32 /* PRIVATE */
@@ -171,7 +178,7 @@
                               png_size_t prefix_size, png_size_t *newlength)
 {
    static char msg[] = "Error decoding compressed text";
-   png_charp text = NULL;
+   png_charp text;
    png_size_t text_size;
 
    if (comp_type == PNG_COMPRESSION_TYPE_BASE)
@@ -199,7 +206,7 @@
 
             if (text ==  NULL)
             {
-               text_size = prefix_size + sizeof(msg) + 1;
+               text_size = prefix_size + png_sizeof(msg) + 1;
                text = (png_charp)png_malloc_warn(png_ptr, text_size);
                if (text ==  NULL)
                  {
@@ -213,7 +220,8 @@
 
             /* Copy what we can of the error message into the text chunk */
             text_size = (png_size_t)(chunklength - (text - chunkdata) - 1);
-            text_size = sizeof(msg) > text_size ? text_size : sizeof(msg);
+            text_size = png_sizeof(msg) > text_size ? text_size :
+               png_sizeof(msg);
             png_memcpy(text + prefix_size, msg, text_size + 1);
             break;
          }
@@ -346,15 +354,14 @@
    png_crc_read(png_ptr, buf, 13);
    png_crc_finish(png_ptr, 0);
 
-   width = png_get_uint_32(buf);
-   height = png_get_uint_32(buf + 4);
+   width = png_get_uint_31(png_ptr, buf);
+   height = png_get_uint_31(png_ptr, buf + 4);
    bit_depth = buf[8];
    color_type = buf[9];
    compression_type = buf[10];
    filter_type = buf[11];
    interlace_type = buf[12];
 
-
    /* set internal variables */
    png_ptr->width = width;
    png_ptr->height = height;
@@ -364,6 +371,7 @@
 #if defined(PNG_MNG_FEATURES_SUPPORTED)
    png_ptr->filter_type = (png_byte)filter_type;
 #endif
+   png_ptr->compression_type = (png_byte)compression_type;
 
    /* find number of channels */
    switch (png_ptr->color_type)
@@ -386,8 +394,7 @@
    /* set up other useful info */
    png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth *
    png_ptr->channels);
-   png_ptr->rowbytes = ((png_ptr->width *
-      (png_uint_32)png_ptr->pixel_depth + 7) >> 3);
+   png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width);
    png_debug1(3,"bit_depth = %d\n", png_ptr->bit_depth);
    png_debug1(3,"channels = %d\n", png_ptr->channels);
    png_debug1(3,"rowbytes = %lu\n", png_ptr->rowbytes);
@@ -542,8 +549,6 @@
    if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT))
    {
       png_error(png_ptr, "No image in file");
-
-      info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */
    }
 
    png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND);
@@ -553,6 +558,9 @@
       png_warning(png_ptr, "Incorrect IEND chunk length");
    }
    png_crc_finish(png_ptr, length);
+
+   if (&info_ptr == NULL) /* quiet compiler warnings about unused info_ptr */
+      return;
 }
 
 #if defined(PNG_READ_gAMA_SUPPORTED)
@@ -579,7 +587,7 @@
       /* Should be an error, but we can cope with it */
       png_warning(png_ptr, "Out of place gAMA chunk");
 
-   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
+   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
 #if defined(PNG_READ_sRGB_SUPPORTED)
       && !(info_ptr->valid & PNG_INFO_sRGB)
 #endif
@@ -612,7 +620,7 @@
 
 #if defined(PNG_READ_sRGB_SUPPORTED)
    if (info_ptr->valid & PNG_INFO_sRGB)
-      if(igamma < 45000L || igamma > 46000L)
+      if (PNG_OUT_OF_RANGE(igamma, 45500L, 500))
       {
          png_warning(png_ptr,
            "Ignoring incorrect gAMA value when sRGB is also present");
@@ -660,7 +668,7 @@
       /* Should be an error, but we can cope with it */
       png_warning(png_ptr, "Out of place sBIT chunk");
    }
-   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT))
+   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT))
    {
       png_warning(png_ptr, "Duplicate sBIT chunk");
       png_crc_finish(png_ptr, length);
@@ -672,7 +680,7 @@
    else
       truelen = (png_size_t)png_ptr->channels;
 
-   if (length != truelen)
+   if (length != truelen || length > 4)
    {
       png_warning(png_ptr, "Incorrect sBIT chunk length");
       png_crc_finish(png_ptr, length);
@@ -729,7 +737,7 @@
       /* Should be an error, but we can cope with it */
       png_warning(png_ptr, "Missing PLTE before cHRM");
 
-   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)
+   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)
 #if defined(PNG_READ_sRGB_SUPPORTED)
       && !(info_ptr->valid & PNG_INFO_sRGB)
 #endif
@@ -825,14 +833,14 @@
 #if defined(PNG_READ_sRGB_SUPPORTED)
    if (info_ptr->valid & PNG_INFO_sRGB)
       {
-      if (abs(int_x_white - 31270L) > 1000 ||
-          abs(int_y_white - 32900L) > 1000 ||
-          abs(int_x_red   - 64000L) > 1000 ||
-          abs(int_y_red   - 33000L) > 1000 ||
-          abs(int_x_green - 30000L) > 1000 ||
-          abs(int_y_green - 60000L) > 1000 ||
-          abs(int_x_blue  - 15000L) > 1000 ||
-          abs(int_y_blue  -  6000L) > 1000)
+      if (PNG_OUT_OF_RANGE(int_x_white, 31270,  1000) ||
+          PNG_OUT_OF_RANGE(int_y_white, 32900,  1000) ||
+          PNG_OUT_OF_RANGE(int_x_red,   64000L, 1000) ||
+          PNG_OUT_OF_RANGE(int_y_red,   33000,  1000) ||
+          PNG_OUT_OF_RANGE(int_x_green, 30000,  1000) ||
+          PNG_OUT_OF_RANGE(int_y_green, 60000L, 1000) ||
+          PNG_OUT_OF_RANGE(int_x_blue,  15000,  1000) ||
+          PNG_OUT_OF_RANGE(int_y_blue,   6000,  1000))
          {
 
             png_warning(png_ptr,
@@ -891,7 +899,7 @@
       /* Should be an error, but we can cope with it */
       png_warning(png_ptr, "Out of place sRGB chunk");
 
-   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB))
+   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB))
    {
       png_warning(png_ptr, "Duplicate sRGB chunk");
       png_crc_finish(png_ptr, length);
@@ -920,15 +928,15 @@
 #if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED)
    if ((info_ptr->valid & PNG_INFO_gAMA))
    {
-   int igamma;
+   png_fixed_point igamma;
 #ifdef PNG_FIXED_POINT_SUPPORTED
-      igamma=(int)info_ptr->int_gamma;
+      igamma=info_ptr->int_gamma;
 #else
 #  ifdef PNG_FLOATING_POINT_SUPPORTED
-      igamma=(int)(info_ptr->gamma * 100000.);
+      igamma=(png_fixed_point)(info_ptr->gamma * 100000.);
 #  endif
 #endif
-      if(igamma < 45000L || igamma > 46000L)
+      if (PNG_OUT_OF_RANGE(igamma, 45500L, 500))
       {
          png_warning(png_ptr,
            "Ignoring incorrect gAMA value when sRGB is also present");
@@ -948,14 +956,14 @@
 #ifdef PNG_READ_cHRM_SUPPORTED
 #ifdef PNG_FIXED_POINT_SUPPORTED
    if (info_ptr->valid & PNG_INFO_cHRM)
-      if (abs(info_ptr->int_x_white - 31270L) > 1000 ||
-          abs(info_ptr->int_y_white - 32900L) > 1000 ||
-          abs(info_ptr->int_x_red   - 64000L) > 1000 ||
-          abs(info_ptr->int_y_red   - 33000L) > 1000 ||
-          abs(info_ptr->int_x_green - 30000L) > 1000 ||
-          abs(info_ptr->int_y_green - 60000L) > 1000 ||
-          abs(info_ptr->int_x_blue  - 15000L) > 1000 ||
-          abs(info_ptr->int_y_blue  -  6000L) > 1000)
+      if (PNG_OUT_OF_RANGE(info_ptr->int_x_white, 31270,  1000) ||
+          PNG_OUT_OF_RANGE(info_ptr->int_y_white, 32900,  1000) ||
+          PNG_OUT_OF_RANGE(info_ptr->int_x_red,   64000L, 1000) ||
+          PNG_OUT_OF_RANGE(info_ptr->int_y_red,   33000,  1000) ||
+          PNG_OUT_OF_RANGE(info_ptr->int_x_green, 30000,  1000) ||
+          PNG_OUT_OF_RANGE(info_ptr->int_y_green, 60000L, 1000) ||
+          PNG_OUT_OF_RANGE(info_ptr->int_x_blue,  15000,  1000) ||
+          PNG_OUT_OF_RANGE(info_ptr->int_y_blue,   6000,  1000))
          {
             png_warning(png_ptr,
               "Ignoring incorrect cHRM value when sRGB is also present");
@@ -977,8 +985,7 @@
    png_bytep pC;
    png_charp profile;
    png_uint_32 skip = 0;
-   png_uint_32 profile_size = 0;
-   png_uint_32 profile_length = 0;
+   png_uint_32 profile_size, profile_length;
    png_size_t slength, prefix_length, data_length;
 
    png_debug(1, "in png_handle_iCCP\n");
@@ -995,7 +1002,7 @@
       /* Should be an error, but we can cope with it */
       png_warning(png_ptr, "Out of place iCCP chunk");
 
-   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP))
+   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP))
    {
       png_warning(png_ptr, "Duplicate iCCP chunk");
       png_crc_finish(png_ptr, length);
@@ -1153,9 +1160,20 @@
       return;
    }
 
-   new_palette.nentries = data_length / entry_size;
-   new_palette.entries = (png_sPLT_entryp)png_malloc(
-       png_ptr, new_palette.nentries * sizeof(png_sPLT_entry));
+   new_palette.nentries = (png_uint_32) (data_length / entry_size);
+   if ((png_uint_32) new_palette.nentries > (png_uint_32) (PNG_SIZE_MAX /
+       png_sizeof(png_sPLT_entry)))
+   {
+       png_warning(png_ptr, "sPLT chunk too long");
+       return;
+   }
+   new_palette.entries = (png_sPLT_entryp)png_malloc_warn(
+       png_ptr, new_palette.nentries * png_sizeof(png_sPLT_entry));
+   if (new_palette.entries == NULL)
+   {
+       png_warning(png_ptr, "sPLT chunk requires too much memory");
+       return;
+   }
 
 #ifndef PNG_NO_POINTER_INDEXING
    for (i = 0; i < new_palette.nentries; i++)
@@ -1234,49 +1252,9 @@
       return;
    }
 
-   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
+   if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)
    {
-      if (!(png_ptr->mode & PNG_HAVE_PLTE))
-      {
-         /* Should be an error, but we can cope with it */
-         png_warning(png_ptr, "Missing PLTE before tRNS");
-      }
-      else if (length > (png_uint_32)png_ptr->num_palette)
-      {
-         png_warning(png_ptr, "Incorrect tRNS chunk length");
-         png_crc_finish(png_ptr, length);
-         return;
-      }
-      if (length == 0)
-      {
-         png_warning(png_ptr, "Zero length tRNS chunk");
-         png_crc_finish(png_ptr, length);
-         return;
-      }
-
-      png_crc_read(png_ptr, readbuf, (png_size_t)length);
-      png_ptr->num_trans = (png_uint_16)length;
-   }
-   else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
-   {
-      png_byte buf[6];
-
-      if (length != 6)
-      {
-         png_warning(png_ptr, "Incorrect tRNS chunk length");
-         png_crc_finish(png_ptr, length);
-         return;
-      }
-
-      png_crc_read(png_ptr, buf, (png_size_t)length);
-      png_ptr->num_trans = 1;
-      png_ptr->trans_values.red = png_get_uint_16(buf);
-      png_ptr->trans_values.green = png_get_uint_16(buf + 2);
-      png_ptr->trans_values.blue = png_get_uint_16(buf + 4);
-   }
-   else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)
-   {
-      png_byte buf[6];
+      png_byte buf[2];
 
       if (length != 2)
       {
@@ -1289,6 +1267,45 @@
       png_ptr->num_trans = 1;
       png_ptr->trans_values.gray = png_get_uint_16(buf);
    }
+   else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
+   {
+      png_byte buf[6];
+
+      if (length != 6)
+      {
+         png_warning(png_ptr, "Incorrect tRNS chunk length");
+         png_crc_finish(png_ptr, length);
+         return;
+      }
+      png_crc_read(png_ptr, buf, (png_size_t)length);
+      png_ptr->num_trans = 1;
+      png_ptr->trans_values.red = png_get_uint_16(buf);
+      png_ptr->trans_values.green = png_get_uint_16(buf + 2);
+      png_ptr->trans_values.blue = png_get_uint_16(buf + 4);
+   }
+   else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
+   {
+      if (!(png_ptr->mode & PNG_HAVE_PLTE))
+      {
+         /* Should be an error, but we can cope with it. */
+         png_warning(png_ptr, "Missing PLTE before tRNS");
+      }
+      if (length > (png_uint_32)png_ptr->num_palette ||
+          length > PNG_MAX_PALETTE_LENGTH)
+      {
+         png_warning(png_ptr, "Incorrect tRNS chunk length");
+         png_crc_finish(png_ptr, length);
+         return;
+      }
+      if (length == 0)
+      {
+         png_warning(png_ptr, "Zero length tRNS chunk");
+         png_crc_finish(png_ptr, length);
+         return;
+      }
+      png_crc_read(png_ptr, readbuf, (png_size_t)length);
+      png_ptr->num_trans = (png_uint_16)length;
+   }
    else
    {
       png_warning(png_ptr, "tRNS chunk not allowed with alpha channel");
@@ -1397,7 +1414,7 @@
 void /* PRIVATE */
 png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
 {
-   int num, i;
+   unsigned int num, i;
    png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH];
 
    png_debug(1, "in png_handle_hIST\n");
@@ -1423,8 +1440,9 @@
       return;
    }
 
-   num = (int)length / 2 ;
-   if (num != png_ptr->num_palette)
+   num = length / 2 ;
+   if (num != (unsigned int) png_ptr->num_palette || num >
+      (unsigned int) PNG_MAX_PALETTE_LENGTH)
    {
       png_warning(png_ptr, "Incorrect hIST chunk length");
       png_crc_finish(png_ptr, length);
@@ -1625,7 +1643,7 @@
 
    png_debug(3, "Allocating pCAL parameters array\n");
    params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)(nparams
-      *sizeof(png_charp))) ;
+      *png_sizeof(png_charp))) ;
    if (params == NULL)
      {
        png_free(png_ptr, purpose);
@@ -1883,7 +1901,8 @@
    if (text != key + slength)
       text++;
 
-   text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)sizeof(png_text));
+   text_ptr = (png_textp)png_malloc_warn(png_ptr,
+      (png_uint_32)png_sizeof(png_text));
    if (text_ptr == NULL)
    {
      png_warning(png_ptr, "Not enough memory to process text chunk.");
@@ -1979,7 +1998,8 @@
    chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata,
                                     (png_size_t)length, prefix_len, &data_len);
 
-   text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)sizeof(png_text));
+   text_ptr = (png_textp)png_malloc_warn(png_ptr,
+     (png_uint_32)png_sizeof(png_text));
    if (text_ptr == NULL)
    {
      png_warning(png_ptr,"Not enough memory to process zTXt chunk.");
@@ -2088,7 +2108,8 @@
           (size_t)length, prefix_len, &data_len);
    else
        data_len=png_strlen(chunkdata + prefix_len);
-   text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)sizeof(png_text));
+   text_ptr = (png_textp)png_malloc_warn(png_ptr,
+      (png_uint_32)png_sizeof(png_text));
    if (text_ptr == NULL)
    {
      png_warning(png_ptr,"Not enough memory to process iTXt chunk.");
@@ -2139,7 +2160,7 @@
    {
 #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
       if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
-           HANDLE_CHUNK_ALWAYS
+           PNG_HANDLE_CHUNK_ALWAYS
 #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
            && png_ptr->read_user_chunk_fn == NULL
 #endif
@@ -2173,7 +2194,7 @@
           {
              if (!(png_ptr->chunk_name[0] & 0x20))
                 if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
-                     HANDLE_CHUNK_ALWAYS)
+                     PNG_HANDLE_CHUNK_ALWAYS)
                  {
                    png_free(png_ptr, chunk.data);
                    png_chunk_error(png_ptr, "unknown critical chunk");
@@ -2193,7 +2214,8 @@
    png_crc_finish(png_ptr, skip);
 
 #if !defined(PNG_READ_USER_CHUNKS_SUPPORTED)
-   info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */
+   if (&info_ptr == NULL) /* quiet compiler warnings about unused info_ptr */
+      return;
 #endif
 }
 
@@ -2203,7 +2225,7 @@
    functions to handle unknown critical chunks after we check that
    the chunk name itself is valid. */
 
-#define isnonalpha(c) ((c) < 41 || (c) > 122 || ((c) > 90 && (c) < 97))
+#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
 
 void /* PRIVATE */
 png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name)
@@ -2234,8 +2256,7 @@
    if (mask == 0xff)
    {
       png_memcpy(row, png_ptr->row_buf + 1,
-         (png_size_t)((png_ptr->width *
-         png_ptr->row_info.pixel_depth + 7) >> 3));
+         PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->width));
    }
    else
    {
@@ -2650,11 +2671,11 @@
          }
       }
       row_info->width = final_width;
-      row_info->rowbytes = ((final_width *
-         (png_uint_32)row_info->pixel_depth + 7) >> 3);
+      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width);
    }
 #if !defined(PNG_READ_PACKSWAP_SUPPORTED)
-   transformations = transformations; /* silence compiler warning */
+   if (&transformations == NULL) /* silence compiler warning */
+      return;
 #endif
 }
 #endif /* !PNG_HAVE_ASSEMBLER_READ_INTERLACE */
@@ -2822,8 +2843,9 @@
             png_pass_inc[png_ptr->pass] - 1 -
             png_pass_start[png_ptr->pass]) /
             png_pass_inc[png_ptr->pass];
-            png_ptr->irowbytes = ((png_ptr->iwidth *
-               (png_uint_32)png_ptr->pixel_depth + 7) >> 3) +1;
+
+         png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,
+            png_ptr->iwidth) + 1;
 
          if (!(png_ptr->transformations & PNG_INTERLACE))
          {
@@ -2863,8 +2885,7 @@
                png_crc_finish(png_ptr, 0);
 
                png_read_data(png_ptr, chunk_length, 4);
-               png_ptr->idat_size = png_get_uint_32(chunk_length);
-
+               png_ptr->idat_size = png_get_uint_31(png_ptr, chunk_length);
                png_reset_crc(png_ptr);
                png_crc_read(png_ptr, png_ptr->chunk_name, 4);
                if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4))
@@ -2950,8 +2971,8 @@
          png_pass_start[png_ptr->pass]) /
          png_pass_inc[png_ptr->pass];
 
-         row_bytes = ((png_ptr->iwidth *
-            (png_uint_32)png_ptr->pixel_depth + 7) >> 3) +1;
+         row_bytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->iwidth) + 1;
+
          png_ptr->irowbytes = (png_size_t)row_bytes;
          if((png_uint_32)png_ptr->irowbytes != row_bytes)
             png_error(png_ptr, "Rowbytes overflow in png_read_start_row");
@@ -3069,7 +3090,7 @@
    row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7));
    /* calculate the maximum bytes needed, adding a byte and a pixel
       for safety's sake */
-   row_bytes = ((row_bytes * (png_uint_32)max_pixel_depth + 7) >> 3) +
+   row_bytes = PNG_ROWBYTES(max_pixel_depth,row_bytes) +
       1 + ((max_pixel_depth + 7) >> 3);
 #ifdef PNG_MAX_MALLOC_64K
    if (row_bytes > (png_uint_32)65536L)
@@ -3085,6 +3106,8 @@
    if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L)
       png_error(png_ptr, "This image requires a row greater than 64KB");
 #endif
+   if ((png_uint_32)png_ptr->rowbytes + 1 > PNG_SIZE_MAX)
+      png_error(png_ptr, "Row has too many bytes to allocate in memory.");
    png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)(
       png_ptr->rowbytes + 1));
 
diff --git a/pngset.c b/pngset.c
index 4b3aee3..5927edb 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1,9 +1,9 @@
 
 /* pngset.c - storage of image information into info struct
  *
- * libpng 1.0.15 - October 3, 2002
+ * libpng 1.0.16 - August 15, 2004
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 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.)
  *
@@ -24,7 +24,7 @@
    if (png_ptr == NULL || info_ptr == NULL)
       return;
 
-   png_memcpy(&(info_ptr->background), background, sizeof(png_color_16));
+   png_memcpy(&(info_ptr->background), background, png_sizeof(png_color_16));
    info_ptr->valid |= PNG_INFO_bKGD;
 }
 #endif
@@ -100,10 +100,14 @@
         "Ignoring attempt to set negative chromaticity value");
       return;
    }
-   if (white_x > (double) PNG_MAX_UINT || white_y > (double) PNG_MAX_UINT ||
-         red_x > (double) PNG_MAX_UINT ||   red_y > (double) PNG_MAX_UINT ||
-       green_x > (double) PNG_MAX_UINT || green_y > (double) PNG_MAX_UINT ||
-        blue_x > (double) PNG_MAX_UINT ||  blue_y > (double) PNG_MAX_UINT)
+   if (white_x > (double) PNG_UINT_31_MAX ||
+       white_y > (double) PNG_UINT_31_MAX ||
+         red_x > (double) PNG_UINT_31_MAX ||
+         red_y > (double) PNG_UINT_31_MAX ||
+       green_x > (double) PNG_UINT_31_MAX ||
+       green_y > (double) PNG_UINT_31_MAX ||
+        blue_x > (double) PNG_UINT_31_MAX ||
+        blue_y > (double) PNG_UINT_31_MAX)
    {
       png_warning(png_ptr,
         "Ignoring attempt to set chromaticity value exceeding 21474.83");
@@ -169,10 +173,10 @@
    if (png_ptr == NULL || info_ptr == NULL)
       return;
 
-   if (int_gamma > (png_fixed_point) PNG_MAX_UINT)
+   if (int_gamma > (png_fixed_point) PNG_UINT_31_MAX)
    {
      png_warning(png_ptr, "Limiting gamma to 21474.83");
-     gamma=PNG_MAX_UINT;
+     gamma=PNG_UINT_31_MAX;
    }
    else
    {
@@ -217,7 +221,7 @@
 #endif
    /* Changed from info->num_palette to 256 in version 1.2.1 */
    png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr,
-      (png_uint_32)(256 * sizeof (png_uint_16)));
+      (png_uint_32)(256 * png_sizeof (png_uint_16)));
    if (png_ptr->hist == NULL)
      {
        png_warning(png_ptr, "Insufficient memory for hIST chunk data.");
@@ -243,7 +247,6 @@
    int color_type, int interlace_type, int compression_type,
    int filter_type)
 {
-   int rowbytes_per_pixel;
    png_debug1(1, "in %s storage function\n", "IHDR");
    if (png_ptr == NULL || info_ptr == NULL)
       return;
@@ -251,8 +254,22 @@
    /* check for width and height valid values */
    if (width == 0 || height == 0)
       png_error(png_ptr, "Image width or height is zero in IHDR");
-   if (width > PNG_MAX_UINT || height > PNG_MAX_UINT)
+#ifdef PNG_SET_USER_LIMITS_SUPPORTED
+   if (width > png_ptr->user_width_max || height > png_ptr->user_height_max)
+      png_error(png_ptr, "image size exceeds user limits in IHDR");
+#else
+   if (width > PNG_USER_WIDTH_MAX || height > PNG_USER_HEIGHT_MAX)
+      png_error(png_ptr, "image size exceeds user limits in IHDR");
+#endif
+   if (width > PNG_UINT_31_MAX || height > PNG_UINT_31_MAX)
       png_error(png_ptr, "Invalid image size in IHDR");
+   if ( width > (PNG_UINT_32_MAX
+                 >> 3)      /* 8-byte RGBA pixels */
+                 - 64       /* bigrowbuf hack */
+                 - 1        /* filter byte */
+                 - 7*8      /* rounding of width to multiple of 8 pixels */
+                 - 8)       /* extra max_pixel_depth pad */
+      png_warning(png_ptr, "Width is too large for libpng to process pixels");
 
    /* check other values */
    if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&
@@ -320,16 +337,16 @@
       info_ptr->channels++;
    info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
 
-   /* check for overflow */
-   rowbytes_per_pixel = (info_ptr->pixel_depth + 7) >> 3;
-   if ( width > PNG_MAX_UINT/rowbytes_per_pixel - 64)
-   {
-      png_warning(png_ptr,
-         "Width too large to process image data; rowbytes will overflow.");
+   /* check for potential overflow */
+   if ( width > (PNG_UINT_32_MAX
+                 >> 3)      /* 8-byte RGBA pixels */
+                 - 64       /* bigrowbuf hack */
+                 - 1        /* filter byte */
+                 - 7*8      /* rounding of width to multiple of 8 pixels */
+                 - 8)       /* extra max_pixel_depth pad */
       info_ptr->rowbytes = (png_size_t)0;
-   }
    else
-      info_ptr->rowbytes = (info_ptr->width * info_ptr->pixel_depth + 7) >> 3;
+      info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,width);
 }
 
 #if defined(PNG_oFFs_SUPPORTED)
@@ -388,7 +405,7 @@
    png_memcpy(info_ptr->pcal_units, units, (png_size_t)length);
 
    info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr,
-      (png_uint_32)((nparams + 1) * sizeof(png_charp)));
+      (png_uint_32)((nparams + 1) * png_sizeof(png_charp)));
    if (info_ptr->pcal_params == NULL)
      {
        png_warning(png_ptr, "Insufficient memory for pCAL params.");
@@ -449,12 +466,21 @@
 
    length = png_strlen(swidth) + 1;
    png_debug1(3, "allocating unit for info (%d bytes)\n", length);
-   info_ptr->scal_s_width = (png_charp)png_malloc(png_ptr, length);
+   info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length);
+   if (info_ptr->scal_s_width == NULL)
+   {
+      png_warning(png_ptr, "Memory allocation failed while processing sCAL.");
+   }
    png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length);
 
    length = png_strlen(sheight) + 1;
    png_debug1(3, "allocating unit for info (%d bytes)\n", length);
-   info_ptr->scal_s_height = (png_charp)png_malloc(png_ptr, length);
+   info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length);
+   if (info_ptr->scal_s_height == NULL)
+   {
+      png_free (png_ptr, info_ptr->scal_s_width);
+      png_warning(png_ptr, "Memory allocation failed while processing sCAL.");
+   }
    png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length);
 
    info_ptr->valid |= PNG_INFO_sCAL;
@@ -499,13 +525,13 @@
 #ifdef PNG_FREE_ME_SUPPORTED
    png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
 #endif
+
    /* 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));
-   if (png_ptr->palette == NULL)
-      png_error(png_ptr, "Unable to malloc palette");
-   png_memcpy(png_ptr->palette, palette, num_palette * sizeof (png_color));
+   png_ptr->palette = (png_colorp)png_malloc(png_ptr,
+      256 * png_sizeof(png_color));
+   png_memset(png_ptr->palette, 0, 256 * png_sizeof(png_color));
+   png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof (png_color));
    info_ptr->palette = png_ptr->palette;
    info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
 
@@ -527,7 +553,7 @@
    if (png_ptr == NULL || info_ptr == NULL)
       return;
 
-   png_memcpy(&(info_ptr->sig_bit), sig_bit, sizeof (png_color_8));
+   png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof (png_color_8));
    info_ptr->valid |= PNG_INFO_sBIT;
 }
 #endif
@@ -628,9 +654,20 @@
    if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
       return;
 
-   new_iccp_name = (png_charp)png_malloc(png_ptr, png_strlen(name)+1);
+   new_iccp_name = (png_charp)png_malloc_warn(png_ptr, png_strlen(name)+1);
+   if (new_iccp_name == NULL)
+   {
+      png_warning(png_ptr, "Insufficient memory to process iCCP chunk.");
+      return;
+   }
    png_strcpy(new_iccp_name, name);
-   new_iccp_profile = (png_charp)png_malloc(png_ptr, proflen);
+   new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen);
+   if (new_iccp_profile == NULL)
+   {
+      png_free (png_ptr, new_iccp_name);
+      png_warning(png_ptr, "Insufficient memory to process iCCP profile.");
+      return;
+   }
    png_memcpy(new_iccp_profile, profile, (png_size_t)proflen);
 
    png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0);
@@ -685,14 +722,14 @@
          info_ptr->max_text = info_ptr->num_text + num_text + 8;
          old_text = info_ptr->text;
          info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
-            (png_uint_32)(info_ptr->max_text * sizeof (png_text)));
+            (png_uint_32)(info_ptr->max_text * png_sizeof (png_text)));
          if (info_ptr->text == NULL)
            {
              png_free(png_ptr, old_text);
              return(1);
            }
          png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max *
-            sizeof(png_text)));
+            png_sizeof(png_text)));
          png_free(png_ptr, old_text);
       }
       else
@@ -700,7 +737,7 @@
          info_ptr->max_text = num_text + 8;
          info_ptr->num_text = 0;
          info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
-            (png_uint_32)(info_ptr->max_text * sizeof (png_text)));
+            (png_uint_32)(info_ptr->max_text * png_sizeof (png_text)));
          if (info_ptr->text == NULL)
            return(1);
 #ifdef PNG_FREE_ME_SUPPORTED
@@ -829,7 +866,7 @@
        (png_ptr->mode & PNG_WROTE_tIME))
       return;
 
-   png_memcpy(&(info_ptr->mod_time), mod_time, sizeof (png_time));
+   png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof (png_time));
    info_ptr->valid |= PNG_INFO_tIME;
 }
 #endif
@@ -867,7 +904,7 @@
    if (trans_values != NULL)
    {
       png_memcpy(&(info_ptr->trans_values), trans_values,
-         sizeof(png_color_16));
+         png_sizeof(png_color_16));
       if (num_trans == 0)
         num_trans = 1;
    }
@@ -885,7 +922,7 @@
     int i;
 
     np = (png_sPLT_tp)png_malloc_warn(png_ptr,
-        (info_ptr->splt_palettes_num + nentries) * sizeof(png_sPLT_t));
+        (info_ptr->splt_palettes_num + nentries) * png_sizeof(png_sPLT_t));
     if (np == NULL)
     {
       png_warning(png_ptr, "No memory for sPLT palettes.");
@@ -893,7 +930,7 @@
     }
 
     png_memcpy(np, info_ptr->splt_palettes,
-           info_ptr->splt_palettes_num * sizeof(png_sPLT_t));
+           info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t));
     png_free(png_ptr, info_ptr->splt_palettes);
     info_ptr->splt_palettes=NULL;
 
@@ -904,11 +941,13 @@
 
         to->name = (png_charp)png_malloc(png_ptr,
             png_strlen(from->name) + 1);
+        /* TODO: use png_malloc_warn */
         png_strcpy(to->name, from->name);
         to->entries = (png_sPLT_entryp)png_malloc(png_ptr,
-            from->nentries * sizeof(png_sPLT_t));
+            from->nentries * png_sizeof(png_sPLT_t));
+        /* TODO: use png_malloc_warn */
         png_memcpy(to->entries, from->entries,
-            from->nentries * sizeof(png_sPLT_t));
+            from->nentries * png_sizeof(png_sPLT_t));
         to->nentries = from->nentries;
         to->depth = from->depth;
     }
@@ -935,7 +974,7 @@
 
     np = (png_unknown_chunkp)png_malloc_warn(png_ptr,
         (info_ptr->unknown_chunks_num + num_unknowns) *
-        sizeof(png_unknown_chunk));
+        png_sizeof(png_unknown_chunk));
     if (np == NULL)
     {
        png_warning(png_ptr, "Out of memory while processing unknown chunk.");
@@ -943,7 +982,7 @@
     }
 
     png_memcpy(np, info_ptr->unknown_chunks,
-           info_ptr->unknown_chunks_num * sizeof(png_unknown_chunk));
+           info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk));
     png_free(png_ptr, info_ptr->unknown_chunks);
     info_ptr->unknown_chunks=NULL;
 
@@ -952,17 +991,19 @@
         png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
         png_unknown_chunkp from = unknowns + i;
 
-        png_strcpy((png_charp)to->name, (png_charp)from->name);
-        to->data = (png_bytep)png_malloc(png_ptr, from->size);
+        png_strncpy((png_charp)to->name, (png_charp)from->name, 5);
+        to->data = (png_bytep)png_malloc_warn(png_ptr, from->size);
         if (to->data == NULL)
-           png_warning(png_ptr, "Out of memory while processing unknown chunk.");
+        {
+           png_warning(png_ptr, "Out of memory processing unknown chunk.");
+        }
         else
         {
-          png_memcpy(to->data, from->data, from->size);
-          to->size = from->size;
+           png_memcpy(to->data, from->data, from->size);
+           to->size = from->size;
 
-          /* note our location in the read or write sequence */
-          to->location = (png_byte)(png_ptr->mode & 0xff);
+           /* note our location in the read or write sequence */
+           to->location = (png_byte)(png_ptr->mode & 0xff);
         }
     }
 
@@ -1020,12 +1061,12 @@
     int i, old_num_chunks;
     if (num_chunks == 0)
     {
-      if(keep == HANDLE_CHUNK_ALWAYS || keep == HANDLE_CHUNK_IF_SAFE)
+      if(keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE)
         png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
       else
         png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
 
-      if(keep == HANDLE_CHUNK_ALWAYS)
+      if(keep == PNG_HANDLE_CHUNK_ALWAYS)
         png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS;
       else
         png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS;
@@ -1083,6 +1124,7 @@
 }
 #endif
 
+#ifdef PNG_WRITE_SUPPORTED
 void PNGAPI
 png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size)
 {
@@ -1093,6 +1135,7 @@
     png_ptr->zstream.next_out = png_ptr->zbuf;
     png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
 }
+#endif
 
 void PNGAPI
 png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)
@@ -1157,4 +1200,20 @@
     png_ptr->mmx_rowbytes_threshold = mmx_rowbytes_threshold;
 }
 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
+
+#ifdef PNG_SET_USER_LIMITS_SUPPORTED
+/* this function was added to libpng 1.2.6 */
+void PNGAPI
+png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,
+    png_uint_32 user_height_max)
+{
+    /* Images with dimensions larger than these limits will be
+     * rejected by png_set_IHDR().  To accept any PNG datastream
+     * regardless of dimensions, set both limits to 0x7ffffffL.
+     */
+    png_ptr->user_width_max = user_width_max;
+    png_ptr->user_height_max = user_height_max;
+}
+#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
+
 #endif /* ?PNG_1_0_X */
diff --git a/pngtest.c b/pngtest.c
index 4b15f23..ab08605 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -1,9 +1,9 @@
 
 /* pngtest.c - a simple test program to test libpng
  *
- * libpng 1.0.15 - October 3, 2002
+ * libpng 1.0.16 - August 15, 2004
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 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.)
  *
@@ -28,6 +28,8 @@
  * of files at once by typing "pngtest -m file1.png file2.png ..."
  */
 
+#include "png.h"
+
 #if defined(_WIN32_WCE)
 #  if _WIN32_WCE < 211
      __error__ (f|w)printf functions are not supported on old WindowsCE.;
@@ -80,8 +82,6 @@
 #include <time.h>
 #endif
 
-#include "png.h"
-
 /* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
 #ifndef png_jmpbuf
 #  define png_jmpbuf(png_ptr) png_ptr->jmpbuf
@@ -127,7 +127,7 @@
 #endif
 read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
 {
-    if(png_ptr == NULL || row_number > PNG_MAX_UINT) return;
+    if(png_ptr == NULL || row_number > PNG_UINT_31_MAX) return;
     if(status_pass != pass)
     {
        fprintf(stdout,"\n Pass %d: ",pass);
@@ -154,7 +154,7 @@
 #endif
 write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
 {
-    if(png_ptr == NULL || row_number > PNG_MAX_UINT || pass > 7) return;
+    if(png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7) return;
     fprintf(stdout, "w");
 }
 
@@ -470,7 +470,7 @@
 /* END of code to validate stdio-free compilation */
 
 /* START of code to validate memory allocation and deallocation */
-#ifdef PNG_USER_MEM_SUPPORTED
+#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
 
 /* Allocate memory.  For reasonable files, size should never exceed
    64K.  However, zlib may allocate more then 64K if you don't tell
@@ -510,23 +510,34 @@
    /* This calls the library allocator twice, once to get the requested
       buffer and once to get a new free list entry. */
    {
-      memory_infop pinfo = (memory_infop)png_malloc_default(png_ptr,
-         (png_uint_32)sizeof *pinfo);
+      /* Disable malloc_fn and free_fn */
+      memory_infop pinfo;
+      png_set_mem_fn(png_ptr, NULL, NULL, NULL);
+      pinfo = (memory_infop)png_malloc(png_ptr,
+         (png_uint_32)png_sizeof (*pinfo));
       pinfo->size = size;
       current_allocation += size;
       total_allocation += size;
       num_allocations ++;
       if (current_allocation > maximum_allocation)
          maximum_allocation = current_allocation;
-      pinfo->pointer = (png_voidp)png_malloc_default(png_ptr, size);
+      pinfo->pointer = (png_voidp)png_malloc(png_ptr, size);
+      /* Restore malloc_fn and free_fn */
+      png_set_mem_fn(png_ptr, png_voidp_NULL, (png_malloc_ptr)png_debug_malloc,
+         (png_free_ptr)png_debug_free);
+      if (size != 0 && pinfo->pointer == NULL)
+      {
+         current_allocation -= size;
+         total_allocation -= size;
+         png_error(png_ptr,
+           "out of memory in pngtest->png_debug_malloc.");
+      }
       pinfo->next = pinformation;
       pinformation = pinfo;
       /* Make sure the caller isn't assuming zeroed memory. */
       png_memset(pinfo->pointer, 0xdd, pinfo->size);
-#if PNG_DEBUG
       if(verbose)
          printf("png_malloc %lu bytes at %x\n",size,pinfo->pointer);
-#endif
       assert(pinfo->size != 12345678);
       return (png_voidp)(pinfo->pointer);
    }
@@ -575,14 +586,12 @@
    }
 
    /* Finally free the data. */
-#if PNG_DEBUG
    if(verbose)
       printf("Freeing %x\n",ptr);
-#endif
    png_free_default(png_ptr, ptr);
    ptr=NULL;
 }
-#endif /* PNG_USER_MEM_SUPPORTED */
+#endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */
 /* END of code to test memory allocation/deallocation */
 
 /* Test one file */
@@ -644,7 +653,7 @@
    }
 
    png_debug(0, "Allocating read and write structures\n");
-#ifdef PNG_USER_MEM_SUPPORTED
+#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
    read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
       png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL,
       (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
@@ -657,7 +666,7 @@
        pngtest_warning);
 #endif
 #ifdef PNG_WRITE_SUPPORTED
-#ifdef PNG_USER_MEM_SUPPORTED
+#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
    write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
       png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL,
       (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
@@ -699,7 +708,7 @@
       return (1);
    }
 #ifdef USE_FAR_KEYWORD
-   png_memcpy(png_jmpbuf(read_ptr),jmpbuf,sizeof(jmp_buf));
+   png_memcpy(png_jmpbuf(read_ptr),jmpbuf,png_sizeof(jmp_buf));
 #endif
 
 #ifdef PNG_WRITE_SUPPORTED
@@ -721,7 +730,7 @@
       return (1);
    }
 #ifdef USE_FAR_KEYWORD
-   png_memcpy(png_jmpbuf(write_ptr),jmpbuf,sizeof(jmp_buf));
+   png_memcpy(png_jmpbuf(write_ptr),jmpbuf,png_sizeof(jmp_buf));
 #endif
 #endif
 #endif
@@ -771,14 +780,18 @@
    png_set_write_user_transform_fn(write_ptr, count_zero_samples);
 #endif
 
-#define HANDLE_CHUNK_IF_SAFE      2
-#define HANDLE_CHUNK_ALWAYS       3
 #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
-   png_set_keep_unknown_chunks(read_ptr, HANDLE_CHUNK_ALWAYS,
+#  ifndef PNG_HANDLE_CHUNK_ALWAYS
+#    define PNG_HANDLE_CHUNK_ALWAYS       3
+#  endif
+   png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS,
       png_bytep_NULL, 0);
 #endif
 #if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
-   png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_IF_SAFE,
+#  ifndef PNG_HANDLE_CHUNK_IF_SAFE
+#    define PNG_HANDLE_CHUNK_IF_SAFE      2
+#  endif
+   png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_IF_SAFE,
       png_bytep_NULL, 0);
 #endif
 
@@ -1306,8 +1319,8 @@
    /* Show the version of libpng used in building the application */
    fprintf(STDERR," pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER,
       PNG_HEADER_VERSION_STRING);
-   fprintf(STDERR," sizeof(png_struct)=%ld, sizeof(png_info)=%ld\n",
-                    (long)sizeof(png_struct), (long)sizeof(png_info));
+   fprintf(STDERR," png_sizeof(png_struct)=%ld, png_sizeof(png_info)=%ld\n",
+                    (long)png_sizeof(png_struct), (long)png_sizeof(png_info));
 
    /* Do some consistency checking on the memory allocation settings, I'm
       not sure this matters, but it is nice to know, the first of these
@@ -1375,7 +1388,7 @@
    if (multiple)
    {
       int i;
-#ifdef PNG_USER_MEM_SUPPORTED
+#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
       int allocation_now = current_allocation;
 #endif
       for (i=2; i<argc; ++i)
@@ -1410,7 +1423,7 @@
             fprintf(STDERR, " FAIL\n");
             ierror += kerror;
          }
-#ifdef PNG_USER_MEM_SUPPORTED
+#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
          if (allocation_now != current_allocation)
             fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
                current_allocation-allocation_now);
@@ -1429,7 +1442,7 @@
          }
 #endif
       }
-#ifdef PNG_USER_MEM_SUPPORTED
+#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
          fprintf(STDERR, " Current memory allocation: %10d bytes\n",
             current_allocation);
          fprintf(STDERR, " Maximum memory allocation: %10d bytes\n",
@@ -1446,7 +1459,7 @@
       for (i=0; i<3; ++i)
       {
          int kerror;
-#ifdef PNG_USER_MEM_SUPPORTED
+#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
          int allocation_now = current_allocation;
 #endif
          if (i == 1) status_dots_requested = 1;
@@ -1485,7 +1498,7 @@
             fprintf(STDERR, " FAIL\n");
             ierror += kerror;
          }
-#ifdef PNG_USER_MEM_SUPPORTED
+#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
          if (allocation_now != current_allocation)
              fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
                current_allocation-allocation_now);
@@ -1504,7 +1517,7 @@
           }
 #endif
        }
-#ifdef PNG_USER_MEM_SUPPORTED
+#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
        fprintf(STDERR, " Current memory allocation: %10d bytes\n",
           current_allocation);
        fprintf(STDERR, " Maximum memory allocation: %10d bytes\n",
@@ -1538,4 +1551,4 @@
 }
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef version_1_0_15 your_png_h_is_not_version_1_0_15;
+typedef version_1_0_16 your_png_h_is_not_version_1_0_16;
diff --git a/pngtest.png b/pngtest.png
index f3a6df4..ebea081 100644
--- a/pngtest.png
+++ b/pngtest.png
Binary files differ
diff --git a/pngtrans.c b/pngtrans.c
index a71bea4..7c5ba4f 100644
--- a/pngtrans.c
+++ b/pngtrans.c
@@ -1,9 +1,9 @@
 
 /* pngtrans.c - transforms the data in a row (used by both readers and writers)
  *
- * libpng 1.0.15 - October 3, 2002
+ * libpng 1.0.16 - August 15, 2004
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 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.)
  */
diff --git a/pngvcrd.c b/pngvcrd.c
index b18907b..4818667 100644
--- a/pngvcrd.c
+++ b/pngvcrd.c
@@ -2,9 +2,9 @@
  *
  * For Intel x86 CPU and Microsoft Visual C++ compiler
  *
- * libpng version 1.0.15 - October 3, 2002
+ * libpng version 1.0.16 - August 15, 2004
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 Glenn Randers-Pehrson
  * Copyright (c) 1998, Intel Corporation
  *
  * Contributed by Nirav Chhatrapati, Intel Corporation, 1998
@@ -115,15 +115,18 @@
    png_debug(1,"in png_combine_row_asm\n");
 
    if (mmx_supported == 2) {
+#if !defined(PNG_1_0_X)
        /* this should have happened in png_init_mmx_flags() already */
        png_warning(png_ptr, "asm_flags may not have been initialized");
+#endif
        png_mmx_support();
    }
 
    if (mask == 0xff)
    {
       png_memcpy(row, png_ptr->row_buf + 1,
-       (png_size_t)((png_ptr->width * png_ptr->row_info.pixel_depth + 7) >> 3));
+       (png_size_t)PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
+       png_ptr->width));
    }
    /* GRR:  add "else if (mask == 0)" case?
     *       or does png_combine_row() not even get called in that case? */
@@ -307,8 +310,12 @@
 
             __int64 mask0=0x0102040810204080;
 
+#if !defined(PNG_1_0_X)
             if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)
                 /* && mmx_supported */ )
+#else
+            if (mmx_supported)
+#endif
             {
                srcptr = png_ptr->row_buf + 1;
                dstptr = row;
@@ -408,8 +415,12 @@
             __int64 mask1=0x0101020204040808,
                     mask0=0x1010202040408080;
 
+#if !defined(PNG_1_0_X)
             if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)
                 /* && mmx_supported */ )
+#else
+            if (mmx_supported)
+#endif
             {
                srcptr = png_ptr->row_buf + 1;
                dstptr = row;
@@ -529,8 +540,12 @@
             len     = (png_ptr->width)&~7;
             diff = (png_ptr->width)&7;
 
+#if !defined(PNG_1_0_X)
             if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)
                 /* && mmx_supported */ )
+#else
+            if (mmx_supported)
+#endif
             {
                _asm
                {
@@ -661,8 +676,12 @@
             len     = (png_ptr->width)&~7;
             diff = (png_ptr->width)&7;
 
+#if !defined(PNG_1_0_X)
             if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)
                 /* && mmx_supported */ )
+#else
+            if (mmx_supported)
+#endif
             {
                _asm
                {
@@ -796,8 +815,12 @@
                     mask1=0x2020202040404040,
                     mask0=0x4040808080808080;
 
+#if !defined(PNG_1_0_X)
             if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)
                 /* && mmx_supported */ )
+#else
+            if (mmx_supported)
+#endif
             {
                srcptr = png_ptr->row_buf + 1;
                dstptr = row;
@@ -987,8 +1010,10 @@
    png_debug(1,"in png_do_read_interlace\n");
 
    if (mmx_supported == 2) {
+#if !defined(PNG_1_0_X)
        /* this should have happened in png_init_mmx_flags() already */
        png_warning(png_ptr, "asm_flags may not have been initialized");
+#endif
        png_mmx_support();
    }
 
@@ -1189,8 +1214,12 @@
             // NOTE:  there is NO MMX code for 48-bit and 64-bit images
 
             // use MMX routine if machine supports it
+#if !defined(PNG_1_0_X)
             if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE)
                 /* && mmx_supported */ )
+#else
+            if (mmx_supported)
+#endif
             {
                if (pixel_bytes == 3)
                {
@@ -1874,8 +1903,8 @@
       } /* end switch (row_info->pixel_depth) */
 
       row_info->width = final_width;
-      row_info->rowbytes = ((final_width *
-         (png_uint_32)row_info->pixel_depth + 7) >> 3);
+
+      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width);
    }
 
 }
@@ -3652,8 +3681,10 @@
 #endif
 
    if (mmx_supported == 2) {
+#if !defined(PNG_1_0_X)
        /* this should have happened in png_init_mmx_flags() already */
        png_warning(png_ptr, "asm_flags may not have been initialized");
+#endif
        png_mmx_support();
    }
 
@@ -3663,6 +3694,7 @@
    {
       case 0: sprintf(filnm, "none");
          break;
+#if !defined(PNG_1_0_X)
       case 1: sprintf(filnm, "sub-%s",
         (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" : "x86");
          break;
@@ -3675,6 +3707,16 @@
       case 4: sprintf(filnm, "Paeth-%s",
         (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "MMX":"x86");
          break;
+#else
+      case 1: sprintf(filnm, "sub");
+         break;
+      case 2: sprintf(filnm, "up");
+         break;
+      case 3: sprintf(filnm, "avg");
+         break;
+      case 4: sprintf(filnm, "Paeth");
+         break;
+#endif
       default: sprintf(filnm, "unknw");
          break;
    }
@@ -3691,9 +3733,13 @@
 
       case PNG_FILTER_VALUE_SUB:
       {
+#if !defined(PNG_1_0_X)
          if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) &&
              (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) &&
              (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold))
+#else
+         if (mmx_supported)
+#endif
          {
             png_read_filter_row_mmx_sub(row_info, row);
          }
@@ -3716,9 +3762,13 @@
 
       case PNG_FILTER_VALUE_UP:
       {
+#if !defined(PNG_1_0_X)
          if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP) &&
              (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) &&
              (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold))
+#else
+         if (mmx_supported)
+#endif
          {
             png_read_filter_row_mmx_up(row_info, row, prev_row);
          }
@@ -3740,9 +3790,13 @@
 
       case PNG_FILTER_VALUE_AVG:
       {
+#if !defined(PNG_1_0_X)
          if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) &&
              (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) &&
              (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold))
+#else
+         if (mmx_supported)
+#endif
          {
             png_read_filter_row_mmx_avg(row_info, row, prev_row);
          }
@@ -3774,9 +3828,13 @@
 
       case PNG_FILTER_VALUE_PAETH:
       {
+#if !defined(PNG_1_0_X)
          if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) &&
              (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) &&
              (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold))
+#else
+         if (mmx_supported)
+#endif
          {
             png_read_filter_row_mmx_paeth(row_info, row, prev_row);
          }
diff --git a/pngwio.c b/pngwio.c
index 88eeba6..77daa88 100644
--- a/pngwio.c
+++ b/pngwio.c
@@ -1,9 +1,9 @@
 
 /* pngwio.c - functions for data output
  *
- * libpng 1.0.15 - October 3, 2002
+ * libpng 1.0.16 - August 15, 2004
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 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.)
  *
diff --git a/pngwrite.c b/pngwrite.c
index 9aa6fe1..5cbd151 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -1,9 +1,9 @@
 
 /* pngwrite.c - general routines to write a PNG file
  *
- * libpng 1.0.15 - October 3, 2002
+ * libpng 1.0.16 - August 15, 2004
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 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.)
  */
@@ -104,9 +104,10 @@
             up++)
        {
          int keep=png_handle_as_unknown(png_ptr, up->name);
-         if (keep != HANDLE_CHUNK_NEVER &&
-            up->location && (!(up->location & PNG_HAVE_PLTE)) &&
-            ((up->name[3] & 0x20) || keep == HANDLE_CHUNK_ALWAYS ||
+         if (keep != PNG_HANDLE_CHUNK_NEVER &&
+            up->location && !(up->location & PNG_HAVE_PLTE) &&
+            !(up->location & PNG_HAVE_IDAT) &&
+            ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||
             (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
          {
             png_write_chunk(png_ptr, up->name, up->data, up->size);
@@ -267,10 +268,10 @@
             up++)
        {
          int keep=png_handle_as_unknown(png_ptr, up->name);
-         if (keep != HANDLE_CHUNK_NEVER &&
+         if (keep != PNG_HANDLE_CHUNK_NEVER &&
             up->location && (up->location & PNG_HAVE_PLTE) &&
             !(up->location & PNG_HAVE_IDAT) &&
-            ((up->name[3] & 0x20) || keep == HANDLE_CHUNK_ALWAYS ||
+            ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||
             (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
          {
             png_write_chunk(png_ptr, up->name, up->data, up->size);
@@ -367,9 +368,9 @@
             up++)
        {
          int keep=png_handle_as_unknown(png_ptr, up->name);
-         if (keep != HANDLE_CHUNK_NEVER &&
+         if (keep != PNG_HANDLE_CHUNK_NEVER &&
             up->location && (up->location & PNG_AFTER_IDAT) &&
-            ((up->name[3] & 0x20) || keep == HANDLE_CHUNK_ALWAYS ||
+            ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||
             (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
          {
             png_write_chunk(png_ptr, up->name, up->data, up->size);
@@ -457,6 +458,12 @@
 #endif
 #endif /* PNG_1_0_X */
 
+   /* added at libpng-1.2.6 */
+#ifdef PNG_SET_USER_LIMITS_SUPPORTED
+   png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
+   png_ptr->user_height_max=PNG_USER_HEIGHT_MAX;
+#endif
+
 #ifdef PNG_SETJMP_SUPPORTED
 #ifdef USE_FAR_KEYWORD
    if (setjmp(jmpbuf))
@@ -470,7 +477,7 @@
       return (NULL);
    }
 #ifdef USE_FAR_KEYWORD
-   png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
+   png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf));
 #endif
 #endif
 
@@ -537,7 +544,7 @@
 #ifdef USE_FAR_KEYWORD
    if (setjmp(jmpbuf))
       PNG_ABORT();
-   png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
+   png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf));
 #else
    if (setjmp(png_ptr->jmpbuf))
       PNG_ABORT();
@@ -561,7 +568,8 @@
 {
    /* We only come here via pre-1.0.12-compiled applications */
 #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
-   if(sizeof(png_struct) > png_struct_size || sizeof(png_info) > png_info_size)
+   if(png_sizeof(png_struct) > png_struct_size ||
+      png_sizeof(png_info) > png_info_size)
    {
       char msg[80];
       png_ptr->warning_fn=NULL;
@@ -576,7 +584,7 @@
       png_warning(png_ptr, msg);
    }
 #endif
-   if(sizeof(png_struct) > png_struct_size)
+   if(png_sizeof(png_struct) > png_struct_size)
      {
        png_ptr->error_fn=NULL;
 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
@@ -585,7 +593,7 @@
        png_error(png_ptr,
        "The png struct allocated by the application for writing is too small.");
      }
-   if(sizeof(png_info) > png_info_size)
+   if(png_sizeof(png_info) > png_info_size)
      {
        png_ptr->error_fn=NULL;
 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
@@ -626,10 +634,10 @@
 
 #ifdef PNG_SETJMP_SUPPORTED
    /* save jump buffer and error functions */
-   png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
+   png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf));
 #endif
 
-   if (sizeof(png_struct) > png_struct_size)
+   if (png_sizeof(png_struct) > png_struct_size)
      {
        png_destroy_struct(png_ptr);
        png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
@@ -637,7 +645,13 @@
      }
 
    /* reset all variables to 0 */
-   png_memset(png_ptr, 0, sizeof (png_struct));
+   png_memset(png_ptr, 0, png_sizeof (png_struct));
+
+   /* added at libpng-1.2.6 */
+#ifdef PNG_SET_USER_LIMITS_SUPPORTED
+   png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
+   png_ptr->user_height_max=PNG_USER_HEIGHT_MAX;
+#endif
 
 #if !defined(PNG_1_0_X)
 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
@@ -647,7 +661,7 @@
 
 #ifdef PNG_SETJMP_SUPPORTED
    /* restore jump buffer */
-   png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
+   png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf));
 #endif
 
    png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL,
@@ -827,8 +841,8 @@
    png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
       png_ptr->row_info.channels);
 
-   png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
-      (png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
+   png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
+      png_ptr->row_info.width);
 
    png_debug1(3, "row_info->color_type = %d\n", png_ptr->row_info.color_type);
    png_debug1(3, "row_info->width = %lu\n", png_ptr->row_info.width);
@@ -1049,7 +1063,7 @@
 
 #ifdef PNG_SETJMP_SUPPORTED
    /* reset structure */
-   png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
+   png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf));
 #endif
 
    error_fn = png_ptr->error_fn;
@@ -1059,7 +1073,7 @@
    free_fn = png_ptr->free_fn;
 #endif
 
-   png_memset(png_ptr, 0, sizeof (png_struct));
+   png_memset(png_ptr, 0, png_sizeof (png_struct));
 
    png_ptr->error_fn = error_fn;
    png_ptr->warning_fn = warning_fn;
@@ -1069,7 +1083,7 @@
 #endif
 
 #ifdef PNG_SETJMP_SUPPORTED
-   png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
+   png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf));
 #endif
 }
 
@@ -1211,7 +1225,7 @@
       if (png_ptr->prev_filters == NULL)
       {
          png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr,
-            (png_uint_32)(sizeof(png_byte) * num_weights));
+            (png_uint_32)(png_sizeof(png_byte) * num_weights));
 
          /* To make sure that the weighting starts out fairly */
          for (i = 0; i < num_weights; i++)
@@ -1223,10 +1237,10 @@
       if (png_ptr->filter_weights == NULL)
       {
          png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr,
-            (png_uint_32)(sizeof(png_uint_16) * num_weights));
+            (png_uint_32)(png_sizeof(png_uint_16) * num_weights));
 
          png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr,
-            (png_uint_32)(sizeof(png_uint_16) * num_weights));
+            (png_uint_32)(png_sizeof(png_uint_16) * num_weights));
          for (i = 0; i < num_weights; i++)
          {
             png_ptr->inv_filter_weights[i] =
@@ -1257,10 +1271,10 @@
    if (png_ptr->filter_costs == NULL)
    {
       png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr,
-         (png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
+         (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
 
       png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr,
-         (png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
+         (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
 
       for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)
       {
diff --git a/pngwtran.c b/pngwtran.c
index 9caccc0..a7031e8 100644
--- a/pngwtran.c
+++ b/pngwtran.c
@@ -1,9 +1,9 @@
 
 /* pngwtran.c - transforms the data in a row for PNG writers
  *
- * libpng 1.0.15 - October 3, 2002
+ * libpng version 1.0.16 - August 15, 2004
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 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.)
  */
@@ -195,8 +195,8 @@
       }
       row_info->bit_depth = (png_byte)bit_depth;
       row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels);
-      row_info->rowbytes =
-         ((row_info->width * row_info->pixel_depth + 7) >> 3);
+      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
+         row_info->width);
    }
 }
 #endif
@@ -546,15 +546,15 @@
 
          for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
          {
-            png_uint_32 s0=*(rp  )<<8 | *(rp+1);
-            png_uint_32 s1=*(rp+2)<<8 | *(rp+3);
-            png_uint_32 s2=*(rp+4)<<8 | *(rp+5);
-            png_uint_32 red=(s0-s1)&0xffff;
-            png_uint_32 blue=(s2-s1)&0xffff;
-            *(rp  ) = (png_byte)((red>>8)&0xff);
-            *(rp+1) = (png_byte)(red&0xff);
-            *(rp+4) = (png_byte)((blue>>8)&0xff);
-            *(rp+5) = (png_byte)(blue&0xff);
+            png_uint_32 s0   = (*(rp  ) << 8) | *(rp+1);
+            png_uint_32 s1   = (*(rp+2) << 8) | *(rp+3);
+            png_uint_32 s2   = (*(rp+4) << 8) | *(rp+5);
+            png_uint_32 red  = (png_uint_32)((s0-s1) & 0xffffL);
+            png_uint_32 blue = (png_uint_32)((s2-s1) & 0xffffL);
+            *(rp  ) = (png_byte)((red >> 8) & 0xff);
+            *(rp+1) = (png_byte)(red & 0xff);
+            *(rp+4) = (png_byte)((blue >> 8) & 0xff);
+            *(rp+5) = (png_byte)(blue & 0xff);
          }
       }
    }
diff --git a/pngwutil.c b/pngwutil.c
index b96556d..00dbb01 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -1,9 +1,9 @@
 
 /* pngwutil.c - utilities to write a PNG file
  *
- * libpng 1.0.15 - October 3, 2002
+ * libpng version 1.0.16 - August 15, 2004
  * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2002 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2004 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.)
  */
@@ -234,14 +234,16 @@
 
                old_ptr = comp->output_ptr;
                comp->output_ptr = (png_charpp)png_malloc(png_ptr,
-                  (png_uint_32)(comp->max_output_ptr * sizeof (png_charpp)));
+                  (png_uint_32)(comp->max_output_ptr *
+                  png_sizeof (png_charpp)));
                png_memcpy(comp->output_ptr, old_ptr, old_max
-                  * sizeof (png_charp));
+                  * png_sizeof (png_charp));
                png_free(png_ptr, old_ptr);
             }
             else
                comp->output_ptr = (png_charpp)png_malloc(png_ptr,
-                  (png_uint_32)(comp->max_output_ptr * sizeof (png_charp)));
+                  (png_uint_32)(comp->max_output_ptr *
+                  png_sizeof (png_charp)));
          }
 
          /* save the data */
@@ -283,14 +285,16 @@
                   old_ptr = comp->output_ptr;
                   /* This could be optimized to realloc() */
                   comp->output_ptr = (png_charpp)png_malloc(png_ptr,
-                     (png_uint_32)(comp->max_output_ptr * sizeof (png_charpp)));
+                     (png_uint_32)(comp->max_output_ptr *
+                     png_sizeof (png_charpp)));
                   png_memcpy(comp->output_ptr, old_ptr,
-                     old_max * sizeof (png_charp));
+                     old_max * png_sizeof (png_charp));
                   png_free(png_ptr, old_ptr);
                }
                else
                   comp->output_ptr = (png_charpp)png_malloc(png_ptr,
-                     (png_uint_32)(comp->max_output_ptr * sizeof (png_charp)));
+                     (png_uint_32)(comp->max_output_ptr *
+                     png_sizeof (png_charp)));
             }
 
             /* save off the data */
@@ -464,11 +468,12 @@
 #if defined(PNG_MNG_FEATURES_SUPPORTED)
    png_ptr->filter_type = (png_byte)filter_type;
 #endif
+   png_ptr->compression_type = (png_byte)compression_type;
    png_ptr->width = width;
    png_ptr->height = height;
 
    png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels);
-   png_ptr->rowbytes = ((width * (png_size_t)png_ptr->pixel_depth + 7) >> 3);
+   png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);
    /* set the usr info, so any transformations can modify it */
    png_ptr->usr_width = png_ptr->width;
    png_ptr->usr_bit_depth = png_ptr->bit_depth;
@@ -596,6 +601,46 @@
    PNG_IDAT;
 #endif
    png_debug(1, "in png_write_IDAT\n");
+
+   /* Optimize the CMF field in the zlib stream. */
+   /* This hack of the zlib stream is compliant to the stream specification. */
+   if (!(png_ptr->mode & PNG_HAVE_IDAT) &&
+       png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)
+   {
+      unsigned int z_cmf = data[0];  /* zlib compression method and flags */
+      if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70)
+      {
+         /* Avoid memory underflows and multiplication overflows. */
+         /* The conditions below are practically always satisfied;
+            however, they still must be checked. */
+         if (length >= 2 &&
+             png_ptr->height < 16384 && png_ptr->width < 16384)
+         {
+            png_uint_32 uncompressed_idat_size = png_ptr->height *
+               (PNG_ROWBYTES(png_ptr->channels*png_ptr->bit_depth,
+                  png_ptr->channels * png_ptr->bit_depth + 15) >> 3);
+            unsigned int z_cinfo = z_cmf >> 4;
+            unsigned int half_z_window_size = 1 << (z_cinfo + 7);
+            while (uncompressed_idat_size <= half_z_window_size &&
+                   half_z_window_size >= 256)
+            {
+               z_cinfo--;
+               half_z_window_size >>= 1;
+            }
+            z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4);
+            if (data[0] != (png_byte)z_cmf)
+            {
+               data[0] = (png_byte)z_cmf;
+               data[1] &= 0xe0;
+               data[1] += (png_byte)(0x1f - ((z_cmf << 8) + data[1]) % 0x1f);
+            }
+         }
+      }
+      else
+         png_error(png_ptr,
+            "Invalid zlib compression method or flags in IDAT");
+   }
+
    png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length);
    png_ptr->mode |= PNG_HAVE_IDAT;
 }
@@ -1141,7 +1186,12 @@
 
    png_debug1(2, "Keyword to be checked is '%s'\n", key);
 
-   *new_key = (png_charp)png_malloc(png_ptr, (png_uint_32)(key_len + 2));
+   *new_key = (png_charp)png_malloc_warn(png_ptr, (png_uint_32)(key_len + 2));
+   if (*new_key == NULL)
+   {
+      png_warning(png_ptr, "Out of memory while procesing keyword");
+      return ((png_size_t)0);
+   }
 
    /* Replace non-printing characters with a blank and print a warning */
    for (kp = key, dp = *new_key; *kp != '\0'; kp++, dp++)
@@ -1353,7 +1403,7 @@
    {
       png_warning(png_ptr, "Empty language field in iTXt chunk");
       new_lang = NULL;
-      lang_len = 0;      
+      lang_len = 0;
    }
 
    if (lang_key == NULL)
@@ -1461,7 +1511,7 @@
    total_len = purpose_len + units_len + 10;
 
    params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams
-      *sizeof(png_uint_32)));
+      *png_sizeof(png_uint_32)));
 
    /* Find the length of each parameter, making sure we don't count the
       null terminator for the last parameter. */
@@ -1641,8 +1691,8 @@
    png_size_t buf_size;
 
    png_debug(1, "in png_write_start_row\n");
-   buf_size = (png_size_t)(((png_ptr->width * png_ptr->usr_channels *
-                            png_ptr->usr_bit_depth + 7) >> 3) + 1);
+   buf_size = (png_size_t)(PNG_ROWBYTES(
+      png_ptr->usr_channels*png_ptr->usr_bit_depth,png_ptr->width)+1);
 
    /* set up row buffer */
    png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size);
@@ -1778,9 +1828,8 @@
       {
          if (png_ptr->prev_row != NULL)
             png_memset(png_ptr->prev_row, 0,
-               (png_size_t) (((png_uint_32)png_ptr->usr_channels *
-               (png_uint_32)png_ptr->usr_bit_depth *
-               png_ptr->width + 7) >> 3) + 1);
+               (png_size_t)(PNG_ROWBYTES(png_ptr->usr_channels*
+               png_ptr->usr_bit_depth,png_ptr->width))+1);
          return;
       }
    }
@@ -1987,8 +2036,8 @@
          png_pass_inc[pass] - 1 -
          png_pass_start[pass]) /
          png_pass_inc[pass];
-         row_info->rowbytes = ((row_info->width *
-            row_info->pixel_depth + 7) >> 3);
+         row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
+            row_info->width);
    }
 }
 #endif
@@ -2014,7 +2063,7 @@
 
    png_debug(1, "in png_write_find_filter\n");
    /* find out how many bytes offset each pixel is */
-   bpp = (row_info->pixel_depth + 7) / 8;
+   bpp = (row_info->pixel_depth + 7) >> 3;
 
    prev_row = png_ptr->prev_row;
    best_row = row_buf = png_ptr->row_buf;
@@ -2165,7 +2214,7 @@
 
          sum += (v < 128) ? v : 256 - v;
       }
-      for (lp = row_buf + 1; i < row_info->rowbytes;
+      for (lp = row_buf + 1; i < row_bytes;
          i++, rp++, lp++, dp++)
       {
          v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
diff --git a/projects/borland/libpng.readme.txt b/projects/borland/libpng.readme.txt
deleted file mode 100644
index efe7cbd..0000000
--- a/projects/borland/libpng.readme.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-Project files to build libpng using Borland C++ Builder v5.0
-
-To use this dll, you will need to:
-
-1) add the following conditional defines to your project
-
-PNG_USE_DLL
-Z_PREFIX
-
-2) add the paths to png.h and zlib.h to your include path
-
-3) add libpng.lib or libpngstat.lib to the project.
-
-If you are using libpng.dll, libpng.dll and zlib.dll will be required for the code to run.
-
-Alternatively, the libpng.dll can be built using zlibstat.lib to produce one dll containing both the zlib and png code.
-
-See the libpng documentation for instructions on how to use the code.
-
diff --git a/projects/borland/zlib+libpng.bpg b/projects/borland/zlib+libpng.bpg
deleted file mode 100644
index f8f4702..0000000
--- a/projects/borland/zlib+libpng.bpg
+++ /dev/null
@@ -1,33 +0,0 @@
-#------------------------------------------------------------------------------
-VERSION = BWS.01
-#------------------------------------------------------------------------------
-!ifndef ROOT
-ROOT = $(MAKEDIR)\..
-!endif
-#------------------------------------------------------------------------------
-MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$**
-DCC = $(ROOT)\bin\dcc32.exe $**
-BRCC = $(ROOT)\bin\brcc32.exe $**
-#------------------------------------------------------------------------------
-PROJECTS = zlibstat.lib libpngstat.lib zlib.dll libpng.dll
-#------------------------------------------------------------------------------
-default: $(PROJECTS)
-#------------------------------------------------------------------------------
-
-libpng.dll: libpng.bpr
-  $(ROOT)\bin\bpr2mak $**
-  $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
-
-zlibstat.lib: zlibstat.bpr
-  $(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $**
-  $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
-
-zlib.dll: zlib.bpr
-  $(ROOT)\bin\bpr2mak $**
-  $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
-
-libpngstat.lib: libpngstat.bpr
-  $(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $**
-  $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
-
-
diff --git a/projects/borland/zlib.bpf b/projects/borland/zlib.bpf
deleted file mode 100644
index 7dca899..0000000
--- a/projects/borland/zlib.bpf
+++ /dev/null
@@ -1,20 +0,0 @@
-USEUNIT("zlib.cpp");
-USEUNIT("..\..\..\zlib\zutil.c");
-USEUNIT("..\..\..\zlib\compress.c");
-USEUNIT("..\..\..\zlib\crc32.c");
-USEUNIT("..\..\..\zlib\deflate.c");
-USEUNIT("..\..\..\zlib\gzio.c");
-USEUNIT("..\..\..\zlib\infblock.c");
-USEUNIT("..\..\..\zlib\infcodes.c");
-USEUNIT("..\..\..\zlib\inffast.c");
-USEUNIT("..\..\..\zlib\inflate.c");
-USEUNIT("..\..\..\zlib\inftrees.c");
-USEUNIT("..\..\..\zlib\infutil.c");
-USEUNIT("..\..\..\zlib\trees.c");
-USEUNIT("..\..\..\zlib\uncompr.c");
-USEUNIT("..\..\..\zlib\adler32.c");
-//---------------------------------------------------------------------------
-This file is used by the project manager only and should be treated like the project file
-
-
-DllEntryPoint
\ No newline at end of file
diff --git a/projects/borland/zlib.bpg b/projects/borland/zlib.bpg
deleted file mode 100644
index 0292b48..0000000
--- a/projects/borland/zlib.bpg
+++ /dev/null
@@ -1,25 +0,0 @@
-#------------------------------------------------------------------------------
-VERSION = BWS.01
-#------------------------------------------------------------------------------
-!ifndef ROOT
-ROOT = $(MAKEDIR)\..
-!endif
-#------------------------------------------------------------------------------
-MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$**
-DCC = $(ROOT)\bin\dcc32.exe $**
-BRCC = $(ROOT)\bin\brcc32.exe $**
-#------------------------------------------------------------------------------
-PROJECTS = zlibstat.lib zlib.dll
-#------------------------------------------------------------------------------
-default: $(PROJECTS)
-#------------------------------------------------------------------------------
-
-zlibstat.lib: zlibstat.bpr
-  $(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $**
-  $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
-
-zlib.dll: zlib.bpr
-  $(ROOT)\bin\bpr2mak $**
-  $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
-
-
diff --git a/projects/borland/zlib.bpr b/projects/borland/zlib.bpr
deleted file mode 100644
index b3dda39..0000000
--- a/projects/borland/zlib.bpr
+++ /dev/null
@@ -1,147 +0,0 @@
-<?xml version='1.0' encoding='utf-8' ?>
-<!-- C++Builder XML Project -->
-<PROJECT>
-  <MACROS>
-    <VERSION value="BCB.05.03"/>
-    <PROJECT value="zlib.dll"/>
-    <OBJFILES value="zlib.obj ..\..\..\zlib\zutil.obj ..\..\..\zlib\compress.obj 
-      ..\..\..\zlib\crc32.obj ..\..\..\zlib\deflate.obj ..\..\..\zlib\gzio.obj 
-      ..\..\..\zlib\infblock.obj ..\..\..\zlib\infcodes.obj 
-      ..\..\..\zlib\inffast.obj ..\..\..\zlib\inflate.obj 
-      ..\..\..\zlib\inftrees.obj ..\..\..\zlib\infutil.obj 
-      ..\..\..\zlib\trees.obj ..\..\..\zlib\uncompr.obj ..\..\..\zlib\adler32.obj"/>
-    <RESFILES value=""/>
-    <DEFFILE value=""/>
-    <RESDEPEN value="$(RESFILES)"/>
-    <LIBFILES value=""/>
-    <LIBRARIES value="bcbsmp50.lib dclocx50.lib NMFast50.lib Tee50.lib Vclx50.lib Vcl50.lib"/>
-    <SPARELIBS value="Vcl50.lib Vclx50.lib Tee50.lib NMFast50.lib dclocx50.lib bcbsmp50.lib"/>
-    <PACKAGES value="Vcl50.bpi Vclx50.bpi bcbsmp50.bpi Qrpt50.bpi Vcldb50.bpi Vclbde50.bpi 
-      ibsmp50.bpi vcldbx50.bpi TeeUI50.bpi TeeDB50.bpi Tee50.bpi TeeQR50.bpi 
-      VCLIB50.bpi bcbie50.bpi vclie50.bpi Inetdb50.bpi Inet50.bpi NMFast50.bpi 
-      dclocx50.bpi bcb97axserver50.bpi SIMULUSCOMPONENTS.bpi Simulus2.bpi"/>
-    <PATHCPP value=".;..\..\..\zlib"/>
-    <PATHPAS value=".;"/>
-    <PATHRC value=".;"/>
-    <PATHASM value=".;"/>
-    <DEBUGLIBPATH value="$(BCB)\lib\debug"/>
-    <RELEASELIBPATH value="$(BCB)\lib\release"/>
-    <LINKER value="tlink32"/>
-    <USERDEFINES value="ZLIB_DLL;Z_PREFIX"/>
-    <SYSDEFINES value="NO_STRICT;_NO_VCL;_RTLDLL"/>
-    <MAINSOURCE value="zlib.bpf"/>
-    <INCLUDEPATH value="..\..\..\zlib;$(BCB)\include"/>
-    <LIBPATH value="..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib"/>
-    <WARNINGS value="-w8092 -w8091 -w8090 -w8089 -w8087 -wprc -wuse -wucp -wstv -wstu -wpin 
-      -w-par -wnod -wnak -wdef -wcln -wbbf -w-aus -wasm -wamp -wamb"/>
-  </MACROS>
-  <OPTIONS>
-    <CFLAG1 value="-WD -O2 -w -Vx -Ve -x- -RT- -ff -X- -a8 -5 -b- -d -k- -vi -tWD -tWM -c"/>
-    <PFLAGS value="-$Y- -$L- -$D- -$C- -v -JPHNE -M"/>
-    <RFLAGS value=""/>
-    <AFLAGS value="/mx /w2 /zn"/>
-    <LFLAGS value="-D&quot;&quot; -aa -Tpd -x -Gn -Gi -w"/>
-  </OPTIONS>
-  <LINKER>
-    <ALLOBJ value="c0d32.obj $(OBJFILES)"/>
-    <ALLRES value="$(RESFILES)"/>
-    <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32mti.lib"/>
-  </LINKER>
-  <IDEOPTIONS>
-[Version Info]
-IncludeVerInfo=0
-AutoIncBuild=0
-MajorVer=1
-MinorVer=0
-Release=0
-Build=0
-Debug=0
-PreRelease=0
-Special=0
-Private=0
-DLL=1
-Locale=2057
-CodePage=1252
-
-[Version Info Keys]
-CompanyName=
-FileDescription=
-FileVersion=1.0.0.0
-InternalName=
-LegalCopyright=
-LegalTrademarks=
-OriginalFilename=
-ProductName=
-ProductVersion=1.0.0.0
-Comments=
-
-[HistoryLists\hlIncludePath]
-Count=16
-Item0=..\..\..\zlib;$(BCB)\include
-Item1=..\..\..;..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;..\..\..\zlib;$(BCB)\include
-Item2=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;..\..\..\zlib;$(BCB)\include
-Item3=P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include
-Item4=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;$(BCB)\include
-Item5=..\Source\ThirdParty\ZLibCompression;$(BCB)\include
-Item6=$(BCB)\include
-Item7=..\Source;..\Source\General\Templates;..\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl
-Item8=P:\Development\Source\;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl
-Item9=P:\Development\Source;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl
-Item10=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl
-Item11=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl
-Item12=P:\Development\Source\General\Templates\;$(BCB)\include;$(BCB)\include\vcl
-Item13=P:\Development\Source\General\Templates;$(BCB)\include;$(BCB)\include\vcl
-Item14=P:\Development\Source;$(BCB)\include;$(BCB)\include\vcl
-Item15=$(BCB)\include;$(BCB)\include\vcl
-
-[HistoryLists\hlLibraryPath]
-Count=12
-Item0=..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib
-Item1=..\..\..;..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib
-Item2=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib
-Item3=P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\lib\obj;$(BCB)\lib
-Item4=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;$(BCB)\lib\obj;$(BCB)\lib
-Item5=$(BCB)\lib\obj;$(BCB)\lib
-Item6=..\Source\ThirdParty\ZLibCompression;$(BCB)\lib\obj;$(BCB)\lib
-Item7=..\Source\SIMUtilities;..\Source;$(BCB)\lib\obj;$(BCB)\lib
-Item8=P:\Development\Source\SIMUtilities\;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib
-Item9=P:\Development\Source\SIMUtilities;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib
-Item10=P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib
-Item11=P:\Development\Source;$(BCB)\lib\obj;$(BCB)\lib
-
-[HistoryLists\hlDebugSourcePath]
-Count=1
-Item0=$(BCB)\source\vcl
-
-[HistoryLists\hlConditionals]
-Count=8
-Item0=ZLIB_DLL;Z_PREFIX
-Item1=ZLIB_DLL;_DEBUG;Z_PREFIX
-Item2=ZLIB_DLL;_DEBUG
-Item3=ZLIB_DLL
-Item4=_WINDOWS;ZLIB_DLL
-Item5=_HTML_FORM
-Item6=_DEBUG;_HTML_FORM
-Item7=_DEBUG
-
-[HistoryLists\hlIntOutputDir]
-Count=2
-Item0=..\Obj
-Item1=P:\Development\Obj
-
-[Debugging]
-DebugSourceDirs=
-
-[Parameters]
-RunParams=
-HostApplication=
-RemoteHost=
-RemotePath=
-RemoteDebug=0
-
-[Compiler]
-ShowInfoMsgs=0
-LinkDebugVcl=0
-LinkCGLIB=0
-  </IDEOPTIONS>
-</PROJECT>
\ No newline at end of file
diff --git a/projects/borland/zlib.cpp b/projects/borland/zlib.cpp
deleted file mode 100644
index 2cef71d..0000000
--- a/projects/borland/zlib.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-//---------------------------------------------------------------------------
-
-#include <windows.h>
-//---------------------------------------------------------------------------
-//   Important note about DLL memory management when your DLL uses the
-//   static version of the RunTime Library:
-//
-//   If your DLL exports any functions that pass String objects (or structs/
-//   classes containing nested Strings) as parameter or function results,
-//   you will need to add the library MEMMGR.LIB to both the DLL project and
-//   any other projects that use the DLL.  You will also need to use MEMMGR.LIB
-//   if any other projects which use the DLL will be performing new or delete
-//   operations on any non-TObject-derived classes which are exported from the
-//   DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
-//   EXE's to use the BORLNDMM.DLL as their memory manager.  In these cases,
-//   the file BORLNDMM.DLL should be deployed along with your DLL.
-//
-//   To avoid using BORLNDMM.DLL, pass string information using "char *" or
-//   ShortString parameters.
-//
-//   If your DLL uses the dynamic version of the RTL, you do not need to
-//   explicitly add MEMMGR.LIB as this will be done implicitly for you
-//---------------------------------------------------------------------------
-
-int WINAPI DllEntryPoint(HINSTANCE, unsigned long, void*)
-{
-    return 1;
-}
-//---------------------------------------------------------------------------
- 
\ No newline at end of file
diff --git a/projects/borland/zlibstat.bpf b/projects/borland/zlibstat.bpf
deleted file mode 100644
index 14c36bc..0000000
--- a/projects/borland/zlibstat.bpf
+++ /dev/null
@@ -1,20 +0,0 @@
-USEUNIT("..\..\..\zlib\zutil.c");
-USEUNIT("..\..\..\zlib\compress.c");
-USEUNIT("..\..\..\zlib\crc32.c");
-USEUNIT("..\..\..\zlib\deflate.c");
-USEUNIT("..\..\..\zlib\gzio.c");
-USEUNIT("..\..\..\zlib\infblock.c");
-USEUNIT("..\..\..\zlib\infcodes.c");
-USEUNIT("..\..\..\zlib\inffast.c");
-USEUNIT("..\..\..\zlib\inflate.c");
-USEUNIT("..\..\..\zlib\inftrees.c");
-USEUNIT("..\..\..\zlib\infutil.c");
-USEUNIT("..\..\..\zlib\trees.c");
-USEUNIT("..\..\..\zlib\uncompr.c");
-USEUNIT("..\..\..\zlib\adler32.c");
-//---------------------------------------------------------------------------
-#define Library
-
-// To add a file to the library use the Project menu 'Add to Project'.
-
- 
\ No newline at end of file
diff --git a/projects/borland/zlibstat.bpr b/projects/borland/zlibstat.bpr
deleted file mode 100644
index 9e09038..0000000
--- a/projects/borland/zlibstat.bpr
+++ /dev/null
@@ -1,131 +0,0 @@
-<?xml version='1.0' encoding='utf-8' ?>
-<!-- C++Builder XML Project -->
-<PROJECT>
-  <MACROS>
-    <VERSION value="BCB.05.03"/>
-    <PROJECT value="zlibstat.lib"/>
-    <OBJFILES value="..\..\..\zlib\zutil.obj ..\..\..\zlib\compress.obj ..\..\..\zlib\crc32.obj 
-      ..\..\..\zlib\deflate.obj ..\..\..\zlib\gzio.obj 
-      ..\..\..\zlib\infblock.obj ..\..\..\zlib\infcodes.obj 
-      ..\..\..\zlib\inffast.obj ..\..\..\zlib\inflate.obj 
-      ..\..\..\zlib\inftrees.obj ..\..\..\zlib\infutil.obj 
-      ..\..\..\zlib\trees.obj ..\..\..\zlib\uncompr.obj ..\..\..\zlib\adler32.obj"/>
-    <RESFILES value=""/>
-    <DEFFILE value=""/>
-    <RESDEPEN value="$(RESFILES)"/>
-    <LIBFILES value=""/>
-    <LIBRARIES value=""/>
-    <PACKAGES value=""/>
-    <PATHCPP value=".;..\..\..\zlib"/>
-    <PATHPAS value=".;"/>
-    <PATHRC value=".;"/>
-    <PATHASM value=".;"/>
-    <LINKER value="TLib"/>
-    <USERDEFINES value="Z_PREFIX"/>
-    <SYSDEFINES value="_RTLDLL;NO_STRICT"/>
-    <MAINSOURCE value="zlibstat.bpf"/>
-    <INCLUDEPATH value="..\..\..\zlib;$(BCB)\include"/>
-    <LIBPATH value="..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib"/>
-    <WARNINGS value="-w8092 -w8091 -w8090 -w8089 -w8087 -wprc -wuse -wucp -wstv -wstu -wpin 
-      -wnod -wnak -wdef -wcln -wbbf -w-aus -wasm -wamp -wamb"/>
-    <LISTFILE value=""/>
-  </MACROS>
-  <OPTIONS>
-    <CFLAG1 value="-O2 -w -Vx -Ve -x- -RT- -X- -a8 -5 -b- -d -k- -vi -c -tW -tWM"/>
-    <PFLAGS value="-$Y- -$L- -$D- -$C- -v -JPHNE -M"/>
-    <AFLAGS value="/mx /w2 /zn"/>
-    <LFLAGS value=""/>
-  </OPTIONS>
-  <LINKER>
-    <ALLOBJ value="$(OBJFILES)"/>
-    <ALLLIB value=""/>
-  </LINKER>
-  <IDEOPTIONS>
-[Version Info]
-IncludeVerInfo=0
-AutoIncBuild=0
-MajorVer=1
-MinorVer=0
-Release=0
-Build=0
-Debug=0
-PreRelease=0
-Special=0
-Private=0
-DLL=0
-Locale=2057
-CodePage=1252
-
-[Version Info Keys]
-CompanyName=
-FileDescription=
-FileVersion=1.0.0.0
-InternalName=
-LegalCopyright=
-LegalTrademarks=
-OriginalFilename=
-ProductName=
-ProductVersion=1.0.0.0
-Comments=
-
-[HistoryLists\hlIncludePath]
-Count=8
-Item0=..\..\..\zlib;$(BCB)\include
-Item1=..\Source\ThirdParty\ZLibCompression\external;..\..\..\zlib;$(BCB)\include
-Item2=P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include
-Item3=..\Source\ThirdParty\ZLibCompression\external;$(BCB)\include
-Item4=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression\ext;..\Source\ThirdParty\ZLibCompression;$(BCB)\include
-Item5=..\Source\ThirdParty\ZLibCompression;$(BCB)\include
-Item6=$(BCB)\include
-Item7=$(BCB)\include;$(BCB)\include\vcl
-
-[HistoryLists\hlLibraryPath]
-Count=7
-Item0=..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib
-Item1=$(BCB)\lib\obj;$(BCB)\lib
-Item2=..\Source\ThirdParty\ZLibCompression\external;..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib
-Item3=P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\lib\obj;$(BCB)\lib
-Item4=..\Source\ThirdParty\ZLibCompression\external;$(BCB)\lib\obj;$(BCB)\lib
-Item5=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression\ext;..\Source\ThirdParty\ZLibCompression;$(BCB)\lib\obj;$(BCB)\lib
-Item6=..\Source\ThirdParty\ZLibCompression;$(BCB)\lib\obj;$(BCB)\lib
-
-[HistoryLists\hlDebugSourcePath]
-Count=1
-Item0=$(BCB)\source\vcl
-
-[HistoryLists\hlConditionals]
-Count=3
-Item0=Z_PREFIX
-Item1=ZLIB_DLL
-Item2=_WINDOWS;ZLIB_DLL
-
-[HistoryLists\hlIntOutputDir]
-Count=2
-Item0=..\Obj
-Item1=P:\Development\Obj
-
-[HistoryLists\hlTlibPageSize]
-Count=1
-Item0=0x0010
-
-[Debugging]
-DebugSourceDirs=
-
-[Parameters]
-RunParams=
-HostApplication=
-RemoteHost=
-RemotePath=
-RemoteDebug=0
-
-[Compiler]
-ShowInfoMsgs=0
-LinkDebugVcl=0
-LinkCGLIB=0
-
-[Language]
-ActiveLang=
-ProjectLang=
-RootDir=
-  </IDEOPTIONS>
-</PROJECT>
\ No newline at end of file
diff --git a/projects/borland/libpng.bpf b/projects/cbuilder5/libpng.bpf
similarity index 94%
rename from projects/borland/libpng.bpf
rename to projects/cbuilder5/libpng.bpf
index e796e3c..2af81e7 100644
--- a/projects/borland/libpng.bpf
+++ b/projects/cbuilder5/libpng.bpf
@@ -1,5 +1,5 @@
 USEUNIT("libpng.cpp");
-USEUNIT("..\..\pngwutil.c");
+USEUNIT("..\..\png.c");
 USEUNIT("..\..\pngerror.c");
 USEUNIT("..\..\pngget.c");
 USEUNIT("..\..\pngmem.c");
@@ -13,10 +13,10 @@
 USEUNIT("..\..\pngwio.c");
 USEUNIT("..\..\pngwrite.c");
 USEUNIT("..\..\pngwtran.c");
-USEUNIT("..\..\png.c");
-USELIB("zlib.lib");
+USEUNIT("..\..\pngwutil.c");
+USELIB("..\..\..\zlib\zlib.lib");
 //---------------------------------------------------------------------------
 This file is used by the project manager only and should be treated like the project file
 
 
-DllEntryPoint
\ No newline at end of file
+DllEntryPoint
diff --git a/projects/borland/libpng.bpg b/projects/cbuilder5/libpng.bpg
similarity index 100%
rename from projects/borland/libpng.bpg
rename to projects/cbuilder5/libpng.bpg
diff --git a/projects/borland/libpng.bpr b/projects/cbuilder5/libpng.bpr
similarity index 98%
rename from projects/borland/libpng.bpr
rename to projects/cbuilder5/libpng.bpr
index f5f062b..b9fdbe4 100644
--- a/projects/borland/libpng.bpr
+++ b/projects/cbuilder5/libpng.bpr
@@ -11,7 +11,7 @@
     <RESFILES value=""/>
     <DEFFILE value=""/>
     <RESDEPEN value="$(RESFILES)"/>
-    <LIBFILES value="zlib.lib"/>
+    <LIBFILES value="..\..\..\zlib\zlib.lib"/>
     <LIBRARIES value="bcbsmp50.lib dclocx50.lib NMFast50.lib Tee50.lib Vclx50.lib Vcl50.lib"/>
     <SPARELIBS value="Vcl50.lib Vclx50.lib Tee50.lib NMFast50.lib dclocx50.lib bcbsmp50.lib"/>
     <PACKAGES value="Vcl50.bpi Vclx50.bpi bcbsmp50.bpi Qrpt50.bpi Vcldb50.bpi Vclbde50.bpi 
@@ -25,7 +25,7 @@
     <DEBUGLIBPATH value="$(BCB)\lib\debug"/>
     <RELEASELIBPATH value="$(BCB)\lib\release"/>
     <LINKER value="tlink32"/>
-    <USERDEFINES value="ZLIB_DLL;Z_PREFIX;PNG_BUILD_DLL;PNG_NO_MODULEDEF"/>
+    <USERDEFINES value="PNG_BUILD_DLL;PNG_NO_MODULEDEF"/>
     <SYSDEFINES value="NO_STRICT;_NO_VCL;_RTLDLL"/>
     <MAINSOURCE value="libpng.bpf"/>
     <INCLUDEPATH value="..\..;..\..\..\zlib;$(BCB)\include"/>
diff --git a/projects/borland/libpng.cpp b/projects/cbuilder5/libpng.cpp
similarity index 100%
rename from projects/borland/libpng.cpp
rename to projects/cbuilder5/libpng.cpp
diff --git a/projects/cbuilder5/libpng.readme.txt b/projects/cbuilder5/libpng.readme.txt
new file mode 100644
index 0000000..c99c1e9
--- /dev/null
+++ b/projects/cbuilder5/libpng.readme.txt
@@ -0,0 +1,25 @@
+Project files to build libpng using Borland C++ Builder v5.0
+
+In order to build and use libpng, please follow these steps:
+
+ 1). Install zlib in a directory at the same level with libpng.
+
+ 2). In a console window, go to the zlib directory and type:
+       make -f win32\Makefile.bor
+     After performing this step, you should have a file named
+     zlib.lib in the zlib directory.
+
+ 3). Add the following conditional define to your project:
+       PNG_USE_DLL
+
+ 4). Add libpng.lib or libpngstat.lib to the project.
+     Build the project.
+
+ 5). If the build fails, add the paths to png.h and zlib.h to
+     your include path, and restart the build.
+
+By default, the libpng project uses zlib as a static library.  If
+you wish to use zlib as a DLL, please read the important notes from
+the zlib DLL FAQ, found inside the zlib distribution.
+
+See the libpng documentation for instructions on how to use the code.
diff --git a/projects/borland/libpngstat.bpf b/projects/cbuilder5/libpngstat.bpf
similarity index 94%
rename from projects/borland/libpngstat.bpf
rename to projects/cbuilder5/libpngstat.bpf
index 9159d02..fbc5c40 100644
--- a/projects/borland/libpngstat.bpf
+++ b/projects/cbuilder5/libpngstat.bpf
@@ -1,7 +1,6 @@
-USELIB("zlibstat.lib");
-USEUNIT("..\..\pngerror.c");
 USEUNIT("..\..\png.c");
-USEUNIT("..\..\pngwutil.c");
+USEUNIT("..\..\pngerror.c");
+USEUNIT("..\..\pngget.c");
 USEUNIT("..\..\pngmem.c");
 USEUNIT("..\..\pngpread.c");
 USEUNIT("..\..\pngread.c");
@@ -13,7 +12,8 @@
 USEUNIT("..\..\pngwio.c");
 USEUNIT("..\..\pngwrite.c");
 USEUNIT("..\..\pngwtran.c");
-USEUNIT("..\..\pngget.c");
+USEUNIT("..\..\pngwutil.c");
+USELIB("..\..\..\zlib\zlib.lib");
 //---------------------------------------------------------------------------
 #define Library
 
diff --git a/projects/borland/libpngstat.bpr b/projects/cbuilder5/libpngstat.bpr
similarity index 97%
rename from projects/borland/libpngstat.bpr
rename to projects/cbuilder5/libpngstat.bpr
index 0b97981..9a51ecc 100644
--- a/projects/borland/libpngstat.bpr
+++ b/projects/cbuilder5/libpngstat.bpr
@@ -11,7 +11,7 @@
     <RESFILES value=""/>
     <DEFFILE value=""/>
     <RESDEPEN value="$(RESFILES)"/>
-    <LIBFILES value="zlibstat.lib"/>
+    <LIBFILES value="..\..\..\zlib\zlib.lib"/>
     <LIBRARIES value=""/>
     <PACKAGES value=""/>
     <PATHCPP value=".;..\.."/>
diff --git a/projects/cbuilder5/zlib.readme.txt b/projects/cbuilder5/zlib.readme.txt
new file mode 100644
index 0000000..cb6a7a8
--- /dev/null
+++ b/projects/cbuilder5/zlib.readme.txt
@@ -0,0 +1,14 @@
+The project that builds libpng under Borland C++ Builder does not
+explicitly build zlib.  By taking this decision, there is no need
+to update the libpng project each time when there is a change in
+the list of zlib source files.  After all, this list is private to
+zlib, and applications (such as libpng) should not assume anything
+about it.
+
+If you wish to contribute a project that builds zlib under Borland
+C++ Builder, please submit it to the zlib developers, not to the
+libpng developers.
+
+By default, the libpng project uses zlib as a static library.  If
+you wish to use zlib as a DLL, please read the important notes from
+the zlib DLL FAQ, found inside the zlib distribution.
diff --git a/projects/msvc/README.txt b/projects/msvc/README.txt
deleted file mode 100644
index 8e288c3..0000000
--- a/projects/msvc/README.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-Microsoft Developer Studio Build File, Format Version 6.00 for
-libpng 1.0.15 (October 3, 2002) and zlib
-
-Copyright (C) 2000 Simon-Pierre Cadieux
-For conditions of distribution and use, see copyright notice in png.h
-
-Assumes that libpng sources are in ..\..
-Assumes that zlib sources have been copied to ..\..\..\zlib
-
-To build:
-
-1) On the main menu Select "Build|Set Active configuration". 
-   Among the configurations beginning with "libpng" select the 
-   one you wish to build (the corresponding "zlib" configuration
-   will be built automatically).
-
-2) Select "Build|Clean"
-
-3) Select "Build|Rebuild All"
-
-4) Look in the appropriate "win32" subdirectories for both "zlib"
-   and "libpng" binaries.
-
-This project will build the PNG Development Group's "official" versions of
-libpng and zlib libraries:
-
-   libpng10.dll          (default version, currently C code only)
-   libpng10.dll         (C + Assembler version)
-   libpng10.dll         (C + Assembler debug version)
-   libpng10.dll         (C code debug version)
-   libpng10[c,e-m].dll   (reserved for official versions) 
-   libpng10[n-z].dll     (available for private versions)
-   zlib.dll             (default version, currently C code only)
-   zlibd.dll            (debug version)
-
-If you change anything in libpng, or select different compiler settings,
-please change the library name to an unreserved name, and define
-DLLFNAME_POSTFIX and (PRIVATEBUILD or SPECIALBUILD) accordingly. DLLFNAME_POSTFIX
-should correspond to a string in the range of "N" to "Z" depending on the letter 
-you choose for your private version.
-
-All DLLs built by this project use the Microsoft dynamic C runtime library
-MSVCRT.DLL (MSVCRTD.DLL for debug versions). If you distribute any of the
-above mentioned libraries you should also include this DLL in your package.
-For a list of files that are redistributable in Visual C++ 6.0, see
-Common\Redist\Redist.txt on Disc 1 of the Visual C++ 6.0 product CDs. 
-
diff --git a/projects/msvc/libpng.dsp b/projects/msvc/libpng.dsp
deleted file mode 100644
index 4b6dd03..0000000
--- a/projects/msvc/libpng.dsp
+++ /dev/null
@@ -1,367 +0,0 @@
-# Microsoft Developer Studio Project File - Name="libpng" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=libpng - Win32 DLL
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "libpng.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "libpng.mak" CFG="libpng - Win32 DLL"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "libpng - Win32 DLL" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libpng - Win32 DLL Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libpng - Win32 DLL ASM" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libpng - Win32 DLL Debug ASM" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libpng - Win32 LIB" (based on "Win32 (x86) Static Library")
-!MESSAGE "libpng - Win32 LIB Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-
-!IF  "$(CFG)" == "libpng - Win32 DLL"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\win32\libpng\dll"
-# PROP Intermediate_Dir ".\win32\libpng\dll"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-CPP=cl.exe
-# ADD BASE CPP /nologo /MD /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /c
-# ADD CPP /nologo /MD /W3 /O1 /I "..\.." /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /Yu"png.h" /FD /c
-MTL=midl.exe
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /dll /machine:I386
-# ADD LINK32 /nologo /dll /machine:I386 /out:".\win32\libpng\dll\libpng10.dll"
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 DLL Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\win32\libpng\dll_dbg"
-# PROP Intermediate_Dir ".\win32\libpng\dll_dbg"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-CPP=cl.exe
-# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "DEBUG" /D "_DEBUG" /D PNG_DEBUG=1 /D "WIN32" /D "_WINDOWS" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /Yu"png.h" /FD /GZ /c
-MTL=midl.exe
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG" /d PNG_DEBUG=1
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /dll /debug /machine:I386 /out:".\win32\libpng\dll_dbg\libpng10d.dll"
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 DLL ASM"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\win32\libpng\dll_asm"
-# PROP Intermediate_Dir ".\win32\libpng\dll_asm"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-CPP=cl.exe
-# ADD BASE CPP /nologo /MD /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /c
-# ADD CPP /nologo /MD /W3 /O1 /I "..\.." /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /Yu"png.h" /FD /c
-MTL=midl.exe
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" /d "PNG_USE_PNGVCRD"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /dll /machine:I386
-# ADD LINK32 /nologo /dll /machine:I386 /out:".\win32\libpng\dll_asm\libpng10a.dll"
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 DLL Debug ASM"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\win32\libpng\dll_dbga"
-# PROP Intermediate_Dir ".\win32\libpng\dll_dbga"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-CPP=cl.exe
-# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "DEBUG" /D "_DEBUG" /D PNG_DEBUG=1 /D "WIN32" /D "_WINDOWS" /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /Yu"png.h" /FD /GZ /c
-MTL=midl.exe
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG" /d PNG_DEBUG=1  /d "PNG_USE_PNGVCRD"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /dll /debug /machine:I386 /out:".\win32\libpng\dll_dbga\libpng10b.dll"
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 LIB"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\win32\libpng\lib"
-# PROP Intermediate_Dir ".\win32\libpng\lib"
-# PROP Target_Dir ""
-MTL=midl.exe
-CPP=cl.exe
-# ADD BASE CPP /nologo /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_LIB" /FD /c
-# ADD CPP /nologo /W3 /O1 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /Yu"png.h" /FD /c
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 LIB Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\win32\libpng\lib_dbg"
-# PROP Intermediate_Dir ".\win32\libpng\lib_dbg"
-# PROP Target_Dir ""
-MTL=midl.exe
-CPP=cl.exe
-# ADD BASE CPP /nologo /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_LIB" /FD /GZ /c
-# ADD CPP /nologo /W3 /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "DEBUG" /D "_DEBUG" /D PNG_DEBUG=1 /D "WIN32" /Yu"png.h" /FD /GZ /c
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ENDIF 
-
-# Begin Target
-
-# Name "libpng - Win32 DLL"
-# Name "libpng - Win32 DLL Debug"
-# Name "libpng - Win32 DLL ASM"
-# Name "libpng - Win32 DLL Debug ASM"
-# Name "libpng - Win32 LIB"
-# Name "libpng - Win32 LIB Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\..\png.c
-# SUBTRACT CPP /YX /Yc /Yu
-# End Source File
-# Begin Source File
-
-SOURCE=.\png.rc
-
-!IF  "$(CFG)" == "libpng - Win32 DLL"
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 DLL Debug"
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 DLL ASM"
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 DLL Debug ASM"
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 LIB"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 LIB Debug"
-
-# PROP Exclude_From_Build 1
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\png32ms.def
-
-!IF  "$(CFG)" == "libpng - Win32 DLL"
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 DLL Debug"
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 DLL ASM"
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 DLL Debug ASM"
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 LIB"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 LIB Debug"
-
-# PROP Exclude_From_Build 1
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\pngerror.c
-# ADD CPP /Yc"png.h"
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\pngget.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\pngmem.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\pngpread.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\pngread.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\pngrio.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\pngrtran.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\pngrutil.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\pngset.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\pngtrans.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\pngvcrd.c
-
-!IF  "$(CFG)" == "libpng - Win32 DLL"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 DLL Debug"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 DLL ASM"
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 DLL Debug ASM"
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 LIB"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF  "$(CFG)" == "libpng - Win32 LIB Debug"
-
-# PROP Exclude_From_Build 1
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\pngwio.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\pngwrite.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\pngwtran.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\pngwutil.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=..\..\png.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\pngconf.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# Begin Source File
-
-SOURCE=.\readme.txt
-# PROP Exclude_From_Build 1
-# End Source File
-# End Target
-# End Project
diff --git a/projects/msvc/zlib.def b/projects/msvc/zlib.def
deleted file mode 100644
index 022aa45..0000000
--- a/projects/msvc/zlib.def
+++ /dev/null
@@ -1,45 +0,0 @@
-LIBRARY
-DESCRIPTION "zlib compression library for Windows"
-
-EXPORTS
-    adler32                        @1
-    compress                       @2
-    crc32                          @3
-    deflate                        @4
-    deflateCopy                    @5
-    deflateEnd                     @6
-    deflateInit2_                  @7
-    deflateInit_                   @8
-    deflateParams                  @9
-    deflateReset                   @10
-    deflateSetDictionary           @11
-    gzclose                        @12
-    gzdopen                        @13
-    gzerror                        @14
-    gzflush                        @15
-    gzopen                         @16
-    gzread                         @17
-    gzwrite                        @18
-    inflate                        @19
-    inflateEnd                     @20
-    inflateInit2_                  @21
-    inflateInit_                   @22
-    inflateReset                   @23
-    inflateSetDictionary           @24
-    inflateSync                    @25
-    uncompress                     @26
-    zlibVersion                    @27
-    gzprintf                       @28
-    gzputc                         @29
-    gzgetc                         @30
-    gzseek                         @31
-    gzrewind                       @32
-    gztell                         @33
-    gzeof                          @34
-    gzsetparams                    @35
-    zError                         @36
-    inflateSyncPoint               @37
-    get_crc_table                  @38
-    compress2                      @39
-    gzputs                         @40
-    gzgets                         @41
diff --git a/projects/msvc/zlib.dsp b/projects/msvc/zlib.dsp
deleted file mode 100644
index e82d612..0000000
--- a/projects/msvc/zlib.dsp
+++ /dev/null
@@ -1,400 +0,0 @@
-# Microsoft Developer Studio Project File - Name="zlib" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=zlib - Win32 DLL
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "zlib.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "zlib.mak" CFG="zlib - Win32 DLL"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "zlib - Win32 DLL" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "zlib - Win32 DLL Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "zlib - Win32 DLL ASM" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "zlib - Win32 DLL Debug ASM" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "zlib - Win32 LIB" (based on "Win32 (x86) Static Library")
-!MESSAGE "zlib - Win32 LIB Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-
-!IF  "$(CFG)" == "zlib - Win32 DLL"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\win32\zlib\dll"
-# PROP Intermediate_Dir ".\win32\zlib\dll"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-CPP=cl.exe
-# ADD BASE CPP /nologo /MD /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /FD /c
-# ADD CPP /nologo /MD /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /FD /c
-MTL=midl.exe
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /dll /machine:I386
-# ADD LINK32 /nologo /dll /machine:I386
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 DLL Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\win32\zlib\dll_dbg"
-# PROP Intermediate_Dir ".\win32\zlib\dll_dbg"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-CPP=cl.exe
-# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Zi /Od /D "DEBUG" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /FD /GZ /c
-MTL=midl.exe
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /dll /debug /machine:I386 /out:".\win32\zlib\dll_dbg\zlibd.dll"
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 DLL ASM"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\win32\zlib\dll_asm"
-# PROP Intermediate_Dir ".\win32\zlib\dll_asm"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-CPP=cl.exe
-# ADD BASE CPP /nologo /MD /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /c
-# ADD CPP /nologo /MD /W3 /O1 /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FD /c
-MTL=midl.exe
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /dll /machine:I386
-# ADD LINK32 gvmat32.obj /nologo /dll /machine:I386 /out:".\win32\zlib\dll_asm\zliba.dll"
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 DLL Debug ASM"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\win32\zlib\dll_dbga"
-# PROP Intermediate_Dir ".\win32\zlib\dll_dbga"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-CPP=cl.exe
-# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Zi /Od /I "..\..\..\zlib" /D "_DEBUG" /D "WIN32" /D "_WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FD /GZ /c
-MTL=midl.exe
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 gvmat32d.obj /nologo /dll /debug /machine:I386 /out:".\win32\zlib\dll_dbga\zlibb.dll"
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 LIB"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\win32\zlib\lib"
-# PROP Intermediate_Dir ".\win32\zlib\lib"
-# PROP Target_Dir ""
-MTL=midl.exe
-CPP=cl.exe
-# ADD BASE CPP /nologo /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_LIB" /FD /c
-# ADD CPP /nologo /W3 /O1 /D "WIN32" /D "NDEBUG" /FD /c
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 LIB Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\win32\zlib\lib_dbg"
-# PROP Intermediate_Dir ".\win32\zlib\lib_dbg"
-# PROP Target_Dir ""
-MTL=midl.exe
-CPP=cl.exe
-# ADD BASE CPP /nologo /W3 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_LIB" /FD /GZ /c
-# ADD CPP /nologo /W3 /Zi /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
-RSC=rc.exe
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ENDIF 
-
-# Begin Target
-
-# Name "zlib - Win32 DLL"
-# Name "zlib - Win32 DLL Debug"
-# Name "zlib - Win32 DLL ASM"
-# Name "zlib - Win32 DLL Debug ASM"
-# Name "zlib - Win32 LIB"
-# Name "zlib - Win32 LIB Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\..\..\zlib\adler32.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\compress.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\crc32.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\deflate.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\contrib\asm386\gvmat32c.c
-
-!IF  "$(CFG)" == "zlib - Win32 DLL"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 DLL Debug"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 DLL ASM"
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 DLL Debug ASM"
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 LIB"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 LIB Debug"
-
-# PROP Exclude_From_Build 1
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\gzio.c
-# ADD CPP /Yc"zutil.h"
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\infblock.c
-# ADD CPP /Yu"zutil.h"
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\infcodes.c
-# ADD CPP /Yu"zutil.h"
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\inffast.c
-# ADD CPP /Yu"zutil.h"
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\inflate.c
-# ADD CPP /Yu"zutil.h"
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\inftrees.c
-# ADD CPP /Yu"zutil.h"
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\infutil.c
-# ADD CPP /Yu"zutil.h"
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\trees.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\uncompr.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\zlib.def
-
-!IF  "$(CFG)" == "zlib - Win32 DLL"
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 DLL Debug"
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 DLL ASM"
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 DLL Debug ASM"
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 LIB"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 LIB Debug"
-
-# PROP Exclude_From_Build 1
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\msdos\zlib.rc
-
-!IF  "$(CFG)" == "zlib - Win32 DLL"
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 DLL Debug"
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 DLL ASM"
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 DLL Debug ASM"
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 LIB"
-
-# PROP Exclude_From_Build 1
-
-!ELSEIF  "$(CFG)" == "zlib - Win32 LIB Debug"
-
-# PROP Exclude_From_Build 1
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\zutil.c
-# ADD CPP /Yu"zutil.h"
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=..\..\..\zlib\deflate.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\infblock.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\infcodes.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\inffast.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\inffixed.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\inftrees.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\infutil.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\trees.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\zconf.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\zlib.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\zlib\zutil.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/projects/visualc6/README.txt b/projects/visualc6/README.txt
new file mode 100644
index 0000000..c1500b2
--- /dev/null
+++ b/projects/visualc6/README.txt
@@ -0,0 +1,64 @@
+Microsoft Developer Studio Project File, Format Version 6.00 for libpng.
+
+Copyright (C) 2000-2004 Simon-Pierre Cadieux.
+Copyright (C) 2004 Cosmin Truta.
+For conditions of distribution and use, see copyright notice in png.h
+
+
+Assumptions:
+* The libpng source files are in ..\..
+* The zlib source files are in ..\..\..\zlib
+* The zlib project files are in ..\..\..\zlib\projects\visualc6
+
+
+To use:
+
+1) On the main menu, select "File | Open Workspace".
+   Open "libpng.dsw".
+
+2) Select "Build | Set Active Configuration".
+   Choose the configuration you wish to build.
+   (Choose libpng or pngtest; zlib will be built automatically.)
+
+3) Select "Build | Clean".
+
+4) Select "Build | Build ... (F7)".  Ignore warning messages about
+   not being able to find certain include files (e.g. alloc.h).
+
+5) If you built the sample program (pngtest),
+   select "Build | Execute ... (Ctrl+F5)".
+
+
+This project builds the libpng binaries as follows:
+
+* Win32_DLL_Release\libpng10.dll      DLL build
+* Win32_DLL_Debug\libpng10d.dll       DLL build (debug version)
+* Win32_DLL_ASM_Release\libpng10.dll  DLL build using ASM code
+* Win32_DLL_ASM_Debug\libpng10d.dll   DLL build using ASM (debug version)
+* Win32_DLL_VB\libpng10vb.dll         DLL build for Visual Basic, using stdcall
+* Win32_LIB_Release\libpng.lib        static build
+* Win32_LIB_Debug\libpngd.lib         static build (debug version)
+* Win32_LIB_ASM_Release\libpng.lib    static build using ASM code
+* Win32_LIB_ASM_Debug\libpngd.lib     static build using ASM (debug version)
+
+
+Notes:
+
+If you change anything in the source files, or select different compiler
+settings, please change the DLL name to something different than any of
+the above names.
+
+Also, make sure that DLLFNAME_POSTFIX and (PRIVATEBUILD or SPECIALBUILD)
+are defined when compiling the resource file.  DLLFNAME_POSTFIX contains
+the trailing letters that come after the version number.  PRIVATEBUILD
+and/or SPECIALBUILD store information describing the type of change made
+in the VERSIONINFO structure.  Please refer to MSDN for more information
+on the used macros and the nature of their content.  For an example on
+how to define these macros, look at the resource compiler settings for
+the "Win32 DLL VB" configuration.
+
+All DLLs built by this project use the Microsoft dynamic C runtime library
+MSVCRT.DLL (MSVCRTD.DLL for debug versions).  If you distribute any of the
+above mentioned libraries you should also include this DLL in your package.
+For a list of files that are redistributable in Visual C++ 6.0, see
+Common\Redist\Redist.txt on Disc 1 of the Visual C++ 6.0 product CDs.
diff --git a/projects/visualc6/libpng.dsp b/projects/visualc6/libpng.dsp
new file mode 100644
index 0000000..d25fc31
--- /dev/null
+++ b/projects/visualc6/libpng.dsp
@@ -0,0 +1,507 @@
+# Microsoft Developer Studio Project File - Name="libpng" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=libpng - Win32 DLL Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "libpng.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "libpng.mak" CFG="libpng - Win32 DLL Release"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "libpng - Win32 DLL Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "libpng - Win32 DLL Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "libpng - Win32 DLL ASM Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "libpng - Win32 DLL ASM Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "libpng - Win32 DLL VB" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "libpng - Win32 LIB Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "libpng - Win32 LIB Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE "libpng - Win32 LIB ASM Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "libpng - Win32 LIB ASM Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+
+!IF  "$(CFG)" == "libpng - Win32 DLL Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "libpng___Win32_DLL_Release"
+# PROP BASE Intermediate_Dir "libpng___Win32_DLL_Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Win32_DLL_Release"
+# PROP Intermediate_Dir "Win32_DLL_Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+CPP=cl.exe
+# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
+# SUBTRACT BASE CPP /YX /Yc /Yu
+# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /FD /c
+# SUBTRACT CPP /YX /Yc /Yu
+MTL=midl.exe
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+RSC=rc.exe
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /dll /machine:I386
+# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_Release\libpng10.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Release"
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 DLL Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "libpng___Win32_DLL_Release"
+# PROP BASE Intermediate_Dir "libpng___Win32_DLL_Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Win32_DLL_Debug"
+# PROP Intermediate_Dir "Win32_DLL_Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+CPP=cl.exe
+# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
+# SUBTRACT BASE CPP /YX /Yc /Yu
+# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /FD /GZ /c
+# SUBTRACT CPP /YX /Yc /Yu
+MTL=midl.exe
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+RSC=rc.exe
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG" /d PNG_DEBUG=1
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 zlib1d.lib /nologo /dll /debug /machine:I386 /out:"Win32_DLL_Debug\libpng10d.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Debug"
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 DLL ASM Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "libpng___Win32_DLL_ASM_Release"
+# PROP BASE Intermediate_Dir "libpng___Win32_DLL_ASM_Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Win32_DLL_ASM_Release"
+# PROP Intermediate_Dir "Win32_DLL_ASM_Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+CPP=cl.exe
+# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
+# SUBTRACT BASE CPP /YX /Yc /Yu
+# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /FD /c
+# SUBTRACT CPP /YX /Yc /Yu
+MTL=midl.exe
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+RSC=rc.exe
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" /d "PNG_USE_PNGVCRD"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /dll /machine:I386
+# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_ASM_Release\libpng10.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Release"
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 DLL ASM Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "libpng___Win32_DLL_ASM_Debug"
+# PROP BASE Intermediate_Dir "libpng___Win32_DLL_ASM_Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Win32_DLL_ASM_Debug"
+# PROP Intermediate_Dir "Win32_DLL_ASM_Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+CPP=cl.exe
+# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
+# SUBTRACT BASE CPP /YX /Yc /Yu
+# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /FD /GZ /c
+# SUBTRACT CPP /YX /Yc /Yu
+MTL=midl.exe
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+RSC=rc.exe
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG" /d PNG_DEBUG=1 /d "PNG_USE_PNGVCRD"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 zlib1d.lib /nologo /dll /debug /machine:I386 /out:"Win32_DLL_ASM_Debug\libpng10d.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Debug"
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 DLL VB"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "libpng___Win32_DLL_VB"
+# PROP BASE Intermediate_Dir "libpng___Win32_DLL_VB"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Win32_DLL_VB"
+# PROP Intermediate_Dir "Win32_DLL_VB"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+CPP=cl.exe
+# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
+# SUBTRACT BASE CPP /YX /Yc /Yu
+# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D PNGAPI=__stdcall /D "PNG_NO_MODULEDEF" /FD /c
+# SUBTRACT CPP /YX /Yc /Yu
+MTL=midl.exe
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+RSC=rc.exe
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" /dDLLFNAME_POSTFIX=""""VB"""" /dSPECIALBUILD=""""__stdcall calling convention used for exported functions""""
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /dll /machine:I386
+# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_VB\libpng10vb.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Release"
+# Begin Special Build Tool
+OutDir=.\Win32_DLL_VB
+TargetName=libpng10vb
+SOURCE="$(InputPath)"
+PostBuild_Cmds=echo    Deleting $(targetname) import library and export file (Not required for VB projects)	del $(outdir)\$(targetname).lib	del $(outdir)\$(targetname).exp
+# End Special Build Tool
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 LIB Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "libpng___Win32_LIB_Release"
+# PROP BASE Intermediate_Dir "libpng___Win32_LIB_Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Win32_LIB_Release"
+# PROP Intermediate_Dir "Win32_LIB_Release"
+# PROP Target_Dir ""
+CPP=cl.exe
+# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
+# SUBTRACT BASE CPP /YX /Yc /Yu
+# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /FD /c
+# SUBTRACT CPP /YX /Yc /Yu
+RSC=rc.exe
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 LIB Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "libpng___Win32_LIB_Debug"
+# PROP BASE Intermediate_Dir "libpng___Win32_LIB_Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Win32_LIB_Debug"
+# PROP Intermediate_Dir "Win32_LIB_Debug"
+# PROP Target_Dir ""
+CPP=cl.exe
+# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
+# SUBTRACT BASE CPP /YX /Yc /Yu
+# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /FD /GZ /c
+# SUBTRACT CPP /YX /Yc /Yu
+RSC=rc.exe
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo /out:"Win32_LIB_Debug\libpngd.lib"
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 LIB ASM Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "libpng___Win32_LIB_ASM_Release"
+# PROP BASE Intermediate_Dir "libpng___Win32_LIB_ASM_Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Win32_LIB_ASM_Release"
+# PROP Intermediate_Dir "Win32_LIB_ASM_Release"
+# PROP Target_Dir ""
+CPP=cl.exe
+# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
+# SUBTRACT BASE CPP /YX /Yc /Yu
+# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_USE_PNGVCRD" /FD /c
+# SUBTRACT CPP /YX /Yc /Yu
+RSC=rc.exe
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 LIB ASM Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "libpng___Win32_LIB_ASM_Debug"
+# PROP BASE Intermediate_Dir "libpng___Win32_LIB_ASM_Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Win32_LIB_ASM_Debug"
+# PROP Intermediate_Dir "Win32_LIB_ASM_Debug"
+# PROP Target_Dir ""
+CPP=cl.exe
+# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
+# SUBTRACT BASE CPP /YX /Yc /Yu
+# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_USE_PNGVCRD" /FD /GZ /c
+# SUBTRACT CPP /YX /Yc /Yu
+RSC=rc.exe
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo /out:"Win32_LIB_ASM_Debug\libpngd.lib"
+
+!ENDIF 
+
+# Begin Target
+
+# Name "libpng - Win32 DLL Release"
+# Name "libpng - Win32 DLL Debug"
+# Name "libpng - Win32 DLL ASM Release"
+# Name "libpng - Win32 DLL ASM Debug"
+# Name "libpng - Win32 DLL VB"
+# Name "libpng - Win32 LIB Release"
+# Name "libpng - Win32 LIB Debug"
+# Name "libpng - Win32 LIB ASM Release"
+# Name "libpng - Win32 LIB ASM Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\png.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\pngerror.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\pngget.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\pngmem.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\pngpread.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\pngread.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\pngrio.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\pngrtran.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\pngrutil.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\pngset.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\pngtrans.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\pngvcrd.c
+
+!IF  "$(CFG)" == "libpng - Win32 DLL Release"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 DLL Debug"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 DLL ASM Release"
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 DLL ASM Debug"
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 DLL VB"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 LIB Release"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 LIB Debug"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 LIB ASM Release"
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 LIB ASM Debug"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\scripts\pngw32.def
+
+!IF  "$(CFG)" == "libpng - Win32 DLL Release"
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 DLL Debug"
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 DLL ASM Release"
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 DLL ASM Debug"
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 DLL VB"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 LIB Release"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 LIB Debug"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 LIB ASM Release"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 LIB ASM Debug"
+
+# PROP Exclude_From_Build 1
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\pngwio.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\pngwrite.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\pngwtran.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\pngwutil.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\..\png.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\pngconf.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=..\..\scripts\pngw32.rc
+
+!IF  "$(CFG)" == "libpng - Win32 DLL Release"
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 DLL Debug"
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 DLL ASM Release"
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 DLL ASM Debug"
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 DLL VB"
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 LIB Release"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 LIB Debug"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 LIB ASM Release"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF  "$(CFG)" == "libpng - Win32 LIB ASM Debug"
+
+# PROP Exclude_From_Build 1
+
+!ENDIF 
+
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\README.txt
+# End Source File
+# End Target
+# End Project
diff --git a/projects/msvc/libpng.dsw b/projects/visualc6/libpng.dsw
similarity index 62%
rename from projects/msvc/libpng.dsw
rename to projects/visualc6/libpng.dsw
index eca5b77..4f3856f 100644
--- a/projects/msvc/libpng.dsw
+++ b/projects/visualc6/libpng.dsw
@@ -3,7 +3,7 @@
 
 ###############################################################################
 
-Project: "libpng"=.\libpng.dsp - Package Owner=<4>
+Project: "libpng"=".\libpng.dsp" - Package Owner=<4>
 
 Package=<5>
 {{{
@@ -18,7 +18,22 @@
 
 ###############################################################################
 
-Project: "zlib"=.\zlib.dsp - Package Owner=<4>
+Project: "pngtest"=".\pngtest.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+    Begin Project Dependency
+    Project_Dep_Name libpng
+    End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "zlib"="..\..\..\zlib\projects\visualc6\zlib.dsp" - Package Owner=<4>
 
 Package=<5>
 {{{
diff --git a/projects/visualc6/pngtest.dsp b/projects/visualc6/pngtest.dsp
new file mode 100644
index 0000000..5aed72b
--- /dev/null
+++ b/projects/visualc6/pngtest.dsp
@@ -0,0 +1,314 @@
+# Microsoft Developer Studio Project File - Name="pngtest" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=pngtest - Win32 DLL Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "pngtest.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "pngtest.mak" CFG="pngtest - Win32 DLL Release"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "pngtest - Win32 DLL Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "pngtest - Win32 DLL Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "pngtest - Win32 DLL ASM Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "pngtest - Win32 DLL ASM Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "pngtest - Win32 LIB Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "pngtest - Win32 LIB Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "pngtest - Win32 LIB ASM Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "pngtest - Win32 LIB ASM Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "pngtest - Win32 DLL Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "pngtest___Win32_DLL_Release"
+# PROP BASE Intermediate_Dir "pngtest___Win32_DLL_Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Win32_DLL_Release"
+# PROP Intermediate_Dir "Win32_DLL_Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
+# SUBTRACT BASE CPP /YX
+# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:console /machine:I386
+# ADD LINK32 Win32_DLL_Release\libpng10.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_Release\zlib1.lib /nologo /subsystem:console /machine:I386
+# Begin Special Build Tool
+OutDir=.\Win32_DLL_Release
+SOURCE="$(InputPath)"
+PostBuild_Desc=[Run Test]
+PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_Release;	$(outdir)\pngtest.exe ..\..\pngtest.png
+# End Special Build Tool
+
+!ELSEIF  "$(CFG)" == "pngtest - Win32 DLL Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "pngtest___Win32_DLL_Debug"
+# PROP BASE Intermediate_Dir "pngtest___Win32_DLL_Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Win32_DLL_Debug"
+# PROP Intermediate_Dir "Win32_DLL_Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
+# SUBTRACT BASE CPP /YX
+# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 Win32_DLL_Debug\libpng10d.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_Debug\zlib1d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# Begin Special Build Tool
+OutDir=.\Win32_DLL_Debug
+SOURCE="$(InputPath)"
+PostBuild_Desc=[Run Test]
+PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_Debug;	$(outdir)\pngtest.exe ..\..\pngtest.png
+# End Special Build Tool
+
+!ELSEIF  "$(CFG)" == "pngtest - Win32 DLL ASM Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "pngtest___Win32_DLL_ASM_Release"
+# PROP BASE Intermediate_Dir "pngtest___Win32_DLL_ASM_Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Win32_DLL_ASM_Release"
+# PROP Intermediate_Dir "Win32_DLL_ASM_Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
+# SUBTRACT BASE CPP /YX
+# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:console /machine:I386
+# ADD LINK32 Win32_DLL_ASM_Release\libpng10.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Release\zlib1.lib /nologo /subsystem:console /machine:I386
+# Begin Special Build Tool
+OutDir=.\Win32_DLL_ASM_Release
+SOURCE="$(InputPath)"
+PostBuild_Desc=[Run Test]
+PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Release;	$(outdir)\pngtest.exe ..\..\pngtest.png
+# End Special Build Tool
+
+!ELSEIF  "$(CFG)" == "pngtest - Win32 DLL ASM Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "pngtest___Win32_DLL_ASM_Debug"
+# PROP BASE Intermediate_Dir "pngtest___Win32_DLL_ASM_Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Win32_DLL_ASM_Debug"
+# PROP Intermediate_Dir "Win32_DLL_ASM_Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
+# SUBTRACT BASE CPP /YX
+# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 Win32_DLL_ASM_Debug\libpng10d.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Debug\zlib1d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# Begin Special Build Tool
+OutDir=.\Win32_DLL_ASM_Debug
+SOURCE="$(InputPath)"
+PostBuild_Desc=[Run Test]
+PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Debug;	$(outdir)\pngtest.exe ..\..\pngtest.png
+# End Special Build Tool
+
+!ELSEIF  "$(CFG)" == "pngtest - Win32 LIB Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "pngtest___Win32_LIB_Release"
+# PROP BASE Intermediate_Dir "pngtest___Win32_LIB_Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Win32_LIB_Release"
+# PROP Intermediate_Dir "Win32_LIB_Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
+# SUBTRACT BASE CPP /YX
+# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:console /machine:I386
+# ADD LINK32 Win32_LIB_Release\libpng.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_Release\zlib.lib /nologo /subsystem:console /machine:I386
+# Begin Special Build Tool
+OutDir=.\Win32_LIB_Release
+SOURCE="$(InputPath)"
+PostBuild_Desc=[Run Test]
+PostBuild_Cmds=$(outdir)\pngtest.exe ..\..\pngtest.png
+# End Special Build Tool
+
+!ELSEIF  "$(CFG)" == "pngtest - Win32 LIB Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "pngtest___Win32_LIB_Debug"
+# PROP BASE Intermediate_Dir "pngtest___Win32_LIB_Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Win32_LIB_Debug"
+# PROP Intermediate_Dir "Win32_LIB_Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
+# SUBTRACT BASE CPP /YX
+# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 Win32_LIB_Debug\libpngd.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_Debug\zlibd.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# Begin Special Build Tool
+OutDir=.\Win32_LIB_Debug
+SOURCE="$(InputPath)"
+PostBuild_Desc=[Run Test]
+PostBuild_Cmds=$(outdir)\pngtest.exe ..\..\pngtest.png
+# End Special Build Tool
+
+!ELSEIF  "$(CFG)" == "pngtest - Win32 LIB ASM Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "pngtest___Win32_LIB_ASM_Release"
+# PROP BASE Intermediate_Dir "pngtest___Win32_LIB_ASM_Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Win32_LIB_ASM_Release"
+# PROP Intermediate_Dir "Win32_LIB_ASM_Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
+# SUBTRACT BASE CPP /YX
+# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:console /machine:I386
+# ADD LINK32 Win32_LIB_ASM_Release\libpng.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_ASM_Release\zlib.lib /nologo /subsystem:console /machine:I386
+# Begin Special Build Tool
+OutDir=.\Win32_LIB_ASM_Release
+SOURCE="$(InputPath)"
+PostBuild_Desc=[Run Test]
+PostBuild_Cmds=$(outdir)\pngtest.exe ..\..\pngtest.png
+# End Special Build Tool
+
+!ELSEIF  "$(CFG)" == "pngtest - Win32 LIB ASM Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "pngtest___Win32_LIB_ASM_Debug"
+# PROP BASE Intermediate_Dir "pngtest___Win32_LIB_ASM_Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Win32_LIB_ASM_Debug"
+# PROP Intermediate_Dir "Win32_LIB_ASM_Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
+# SUBTRACT BASE CPP /YX
+# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 Win32_LIB_ASM_Debug\libpngd.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_ASM_Debug\zlibd.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# Begin Special Build Tool
+OutDir=.\Win32_LIB_ASM_Debug
+SOURCE="$(InputPath)"
+PostBuild_Desc=[Run Test]
+PostBuild_Cmds=$(outdir)\pngtest.exe ..\..\pngtest.png
+# End Special Build Tool
+
+!ENDIF 
+
+# Begin Target
+
+# Name "pngtest - Win32 DLL Release"
+# Name "pngtest - Win32 DLL Debug"
+# Name "pngtest - Win32 DLL ASM Release"
+# Name "pngtest - Win32 DLL ASM Debug"
+# Name "pngtest - Win32 LIB Release"
+# Name "pngtest - Win32 LIB Debug"
+# Name "pngtest - Win32 LIB ASM Release"
+# Name "pngtest - Win32 LIB ASM Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\pngtest.c
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/scripts/libpng-config-head.in b/scripts/libpng-config-head.in
index 0316489..eb1e678 100755
--- a/scripts/libpng-config-head.in
+++ b/scripts/libpng-config-head.in
@@ -8,7 +8,7 @@
 
 # Modeled after libxml-config.
 
-version=1.0.15
+version=1.0.16
 prefix=""
 libdir=""
 libs=""
diff --git a/scripts/libpng.pc.in b/scripts/libpng.pc.in
index 8aac02b..e7705f9 100644
--- a/scripts/libpng.pc.in
+++ b/scripts/libpng.pc.in
@@ -6,6 +6,6 @@
 
 Name: libpng10
 Description: Loads and saves PNG files
-Version: 1.0.15
+Version: 1.0.16
 Libs: -L${libdir} -lpng10 -lz -lm
 Cflags: -I${includedir}/libpng10
diff --git a/scripts/makefile.32sunu b/scripts/makefile.32sunu
index f21c998..fbcc6cc 100644
--- a/scripts/makefile.32sunu
+++ b/scripts/makefile.32sunu
@@ -26,14 +26,14 @@
 	-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
 CFLAGS=-I$(ZLIBINC) $(SUN_CC_FLAGS) \
 	# $(WARNMORE) -g -DPNG_DEBUG=5
-LDFLAGS=-L. -R. $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng10 -lz -lm
+LDFLAGS=$(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) libpng.a -lz -lm
 
 #RANLIB=ranlib
 RANLIB=echo
 
 LIBNAME=libpng10
 PNGMAJ = 0
-PNGMIN = 1.0.15
+PNGMIN = 1.0.16
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
@@ -138,9 +138,10 @@
 	(cd $(DL); ln -f -s $(LIBNAME).a libpng.a)
 
 install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc \
-	libpng.so.2
+	libpng.so.2.$(PNGMIN)
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
 	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.2
 	-@/bin/rm -f $(DL)/libpng.so.2.$(PNGVER)*
@@ -177,7 +178,7 @@
 	-@/bin/rm -f $(DB)/libpng10-config
 	cp libpng-config $(DB)/libpng10-config
 	chmod 755 $(DB)/libpng10-config
-	(cd $(DB); ln -sf libpng10-config libpng-config)
+	(cd $(DB); ln -f -s libpng10-config libpng-config)
 
 install: install-static install-shared install-man install-config
 
diff --git a/scripts/makefile.64sunu b/scripts/makefile.64sunu
index f0a394e..bc24eb3 100644
--- a/scripts/makefile.64sunu
+++ b/scripts/makefile.64sunu
@@ -33,7 +33,7 @@
 
 LIBNAME=libpng10
 PNGMAJ = 0
-PNGMIN = 1.0.15
+PNGMIN = 1.0.16
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
@@ -140,7 +140,9 @@
 install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc \
 	libpng.so.2.$(PNGMIN)
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ).$(PNGVER)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ).$(PNGVER)*
+	-@/bin/rm -f $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.2
 	-@/bin/rm -f $(DL)/libpng.so.2.$(PNGVER)*
@@ -177,7 +179,7 @@
 	-@/bin/rm -f $(DB)/$(LIBNAME)-config
 	cp libpng-config $(DB)/$(LIBNAME)-config
 	chmod 755 $(DB)/$(LIBNAME)-config
-	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
+	(cd $(DB); ln -f -s $(LIBNAME)-config libpng-config)
 
 install: install-static install-shared install-man install-config
 
diff --git a/scripts/makefile.aix b/scripts/makefile.aix
index 4e68dde..bda1c13 100644
--- a/scripts/makefile.aix
+++ b/scripts/makefile.aix
@@ -16,8 +16,9 @@
 RANLIB = ranlib
 RM = rm -f
 
+LIBNAME=libpng10
 PNGMAJ = 0
-PNGMIN = 1.0.15
+PNGMIN = 1.0.16
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 prefix=/usr/local
@@ -34,15 +35,16 @@
 # you execute make install.
 DESTDIR=
 
-DI=$(DESTDIR)/$(INCPATH)
-DL=$(DESTDIR)/$(LIBPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
 
 CDEBUG = -g -DPNG_DEBUG=5
 LDDEBUG =
 CRELEASE = -O2
 LDRELEASE = -s
-CFLAGS = -I$(ZLIBINC) -Wall $(CRELEASE)
-LDFLAGS = -L. -L$(ZLIBLIB) -lpng -lz -lm $(LDRELEASE)
+WARNMORE=-Wall
+CFLAGS = -I$(ZLIBINC) $(WARNMORE) $(CRELEASE)
+LDFLAGS = -L. -L$(ZLIBLIB) -lpng10 -lz -lm $(LDRELEASE)
 
 # File extensions
 O=.o
@@ -55,32 +57,40 @@
 	pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O)
 
 # Targets
-all: libpng$(A) pngtest$(E)
+all: $(LIBNAME)$(A) pngtest$(E)
 
-libpng$(A): $(OBJS)
+$(LIBNAME)$(A): $(OBJS)
 	$(AR) $@ $(OBJS)
 	$(RANLIB) $@
 
 test: pngtest$(E)
 	./pngtest$(E)
 
-pngtest$(E): pngtest$(O) libpng$(A)
+pngtest$(E): pngtest$(O) $(LIBNAME)$(A)
 	$(LD) -o $@ pngtest$(O) $(LDFLAGS)
 
-install: libpng.a
+install: $(LIBNAME)$(A)
 	-@if [ ! -d $(DI)  ]; then mkdir $(DI); fi
-	-@if [ ! -d $(DI)/libpng  ]; then mkdir $(DI)/libpng; fi
+	-@if [ ! -d $(DI)/$(LIBNAME)  ]; then mkdir $(DI)/$(LIBNAME); fi
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-	-@rm $(DI)/png.h
-	-@rm $(DI)/pngconf.h
-	cp png.h pngconf.h $(DI)/libpng
-	chmod 644 $(DI)/libpng/png.h \
-	$(DI)/libpng/pngconf.h
-	(cd $(DI); ln -f -s libpng/* .)
-	cp libpng.a $(DL)
+	-@rm -f $(DI)/$(LIBNAME)/png.h
+	-@rm -f $(DI)/$(LIBNAME)/pngconf.h
+	-@rm -f $(DI)/png.h
+	-@rm -f $(DI)/pngconf.h
+	cp png.h pngconf.h $(DI)/$(LIBNAME)
+	chmod 644 $(DI)/$(LIBNAME)/png.h \
+	$(DI)/$(LIBNAME)/pngconf.h
+	-@rm -rf $(DI)/libpng
+	(cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .)
+	-@rm -f $(DL)/$(LIBNAME)$(A)
+	-@rm -f $(DL)/libpng$(A)
+	cp $(LIBNAME)$(A) $(DL)/$(LIBNAME)$(A)
+	chmod 644 $(DL)/$(LIBNAME)$(A)
+	(cd $(DL); ln -f -s $(LIBNAME)$(A) libpng$(A))
+	(cd $(DI); ln -f -s libpng/* .;)
 
 clean:
-	/bin/rm -f *.o libpng.a pngtest pngout.png
+	/bin/rm -f *.o $(LIBNAME)$(A) pngtest pngout.png
 
 png$(O): png.h pngconf.h
 pngerror$(O): png.h pngconf.h
diff --git a/scripts/makefile.bd32 b/scripts/makefile.bd32
deleted file mode 100644
index 92a57ab..0000000
--- a/scripts/makefile.bd32
+++ /dev/null
@@ -1,76 +0,0 @@
-# Makefile for png32bd.dll
-# -------------------- 32-bit Borland C++ --------------------
-
-# This makefile expects to find zlib.h and zlib32bd.lib in the
-# $(ZLIBDIR) directory.
-
-# The object files here are compiled with the "stdcall" calling convention.
-# This DLL requires zlib32bd.lib to be compiled in the same way.
-
-# Note that png32bd.dll exports the zlib functions adler32, crc32 and
-# the deflate... and inflate... functions. It does not export the
-# compress and uncompress functions, nor any of the gz... functions,
-# since libpng does not call them.
-
-.AUTODEPEND
-
-ZLIBDIR=..\zlib
-ZLIB=zlib32bd.lib
-PNGDLL=png32bd.dll
-PNGLIB=png32bd.lib
-
-CC=bcc32
-CFLAGS= -ps -O2 -N- -k- -d -r- -w-par -w-aus -I$(ZLIBDIR) \
-	-DPNG_NO_GLOBAL_ARRAYS #-DPNG_DEBUG=5
-#LINK=tlink32
-#LINK=ilink32
-LINK=bcc32
-#LINKFLAGS= -Tpd -aa -c
-LINKFLAGS= -WDE
-IMPLIB=implib
-
-# Use this if you don't want Borland's fancy exception handling
-NOEHLIB=noeh32.lib
-
-.c.obj:
-	$(CC) -c $(CFLAGS) $<
-
-.c.exe:
-	$(CC) $(CFLAGS) $< $(PNGLIB) $(NOEHLIB)
-
-
-OBJ1=png.obj pngerror.obj pngget.obj pngmem.obj pngpread.obj
-OBJ2=pngread.obj pngrio.obj pngrtran.obj pngrutil.obj pngset.obj
-OBJ3=pngtrans.obj pngwio.obj pngwrite.obj pngwtran.obj pngwutil.obj
-
-all: $(PNGDLL)
-
-test: pngtest.exe
-	pngtest
-
-
-$(PNGDLL): $(OBJ1) $(OBJ2) $(OBJ3) $(ZLIBDIR)\$(ZLIB)
-	$(LINK) @&&|
-$(LINKFLAGS)
--e$(PNGDLL)
-$(OBJ1)
-$(OBJ2)
-$(OBJ3)
-$(ZLIBDIR)\$(ZLIB)
-$(NOEHLIB)
-|
-	$(IMPLIB) -c $(@R).lib $@
-
-
-# Clean up anything else you want
-clean:
-	-del *.obj
-	-del *.dll
-	-del *.exe
-	-del *.lib
-	-del *.lst
-	-del *.map
-	-del *.tds
-
-
-# End of makefile for png32bd.dll
diff --git a/scripts/makefile.beos b/scripts/makefile.beos
index 5896b89..9799a34 100644
--- a/scripts/makefile.beos
+++ b/scripts/makefile.beos
@@ -12,7 +12,7 @@
 ZLIBINC=/usr/local/include
 
 PNGMAJ = 0
-PNGMIN = 1.0.15
+PNGMIN = 1.0.16
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 ALIGN=
@@ -123,6 +123,7 @@
 	libpng.so.2.$(PNGMIN)
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
 	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.2
 	-@/bin/rm -f $(DL)/libpng.so.2.$(PNGMIN)*
diff --git a/scripts/makefile.cygwin b/scripts/makefile.cygwin
index 4d19355..7c43dc9 100644
--- a/scripts/makefile.cygwin
+++ b/scripts/makefile.cygwin
@@ -78,8 +78,8 @@
 
 LIBNAME = libpng10
 PNGMAJ = 0
-CYGDLL = 10
-PNGMIN = 1.0.15
+CYGDLL = 12
+PNGMIN = 1.0.16
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 SHAREDLIB=cygpng$(CYGDLL).dll
diff --git a/scripts/makefile.darwin b/scripts/makefile.darwin
index 0f68fa6..6ab05b4 100644
--- a/scripts/makefile.darwin
+++ b/scripts/makefile.darwin
@@ -1,5 +1,5 @@
 # makefile for libpng on Darwin / Mac OS X
-# Copyright (C) 2002 Glenn Randers-Pehrson
+# Copyright (C) 2002,2004 Glenn Randers-Pehrson
 # Copyright (C) 2001 Christoph Pfisterer
 # derived from makefile.linux:
 #  Copyright (C) 1998, 1999 Greg Roelofs
@@ -23,7 +23,7 @@
 RANLIB=ranlib
 
 PNGMAJ = 0
-PNGMIN = 1.0.15
+PNGMIN = 1.0.16
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng10
 
@@ -85,18 +85,17 @@
 
 $(LIBNAME).$(PNGVER).dylib: $(OBJSDLL)
 	$(CC) -dynamiclib \
-	 -install_name $(DL)/$(LIBNAME).$(PNGMAJ).dylib \
-	 -flat_namespace -undefined suppress \
+	 -install_name $(LIBPATH)/$(LIBNAME).$(PNGMAJ).dylib \
+	 -current_version $(PNGVER) -compatibility_version $(PNGVER) \
 	 -o $(LIBNAME).$(PNGVER).dylib \
-	 $(OBJSDLL)
+	 $(OBJSDLL) -L$(ZLIBLIB) -lz
 
-libpng.2.$(PNGMIN).dylib: $(OBJSDLL)
+libpng.3.$(PNGMIN).dylib: $(OBJSDLL)
 	$(CC) -dynamiclib \
-	 -install_name $(DL)/libpng.2.dylib \
-	 -current_version 2 -compatibility_version 2 \
-	 -flat_namespace -undefined suppress \
-	 -o libpng.2.$(PNGMIN).dylib \
-	 $(OBJSDLL)
+	 -install_name $(LIBPATH)/libpng.3.dylib \
+	 -current_version 3 -compatibility_version 3 \
+	 -o libpng.3.$(PNGMIN).dylib \
+	 $(OBJSDLL) -L$(ZLIBLIB) -lz
 
 pngtest: pngtest.o $(LIBNAME).dylib
 	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
@@ -117,24 +116,26 @@
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
 	cp libpng.a $(DL)/$(LIBNAME).a
 	chmod 644 $(DL)/$(LIBNAME).a
+	$(RANLIB) $(DL)/$(LIBNAME).a
 	-@/bin/rm -f $(DL)/libpng.a
 	(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
 
 install-shared: install-headers $(LIBNAME).dylib libpng.pc \
-	libpng.2.$(PNGMIN).dylib
+	libpng.3.$(PNGMIN).dylib
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
 	-@/bin/rm -f $(DL)/$(LIBNAME).$(PNGVER)*.dylib
+	-@/bin/rm -f $(DL)/$(LIBNAME).$(PNGMAJ)*.dylib
 	-@/bin/rm -f $(DL)/$(LIBNAME).dylib
 	-@/bin/rm -f $(DL)/libpng.dylib
-	-@/bin/rm -f $(DL)/libpng.2.dylib
-	-@/bin/rm -f $(DL)/libpng.2.$(PNGMIN)*.dylib
+	-@/bin/rm -f $(DL)/libpng.3.dylib
+	-@/bin/rm -f $(DL)/libpng.3.$(PNGMIN)*.dylib
 	cp $(LIBNAME).$(PNGVER).dylib $(DL)
-	cp libpng.2.$(PNGMIN).dylib $(DL)
+	cp libpng.3.$(PNGMIN).dylib $(DL)
 	chmod 755 $(DL)/$(LIBNAME).$(PNGVER).dylib
-	chmod 755 $(DL)/libpng.2.$(PNGMIN).dylib
+	chmod 755 $(DL)/libpng.3.$(PNGMIN).dylib
 	(cd $(DL); \
-	ln -sf libpng.2.$(PNGMIN).dylib libpng.2.dylib; \
-	ln -sf libpng.2.dylib libpng.dylib; \
+	ln -sf libpng.3.$(PNGMIN).dylib libpng.3.dylib; \
+	ln -sf libpng.3.dylib libpng.dylib; \
 	ln -sf $(LIBNAME).$(PNGVER).dylib $(LIBNAME).$(PNGMAJ).dylib; \
 	ln -sf $(LIBNAME).$(PNGMAJ).dylib $(LIBNAME).dylib)
 	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
@@ -177,7 +178,7 @@
 
 clean:
 	rm -f *.o libpng.a pngtest pngout.png libpng-config \
-	libpng.2.$(PNGMIN).dylib \
+	libpng.3.$(PNGMIN).dylib \
 	libpng.pc $(LIBNAME).*dylib pngtesti
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
diff --git a/scripts/makefile.dec b/scripts/makefile.dec
index 15f4a8f..ff88f0f 100644
--- a/scripts/makefile.dec
+++ b/scripts/makefile.dec
@@ -32,13 +32,13 @@
 ZLIBINC=../zlib
 
 PNGMAJ = 0
-PNGMIN = 1.0.15
+PNGMIN = 1.0.16
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng10
 
 CC=cc
 CFLAGS=-std -w1 -I$(ZLIBINC) -O # -g -DPNG_DEBUG=1
-LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
+LDFLAGS=-L$(ZLIBLIB) -rpath $(ZLIBLIB) libpng.a -lz -lm
 
 #RANLIB=echo
 RANLIB=ranlib
@@ -73,11 +73,11 @@
 	ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
 
 $(LIBNAME).so.$(PNGVER): $(OBJS)
-	$(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB)
+	$(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB) \
 	-soname $(LIBNAME).so.$(PNGMAJ)
 
 libpng.so.2.$(PNGMIN): $(OBJS)
-	$(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB)
+	$(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB) \
 	-soname libpng.so.2
 
 pngtest: pngtest.o libpng.a
@@ -106,6 +106,7 @@
 	libpng.so.2.$(PNGMIN)
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
 	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.2
 	-@/bin/rm -f $(DL)/libpng.so.2.$(PNGMIN)*
diff --git a/scripts/makefile.gcmmx b/scripts/makefile.gcmmx
index 309aab8..3a1ad03 100644
--- a/scripts/makefile.gcmmx
+++ b/scripts/makefile.gcmmx
@@ -15,7 +15,7 @@
 
 LIBNAME = libpng10
 PNGMAJ = 0
-PNGMIN = 1.0.15
+PNGMIN = 1.0.16
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 CC=gcc
@@ -170,6 +170,7 @@
 	libpng.so.2.$(PNGMIN)
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
 	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.2
 	-@/bin/rm -f $(DL)/libpng.so.2.$(PNGMIN)*
diff --git a/scripts/makefile.hpgcc b/scripts/makefile.hpgcc
index af892e5..7c496ef 100644
--- a/scripts/makefile.hpgcc
+++ b/scripts/makefile.hpgcc
@@ -41,7 +41,7 @@
 #RANLIB=echo
 
 PNGMAJ = 0
-PNGMIN = 1.0.15
+PNGMIN = 1.0.16
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng10
 
@@ -103,9 +103,9 @@
 	$(LD) -b +s \
 	+h $(LIBNAME).sl.$(PNGMAJ) -o $(LIBNAME).sl.$(PNGVER) $(OBJSDLL)
 
-libpng.sl.2.$(PNGMIN): $(OBJSDLL)
+libpng.sl.3.$(PNGMIN): $(OBJSDLL)
 	$(LD) -b +s \
-	+h libpng.sl.2 -o libpng.sl.2.$(PNGMIN) $(OBJSDLL)
+	+h libpng.sl.3 -o libpng.sl.3.$(PNGMIN) $(OBJSDLL)
 
 pngtest: pngtest.o $(LIBNAME).sl
 	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
@@ -131,19 +131,20 @@
 	(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
 
 install-shared: install-headers $(LIBNAME).sl.$(PNGVER) libpng.pc \
-	libpng.sl.2.$(PNGMIN)
+	libpng.sl.3.$(PNGMIN)
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
 	-@/bin/rm -f $(DL)/$(LIBNAME).sl.$(PNGVER)* $(DL)/$(LIBNAME).sl
+	-@/bin/rm -f $(DL)/$(LIBNAME).sl.$(PNGMAJ)
 	-@/bin/rm -f $(DL)/libpng.sl
-	-@/bin/rm -f $(DL)/libpng.sl.2
-	-@/bin/rm -f $(DL)/libpng.sl.2.$(PNGMIN)*
+	-@/bin/rm -f $(DL)/libpng.sl.3
+	-@/bin/rm -f $(DL)/libpng.sl.3.$(PNGMIN)*
 	cp $(LIBNAME).sl.$(PNGVER) $(DL)
-	cp libpng.sl.2.$(PNGMIN) $(DL)
+	cp libpng.sl.3.$(PNGMIN) $(DL)
 	chmod 755 $(DL)/$(LIBNAME).sl.$(PNGVER)
-	chmod 755 $(DL)/libpng.sl.2.$(PNGMIN)
+	chmod 755 $(DL)/libpng.sl.3.$(PNGMIN)
 	(cd $(DL); \
-	ln -sf libpng.sl.2.$(PNGMIN) libpng.sl.2; \
-	ln -sf libpng.sl.2 libpng.sl; \
+	ln -sf libpng.sl.3.$(PNGMIN) libpng.sl.3; \
+	ln -sf libpng.sl.3 libpng.sl; \
 	ln -sf $(LIBNAME).sl.$(PNGVER) $(LIBNAME).sl.$(PNGMAJ); \
 	ln -sf $(LIBNAME).sl.$(PNGMAJ) $(LIBNAME).sl)
 	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
@@ -189,7 +190,7 @@
 clean:
 	/bin/rm -f *.o libpng.a pngtest pngtesti pngout.png \
 	libpng-config $(LIBNAME).sl $(LIBNAME).sl.$(PNGMAJ)* \
-	libpng.sl.2.$(PNGMIN) \
+	libpng.sl.3.$(PNGMIN) \
 	libpng.pc
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
diff --git a/scripts/makefile.hpux b/scripts/makefile.hpux
index 60f0191..e4daba7 100644
--- a/scripts/makefile.hpux
+++ b/scripts/makefile.hpux
@@ -24,7 +24,7 @@
 RANLIB=ranlib
 
 PNGMAJ = 0
-PNGMIN = 1.0.15
+PNGMIN = 1.0.16
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng10
 
@@ -90,9 +90,9 @@
 	$(LD) -b +s \
 	+h $(LIBNAME).sl.$(PNGMAJ) -o $(LIBNAME).sl.$(PNGVER) $(OBJSDLL)
 
-libpng.sl.2.$(PNGMIN): $(OBJSDLL)
+libpng.sl.3.$(PNGMIN): $(OBJSDLL)
 	$(LD) -b +s \
-	+h libpng.sl.2 -o libpng.sl.2.$(PNGMIN) $(OBJSDLL)
+	+h libpng.sl.3 -o libpng.sl.3.$(PNGMIN) $(OBJSDLL)
 
 pngtest: pngtest.o libpng.a
 	$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
@@ -117,19 +117,20 @@
 	(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
 
 install-shared: install-headers $(LIBNAME).sl.$(PNGVER) libpng.pc \
-	libpng.sl.2.$(PNGMIN)
+	libpng.sl.3.$(PNGMIN)
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
 	-@/bin/rm -f $(DL)/$(LIBNAME).sl.$(PNGVER)* $(DL)/$(LIBNAME).sl
+	-@/bin/rm -f $(DL)/$(LIBNAME).sl.$(PNGMAJ)
 	-@/bin/rm -f $(DL)/libpng.sl
-	-@/bin/rm -f $(DL)/libpng.sl.2
-	-@/bin/rm -f $(DL)/libpng.sl.2.$(PNGMIN)*
+	-@/bin/rm -f $(DL)/libpng.sl.3
+	-@/bin/rm -f $(DL)/libpng.sl.3.$(PNGMIN)*
 	cp $(LIBNAME).sl.$(PNGVER) $(DL)
-	cp libpng.sl.2.$(PNGMIN) $(DL)
+	cp libpng.sl.3.$(PNGMIN) $(DL)
 	chmod 755 $(DL)/$(LIBNAME).sl.$(PNGVER)
-	chmod 755 $(DL)/libpng.sl.2.$(PNGMIN)
+	chmod 755 $(DL)/libpng.sl.3.$(PNGMIN)
 	(cd $(DL); \
-	ln -sf libpng.sl.2.$(PNGMIN) libpng.sl.2; \
-	ln -sf libpng.sl.2 libpng.sl; \
+	ln -sf libpng.sl.3.$(PNGMIN) libpng.sl.3; \
+	ln -sf libpng.sl.3 libpng.sl; \
 	ln -sf $(LIBNAME).sl.$(PNGVER) $(LIBNAME).sl.$(PNGMAJ); \
 	ln -sf $(LIBNAME).sl.$(PNGMAJ) $(LIBNAME).sl)
 	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
@@ -175,7 +176,7 @@
 clean:
 	/bin/rm -f *.o libpng.a pngtest pngtesti pngout.png \
 	libpng-config $(LIBNAME).sl $(LIBNAME).sl.$(PNGMAJ)* \
-	libpng.sl.2.$(PNGMIN) \
+	libpng.sl.3.$(PNGMIN) \
 	libpng.pc
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
diff --git a/scripts/makefile.linux b/scripts/makefile.linux
index 5a4bbeb..5e60ac8 100644
--- a/scripts/makefile.linux
+++ b/scripts/makefile.linux
@@ -5,7 +5,7 @@
 
 LIBNAME = libpng10
 PNGMAJ = 0
-PNGMIN = 1.0.15
+PNGMIN = 1.0.16
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 CC=gcc
@@ -142,6 +142,7 @@
 	libpng.so.2.$(PNGMIN)
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
 	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.2
 	-@/bin/rm -f $(DL)/libpng.so.2.$(PNGMIN)*
diff --git a/scripts/makefile.macosx b/scripts/makefile.macosx
deleted file mode 100644
index 74a370a..0000000
--- a/scripts/makefile.macosx
+++ /dev/null
@@ -1,197 +0,0 @@
-# makefile for libpng, MACOS X
-# Copyright (C) 2002 Glenn Randers-Pehrson
-# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
-# Modified by Karin Kosina <kyrah@sim.no> 20011010:
-# build shared library (*.dylib)
-# For conditions of distribution and use, see copyright notice in png.h
-
-# where make install puts libpng.a and png.h
-prefix=/usr/local
-
-# Where the zlib library and include files are located
-#ZLIBLIB=/usr/local/lib
-#ZLIBINC=/usr/local/include
-ZLIBLIB=../zlib
-ZLIBINC=../zlib
-
-CC=cc
-
-PNGMAJ = 0
-PNGMIN = 1.0.15
-PNGVER = $(PNGMAJ).$(PNGMIN)
-
-CFLAGS=-fno-common -I$(ZLIBINC) -O # -g -DPNG_DEBUG=5
-LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -current_version $(PNGVER)
-
-LIBNAME=libpng10
-SHAREDLIB_POSTFIX=dylib
-INCPATH=$(prefix)/include
-LIBPATH=$(prefix)/lib
-MANPATH=$(prefix)/man
-BINPATH=$(prefix)/bin
-
-# override DESTDIR= on the make install command line to easily support
-# installing into a temporary location.  Example:
-#
-#    make install DESTDIR=/tmp/build/libpng
-#
-# If you're going to install into a temporary location
-# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
-# you execute make install.
-DESTDIR=
-
-DB=$(DESTDIR)$(BINPATH)
-DI=$(DESTDIR)$(INCPATH)
-DL=$(DESTDIR)$(LIBPATH)
-DM=$(DESTDIR)$(MANPATH)
-
-#RANLIB=echo
-RANLIB=ranlib
-
-OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
-	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
-	pngwtran.o pngmem.o pngerror.o pngpread.o
-
-all: libpng.a pngtest shared libpng.pc libpng-config
-
-shared: $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX)
-
-libpng.pc:
-	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \
-	   sed -e s/-lm// > libpng.pc
-
-libpng-config:
-	( cat scripts/libpng-config-head.in; \
-	echo prefix=\"$(prefix)\"; \
-	echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
-	echo L_opts=\"-L$(LIBPATH)\"; \
-	echo libs=\"-lpng10 -lz\"; \
-	cat scripts/libpng-config-body.in ) > libpng-config
-	chmod +x libpng-config
-
-libpng.a: $(OBJS)
-	ar rc $@  $(OBJS)
-	$(RANLIB) $@
-
-$(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX): $(OBJS)
-	cc -dynamiclib -flat_namespace -undefined suppress -o $@ $(OBJS)
-
-libpng.2.$(PNGMIN).$(SHAREDLIB_POSTFIX): $(OBJS)
-	cc -dynamiclib -compatibility_version 2 -flat_namespace \
-	-undefined suppress -o $@ $(OBJS)
-
-pngtest: pngtest.o libpng.a
-	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
-
-test: pngtest
-	./pngtest
-
-install-headers: png.h pngconf.h
-	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
-	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
-	cp png.h pngconf.h $(DI)/$(LIBNAME)
-	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
-	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
-	-@/bin/rm -f $(DI)/libpng
-	(cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .)
-
-install-static: install-headers libpng.a
-	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-	cp libpng.a $(DL)/$(LIBNAME).a
-	chmod 644 $(DL)/$(LIBNAME).a
-	-@/bin/rm -f $(DL)/libpng.a
-	(cd $(DL); ln -f -s $(LIBNAME).a libpng.a)
-
-install-shared: install-headers $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) \
-	libpng.pc libpng.2.$(PNGMIN).$(SHAREDLIB_POSTFIX)
-	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-	-@/bin/rm -f \
-	$(DL)/$(LIBNAME).$(PNGVER)*.$(SHAREDLIB_POSTFIX)
-	-@/bin/rm -f $(DL)/$(LIBNAME).$(SHAREDLIB_POSTFIX)
-	-@/bin/rm -f libpng.$(SHARED_POSTFIX)
-	-@/bin/rm -f libpng.2.$(SHARED_POSTFIX)
-	-@/bin/rm -f libpng.2.$(PNGMIN)*.$(SHARED_POSTFIX)
-	cp libpng.2.$(PNGMIN).$(SHAREDLIB_POSTFIX) $(DL)
-	cp $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) $(DL)
-	chmod 755 $(DL)/$(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX)
-	chmod 755 $(DL)/libpng.2.$(PNGMIN).$(SHAREDLIB_POSTFIX)
-	(cd $(DL); \
-	ln -f -s libpng.2.$(PNGMIN).$(SHARED_POSTFIX) \
-	libpng.2.$(SHARED_POSTFIX); \
-	ln -f -s libpng.2.$(SHARED_POSTFIX) libpng.$(SHARED_POSTFIX); \
-	ln -f -s $(LIBNAME).$(PNGVER).$(SHARED_POSTFIX) \
-	libpng.$(SHARED_POSTFIX); \
-	ln -f -s libpng.2.$(PNGMIN).$(SHARED_POSTFIX) \
-	libpng.2.$(SHARED_POSTFIX); \
-	ln -f -s $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) \
-	$(LIBNAME).$(PNGMAJ).$(SHAREDLIB_POSTFIX); \
-	ln -f -s $(LIBNAME).$(PNGMAJ).$(SHAREDLIB_POSTFIX) \
-	$(LIBNAME).$(SHAREDLIB_POSTFIX))
-	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
-	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
-	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
-	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
-	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
-	(cd $(DL)/pkgconfig; ln -f -s $(LIBNAME).pc libpng.pc)
-
-install-man: libpng.3 libpngpf.3 png.5
-	-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
-	-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
-	-@/bin/rm -f $(DM)/man3/libpng.3
-	-@/bin/rm -f $(DM)/man3/libpngpf.3
-	cp libpng.3 $(DM)/man3
-	cp libpngpf.3 $(DM)/man3
-	-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
-	-@/bin/rm -f $(DM)/man5/png.5
-	cp png.5 $(DM)/man5
-
-install-config: libpng-config
-	-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
-	-@/bin/rm -f $(DB)/libpng-config
-	-@/bin/rm -f $(DB)/$(LIBNAME)-config
-	cp libpng-config $(DB)/$(LIBNAME)-config
-	chmod 755 $(DB)/$(LIBNAME)-config
-	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
-
-install: install-static install-shared install-man install-config
-
-# If you installed in $(DESTDIR), test-installed won't work until you
-# move the library to its final location.
-
-test-installed:
-	$(CC) $(CFLAGS) \
-	   `$(BINPATH)/libpng10-config --cflags` pngtest.c \
-	   -L$(ZLIBLIB) \
-	   -o pngtesti `$(BINPATH)/libpng10-config --ldflags`
-	./pngtesti pngtest.png
-
-clean:
-	rm -f *.o libpng.a pngtest pngout.png libpng-config \
-	$(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) \
-	$(LIBNAME).$(SHAREDLIB_POSTFIX) \
-	libpng.2.$(PNGMIN).$(SHAREDLIB_POSTFIX) \
-	libpng.pc
-
-DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
-writelock:
-	chmod a-w *.[ch35] $(DOCS) scripts/*
-
-# DO NOT DELETE THIS LINE -- make depend depends on it.
-
-png.o: png.h pngconf.h
-pngerror.o: png.h pngconf.h
-pngrio.o: png.h pngconf.h
-pngwio.o: png.h pngconf.h
-pngmem.o: png.h pngconf.h
-pngset.o: png.h pngconf.h
-pngget.o: png.h pngconf.h
-pngread.o: png.h pngconf.h
-pngrtran.o: png.h pngconf.h
-pngrutil.o: png.h pngconf.h
-pngtest.o: png.h pngconf.h
-pngtrans.o: png.h pngconf.h
-pngwrite.o: png.h pngconf.h
-pngwtran.o: png.h pngconf.h
-pngwutil.o: png.h pngconf.h
-pngpread.o: png.h pngconf.h
-
diff --git a/scripts/makefile.ne10bsd b/scripts/makefile.ne12bsd
similarity index 97%
rename from scripts/makefile.ne10bsd
rename to scripts/makefile.ne12bsd
index f5a1a88..782f939 100644
--- a/scripts/makefile.ne10bsd
+++ b/scripts/makefile.ne12bsd
@@ -11,9 +11,9 @@
 MANDIR= ${LOCALBASE}/man
 INCSDIR=${LOCALBASE}/include/libpng10
 
-LIB=	png10
+LIB=	png12
 SHLIB_MAJOR=	0
-SHLIB_MINOR=	1.0.15
+SHLIB_MINOR=	1.0.16
 SRCS=	pnggccrd.c png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
 		pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
 		pngwtran.c pngmem.c pngerror.c pngpread.c
diff --git a/scripts/makefile.netbsd b/scripts/makefile.netbsd
index 0cab8e6..86c3568 100644
--- a/scripts/makefile.netbsd
+++ b/scripts/makefile.netbsd
@@ -12,8 +12,8 @@
 INCSDIR=${LOCALBASE}/include/libpng
 
 LIB=	png
-SHLIB_MAJOR=	2
-SHLIB_MINOR=	1.0.15
+SHLIB_MAJOR=	3
+SHLIB_MINOR=	1.0.16
 SRCS=	pnggccrd.c png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
 		pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
 		pngwtran.c pngmem.c pngerror.c pngpread.c
diff --git a/scripts/makefile.openbsd b/scripts/makefile.openbsd
index 241d43a..a357e7a 100644
--- a/scripts/makefile.openbsd
+++ b/scripts/makefile.openbsd
@@ -7,7 +7,7 @@
 MANDIR= ${PREFIX}/man/cat
 
 SHLIB_MAJOR=	0
-SHLIB_MINOR=	1.0.15
+SHLIB_MINOR=	1.0.16
 
 LIB=	png
 SRCS=	png.c pngerror.c pnggccrd.c pngget.c pngmem.c pngpread.c \
diff --git a/scripts/makefile.sco b/scripts/makefile.sco
index 264aad7..9548585 100644
--- a/scripts/makefile.sco
+++ b/scripts/makefile.sco
@@ -24,7 +24,7 @@
 RANLIB=echo
 
 PNGMAJ = 0
-PNGMIN = 1.0.15
+PNGMIN = 1.0.16
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng10
 
@@ -120,6 +120,7 @@
 	libpng.so.2.$(PNGMIN)
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
 	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.2
 	-@/bin/rm -f $(DL)/libpng.so.2.$(PNGMIN)*
@@ -156,7 +157,7 @@
 	-@/bin/rm -f $(DB)/$(LIBNAME)-config
 	cp libpng-config $(DB)/$(LIBNAME)-config
 	chmod 755 $(DB)/$(LIBNAME)-config
-	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
+	(cd $(DB); ln -f -s $(LIBNAME)-config libpng-config)
 
 install: install-static install-shared install-man install-config
 
diff --git a/scripts/makefile.sggcc b/scripts/makefile.sggcc
index e8c5a08..ce4444f 100644
--- a/scripts/makefile.sggcc
+++ b/scripts/makefile.sggcc
@@ -18,7 +18,7 @@
 
 LIBNAME=libpng10
 PNGMAJ = 0
-PNGMIN = 1.0.15
+PNGMIN = 1.0.16
 PNGVER = $(PNGMAJ).$(PNGMIN)
 CC=gcc
 
@@ -32,7 +32,7 @@
 LDSHARED=cc $(ABI) -shared -soname $(LIBNAME).so.$(PNGMAJ) \
   -set_version sgi$(PNGMAJ).0
 LDLEGACY=cc $(ABI) -shared -soname libpng.so.2 \
-  -set_version sgi$2.0
+  -set_version sgi$3.0
 # See "man dso" for info about shared objects
 
 RANLIB=echo
@@ -127,6 +127,7 @@
 	libpng.so.2.$(PNGMIN)
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
 	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.2
 	-@/bin/rm -f $(DL)/libpng.so.2.$(PNGMIN)*
diff --git a/scripts/makefile.sgi b/scripts/makefile.sgi
index a358fd4..2b3df66 100644
--- a/scripts/makefile.sgi
+++ b/scripts/makefile.sgi
@@ -5,7 +5,7 @@
 
 LIBNAME=libpng10
 PNGMAJ = 0
-PNGMIN = 1.0.15
+PNGMIN = 1.0.16
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # Where make install puts libpng.a, libpng10.so, and libpng10/png.h
@@ -37,7 +37,7 @@
 LDSHARED=cc $(ABI) -shared -soname $(LIBNAME).so.$(PNGMAJ) \
   -set_version sgi$(PNGMAJ).0
 LDLEGACY=cc $(ABI) -shared -soname libpng.so.2 \
-  -set_version sgi$2.0
+  -set_version sgi$3.0
 # See "man dso" for info about shared objects
 
 RANLIB=echo
@@ -133,6 +133,7 @@
 	libpng.so.2.$(PNGMIN)
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
 	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.2
 	-@/bin/rm -f $(DL)/libpng.so.2.$(PNGMIN)*
diff --git a/scripts/makefile.so9 b/scripts/makefile.so9
index 5e9d277..80c803b 100644
--- a/scripts/makefile.so9
+++ b/scripts/makefile.so9
@@ -34,7 +34,7 @@
 RANLIB=echo
 
 PNGMAJ = 0
-PNGMIN = 1.0.15
+PNGMIN = 1.0.16
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng10
 
@@ -140,6 +140,7 @@
 	libpng.so.2.$(PNGMIN)
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
 	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.2
 	-@/bin/rm -f $(DL)/libpng.so.2.$(PNGMIN)*
@@ -176,7 +177,7 @@
 	-@/bin/rm -f $(DB)/$(LIBNAME)-config
 	cp libpng-config $(DB)/$(LIBNAME)-config
 	chmod 755 $(DB)/$(LIBNAME)-config
-	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
+	(cd $(DB); ln -f -s $(LIBNAME)-config libpng-config)
 
 install: install-static install-shared install-man install-config
 
diff --git a/scripts/makefile.solaris b/scripts/makefile.solaris
index 8832aa8..91fbe9e 100644
--- a/scripts/makefile.solaris
+++ b/scripts/makefile.solaris
@@ -1,5 +1,5 @@
 # makefile for libpng on Solaris 2.x with gcc
-# Copyright (C) 2002 Glenn Randers-Pehrson
+# Copyright (C) 2004 Glenn Randers-Pehrson
 # Contributed by William L. Sebok, based on makefile.linux
 # Copyright (C) 1998 Greg Roelofs
 # Copyright (C) 1996, 1997 Andreas Dilger
@@ -22,7 +22,7 @@
 WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
 	-Wmissing-declarations -Wtraditional -Wcast-align \
 	-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
-CFLAGS=-I$(ZLIBINC) -Wall -O3 \
+CFLAGS=-I$(ZLIBINC) -Wall -O \
 	# $(WARNMORE) -g -DPNG_DEBUG=5
 LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng10 -lz -lm
 
@@ -30,7 +30,7 @@
 RANLIB=echo
 
 PNGMAJ = 0
-PNGMIN = 1.0.15
+PNGMIN = 1.0.16
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng10
 
@@ -137,6 +137,7 @@
 	libpng.so.2.$(PNGMIN)
 	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
 	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)
 	-@/bin/rm -f $(DL)/libpng.so
 	-@/bin/rm -f $(DL)/libpng.so.2
 	-@/bin/rm -f $(DL)/libpng.so.2.$(PNGMIN)*
@@ -173,7 +174,7 @@
 	-@/bin/rm -f $(DB)/$(LIBNAME)-config
 	cp libpng-config $(DB)/$(LIBNAME)-config
 	chmod 755 $(DB)/$(LIBNAME)-config
-	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
+	(cd $(DB); ln -s -f $(LIBNAME)-config libpng-config)
 
 install: install-static install-shared install-man install-config
 
diff --git a/scripts/makefile.vcawin32 b/scripts/makefile.vcawin32
index 812dd8f..4c2f3cc 100644
--- a/scripts/makefile.vcawin32
+++ b/scripts/makefile.vcawin32
@@ -5,31 +5,35 @@
 # To use, do "nmake /f scripts\makefile.vcawin32"
 
 # -------- Microsoft Visual C++ 5.0 and later, uses assembler code --------
+# If you don't want to use assembler (MMX) code, use makefile.vcwin32 instead.
 
-# Caution: the assembler code was introduced at libpng version 1.0.4 and has
-# not yet been thoroughly tested.
+# Compiler, linker, librarian, and other tools
+CC = cl
+LD = link
+AR = lib
+CFLAGS  = -DPNG_USE_PNGVCRD -nologo -MD -O2 -W3 -I..\zlib
+LDFLAGS = -nologo
+ARFLAGS = -nologo
+RM = del
 
-# If you don't want to use assembler code, use makefile.vcwin32 instead.
-
-CFLAGS=-DPNG_USE_PNGVCRD -Ox -GA3s -nologo -W3 -I..\zlib
-
-CC=cl
-LD=link
-LDFLAGS= 
+# File extensions
 O=.obj
 
 #uncomment next to put error messages in a file
-#ERRFILE= >> pngerrs
+#ERRFILE= >> pngerrs.log
 
-# variables
-OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O)
-OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O)
-OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) pngvcrd$(O)
+# Variables
+OBJS1 = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O)
+OBJS2 = pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O)
+OBJS3 = pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O)
+OBJS4 = pngvcrd$(O)
+OBJS  = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4)
 
+# Targets
 all: libpng.lib
 
 png$(O): png.h pngconf.h
-		  $(CC) -c $(CFLAGS) $*.c $(ERRFILE)
+	$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
 
 pngset$(O): png.h pngconf.h
 	$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
@@ -49,9 +53,6 @@
 pngrutil$(O): png.h pngconf.h
 	$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
 
-pngvcrd$(O): png.h pngconf.h
-	$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
-
 pngerror$(O): png.h pngconf.h
 	$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
 
@@ -79,16 +80,24 @@
 pngwutil$(O): png.h pngconf.h
 	$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
 
-libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3)
-	echo something to del > libpng.lib
-	del libpng.lib
-	lib /OUT:libpng.lib $(OBJS1) $(OBJS2) $(OBJS3)
+pngvcrd$(O): png.h pngconf.h
+	$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
 
-pngtest.exe: pngtest.obj libpng.lib
-	$(LD) $(LDFLAGS) pngtest.obj libpng.lib ..\zlib\zlib.lib /OUT:pngtest.exe /SUBSYSTEM:CONSOLE
+libpng.lib: $(OBJS)
+	-$(RM) $@
+	$(AR) $(ARFLAGS) -out:$@ $(OBJS) $(ERRFILE)
+
+pngtest.exe: pngtest$(O) libpng.lib
+	$(LD) $(LDFLAGS) -out:$@ pngtest$(O) libpng.lib ..\zlib\zlib.lib $(ERRFILE)
 
 test: pngtest.exe
 	pngtest
 
+clean:
+	-$(RM) *$(O)
+	-$(RM) libpng.lib
+	-$(RM) pngtest.exe
+	-$(RM) pngout.png
+
 # End of makefile for libpng
 
diff --git a/scripts/makefile.vcwin32 b/scripts/makefile.vcwin32
index 64b762e..d23d812 100644
--- a/scripts/makefile.vcwin32
+++ b/scripts/makefile.vcwin32
@@ -4,28 +4,35 @@
 # Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib
 # To use, do "nmake /f scripts\makefile.vcwin32"
 
-# -------- Microsoft Visual C++ 4.0 and later, no assembler code --------
-# If you want to use assembler code, use makefile.vcawin32 instead.
+# -------- Microsoft Visual C++ 2.0 and later, no assembler code --------
+# If you want to use assembler (MMX) code, use makefile.vcawin32 instead.
 
-CFLAGS= -Ox -GA3s -nologo -W3 -I..\zlib
+# Compiler, linker, librarian, and other tools
+CC = cl
+LD = link
+AR = lib
+CFLAGS  = -nologo -MD -O2 -W3 -I..\zlib
+LDFLAGS = -nologo
+ARFLAGS = -nologo
+RM = del
 
-CC=cl
-LD=link
-LDFLAGS= 
+# File extensions
 O=.obj
 
 #uncomment next to put error messages in a file
-#ERRFILE= >> pngerrs
+#ERRFILE= >> pngerrs.log
 
-# variables
-OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O)
-OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O)
-OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O)
+# Variables
+OBJS1 = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O)
+OBJS2 = pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O)
+OBJS3 = pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O)
+OBJS  = $(OBJS1) $(OBJS2) $(OBJS3)
 
+# Targets
 all: libpng.lib
 
 png$(O): png.h pngconf.h
-		  $(CC) -c $(CFLAGS) $*.c $(ERRFILE)
+	$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
 
 pngset$(O): png.h pngconf.h
 	$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
@@ -72,16 +79,21 @@
 pngwutil$(O): png.h pngconf.h
 	$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
 
-libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3)
-	echo something to del > libpng.lib
-	del libpng.lib
-	lib /OUT:libpng.lib $(OBJS1) $(OBJS2) $(OBJS3)
+libpng.lib: $(OBJS)
+	-$(RM) $@
+	$(AR) $(ARFLAGS) -out:$@ $(OBJS) $(ERRFILE)
 
-pngtest.exe: pngtest.obj libpng.lib
-	$(LD) $(LDFLAGS) pngtest.obj libpng.lib ..\zlib\zlib.lib /OUT:pngtest.exe /SUBSYSTEM:CONSOLE
+pngtest.exe: pngtest$(O) libpng.lib
+	$(LD) $(LDFLAGS) -out:$@ pngtest$(O) libpng.lib ..\zlib\zlib.lib $(ERRFILE)
 
 test: pngtest.exe
 	pngtest
 
+clean:
+	-$(RM) *$(O)
+	-$(RM) libpng.lib
+	-$(RM) pngtest.exe
+	-$(RM) pngout.png
+
 # End of makefile for libpng
 
diff --git a/scripts/pngdef.pas b/scripts/pngdef.pas
deleted file mode 100644
index 92e6f82..0000000
--- a/scripts/pngdef.pas
+++ /dev/null
@@ -1,795 +0,0 @@
-unit pngdef;
-
-// Caution: this file has fallen out of date since version 1.0.5.  Write to
-// png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu about volunteering
-// to it up to date.
-
-interface
-
-const
-  PNG_LIBPNG_VER_STRING = '1.0.15';
-  PNG_LIBPNG_VER        =  10015;
-
-type
-  png_uint_32 = Cardinal;
-  png_int_32  = Longint;
-  png_uint_16 = Word;
-  png_int_16  = Smallint;
-  png_byte    = Byte;
-  png_size_t  = png_uint_32;
-  png_charpp  = ^png_charp;
-  png_charp   = PChar;
-  float       = single;
-  int         = Integer;
-  png_bytepp  = ^png_bytep;
-  png_bytep   = ^png_byte;
-  png_uint_16p = ^png_uint_16;
-  png_uint_16pp = ^png_uint_16p;
-  png_voidp    = pointer;
-  time_t       = Longint;
-  png_doublep  = ^png_double;
-  png_double   = double;
-
-  user_error_ptr  = Pointer;
-  png_error_ptrp = ^png_error_ptr;
-  png_error_ptr  = procedure(png_ptr: Pointer; msg: Pointer);
-             stdcall;
-  png_rw_ptrp = ^png_rw_ptr;
-  png_rw_ptr = procedure(png_ptr: Pointer; data: Pointer;
-                         length: png_size_t);
-             stdcall;
-  png_flush_ptrp = ^png_flush_ptr;
-  png_flush_ptr = procedure(png_ptr: Pointer);
-             stdcall;
-  png_progressive_info_ptrp = ^png_progressive_info_ptr;
-  png_progressive_info_ptr  = procedure(png_ptr: Pointer;
-                                        info_ptr: Pointer);
-             stdcall;
-  png_progressive_end_ptrp  = ^png_progressive_end_ptr;
-  png_progressive_end_ptr   = procedure(png_ptr: Pointer;
-                                        info_ptr: Pointer);
-             stdcall;
-  png_progressive_row_ptrp  = ^png_progressive_row_ptr;
-  png_progressive_row_ptr   = procedure(png_ptr: Pointer;
-                                data: Pointer; length: png_uint_32;
-                                count: int);
-             stdcall;
-  png_read_status_ptr = procedure(png_ptr: Pointer;
-                          row_number: png_uint_32; pass: int);
-             stdcall;
-  png_write_status_ptr = procedure(png_ptr: Pointer;
-                           row_number: png_uint_32; pass: int);
-             stdcall;
-  png_user_chunk_ptr = procedure(png_ptr: Pointer;
-                             data: png_unknown_chunkp);
-             stdcall;
-  png_user_transform_ptr = procedure(png_ptr: Pointer;
-                             row_info: Pointer; data: png_bytep);
-             stdcall;
-
-  png_colorpp = ^png_colorp;
-  png_colorp = ^png_color;
-  png_color = packed record
-    red, green, blue: png_byte;
-    end;
-
-  png_color_16pp = ^png_color_16p;
-  png_color_16p = ^png_color_16;
-  png_color_16 = packed record
-    index: png_byte;                 //used for palette files
-    red, green, blue: png_uint_16;   //for use in red green blue files
-    gray: png_uint_16;               //for use in grayscale files
-    end;
-
-  png_color_8pp = ^png_color_8p;
-  png_color_8p = ^png_color_8;
-  png_color_8 = packed record
-    red, green, blue: png_byte;   //for use in red green blue files
-    gray: png_byte;               //for use in grayscale files
-    alpha: png_byte;              //for alpha channel files
-    end;
-
-  png_textpp = ^png_textp;
-  png_textp = ^png_text;
-  png_text = packed record
-    compression: int;            //compression value
-    key: png_charp;              //keyword, 1-79 character description of "text"
-    text: png_charp;             //comment, may be empty ("")
-    text_length: png_size_t;     //length of text field
-    end;
-
-  png_timepp = ^png_timep;
-  png_timep = ^png_time;
-  png_time = packed record
-    year: png_uint_16;           //yyyy
-    month: png_byte;             //1..12
-    day: png_byte;               //1..31
-    hour: png_byte;              //0..23
-    minute: png_byte;            //0..59
-    second: png_byte;            //0..60 (leap seconds)
-    end;
-
-  png_infopp = ^png_infop;
-  png_infop = Pointer;
-
-  png_row_infopp = ^png_row_infop;
-  png_row_infop = ^png_row_info;
-  png_row_info = packed record
-    width: png_uint_32;          //width of row
-    rowbytes: png_size_t;        //number of bytes in row
-    color_type: png_byte;        //color type of row
-    bit_depth: png_byte;         //bit depth of row
-    channels: png_byte;          //number of channels (1, 2, 3, or 4)
-    pixel_depth: png_byte;       //bits per pixel (depth * channels)
-    end;
-
-  png_structpp = ^png_structp;
-  png_structp = Pointer;
-
-const
-
-// Supported compression types for text in PNG files (tEXt, and zTXt).
-// The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed.
-
-  PNG_TEXT_COMPRESSION_NONE_WR = -3;
-  PNG_TEXT_COMPRESSION_zTXt_WR = -2;
-  PNG_TEXT_COMPRESSION_NONE    = -1;
-  PNG_TEXT_COMPRESSION_zTXt    = 0;
-
-// These describe the color_type field in png_info.
-// color type masks
-
-  PNG_COLOR_MASK_PALETTE   = 1;
-  PNG_COLOR_MASK_COLOR     = 2;
-  PNG_COLOR_MASK_ALPHA     = 4;
-
-// color types.  Note that not all combinations are legal
-
-  PNG_COLOR_TYPE_GRAY       = 0;
-  PNG_COLOR_TYPE_PALETTE    = PNG_COLOR_MASK_COLOR or
-                              PNG_COLOR_MASK_PALETTE;
-  PNG_COLOR_TYPE_RGB        = PNG_COLOR_MASK_COLOR;
-  PNG_COLOR_TYPE_RGB_ALPHA  = PNG_COLOR_MASK_COLOR or
-                              PNG_COLOR_MASK_ALPHA;
-  PNG_COLOR_TYPE_GRAY_ALPHA = PNG_COLOR_MASK_ALPHA;
-
-// This is for compression type. PNG 1.0 only defines the single type.
-
-  PNG_COMPRESSION_TYPE_BASE    = 0;   // Deflate method 8, 32K window
-  PNG_COMPRESSION_TYPE_DEFAULT = PNG_COMPRESSION_TYPE_BASE;
-
-// This is for filter type. PNG 1.0 only defines the single type.
-
-  PNG_FILTER_TYPE_BASE    = 0;       // Single row per-byte filtering
-  PNG_FILTER_TYPE_DEFAULT = PNG_FILTER_TYPE_BASE;
-
-// These are for the interlacing type.  These values should NOT be changed.
-
-  PNG_INTERLACE_NONE  = 0;      // Non-interlaced image
-  PNG_INTERLACE_ADAM7 = 1;      // Adam7 interlacing
-
-// These are for the oFFs chunk.  These values should NOT be changed.
-
-  PNG_OFFSET_PIXEL      = 0;    // Offset in pixels
-  PNG_OFFSET_MICROMETER = 1;    // Offset in micrometers (1/10^6 meter)
-
-// These are for the pCAL chunk.  These values should NOT be changed.
-
-  PNG_EQUATION_LINEAR     = 0;  // Linear transformation
-  PNG_EQUATION_BASE_E     = 1;  // Exponential base e transform
-  PNG_EQUATION_ARBITRARY  = 2;  // Arbitrary base exponential transform
-  PNG_EQUATION_HYPERBOLIC = 3;  // Hyperbolic sine transformation
-
-// These are for the pHYs chunk.  These values should NOT be changed.
-
-  PNG_RESOLUTION_UNKNOWN = 0;   // pixels/unknown unit (aspect ratio)
-  PNG_RESOLUTION_METER   = 1;   // pixels/meter
-
-// These are for the sRGB chunk.  These values should NOT be changed.
- PNG_sRGB_INTENT_PERCEPTUAL = 0;
- PNG_sRGB_INTENT_RELATIVE   = 1;
- PNG_sRGB_INTENT_SATURATION = 2;
- PNG_sRGB_INTENT_ABSOLUTE   = 3;
-
-// Handle alpha and tRNS by replacing with a background color.
-  PNG_BACKGROUND_GAMMA_UNKNOWN = 0;
-  PNG_BACKGROUND_GAMMA_SCREEN  = 1;
-  PNG_BACKGROUND_GAMMA_FILE    = 2;
-  PNG_BACKGROUND_GAMMA_UNIQUE  = 3;
-
-// Values for png_set_crc_action() to say how to handle CRC errors in
-// ancillary and critical chunks, and whether to use the data contained
-// therein.  Note that it is impossible to "discard" data in a critical
-// chunk.  For versions prior to 0.90, the action was always error/quit,
-// whereas in version 0.90 and later, the action for CRC errors in ancillary
-// chunks is warn/discard.  These values should NOT be changed.
-
-//      value                   action:critical     action:ancillary
-
-  PNG_CRC_DEFAULT      = 0;  // error/quit          warn/discard data
-  PNG_CRC_ERROR_QUIT   = 1;  // error/quit          error/quit
-  PNG_CRC_WARN_DISCARD = 2;  // (INVALID)           warn/discard data
-  PNG_CRC_WARN_USE     = 3;  // warn/use data       warn/use data
-  PNG_CRC_QUIET_USE    = 4;  // quiet/use data      quiet/use data
-  PNG_CRC_NO_CHANGE    = 5;  // use current value   use current value
-
-// Flags for png_set_filter() to say which filters to use.  The flags
-// are chosen so that they don't conflict with real filter types
-// below, in case they are supplied instead of the #defined constants.
-// These values should NOT be changed.
-
-  PNG_NO_FILTERS   = $00;
-  PNG_FILTER_NONE  = $08;
-  PNG_FILTER_SUB   = $10;
-  PNG_FILTER_UP    = $20;
-  PNG_FILTER_AVG   = $40;
-  PNG_FILTER_PAETH = $80;
-  PNG_ALL_FILTERS  = PNG_FILTER_NONE or PNG_FILTER_SUB or
-                     PNG_FILTER_UP   or PNG_FILTER_AVG or
-                     PNG_FILTER_PAETH;
-
-// Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
-// These defines should NOT be changed.
-
-  PNG_FILTER_VALUE_NONE  = 0;
-  PNG_FILTER_VALUE_SUB   = 1;
-  PNG_FILTER_VALUE_UP    = 2;
-  PNG_FILTER_VALUE_AVG   = 3;
-  PNG_FILTER_VALUE_PAETH = 4;
-
-// Heuristic used for row filter selection.  These defines should NOT be
-// changed.
-
-  PNG_FILTER_HEURISTIC_DEFAULT    = 0;  // Currently "UNWEIGHTED"
-  PNG_FILTER_HEURISTIC_UNWEIGHTED = 1;  // Used by libpng < 0.95
-  PNG_FILTER_HEURISTIC_WEIGHTED   = 2;  // Experimental feature
-  PNG_FILTER_HEURISTIC_LAST       = 3;  // Not a valid value
-
-procedure png_build_grayscale_palette(bit_depth: int; palette: png_colorp);
-             stdcall;
-function png_check_sig(sig: png_bytep; num: int): int;
-             stdcall;
-procedure png_chunk_error(png_ptr: png_structp;
-             const mess: png_charp);
-             stdcall;
-procedure png_chunk_warning(png_ptr: png_structp;
-             const mess: png_charp);
-             stdcall;
-procedure png_convert_from_time_t(ptime: png_timep; ttime: time_t);
-             stdcall;
-function png_convert_to_rfc1123(png_ptr: png_structp; ptime: png_timep):
-             png_charp;
-             stdcall;
-function png_create_info_struct(png_ptr: png_structp): png_infop;
-             stdcall;
-function png_create_read_struct(user_png_ver: png_charp;
-             error_ptr: user_error_ptr; error_fn: png_error_ptr;
-             warn_fn: png_error_ptr): png_structp;
-             stdcall;
-function png_get_copyright(png_ptr: png_structp): png_charp;
-             stdcall;
-function png_get_header_ver(png_ptr: png_structp): png_charp;
-             stdcall;
-function png_get_header_version(png_ptr: png_structp): png_charp;
-             stdcall;
-function png_get_libpng_ver(png_ptr: png_structp): png_charp;
-             stdcall;
-function png_create_write_struct(user_png_ver: png_charp;
-             error_ptr: user_error_ptr; error_fn: png_error_ptr;
-             warn_fn: png_error_ptr): png_structp;
-             stdcall;
-procedure png_destroy_info_struct(png_ptr: png_structp;
-             info_ptr_ptr: png_infopp);
-             stdcall;
-procedure png_destroy_read_struct(png_ptr_ptr: png_structpp;
-             info_ptr_ptr, end_info_ptr_ptr: png_infopp);
-             stdcall;
-procedure png_destroy_write_struct(png_ptr_ptr: png_structpp;
-             info_ptr_ptr: png_infopp);
-             stdcall;
-function png_get_IHDR(png_ptr: png_structp; info_ptr: png_infop;
-             var width, height: png_uint_32; var bit_depth,
-             color_type, interlace_type, compression_type,
-             filter_type: int): png_uint_32;
-             stdcall;
-function png_get_PLTE(png_ptr: png_structp; info_ptr: png_infop;
-             var palette: png_colorp; var num_palette: int):
-             png_uint_32;
-             stdcall;
-function png_get_bKGD(png_ptr: png_structp; info_ptr: png_infop;
-             var background: png_color_16p): png_uint_32;
-             stdcall;
-function png_get_bit_depth(png_ptr: png_structp; info_ptr: png_infop):
-             png_byte;
-             stdcall;
-function png_get_cHRM(png_ptr: png_structp; info_ptr: png_infop;
-             var white_x, white_y, red_x, red_y, green_x, green_y,
-             blue_x, blue_y: double): png_uint_32;
-             stdcall;
-function png_get_channels(png_ptr: png_structp; info_ptr: png_infop):
-             png_byte;
-             stdcall;
-function png_get_color_type(png_ptr: png_structp; info_ptr: png_infop):
-             png_byte;
-             stdcall;
-function png_get_compression_type(png_ptr: png_structp;
-             info_ptr: png_infop): png_byte;
-             stdcall;
-function png_get_error_ptr(png_ptr: png_structp): png_voidp;
-             stdcall;
-function png_get_filter_type(png_ptr: png_structp; info_ptr: png_infop):
-             png_byte;
-             stdcall;
-function png_get_gAMA(png_ptr: png_structp; info_ptr: png_infop;
-             var file_gamma: double): png_uint_32;
-             stdcall;
-function png_get_hIST(png_ptr: png_structp; info_ptr: png_infop;
-             var hist: png_uint_16p): png_uint_32;
-             stdcall;
-function png_get_image_height(png_ptr: png_structp; info_ptr: png_infop):
-             png_uint_32;
-             stdcall;
-function png_get_image_width(png_ptr: png_structp; info_ptr: png_infop):
-             png_uint_32;
-             stdcall;
-function png_get_interlace_type(png_ptr: png_structp;
-             info_ptr: png_infop): png_byte;
-             stdcall;
-function png_get_io_ptr(png_ptr: png_structp): png_voidp;
-             stdcall;
-function png_get_oFFs(png_ptr: png_structp; info_ptr: png_infop;
-             var offset_x, offset_y: png_uint_32;
-             var unit_type: int): png_uint_32;
-             stdcall;
-function png_get_sCAL(png_ptr: png_structp; info_ptr: png_infop;
-             var unit:int; var width: png_uint_32; height: png_uint_32):
-             png_uint_32;
-             stdcall
-function png_get_pCAL(png_ptr: png_structp; info_ptr: png_infop;
-             var purpose: png_charp; var X0, X1: png_int_32;
-             var typ, nparams: int; var units: png_charp;
-             var params: png_charpp): png_uint_32;
-             stdcall;
-function png_get_pHYs(png_ptr: png_structp; info_ptr: png_infop;
-             var res_x, res_y: png_uint_32; var unit_type: int):
-             png_uint_32;
-             stdcall;
-function png_get_pixel_aspect_ratio(png_ptr: png_structp;
-             info_ptr: png_infop): float;
-             stdcall;
-function png_get_pixels_per_meter(png_ptr: png_structp;
-             info_ptr: png_infop): png_uint_32;
-             stdcall;
-function png_get_progressive_ptr(png_ptr: png_structp): png_voidp;
-             stdcall;
-function png_get_rgb_to_gray_status(png_ptr: png_structp);
-             stdcall;
-function png_get_rowbytes(png_ptr: png_structp; info_ptr: png_infop):
-             png_uint_32;
-             stdcall;
-function png_get_rows(png_ptr: png_structp; info_ptr: png_infop):
-             png_bytepp;
-             stdcall;
-function png_get_sBIT(png_ptr: png_structp; info_ptr: png_infop;
-             var sig_bits: png_color_8p): png_uint_32;
-             stdcall;
-function png_get_sRGB(png_ptr: png_structp; info_ptr: png_infop;
-             var file_srgb_intent: int): png_uint_32;
-             stdcall;
-function png_get_signature(png_ptr: png_structp; info_ptr: png_infop):
-             png_bytep;
-             stdcall;
-function png_get_tIME(png_ptr: png_structp; info_ptr: png_infop;
-             var mod_time: png_timep): png_uint_32;
-             stdcall;
-function png_get_tRNS(png_ptr: png_structp; info_ptr: png_infop;
-             var trans: png_bytep; var num_trans: int;
-             var trans_values: png_color_16p): png_uint_32;
-             stdcall;
-function png_get_text(png_ptr: png_structp; info_ptr: png_infop;
-             var text_ptr: png_textp; var num_text: int):
-             png_uint_32;
-             stdcall;
-function png_get_user_chunk_ptr(png_ptr: png_structp):
-             png_voidp;
-             stdcall;
-function png_get_valid(png_ptr: png_structp; info_ptr: png_infop;
-             flag: png_uint_32): png_uint_32;
-             stdcall;
-function png_get_x_offset_microns(png_ptr: png_structp;
-             info_ptr: png_infop): png_uint_32;
-             stdcall;
-function png_get_x_offset_pixels(png_ptr: png_structp;
-             info_ptr: png_infop): png_uint_32;
-             stdcall;
-function png_get_x_pixels_per_meter(png_ptr: png_structp;
-             info_ptr: png_infop): png_uint_32;
-             stdcall;
-function png_get_y_offset_microns(png_ptr: png_structp;
-             info_ptr: png_infop): png_uint_32;
-             stdcall;
-function png_get_y_offset_pixels(png_ptr: png_structp;
-             info_ptr: png_infop): png_uint_32;
-             stdcall;
-function png_get_y_pixels_per_meter(png_ptr: png_structp;
-             info_ptr: png_infop): png_uint_32;
-             stdcall;
-procedure png_process_data(png_ptr: png_structp; info_ptr: png_infop;
-             buffer: png_bytep; buffer_size: png_size_t);
-             stdcall;
-procedure png_progressive_combine_row(png_ptr: png_structp;
-             old_row, new_row: png_bytep);
-             stdcall;
-procedure png_read_end(png_ptr: png_structp; info_ptr: png_infop);
-              stdcall;
-procedure png_read_image(png_ptr: png_structp; image: png_bytepp);
-             stdcall;
-procedure png_read_info(png_ptr: png_structp; info_ptr: png_infop);
-             stdcall;
-procedure png_read_row(png_ptr: png_structp; row, dsp_row: png_bytep);
-             stdcall;
-procedure png_read_rows(png_ptr: png_structp; row, display_row:
-              png_bytepp; num_rows: png_uint_32);
-             stdcall;
-procedure png_read_update_info(png_ptr: png_structp; info_ptr: png_infop);
-             stdcall;
-procedure png_set_IHDR(png_ptr: png_structp; info_ptr: png_infop;
-             width, height: png_uint_32; bit_depth, color_type,
-             interlace_type, compression_type, filter_type: int);
-             stdcall;
-procedure png_set_PLTE(png_ptr: png_structp; info_ptr: png_infop;
-             palette: png_colorp; num_palette: int);
-             stdcall;
-procedure png_set_bKGD(png_ptr: png_structp; info_ptr: png_infop;
-             background: png_color_16p);
-             stdcall;
-procedure png_set_background(png_ptr: png_structp;
-             background_color: png_color_16p;
-             background_gamma_code, need_expand: int;
-             background_gamma: double);
-             stdcall;
-procedure png_set_bgr(png_ptr: png_structp);
-             stdcall;
-procedure png_set_cHRM(png_ptr: png_structp; info_ptr: png_infop;
-             white_x, white_y, red_x, red_y, green_x, green_y,
-             blue_x, blue_y: double);
-             stdcall;
-procedure png_set_cHRM_fixed(png_ptr: png_structp; info_ptr: png_infop;
-             white_x, white_y, red_x, red_y, green_x, green_y,
-             blue_x, blue_y: png_fixed_point);
-             stdcall;
-procedure png_set_compression_level(png_ptr: png_structp; level: int);
-             stdcall;
-procedure png_set_compression_mem_level(png_ptr: png_structp;
-             mem_level: int);
-             stdcall;
-procedure png_set_compression_method(png_ptr: png_structp; method: int);
-             stdcall;
-procedure png_set_compression_strategy(png_ptr: png_structp;
-             strategy: int);
-             stdcall;
-procedure png_set_compression_window_bits(png_ptr: png_structp;
-             window_bits: int);
-             stdcall;
-procedure png_set_crc_action(png_ptr: png_structp;
-             crit_action, ancil_action: int);
-             stdcall;
-procedure png_set_dither(png_ptr: png_structp; plaette: png_colorp;
-             num_palette, maximum_colors: int;
-             histogram: png_uint_16p; full_dither: int);
-             stdcall;
-procedure png_set_error_fn(png_ptr: png_structp; error_ptr: png_voidp;
-             error_fn, warning_fn: png_error_ptr);
-             stdcall;
-procedure png_set_expand(png_ptr: png_structp);
-             stdcall;
-procedure png_set_filler(png_ptr: png_structp; filler: png_uint_32;
-             filler_loc: int);
-             stdcall;
-procedure png_set_filter(png_ptr: png_structp; method, filters: int);
-             stdcall;
-procedure png_set_filter_heuristics(png_ptr: png_structp;
-             heuristic_method, num_weights: int;
-             filter_weights, filter_costs: png_doublep);
-             stdcall;
-procedure png_set_flush(png_ptr: png_structp; nrows: int);
-             stdcall;
-procedure png_set_gAMA(png_ptr: png_structp; info_ptr: png_infop;
-             file_gamma: double);
-             stdcall;
-procedure png_set_gAMA_fixed(png_ptr: png_structp; info_ptr: png_infop;
-             file_gamma: png_fixed_point);
-             stdcall;
-procedure png_set_gamma(png_ptr: png_structp; screen_gamma,
-             default_file_gamma: double);
-             stdcall;
-procedure png_set_gray_1_2_4_to_8(png_ptr: png_structp);
-             stdcall;
-procedure png_set_gray_to_rgb(png_ptr: png_structp);
-             stdcall;
-procedure png_set_hIST(png_ptr: png_structp; info_ptr: png_infop;
-             hist: png_uint_16p);
-             stdcall;
-function png_set_interlace_handling(png_ptr: png_structp): int;
-             stdcall;
-procedure png_set_invalid(png_ptr: png_structp; info_ptr:png_infop;
-             mask: int);
-             stdcall;
-procedure png_set_invert_alpha(png_ptr: png_structp);
-             stdcall;
-procedure png_set_invert_mono(png_ptr: png_structp);
-             stdcall;
-procedure png_set_oFFs(png_ptr: png_structp; info_ptr: png_infop;
-             offset_x, offset_y: png_uint_32; unit_type: int);
-             stdcall;
-procedure png_set_palette_to_rgb(png_ptr: png_structp);
-             stdcall;
-procedure png_set_pCAL(png_ptr: png_structp; info_ptr: png_infop;
-             purpose: png_charp; X0, X1: png_int_32;
-             typ, nparams: int; units: png_charp;
-             params: png_charpp);
-             stdcall;
-procedure png_set_pHYs(png_ptr: png_structp; info_ptr: png_infop;
-             res_x, res_y: png_uint_32; unit_type: int);
-             stdcall;
-procedure png_set_packing(png_ptr: png_structp);
-             stdcall;
-procedure png_set_packswap(png_ptr: png_structp);
-             stdcall;
-procedure png_set_progressive_read_fn(png_ptr: png_structp;
-             progressive_ptr: png_voidp;
-             info_fn: png_progressive_info_ptr;
-             row_fn: png_progressive_row_ptr;
-             end_fn: png_progressive_end_ptr);
-             stdcall;
-procedure png_set_read_fn(png_ptr: png_structp;
-             io_ptr: png_voidp; read_data_fn: png_rw_ptr);
-             stdcall;
-procedure png_set_read_status_fn(png_ptr: png_structp;
-             read_row_fn: png_read_status_ptr);
-             stdcall;
-procedure png_set_read_user_chunk_fn(png_ptr: png_structp;
-             read_user_chunk_fn: png_user_chunk_ptr);
-             stdcall;
-procedure png_set_read_user_transform_fn(png_ptr: png_structp;
-             read_user_transform_fn: png_user_transform_ptr);
-             stdcall;
-procedure png_set_rgb_to_gray(png_ptr: png_structp; int: error_action;
-             red_weight, green_weight: double);
-             stdcall;
-procedure png_set_rgb_to_gray_fixed(png_ptr: png_structp; int: error_action;
-             red_weight, green_weight: png_fixed_point);
-             stdcall;
-procedure png_set_rows(png_ptr: png_structp; info_ptr: png_infop;
-             row_pointers: png_bytepp);
-             stdcall;
-procedure png_set_sBIT(png_ptr: png_structp; info_ptr: png_infop;
-             sig_bits: png_color_8p);
-             stdcall;
-procedure png_set_sRGB(png_ptr: png_structp; info_ptr: png_infop;
-             intent: int);
-             stdcall;
-procedure png_set_sRGB_gAMA_and_cHRM(png_ptr: png_structp;
-             info_ptr: png_infop; intent: int);
-             stdcall;
-procedure png_set_shift(png_ptr: png_structp; true_bits: png_color_8p);
-             stdcall;
-procedure png_set_sig_bytes(png_ptr: png_structp; num_bytes: int);
-             stdcall;
-procedure png_set_strip_16(png_ptr: png_structp);
-             stdcall;
-procedure png_set_strip_alpha(png_ptr: png_structp);
-             stdcall;
-procedure png_set_swap(png_ptr: png_structp);
-             stdcall;
-procedure png_set_swap_alpha(png_ptr: png_structp);
-             stdcall;
-procedure png_set_tIME(png_ptr: png_structp; info_ptr: png_infop;
-             mod_time: png_timep);
-             stdcall;
-procedure png_set_tRNS(png_ptr: png_structp; info_ptr: png_infop;
-             trans: png_bytep; num_trans: int;
-             trans_values: png_color_16p);
-             stdcall;
-procedure png_set_tRNS_to_alpha(png_ptr: png_structp);
-             stdcall;
-procedure png_set_text(png_ptr: png_structp; info_ptr: png_infop;
-             text_ptr: png_textp; num_text: int);
-             stdcall;
-procedure png_set_write_fn(png_ptr: png_structp;
-             io_ptr: png_voidp; write_data_fn: png_rw_ptr;
-             output_flush_fn: png_flush_ptr);
-             stdcall;
-procedure png_set_write_status_fn(png_ptr: png_structp;
-             write_row_fn: png_write_status_ptr);
-             stdcall;
-procedure png_set_write_user_transform_fn(png_ptr: png_structp;
-             write_user_transform_fn: png_user_transform_ptr);
-             stdcall;
-function png_sig_cmp(sig: png_bytep; start, num_to_check: png_size_t):
-             int;
-             stdcall;
-procedure png_start_read_image(png_ptr: png_structp);
-             stdcall;
-procedure png_write_chunk(png_ptr: png_structp;
-             chunk_name, data: png_bytep; length: png_size_t);
-             stdcall;
-procedure png_write_chunk_data(png_ptr: png_structp;
-             data: png_bytep; length: png_size_t);
-             stdcall;
-procedure png_write_chunk_end(png_ptr: png_structp);
-             stdcall;
-procedure png_write_chunk_start(png_ptr: png_structp;
-             chunk_name: png_bytep; length: png_uint_32);
-             stdcall;
-procedure png_write_end(png_ptr: png_structp; info_ptr: png_infop);
-             stdcall;
-procedure png_write_flush(png_ptr: png_structp);
-             stdcall;
-procedure png_write_image(png_ptr: png_structp; image: png_bytepp);
-             stdcall;
-procedure png_write_info(png_ptr: png_structp; info_ptr: png_infop);
-             stdcall;
-procedure png_write_info_before_PLTE(png_ptr: png_structp; info_ptr: png_infop);
-             stdcall;
-procedure png_write_row(png_ptr: png_structp; row: png_bytep);
-             stdcall;
-procedure png_write_rows(png_ptr: png_structp; row: png_bytepp;
-             num_rows: png_uint_32);
-             stdcall;
-procedure png_get_iCCP(png_ptr: png_structp; info_ptr: png_infop;
-             name: png_charpp; compression_type: int *; profile: png_charpp;
-             proflen: png_int_32): png_bytep;
-             stdcall;
-procedure png_get_sPLT(png_ptr: png_structp;
-             info_ptr: png_infop;  entries: png_spalette_pp): png_uint_32;
-             stdcall;
-procedure png_set_iCCP(png_ptr: png_structp; info_ptr: png_infop;
-             name: png_charp; compression_type: int; profile: png_charp;
-             proflen: int);
-             stdcall;
-procedure png_free_data(png_ptr: png_structp; info_ptr: png_infop; num: int);
-             stdcall;
-procedure png_set_sPLT(png_ptr: png_structp; info_ptr: png_infop;
-             entries: png_spalette_p; nentries: int);
-             stdcall;
-
-implementation
-
-const
-  pngDLL = 'png32bd.dll';
-
-procedure png_build_grayscale_palette; external pngDLL;
-function png_check_sig; external pngDLL;
-procedure png_chunk_error; external pngDLL;
-procedure png_chunk_warning; external pngDLL;
-procedure png_convert_from_time_t; external pngDLL;
-function png_convert_to_rfc1123; external pngDLL;
-function png_create_info_struct; external pngDLL;
-function png_create_read_struct; external pngDLL;
-function png_create_write_struct; external pngDLL;
-procedure png_destroy_info_struct; external pngDLL;
-procedure png_destroy_read_struct; external pngDLL;
-procedure png_destroy_write_struct; external pngDLL;
-function png_get_IHDR; external pngDLL;
-function png_get_PLTE; external pngDLL;
-function png_get_bKGD; external pngDLL;
-function png_get_bit_depth; external pngDLL;
-function png_get_cHRM; external pngDLL;
-function png_get_channels; external pngDLL;
-function png_get_color_type; external pngDLL;
-function png_get_compression_type; external pngDLL;
-function png_get_error_ptr; external pngDLL;
-function png_get_filter_type; external pngDLL;
-function png_get_gAMA; external pngDLL;
-function png_get_hIST; external pngDLL;
-function png_get_image_height; external pngDLL;
-function png_get_image_width; external pngDLL;
-function png_get_interlace_type; external pngDLL;
-function png_get_io_ptr; external pngDLL;
-function png_get_oFFs; external pngDLL;
-function png_get_pCAL; external pngDLL;
-function png_get_pHYs; external pngDLL;
-function png_get_pixel_aspect_ratio; external pngDLL;
-function png_get_pixels_per_meter; external pngDLL;
-function png_get_progressive_ptr; external pngDLL;
-function png_get_rowbytes; external pngDLL;
-function png_get_rows; external pngDLL;
-function png_get_sBIT; external pngDLL;
-function png_get_sRGB; external pngDLL;
-function png_get_signature; external pngDLL;
-function png_get_tIME; external pngDLL;
-function png_get_tRNS; external pngDLL;
-function png_get_text; external pngDLL;
-function png_get_user_chunk_ptr; external pngDLL;
-function png_get_valid; external pngDLL;
-function png_get_x_offset_microns; external pngDLL;
-function png_get_x_offset_pixels; external pngDLL;
-function png_get_x_pixels_per_meter; external pngDLL;
-function png_get_y_offset_microns; external pngDLL;
-function png_get_y_offset_pixels; external pngDLL;
-function png_get_y_pixels_per_meter; external pngDLL;
-procedure png_process_data; external pngDLL;
-procedure png_progressive_combine_row; external pngDLL;
-procedure png_read_end; external pngDLL;
-procedure png_read_image; external pngDLL;
-procedure png_read_info; external pngDLL;
-procedure png_read_row; external pngDLL;
-procedure png_read_rows; external pngDLL;
-procedure png_read_update_info; external pngDLL;
-procedure png_set_IHDR; external pngDLL;
-procedure png_set_PLTE; external pngDLL;
-procedure png_set_bKGD; external pngDLL;
-procedure png_set_background; external pngDLL;
-procedure png_set_bgr; external pngDLL;
-procedure png_set_cHRM; external pngDLL;
-procedure png_set_cHRM_fixed; external pngDLL;
-procedure png_set_compression_level; external pngDLL;
-procedure png_set_compression_mem_level; external pngDLL;
-procedure png_set_compression_method; external pngDLL;
-procedure png_set_compression_strategy; external pngDLL;
-procedure png_set_compression_window_bits; external pngDLL;
-procedure png_set_crc_action; external pngDLL;
-procedure png_set_dither; external pngDLL;
-procedure png_set_error_fn; external pngDLL;
-procedure png_set_expand; external pngDLL;
-procedure png_set_filler; external pngDLL;
-procedure png_set_filter; external pngDLL;
-procedure png_set_filter_heuristics; external pngDLL;
-procedure png_set_flush; external pngDLL;
-procedure png_set_gAMA; external pngDLL;
-procedure png_set_gAMA_fixed; external pngDLL;
-procedure png_set_gamma; external pngDLL;
-procedure png_set_gray_to_rgb; external pngDLL;
-procedure png_set_hIST; external pngDLL;
-function png_set_interlace_handling; external pngDLL;
-procedure png_set_invert_alpha; external pngDLL;
-procedure png_set_invert_mono; external pngDLL;
-procedure png_set_oFFs; external pngDLL;
-procedure png_set_pCAL; external pngDLL;
-procedure png_set_pHYs; external pngDLL;
-procedure png_set_packing; external pngDLL;
-procedure png_set_packswap; external pngDLL;
-procedure png_set_progressive_read_fn; external pngDLL;
-procedure png_set_read_fn; external pngDLL;
-procedure png_set_read_status_fn; external pngDLL;
-procedure png_set_read_user_transform_fn; external pngDLL;
-procedure png_set_rgb_to_gray; external pngDLL;
-procedure png_set_rgb_to_gray_fixed; external pngDLL;
-procedure png_set_rows; external pngDLL;
-procedure png_set_sBIT; external pngDLL;
-procedure png_set_sRGB; external pngDLL;
-procedure png_set_sRGB_gAMA_and_cHRM; external pngDLL;
-procedure png_set_shift; external pngDLL;
-procedure png_set_sig_bytes; external pngDLL;
-procedure png_set_strip_16; external pngDLL;
-procedure png_set_strip_alpha; external pngDLL;
-procedure png_set_swap; external pngDLL;
-procedure png_set_swap_alpha; external pngDLL;
-procedure png_set_tIME; external pngDLL;
-procedure png_set_tRNS; external pngDLL;
-procedure png_set_text; external pngDLL;
-procedure png_set_user_chunk_fn; external pngDLL;
-procedure png_set_write_fn; external pngDLL;
-procedure png_set_write_status_fn; external pngDLL;
-procedure png_set_write_user_transform_fn; external pngDLL;
-function png_sig_cmp; external pngDLL;
-procedure png_start_read_image; external pngDLL;
-procedure png_write_chunk; external pngDLL;
-procedure png_write_chunk_data; external pngDLL;
-procedure png_write_chunk_end; external pngDLL;
-procedure png_write_chunk_start; external pngDLL;
-procedure png_write_end; external pngDLL;
-procedure png_write_flush; external pngDLL;
-procedure png_write_image; external pngDLL;
-procedure png_write_info; external pngDLL;
-procedure png_write_info_before_PLTE; external pngDLL;
-procedure png_write_row; external pngDLL;
-procedure png_write_rows; external pngDLL;
-procedure png_get_iCCP; external pngDLL;
-procedure png_get_sPLT; external pngDLL;
-procedure png_set_iCCP; external pngDLL;
-procedure png_set_sPLT; external pngDLL;
-procedure png_free_data; external pngDLL;
-
-end.
diff --git a/scripts/pngos2.def b/scripts/pngos2.def
index 82da4a6..6c806f5 100644
--- a/scripts/pngos2.def
+++ b/scripts/pngos2.def
@@ -2,7 +2,7 @@
 ; PNG.LIB module definition file for OS/2
 ;----------------------------------------
 
-; Version 1.0.15
+; Version 1.0.16
 
 LIBRARY		PNG
 DESCRIPTION	"PNG image compression library for OS/2"
@@ -206,6 +206,11 @@
 ; Added at version 1.2.4
   png_malloc_warn
 
+; Added at version 1.2.6
+  png_set_user_limits
+  png_get_user_height_max
+  png_get_user_width_max
+
 ; These are not present when libpng is compiled with PNG_NO_GLOBAL_ARRAYS
   png_libpng_ver
   png_pass_start
diff --git a/projects/msvc/png32ms.def b/scripts/pngw32.def
similarity index 87%
rename from projects/msvc/png32ms.def
rename to scripts/pngw32.def
index 69a1af1..60843dc 100644
--- a/projects/msvc/png32ms.def
+++ b/scripts/pngw32.def
@@ -6,7 +6,7 @@
 DESCRIPTION "PNG image compression library for Windows"
 
 EXPORTS
-;Version 1.0.15
+;Version 1.0.16
   png_build_grayscale_palette  @1
   png_check_sig        @2
   png_chunk_error      @3
@@ -193,28 +193,33 @@
   png_destroy_struct  @178
 ; Added at version 1.2.0
 ; For use with PNG_USER_MEM_SUPPORTED
-; png_destroy_struct_2  @179
-; png_create_read_struct_2 @180
-; png_create_write_struct_2 @181
-; png_malloc_default @182
-; png_free_default @183
+  png_destroy_struct_2  @179
+  png_create_read_struct_2 @180
+  png_create_write_struct_2 @181
+  png_malloc_default @182
+  png_free_default @183
 ; MNG features
-; png_permit_mng_features  @184
+  png_permit_mng_features  @184
 ; MMX support
-; png_mmx_support  @185
-; png_get_mmx_flagmask  @186
-; png_get_asm_flagmask  @187
-; png_get_asm_flags  @188
-; png_get_mmx_bitdepth_threshold  @189
-; png_get_mmx_rowbytes_threshold  @190
-; png_set_asm_flags  @191
-; png_init_mmx_flags  @192
+  png_mmx_support  @185
+  png_get_mmx_flagmask  @186
+  png_get_asm_flagmask  @187
+  png_get_asm_flags  @188
+  png_get_mmx_bitdepth_threshold  @189
+  png_get_mmx_rowbytes_threshold  @190
+  png_set_asm_flags  @191
+  png_init_mmx_flags  @192
 ; Strip error numbers
-; png_set_strip_error_numbers @193
+  png_set_strip_error_numbers @193
 ; Added at version 1.2.2
-  png_handle_as_unknown @179
-  png_zalloc @180
-  png_zfree @181
-; png_handle_as_unknown @194
+  png_handle_as_unknown @194
+; Added at version 1.2.2 and deleted from 1.2.3
 ; png_zalloc @195
 ; png_zfree @196
+; Added at version 1.2.4
+  png_malloc_warn @195
+; Added at version 1.2.6
+  png_malloc_warn @195
+  png_get_user_height_max @196
+  png_get_user_width_max @197
+  png_set_user_limits @198
diff --git a/projects/msvc/png.rc b/scripts/pngw32.rc
similarity index 86%
rename from projects/msvc/png.rc
rename to scripts/pngw32.rc
index 9912471..e69d732 100644
--- a/projects/msvc/png.rc
+++ b/scripts/pngw32.rc
@@ -1,7 +1,7 @@
 #define PNG_VERSION_INFO_ONLY
 
 #include <windows.h>
-#include "png.h"
+#include "../png.h"
 
 #define _QUOTE(x) # x
 #define QUOTE(x) _QUOTE(x)
@@ -12,12 +12,7 @@
 #  error PRIVATEBUILD or SPECIALBUILD must be defined as a string describing the type of change brought to the standard library
 #endif /* defined(DLLFNAME_POSTFIX)... */
 
-#if !defined(DLLFNAME_POSTFIX) && defined(PNG_USE_PNGVCRD)
-#  if defined(PNG_DEBUG) && (PNG_DEBUG > 0)
-#    define DLLFNAME_POSTFIX "B"
-#  else
-#    define DLLFNAME_POSTFIX "A"
-#  endif /* !defined(DLLFNAME_POSTFIX)... */
+#if defined(PNG_USE_PNGVCRD)
 #  if !defined(SPECIALBUILD)
 #    define SPECIALBUILD "Use MMX instructions"
 #  endif /* SPECIALBUILD */
@@ -80,9 +75,9 @@
 #endif /* COMMENTS */
       VALUE "FileDescription", "PNG image compression library\000"
       VALUE "FileVersion", PNG_LIBPNG_VER_STRING "\000"
-      VALUE "InternalName", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_MAJOR) DLLFNAME_POSTFIX " (Windows 32 bit)\000"
-      VALUE "LegalCopyright", "\251 1998-2002 Glenn Randers-Pehrson\000"
-      VALUE "OriginalFilename", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_MAJOR) DLLFNAME_POSTFIX ".DLL\000"
+      VALUE "InternalName", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_DLLNUM) DLLFNAME_POSTFIX " (Windows 32 bit)\000"
+      VALUE "LegalCopyright", "\251 1998-2004 Glenn Randers-Pehrson et al.\000"
+      VALUE "OriginalFilename", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_DLLNUM) DLLFNAME_POSTFIX ".DLL\000"
 #ifdef PRIVATEBUILD
       VALUE "PrivateBuild", PRIVATEBUILD
 #endif /* PRIVATEBUILD */