Imported from libpng-1.0.6g.tar
diff --git a/ANNOUNCE b/ANNOUNCE
index c1e80eb..03ca582 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,5 +1,5 @@
 
-Libpng 1.0.6f - April 14, 2000
+Libpng 1.0.6g - April 24, 2000
 
 This is not intended to be a public release.  It will be replaced
 within a few weeks by a public version or by another test version.
@@ -15,7 +15,7 @@
   Renamed makefile.ibmvac3 to makefile.ibmc, added libpng.icc IBM project file
   Added a check for info_ptr->free_me&PNG_FREE_TEXT when free'ing text in png.c
   Simplify png_sig_bytes() function to remove use of non-ISO-C strdup().
-version 1.0.6f [April 14, 2000]
+version 1.0.6e [April 9, 2000]
   Added png_data_freer() function.
   In the code that checks for over-length tRNS chunks, added check of
     info_ptr->num_trans as well as png_ptr->num_trans (Matthias Benckmann)
@@ -26,11 +26,20 @@
     is defined.
   Changed several instances of PNG_NO_CONSOLE_ID to PNG_NO_STDIO in pngrutil.c
     and mentioned the purposes of the two macros in libpng.txt/libpng.3.
-
-Send comments/corrections/commendations to
-png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
-
-Glenn R-P
+version 1.0.6f [April 14, 2000]
+  Revised png_set_iCCP() and png_set_rows() to avoid prematurely freeing data.
+  Add checks in png_set_text() for NULL members of the input text structure.
+  Revised libpng.txt/libpng.3.
+  Removed superfluous prototype for png_set_itxt from png.h
+  Removed "else" from pngread.c, after png_error(), and changed "0" to "length".
+  Changed several png_errors about malformed ancillary chunks to png_warnings.
+version 1.0.6g [April 24, 2000]
+  Added png_pass-* arrays to pnggccrd.c when PNG_USE_LOCAL_ARRAYS is defined.
+  Relocated paragraph about png_set_background() in libpng.3/libpng.txt
+    and other revisions (Matthias Benckmann)
+  Relocated info_ptr->free_me, png_ptr->free_me, and other info_ptr and
+    png_ptr members to restore binary compatibility with libpng-1.0.5
+    (breaks compatibility with libpng-1.0.6).
 
 Send comments/corrections/commendations to
 png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
diff --git a/CHANGES b/CHANGES
index 8a4be2d..752eb58 100644
--- a/CHANGES
+++ b/CHANGES
@@ -123,6 +123,7 @@
      - all chunk handling routines have the same prototypes, so we will
        be able to handle all chunks via a callback mechanism
   try to fix Linux "setjmp" buffer size problems
+  removed png_large_malloc, png_large_free, and png_realloc functions.
 version 0.95 [March, 1997]
   fixed bug in pngwutil.c allocating "up_row" twice and "avg_row" never
   fixed bug in PNG file signature compares when start != 0
@@ -259,6 +260,7 @@
   Minor changes to previous minor changes to pngtest.c
   Changed PNG_READ_NOT_FULLY_SUPPORTED to PNG_READ_TRANSFORMS_NOT_SUPPORTED
   and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro
+  Added user transform capability
 version 1.00 [March 7, 1998]
   Changed several typedefs in pngrutil.c
   Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik)
@@ -687,6 +689,13 @@
   Removed superfluous prototype for png_set_itxt from png.h
   Removed "else" from pngread.c, after png_error(), and changed "0" to "length".
   Changed several png_errors about malformed ancillary chunks to png_warnings.
+version 1.0.6g [April 24, 2000]
+  Added png_pass-* arrays to pnggccrd.c when PNG_USE_LOCAL_ARRAYS is defined.
+  Relocated paragraph about png_set_background() in libpng.3/libpng.txt
+    and other revisions (Matthias Benckmann)
+  Relocated info_ptr->free_me, png_ptr->free_me, and other info_ptr and
+    png_ptr members to restore binary compatibility with libpng-1.0.5
+    (breaks compatibility with libpng-1.0.6).
 
 Send comments/corrections/commendations to
 png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
diff --git a/INSTALL b/INSTALL
index d065df9..7ef00c3 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
 
-Installing libpng version 1.0.6f - April 14, 2000
+Installing libpng version 1.0.6g - April 24, 2000
 
 Before installing libpng, you must first install zlib.  zlib
 can usually be found wherever you got libpng.  zlib can be
@@ -10,7 +10,7 @@
 version of zlib that's installed.
 
 You can rename the directories that you downloaded (they
-might be called "libpng-1.0.6f" or "lpng106" and "zlib-1.1.3"
+might be called "libpng-1.0.6g" or "lpng106" and "zlib-1.1.3"
 or "zlib113") so that you have directories called "zlib" and "libpng".
 
 Your directory structure should look like this:
@@ -47,8 +47,8 @@
 include
 
  makefile.std      =>  Generic UNIX makefile (cc, creates static libpng.a)
- makefile.linux    =>  Linux/ELF makefile (gcc, creates libpng.so.2.1.0.6f)
- makefile.gcmmx    =>  Linux/ELF makefile (gcc, creates libpng.so.2.1.0.6f,
+ makefile.linux    =>  Linux/ELF makefile (gcc, creates libpng.so.2.1.0.6g)
+ makefile.gcmmx    =>  Linux/ELF makefile (gcc, creates libpng.so.2.1.0.6g,
                        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
@@ -59,9 +59,9 @@
  makefile.ibmc     =>  IBM C/C++ version 3.x for Win32 and OS/2 (static)
  libpng.icc        =>  Project file for IBM VisualAge/C++ version 4.0 or later
  makefile.sgi      =>  Silicon Graphics IRIX makefile (cc, creates static lib)
- makefile.sggcc    =>  Silicon Graphics (gcc, creates libpng.so.2.1.0.6f)
+ makefile.sggcc    =>  Silicon Graphics (gcc, creates libpng.so.2.1.0.6g)
  makefile.sunos    =>  Sun makefile
- makefile.solaris  =>  Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.6f)
+ makefile.solaris  =>  Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.6g)
  makefile.sco      =>  For SCO OSr5  ELF and Unixware 7 with Native cc
  makefile.mips     =>  MIPS makefile
  makefile.acorn    =>  Acorn makefile
diff --git a/KNOWNBUG b/KNOWNBUG
index 64e2cfe..909dda3 100644
--- a/KNOWNBUG
+++ b/KNOWNBUG
@@ -1,47 +1,61 @@
 
 Known bugs and suggested enhancements in libpng-1.0.6
 
-1. April 1, 2000 -- BUG
+1. April 23, 2000 -- BUG -- binary incompatibility
+
+   Libpng-1.0.6 introduced binary incompatibility for applications that
+   make direct access to the info_ptr and png_ptr, due to the insertion
+   of the free_me member ahead of some previously existing members.
+
+   STATUS:  Fixed in libpng-1.0.6g
+
+2. April 15, 2000 -- BUG -- pnggccrd.c
+
+   If PNG_NO_GLOBAL_ARRAYS is defined, pnggccrd.c will not compile.
+
+   STATUS: Fixed in libpng-1.0.6g
+
+3. April 1, 2000 -- BUG
 
    Under some circumstances old applications that make direct access to
    the info_ptr->text and its members might free the same memory that
    is also free'ed by libpng during the png_destroy_struct process.
 
-   Fixed in libpng-1.0.6-patch-03 and libpng-1.0.6d.  The PNG_FREE_TEXT flag
+   Fixed in libpng-1.0.6-patch-c and libpng-1.0.6d.  The PNG_FREE_TEXT flag
    bit in info_ptr->free_me is now checked to make sure libpng is responsible
    for freeing the memory.
 
-2. April 1, 2000 -- BUG
+4. April 1, 2000 -- BUG
 
    The non-ISO-C "strdup()" function is used in png.c
 
    STATUS: The function has been simplified and no longer uses strdup()
-   in libpng-1.0.6-patch-03 and libpng-1.0.6d.
+   in libpng-1.0.6-patch-c and libpng-1.0.6d.
 
-3. March 24, 2000 -- BUG
+5. March 24, 2000 -- BUG
 
    The png_set_rgb_to_gray_fixed() function is setting incorrect weighting
    factors.
 
-   STATUS: Fixed in libpng-1.0.6-patch-02 and libpng-1.0.6d.
+   STATUS: Fixed in libpng-1.0.6-patch-b and libpng-1.0.6d.
 
-4. March 22, 2000 -- BUG
+6. March 22, 2000 -- BUG
 
    There are some printf() and fprintf() statements active in pngwutil.c
    when PNG_NO_STDIO and PNG_sCAL_SUPPORTED are both defined.
 
-   STATUS: Fixed in libpng-1.0.6-patch-01 and libpng-1.0.6d.  The strcpy()
+   STATUS: Fixed in libpng-1.0.6-patch-a and libpng-1.0.6d.  The strcpy()
    function is used instead.
 
-5. March 22, 2000 -- BUG
+7. March 22, 2000 -- BUG
 
    The length of the iCCP chunk data is calculated incorrectly; because
    it can contain zeroes, strlen() doesn't work.
 
-   STATUS: Fixed in libpng-1.0.6-patch-01 and libpng-1.0.6d by adding a
+   STATUS: Fixed in libpng-1.0.6-patch-a and libpng-1.0.6d by adding a
    data_length parameter to the png_decompress_chunk() function.
 
-6. March 15, 1998 -- OPTIMIZATION -- Kevin Bracey
+8. March 15, 1998 -- OPTIMIZATION -- Kevin Bracey
 
    Loops need to be optimized everywhere
 
@@ -56,7 +70,7 @@
    libpng-1.1.0.  About 160 loops will be turned around
    in libpng-1.1.Nn, for testing.
 
-7. July 4, 1998 -- ENHANCEMENT -- Glenn R-P
+9. July 4, 1998 -- ENHANCEMENT -- Glenn R-P
 
    libpng-1.0.5 and earlier transform colors to gamma=1.0 space for
    merging with background, and then back to the image's gamma.  The
@@ -68,7 +82,7 @@
 
    STATUS: under development.
 
-8. September 1999 -- ENHANCEMENT --
+10. September 1999 -- ENHANCEMENT --
 
    It should be possible to use libpng without floating-point aritmetic.
 
diff --git a/LICENSE b/LICENSE
index c474ec3..cd76479 100644
--- a/LICENSE
+++ b/LICENSE
@@ -5,7 +5,7 @@
 Copyright (c) 1996, 1997 Andreas Dilger
 (libpng versions 0.90, December 1996, through 0.96, May 1997)
 Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
-(libpng versions 0.97, January 1998, through 1.0.6f, April 14, 2000)
+(libpng versions 0.97, January 1998, through 1.0.6g, April 24, 2000)
 
 For the purposes of this copyright and license, "Contributing Authors"
 is defined as the following set of individuals:
@@ -68,4 +68,4 @@
 
 Glenn Randers-Pehrson
 randeg@alum.rpi.edu
-April 14, 2000
+April 24, 2000
diff --git a/README b/README
index 359886d..abab501 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README for libpng 1.0.6f - April 14, 2000 (shared library 2.1)
+README for libpng 1.0.6g - April 24, 2000 (shared library 2.1)
 See the note about version numbers near the top of png.h
 
 See INSTALL for instructions on how to install libpng.
@@ -172,9 +172,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 libpng.so.2.1.0.6f)
+                            (gcc, creates libpng.so.2.1.0.6g)
        makefile.gcmmx   =>  Linux/ELF makefile (gcc, creates
-                            libpng.so.2.1.0.6f, uses assembler code
+                            libpng.so.2.1.0.6g, 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
@@ -185,10 +185,10 @@
        makefile.ibmc    =>  IBM C/C++ version 3.x for Win32 and OS/2 (static)
        libpng.icc       =>  Project file, IBM VisualAge/C++ 4.0 or later
        makefile.sgi     =>  Silicon Graphics IRIX (cc, creates static lib)
-       makefile.sggcc   =>  Silicon Graphics (gcc, creates libpng.so.2.1.0.6f)
+       makefile.sggcc   =>  Silicon Graphics (gcc, creates libpng.so.2.1.0.6g)
        makefile.sunos   =>  Sun makefile
        makefile.solaris =>  Solaris 2.X makefile
-                            (gcc, creates libpng.so.2.1.0.6f)
+                            (gcc, creates libpng.so.2.1.0.6g)
        makefile.sco     =>  For SCO OSr5  ELF and Unixware 7 with Native cc
        makefile.mips    =>  MIPS makefile
        makefile.acorn   =>  Acorn makefile
diff --git a/Y2KINFO b/Y2KINFO
index 03fe895..2c5fe69 100644
--- a/Y2KINFO
+++ b/Y2KINFO
@@ -1,13 +1,13 @@
    Y2K compliance in libpng:
    =========================
 
-      April 14, 2000
+      April 24, 2000
 
       Since the PNG Development group is an ad-hoc body, we can't make
       an official declaration.
 
       This is your unofficial assurance that libpng from version 0.71 and
-      upward through 1.0.6f are Y2K compliant.  It is my belief that earlier
+      upward through 1.0.6g 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 3ecaa4d..0f55c5a 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 echo "
-  There is no \"configure\" script for Libpng-1.0.6f.  Instead, please
+  There is no \"configure\" script for Libpng-1.0.6g.  Instead, please
   copy the appropriate makefile for your system from the \"scripts\"
   directory.  Read the INSTALL file for more details.
 "
diff --git a/contrib/gregbook/makefile b/contrib/gregbook/makefile
deleted file mode 100644
index 500f74f..0000000
--- a/contrib/gregbook/makefile
+++ /dev/null
@@ -1,104 +0,0 @@
-# Sample makefile for rpng-x / rpng2-x / wpng using gcc and make.
-# Greg Roelofs
-# Last modified:  28 February 2000
-#
-#	The programs built by this makefile are described in the book,
-#	"PNG:  The Definitive Guide," by Greg Roelofs (O'Reilly and
-#	Associates, 1999).  Go buy a copy, eh?  Buy some for friends
-#	and family, too.  (Not that this is a blatant plug or anything.)
-#
-# Invoke this makefile from a shell prompt in the usual way; for example:
-#
-#	make -f Makefile.unx
-#
-# This makefile assumes libpng and zlib have already been built or downloaded
-# and are both installed in /usr/local/{include,lib} (as indicated by the
-# PNG* and Z* macros below).  Edit as appropriate--choose only ONE each of
-# the PNGINC, PNGLIB, ZINC and ZLIB lines.
-#
-# This makefile builds statically linked executables (against libpng and zlib,
-# that is), but that can be changed by uncommenting the appropriate PNGLIB and
-# ZLIB lines.
-
-
-# macros --------------------------------------------------------------------
-
-PNGINC = -I/usr/local/include
-#PNGLIB = -L/usr/local/lib -lpng	# dynamically linked against libpng
-PNGLIB = /usr/local/lib/libpng.a	# statically linked against libpng
-# or:
-#PNGINC = -I../..
-#PNGLIB = -L../.. -lpng
-#PNGLIB = ../../libpng.a
-
-ZINC = -I/usr/local/include
-#ZLIB = -L/usr/local/lib -lz		# dynamically linked against zlib
-ZLIB = /usr/local/lib/libz.a		# statically linked against zlib
-#ZINC = -I../zlib
-#ZLIB = -L../zlib -lz
-#ZLIB = ../../../zlib/libz.a
-
-XINC = -I/usr/include/X11		# old-style, stock X distributions
-XLIB = -L/usr/lib/X11 -lX11
-#XINC = -I/usr/openwin/include/X11	# Sun workstations (OpenWindows)
-#XLIB = -L/usr/openwin/lib -lX11
-#XINC = -I/usr/X11R6/include		# new X distributions (XFree86, etc.)
-#XLIB = -L/usr/X11R6/lib -lX11
-
-INCS = $(PNGINC) $(ZINC) $(XINC)
-RLIBS = $(PNGLIB) $(ZLIB) $(XLIB) -lm
-WLIBS = $(PNGLIB) $(ZLIB)
-
-CC = cc -n32
-LD = cc -n32
-RM = rm -f
-CFLAGS = -O -fullwarn $(INCS)
-# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
-# [-ansi, -pedantic and -W can also be used]
-LDFLAGS =
-O = .o
-E =
-
-RPNG  = rpng-x
-RPNG2 = rpng2-x
-WPNG  = wpng
-
-ROBJS  = $(RPNG)$(O) readpng$(O)
-ROBJS2 = $(RPNG2)$(O) readpng2$(O)
-WOBJS  = $(WPNG)$(O) writepng$(O)
-
-EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
-
-
-# implicit make rules -------------------------------------------------------
-
-.c$(O):
-	$(CC) -c $(CFLAGS) $<
-
-
-# dependencies --------------------------------------------------------------
-
-all:  $(EXES)
-
-$(RPNG)$(E): $(ROBJS)
-	$(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBS)
-
-$(RPNG2)$(E): $(ROBJS2)
-	$(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBS)
-
-$(WPNG)$(E): $(WOBJS)
-	$(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBS)
-
-$(RPNG)$(O):	$(RPNG).c readpng.h
-$(RPNG2)$(O):	$(RPNG2).c readpng2.h
-$(WPNG)$(O):	$(WPNG).c writepng.h
-
-readpng$(O):	readpng.c readpng.h
-readpng2$(O):	readpng2.c readpng2.h
-writepng$(O):	writepng.c writepng.h
-
-
-# maintenance ---------------------------------------------------------------
-
-clean:
-	$(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS)
diff --git a/contrib/gregbook/rpng-x b/contrib/gregbook/rpng-x
deleted file mode 100755
index ad371c8..0000000
--- a/contrib/gregbook/rpng-x
+++ /dev/null
Binary files differ
diff --git a/contrib/gregbook/rpng2-x b/contrib/gregbook/rpng2-x
deleted file mode 100755
index 25f22e5..0000000
--- a/contrib/gregbook/rpng2-x
+++ /dev/null
Binary files differ
diff --git a/contrib/gregbook/wpng b/contrib/gregbook/wpng
deleted file mode 100755
index 2037f75..0000000
--- a/contrib/gregbook/wpng
+++ /dev/null
Binary files differ
diff --git a/contrib/pngminus/makefile b/contrib/pngminus/makefile
deleted file mode 100644
index 3ccbc8f..0000000
--- a/contrib/pngminus/makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-# Makefile for PngMinus (png2pnm and pnm2png)
-# Linux / Unix
-
-CC=cc -O -n32
-LD=cc -O -n32
-#CC=gcc -O
-#LD=gcc -O
-LB=ar
-RM=rm
-CP=cp
-
-PNGPATH = /usr/local
-PNGINC = $(PNGPATH)/include
-PNGLIB = $(PNGPATH)/lib -lpng
-# PNGLIB = $(PNGPATH)/libpng.a
-
-ZPATH = /usr/local
-ZINC = $(ZPATH)/include
-ZLIB = $(ZPATH)/lib -lz
-# ZLIB = $(ZPATH)/libz.a
-
-CCFLAGS=-I$(PNGINC) -I$(ZINC)
-LDFLAGS=-L$(PNGLIB) -L$(ZLIB) -lm
-C=.c
-O=.o
-L=.a
-E=
-
-# dependencies
-
-all: png2pnm$(E) pnm2png$(E)
-
-png2pnm$(O): png2pnm$(C)
-	$(CC) -c $(CCFLAGS) png2pnm$(C)
-
-png2pnm$(E): png2pnm$(O)
-	$(LD) -o png2pnm$(E) png2pnm$(O) $(LDFLAGS)
-
-pnm2png$(O): pnm2png$(C)
-	$(CC) -c $(CCFLAGS) pnm2png$(C)
-
-pnm2png$(E): pnm2png$(O)
-	$(LD) -o pnm2png$(E) pnm2png$(O) $(LDFLAGS)
-
-clean:
-	$(RM) png2pnm$(O)
-	$(RM) pnm2png$(O)
-	$(RM) png2pnm$(E)
-	$(RM) pnm2png$(E)
-
-# End of makefile for png2pnm / pnm2png
-
diff --git a/libpng.3 b/libpng.3
index 6300b86..a462167 100644
--- a/libpng.3
+++ b/libpng.3
@@ -1,6 +1,6 @@
-.TH LIBPNG 3 "April 14, 2000"
+.TH LIBPNG 3 "April 24, 2000"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.0.6f
+libpng \- Portable Network Graphics (PNG) Reference Library 1.0.6g
 .SH SYNOPSIS
 \fI\fB
 
@@ -234,7 +234,7 @@
 
 \fI\fB
 
-\fBpng_uint_32 png_get_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fP\fI*splt_ptr\fP\fB, int \fInum\fP\fB);\fP
+\fBpng_uint_32 png_get_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fI*splt_ptr\fP\fB);\fP
 
 \fI\fB
 
@@ -294,6 +294,10 @@
 
 \fI\fB
 
+\fBpng_uint_32 png_get_compression_buffer_size (png_structp \fIpng_ptr\fP\fB);\fP
+
+\fI\fB
+
 \fBvoid png_info_init (png_infop \fIinfo_ptr\fP\fB);\fP
 
 \fI\fB
@@ -614,6 +618,10 @@
 
 \fI\fB
 
+\fBvoid png_set_unknown_chunk_location(png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIchunk\fP\fB, int \fIlocation\fP\fB);\fP
+
+\fI\fB
+
 \fBvoid png_set_read_user_chunk_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIuser_chunk_ptr\fP\fB, png_user_chunk_ptr \fIread_user_chunk_fn\fP\fB);\fP
 
 \fI\fB
@@ -634,6 +642,10 @@
 
 \fI\fB
 
+\fBvoid png_set_compression_buffer_size(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
+
+\fI\fB
+
 \fBint png_sig_cmp (png_bytep \fP\fIsig\fP\fB, png_size_t \fP\fIstart\fP\fB, png_size_t \fInum_to_check\fP\fB);\fP
 
 \fI\fB
@@ -713,7 +725,7 @@
 .SH LIBPNG.TXT
 libpng.txt - A description on how to use and modify libpng
 
- libpng version 1.0.6f - April 14, 2000
+ libpng version 1.0.6g - April 24, 2000
  Updated and distributed by Glenn Randers-Pehrson
  <randeg@alum.rpi.edu>
  Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
@@ -1393,8 +1405,8 @@
 grayscale images with bit depths of 2 or 4 or if there is a multiple-image
 viewing application that wishes to treat all images in the same way.
 
-    if (color_type == PNG_COLOR_TYPE_PALETTE &&
-        bit_depth <= 8) png_set_palette_to_rgb(png_ptr);
+    if (color_type == PNG_COLOR_TYPE_PALETTE)
+        png_set_palette_to_rgb(png_ptr);
 
     if (color_type == PNG_COLOR_TYPE_GRAY &&
         bit_depth < 8) png_set_gray_1_2_4_to_8(png_ptr);
@@ -1413,17 +1425,6 @@
     if (bit_depth == 16)
         png_set_strip_16(png_ptr);
 
-The png_set_background() function tells libpng to composite images
-with alpha or simple transparency against the supplied background
-color.  If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
-you may use this color, or supply another color more suitable for
-the current display (e.g., the background color from a web page).  You
-need to tell libpng whether the color is in the gamma space of the
-display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file
-(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one
-that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't
-know why anyone would use this, but it's here).
-
 If, for some reason, you don't need the alpha channel on an image,
 and you want to remove it rather than combining it with the background
 (but the image author certainly had in mind that you *would* combine
@@ -1567,6 +1568,17 @@
         png_set_background(png_ptr, &my_background,
           PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
 
+The png_set_background() function tells libpng to composite images
+with alpha or simple transparency against the supplied background
+color.  If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
+you may use this color, or supply another color more suitable for
+the current display (e.g., the background color from a web page).  You
+need to tell libpng whether the color is in the gamma space of the
+display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file
+(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one
+that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't
+know why anyone would use this, but it's here).
+
 To properly display PNG images on any kind of system, the application needs
 to know what the display gamma is.  Ideally, the user will know this, and
 the application will allow them to set it.  One method of allowing the user
@@ -1763,7 +1775,7 @@
 a single row_pointer instead of an array of row_pointers:
 
     png_bytep row_pointer = row;
-    png_read_row(png_ptr, row_pointers, NULL);
+    png_read_row(png_ptr, row_pointer, NULL);
 
 If the file is interlaced (interlace_type != 0 in the IHDR chunk), things
 get somewhat harder.  The only current (PNG Specification version 1.2)
@@ -2182,21 +2194,33 @@
 the filter method, for which the only valid value is '0' (as of the
 July 1999 PNG specification, version 1.2).  The third parameter is a
 flag that indicates which filter type(s) are to be tested for each
-scanline.  See the Compression Library for details on the specific filter
+scanline.  See the PNG specification for details on the specific filter
 types.
 
 
     /* turn on or off filtering, and/or choose
-       specific filters */
+       specific filters.  You can use either a single PNG_FILTER_VALUE_NAME
+       or the "OR" of one or more PNG_FILTER_NAME masks. */
     png_set_filter(png_ptr, 0,
-       PNG_FILTER_NONE | PNG_FILTER_SUB |
-       PNG_FILTER_PAETH);
+       PNG_FILTER_NONE  | PNG_FILTER_VALUE_NONE |
+       PNG_FILTER_SUB   | PNG_FILTER_VALUE_SUB  |
+       PNG_FILTER_UP    | PNG_FILTER_VALUE_UP   |
+       PNG_FILTER_AVE   | PNG_FILTER_VALUE_AVE  |
+       PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH|
+       PNG_ALL_FILTERS);
+
+If an application
+wants to start and stop using particular filters during compression,
+it should start out with all of the filters (to ensure that the previous
+row of pixels will be stored in case it's needed later), and then add
+and remove them after the start of compression.
 
 The png_set_compression_*() functions interface to the zlib compression
 library, and should mostly be ignored unless you really know what you are
 doing.  The only generally useful call is png_set_compression_level()
 which changes how much time zlib spends on trying to compress the image
-data.  See the Compression Library for details on the compression levels.
+data.  See the Compression Library (zlib.h and algorithm.txt, distributed
+with zlib) for details on the compression levels.
 
     /* set the zlib compression level */
     png_set_compression_level(png_ptr,
@@ -2208,6 +2232,9 @@
         Z_DEFAULT_STRATEGY);
     png_set_compression_window_bits(png_ptr, 15);
     png_set_compression_method(png_ptr, 8);
+    png_set_compression_buffer_size(png_ptr, 8192)
+
+extern PNG_EXPORT(void,png_set_zbuf_size)
 
 .SS Setting the contents of info for output
 
@@ -2416,18 +2443,17 @@
 
 A quick word about text and num_text.  text is an array of png_text
 structures.  num_text is the number of valid structures in the array.
-If you want, you can use max_text to hold the size of the array, but
-libpng ignores it for writing (it does use it for reading).  Each
-png_text structure holds a language code, a keyword, a text value, and
-a compression type.
+Each png_text structure holds a language code, a keyword, a text value,
+and a compression type.
 
 The compression types have the same valid numbers as the compression
 types of the image data.  Currently, the only valid number is zero.
 However, you can store text either compressed or uncompressed, unlike
 images, which always have to be compressed.  So if you don't want the
 text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE.
-Because compressed-text chunks don't have a language field, if you
-specify compression any language code will not be written out.
+Because tEXt and zTXt chunks don't have a language field, if you
+specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt
+any language code or translated keyword will not be written out.
 
 Until text gets around 1000 bytes, it is not worth compressing it.
 After the text has been written out to the file, the compression type
@@ -2587,8 +2613,8 @@
     png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
 
 where the 0 is unused, and the location is either PNG_FILLER_BEFORE or
-PNG_FILLER_AFTER, depending upon whether the filler byte in the is stored
-XRGB or RGBX.
+PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel
+is stored XRGB or RGBX.
 
 PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
 they can, resulting in, for example, 8 pixels per byte for 1 bit files.
@@ -2599,7 +2625,7 @@
 
 PNG files reduce possible bit depths to 1, 2, 4, 8, and 16.  If your
 data is of another bit depth, you can write an sBIT chunk into the
-file so that decoders can get the original data if desired.
+file so that decoders can recover the original data if desired.
 
     /* Set the true bit depth of the image data */
     if (color_type & PNG_COLOR_MASK_COLOR)
@@ -2674,8 +2700,8 @@
 The user_channels and user_depth parameters of this function are ignored
 when writing; you can set them to zero as shown.
 
-You can retrieve the pointer via the function
-png_get_user_transform_ptr().  For example:
+You can retrieve the pointer via the function png_get_user_transform_ptr().
+For example:
 
     voidp write_user_transform_ptr =
        png_get_user_transform_ptr(png_ptr);
@@ -2737,7 +2763,7 @@
     png_write_row(png_ptr, row_pointer);
 
 When the file is interlaced, things can get a good deal more
-complicated.  The only currently (as of January 2000 -- PNG Specification
+complicated.  The only currently (as of the PNG Specification
 version 1.2, dated July 1999) defined interlacing scheme for PNG files
 is the "Adam7" interlace scheme, that breaks down an
 image into seven smaller images of varying size.  libpng will build
@@ -2828,7 +2854,7 @@
        PNG_DESTROY_WILL_FREE_DATA,
        PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST)
 
-Thereby briefly reassigning responsibility for freeing to the user but
+thereby briefly reassigning responsibility for freeing to the user but
 immediately afterwards reassigning it once more to the write_destroy
 function.  Having done this, it would then be safe to destroy the read
 structure and continue to use the PLTE, tRNS, and hIST data in the write
@@ -2845,13 +2871,11 @@
 
 All of the memory allocation, input/output, and error handling in libpng
 goes through callbacks that are user settable.  The default routines are
-in pngmem.c, pngrio.c, pngwio.c, and pngerror.c respectively.  To change
+in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively.  To change
 these functions, call the appropriate png_set_*_fn() function.
 
-Memory allocation is done through the functions png_large_malloc(),
-png_malloc(), png_realloc(), png_large_free(), and png_free().  These
-currently just call the standard C functions.  The large functions must
-handle exactly 64K, but they don't have to handle more than that.  If
+Memory allocation is done through the functions png_malloc() and png_free().
+These currently just call the standard C functions.  If
 your pointers can't access more then 64K at a time, you will want to set
 MAXSEG_64K in zlib.h.  Since it is unlikely that the method of handling
 memory allocation on a platform will change between applications, these
@@ -2904,8 +2928,8 @@
 fprintf() isn't available).  If you wish to change the behavior of the error
 functions, you will need to set up your own message callbacks.  These
 functions are normally supplied at the time that the png_struct is created.
-It is also possible to change these functions after png_create_*_struct()
-has been called by calling:
+It is also possible to redirect errors and warnings to your own replacement
+functions after png_create_*_struct() has been called by calling:
 
     png_set_error_fn(png_structp png_ptr,
         png_voidp error_ptr, png_error_ptr error_fn,
@@ -2929,7 +2953,8 @@
 However, there are some uncertainties about the status of local variables
 after a longjmp, so the user may want to be careful about doing anything after
 setjmp returns non-zero besides returning itself.  Consult your compiler
-documentation for more details.
+documentation for more details.  For an alternative approach, you may wish
+to use the "cexcept" facility (see http://cexcept.sourceforge.net).
 
 .SS Custom chunks
 
@@ -2959,10 +2984,7 @@
 
 .SS Configuring for 16 bit platforms
 
-You may need to change the png_large_malloc() and png_large_free()
-routines in pngmem.c, as these are required to allocate 64K, although
-there is already support for many of the common DOS compilers.  Also,
-you will want to look into zconf.h to tell zlib (and thus libpng) that
+You will want to look into zconf.h to tell zlib (and thus libpng) that
 it cannot allocate more then 64K at a time.  Even if you can, the memory
 won't be accessible.  So limit zlib and libpng to 64K by defining MAXSEG_64K.
 
@@ -3031,6 +3053,7 @@
     png_set_compression_window_bits(png_ptr,
         window_bits);
     png_set_compression_method(png_ptr, method);
+    png_set_compression_buffer_size(png_ptr, size);
 
 .SS Controlling row filtering
 
@@ -3059,7 +3082,13 @@
 structures appropriately for all of the filter types.
 
     filters = PNG_FILTER_NONE | PNG_FILTER_SUB
-       | PNG_FILTER_UP;
+              PNG_FILTER_UP | PNG_FILTER_AVE |
+              PNG_FILTER_PAETH | PNG_ALL_FILTERS;
+    or
+    filters = one of PNG_FILTER_VALUE_NONE,
+              PNG_FILTER_VALUE_SUB, PNG_FILTER_VALUE_UP,
+              PNG_FILTER_VALUE_AVE, PNG_FILTER_VALUE_PAETH
+
     png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE,
        filters);
 
@@ -3108,7 +3137,7 @@
 PNG_NO_.
 
 You can also turn all of the transforms and ancillary chunk capabilities
-off en masse with  compiler directives that define
+off en masse with compiler directives that define
 PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
 or all four,
 along with directives to turn on any of the capabilities that you do
@@ -3208,13 +3237,13 @@
 
 .SH VII. Y2K Compliance in libpng
 
-April 14, 2000
+April 24, 2000
 
 Since the PNG Development group is an ad-hoc body, we can't make
 an official declaration.
 
 This is your unofficial assurance that libpng from version 0.71 and
-upward through 1.0.6f are Y2K compliant.  It is my belief that earlier
+upward through 1.0.6g 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
@@ -3355,7 +3384,7 @@
 
 Thanks to Frank J. T. Wojcik for helping with the documentation.
 
-Libpng version 1.0.6f - April 14, 2000:
+Libpng version 1.0.6g - April 24, 2000:
 Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
 Currently maintained by Glenn Randers-Pehrson (randeg@alum.rpi.edu).
 
@@ -3370,7 +3399,7 @@
 Copyright (c) 1996, 1997 Andreas Dilger
 (libpng versions 0.89c, May 1996, through 0.96, May 1997)
 Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
-(libpng versions 0.97, January 1998, through 1.0.6f, April 14, 2000)
+(libpng versions 0.97, January 1998, through 1.0.6g, April 24, 2000)
 
 For the purposes of this copyright and license, "Contributing Authors"
 is defined as the following set of individuals:
diff --git a/libpng.txt b/libpng.txt
index 749cc2b..7bd87c1 100644
--- a/libpng.txt
+++ b/libpng.txt
@@ -1,6 +1,6 @@
 libpng.txt - A description on how to use and modify libpng
 
- libpng version 1.0.6f - April 14, 2000
+ libpng version 1.0.6g - April 24, 2000
  Updated and distributed by Glenn Randers-Pehrson
  <randeg@alum.rpi.edu>
  Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
@@ -680,8 +680,8 @@
 grayscale images with bit depths of 2 or 4 or if there is a multiple-image
 viewing application that wishes to treat all images in the same way.
 
-    if (color_type == PNG_COLOR_TYPE_PALETTE &&
-        bit_depth <= 8) png_set_palette_to_rgb(png_ptr);
+    if (color_type == PNG_COLOR_TYPE_PALETTE)
+        png_set_palette_to_rgb(png_ptr);
 
     if (color_type == PNG_COLOR_TYPE_GRAY &&
         bit_depth < 8) png_set_gray_1_2_4_to_8(png_ptr);
@@ -700,17 +700,6 @@
     if (bit_depth == 16)
         png_set_strip_16(png_ptr);
 
-The png_set_background() function tells libpng to composite images
-with alpha or simple transparency against the supplied background
-color.  If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
-you may use this color, or supply another color more suitable for
-the current display (e.g., the background color from a web page).  You
-need to tell libpng whether the color is in the gamma space of the
-display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file
-(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one
-that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't
-know why anyone would use this, but it's here).
-
 If, for some reason, you don't need the alpha channel on an image,
 and you want to remove it rather than combining it with the background
 (but the image author certainly had in mind that you *would* combine
@@ -854,6 +843,17 @@
         png_set_background(png_ptr, &my_background,
           PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
 
+The png_set_background() function tells libpng to composite images
+with alpha or simple transparency against the supplied background
+color.  If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
+you may use this color, or supply another color more suitable for
+the current display (e.g., the background color from a web page).  You
+need to tell libpng whether the color is in the gamma space of the
+display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file
+(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one
+that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't
+know why anyone would use this, but it's here).
+
 To properly display PNG images on any kind of system, the application needs
 to know what the display gamma is.  Ideally, the user will know this, and
 the application will allow them to set it.  One method of allowing the user
@@ -1050,7 +1050,7 @@
 a single row_pointer instead of an array of row_pointers:
 
     png_bytep row_pointer = row;
-    png_read_row(png_ptr, row_pointers, NULL);
+    png_read_row(png_ptr, row_pointer, NULL);
 
 If the file is interlaced (interlace_type != 0 in the IHDR chunk), things
 get somewhat harder.  The only current (PNG Specification version 1.2)
@@ -1469,21 +1469,33 @@
 the filter method, for which the only valid value is '0' (as of the
 July 1999 PNG specification, version 1.2).  The third parameter is a
 flag that indicates which filter type(s) are to be tested for each
-scanline.  See the Compression Library for details on the specific filter
+scanline.  See the PNG specification for details on the specific filter
 types.
 
 
     /* turn on or off filtering, and/or choose
-       specific filters */
+       specific filters.  You can use either a single PNG_FILTER_VALUE_NAME
+       or the "OR" of one or more PNG_FILTER_NAME masks. */
     png_set_filter(png_ptr, 0,
-       PNG_FILTER_NONE | PNG_FILTER_SUB |
-       PNG_FILTER_PAETH);
+       PNG_FILTER_NONE  | PNG_FILTER_VALUE_NONE |
+       PNG_FILTER_SUB   | PNG_FILTER_VALUE_SUB  |
+       PNG_FILTER_UP    | PNG_FILTER_VALUE_UP   |
+       PNG_FILTER_AVE   | PNG_FILTER_VALUE_AVE  |
+       PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH|
+       PNG_ALL_FILTERS);
+
+If an application
+wants to start and stop using particular filters during compression,
+it should start out with all of the filters (to ensure that the previous
+row of pixels will be stored in case it's needed later), and then add
+and remove them after the start of compression.
 
 The png_set_compression_*() functions interface to the zlib compression
 library, and should mostly be ignored unless you really know what you are
 doing.  The only generally useful call is png_set_compression_level()
 which changes how much time zlib spends on trying to compress the image
-data.  See the Compression Library for details on the compression levels.
+data.  See the Compression Library (zlib.h and algorithm.txt, distributed
+with zlib) for details on the compression levels.
 
     /* set the zlib compression level */
     png_set_compression_level(png_ptr,
@@ -1495,6 +1507,9 @@
         Z_DEFAULT_STRATEGY);
     png_set_compression_window_bits(png_ptr, 15);
     png_set_compression_method(png_ptr, 8);
+    png_set_compression_buffer_size(png_ptr, 8192)
+
+extern PNG_EXPORT(void,png_set_zbuf_size)
 
 Setting the contents of info for output
 
@@ -1703,18 +1718,17 @@
 
 A quick word about text and num_text.  text is an array of png_text
 structures.  num_text is the number of valid structures in the array.
-If you want, you can use max_text to hold the size of the array, but
-libpng ignores it for writing (it does use it for reading).  Each
-png_text structure holds a language code, a keyword, a text value, and
-a compression type.
+Each png_text structure holds a language code, a keyword, a text value,
+and a compression type.
 
 The compression types have the same valid numbers as the compression
 types of the image data.  Currently, the only valid number is zero.
 However, you can store text either compressed or uncompressed, unlike
 images, which always have to be compressed.  So if you don't want the
 text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE.
-Because compressed-text chunks don't have a language field, if you
-specify compression any language code will not be written out.
+Because tEXt and zTXt chunks don't have a language field, if you
+specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt
+any language code or translated keyword will not be written out.
 
 Until text gets around 1000 bytes, it is not worth compressing it.
 After the text has been written out to the file, the compression type
@@ -1874,8 +1888,8 @@
     png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
 
 where the 0 is unused, and the location is either PNG_FILLER_BEFORE or
-PNG_FILLER_AFTER, depending upon whether the filler byte in the is stored
-XRGB or RGBX.
+PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel
+is stored XRGB or RGBX.
 
 PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
 they can, resulting in, for example, 8 pixels per byte for 1 bit files.
@@ -1886,7 +1900,7 @@
 
 PNG files reduce possible bit depths to 1, 2, 4, 8, and 16.  If your
 data is of another bit depth, you can write an sBIT chunk into the
-file so that decoders can get the original data if desired.
+file so that decoders can recover the original data if desired.
 
     /* Set the true bit depth of the image data */
     if (color_type & PNG_COLOR_MASK_COLOR)
@@ -1961,8 +1975,8 @@
 The user_channels and user_depth parameters of this function are ignored
 when writing; you can set them to zero as shown.
 
-You can retrieve the pointer via the function
-png_get_user_transform_ptr().  For example:
+You can retrieve the pointer via the function png_get_user_transform_ptr().
+For example:
 
     voidp write_user_transform_ptr =
        png_get_user_transform_ptr(png_ptr);
@@ -2024,7 +2038,7 @@
     png_write_row(png_ptr, row_pointer);
 
 When the file is interlaced, things can get a good deal more
-complicated.  The only currently (as of January 2000 -- PNG Specification
+complicated.  The only currently (as of the PNG Specification
 version 1.2, dated July 1999) defined interlacing scheme for PNG files
 is the "Adam7" interlace scheme, that breaks down an
 image into seven smaller images of varying size.  libpng will build
@@ -2115,7 +2129,7 @@
        PNG_DESTROY_WILL_FREE_DATA,
        PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST)
 
-Thereby briefly reassigning responsibility for freeing to the user but
+thereby briefly reassigning responsibility for freeing to the user but
 immediately afterwards reassigning it once more to the write_destroy
 function.  Having done this, it would then be safe to destroy the read
 structure and continue to use the PLTE, tRNS, and hIST data in the write
@@ -2132,13 +2146,11 @@
 
 All of the memory allocation, input/output, and error handling in libpng
 goes through callbacks that are user settable.  The default routines are
-in pngmem.c, pngrio.c, pngwio.c, and pngerror.c respectively.  To change
+in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively.  To change
 these functions, call the appropriate png_set_*_fn() function.
 
-Memory allocation is done through the functions png_large_malloc(),
-png_malloc(), png_realloc(), png_large_free(), and png_free().  These
-currently just call the standard C functions.  The large functions must
-handle exactly 64K, but they don't have to handle more than that.  If
+Memory allocation is done through the functions png_malloc() and png_free().
+These currently just call the standard C functions.  If
 your pointers can't access more then 64K at a time, you will want to set
 MAXSEG_64K in zlib.h.  Since it is unlikely that the method of handling
 memory allocation on a platform will change between applications, these
@@ -2191,8 +2203,8 @@
 fprintf() isn't available).  If you wish to change the behavior of the error
 functions, you will need to set up your own message callbacks.  These
 functions are normally supplied at the time that the png_struct is created.
-It is also possible to change these functions after png_create_*_struct()
-has been called by calling:
+It is also possible to redirect errors and warnings to your own replacement
+functions after png_create_*_struct() has been called by calling:
 
     png_set_error_fn(png_structp png_ptr,
         png_voidp error_ptr, png_error_ptr error_fn,
@@ -2216,7 +2228,8 @@
 However, there are some uncertainties about the status of local variables
 after a longjmp, so the user may want to be careful about doing anything after
 setjmp returns non-zero besides returning itself.  Consult your compiler
-documentation for more details.
+documentation for more details.  For an alternative approach, you may wish
+to use the "cexcept" facility (see http://cexcept.sourceforge.net).
 
 Custom chunks
 
@@ -2246,10 +2259,7 @@
 
 Configuring for 16 bit platforms
 
-You may need to change the png_large_malloc() and png_large_free()
-routines in pngmem.c, as these are required to allocate 64K, although
-there is already support for many of the common DOS compilers.  Also,
-you will want to look into zconf.h to tell zlib (and thus libpng) that
+You will want to look into zconf.h to tell zlib (and thus libpng) that
 it cannot allocate more then 64K at a time.  Even if you can, the memory
 won't be accessible.  So limit zlib and libpng to 64K by defining MAXSEG_64K.
 
@@ -2318,6 +2328,7 @@
     png_set_compression_window_bits(png_ptr,
         window_bits);
     png_set_compression_method(png_ptr, method);
+    png_set_compression_buffer_size(png_ptr, size);
 
 Controlling row filtering
 
@@ -2346,7 +2357,13 @@
 structures appropriately for all of the filter types.
 
     filters = PNG_FILTER_NONE | PNG_FILTER_SUB
-       | PNG_FILTER_UP;
+              PNG_FILTER_UP | PNG_FILTER_AVE |
+              PNG_FILTER_PAETH | PNG_ALL_FILTERS;
+    or
+    filters = one of PNG_FILTER_VALUE_NONE,
+              PNG_FILTER_VALUE_SUB, PNG_FILTER_VALUE_UP,
+              PNG_FILTER_VALUE_AVE, PNG_FILTER_VALUE_PAETH
+
     png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE,
        filters);
 
@@ -2395,7 +2412,7 @@
 PNG_NO_.
 
 You can also turn all of the transforms and ancillary chunk capabilities
-off en masse with  compiler directives that define
+off en masse with compiler directives that define
 PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
 or all four,
 along with directives to turn on any of the capabilities that you do
@@ -2495,13 +2512,13 @@
 
 VII. Y2K Compliance in libpng
 
-April 14, 2000
+April 24, 2000
 
 Since the PNG Development group is an ad-hoc body, we can't make
 an official declaration.
 
 This is your unofficial assurance that libpng from version 0.71 and
-upward through 1.0.6f are Y2K compliant.  It is my belief that earlier
+upward through 1.0.6g 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 b9852ba..c12e130 100644
--- a/libpngpf.3
+++ b/libpngpf.3
@@ -1,6 +1,6 @@
-.TH LIBPNGPF 3 April 14, 2000
+.TH LIBPNGPF 3 "April 24, 2000"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.0.6f
+libpng \- Portable Network Graphics (PNG) Reference Library 1.0.6g
 (private functions)
 .SH SYNOPSIS
 \fB#include <png.h>\fP
diff --git a/png.5 b/png.5
index 3faa08a..133d25d 100644
--- a/png.5
+++ b/png.5
@@ -1,4 +1,4 @@
-.TH PNG 5 "April 14, 2000"
+.TH PNG 5 "April 24, 2000"
 .SH NAME
 png \- Portable Network Graphics (PNG) format
 .SH DESCRIPTION
diff --git a/png.c b/png.c
index f842275..d094068 100644
--- a/png.c
+++ b/png.c
@@ -1,7 +1,7 @@
 
 /* png.c - location for general purpose libpng functions
  *
- * libpng version 1.0.6f - April 14, 2000
+ * libpng version 1.0.6g - April 24, 2000
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
  * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
@@ -14,14 +14,14 @@
 #include "png.h"
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef version_1_0_6f Your_png_h_is_not_version_1_0_6f;
+typedef version_1_0_6g Your_png_h_is_not_version_1_0_6g;
 
 /* 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 */
-char png_libpng_ver[12] = "1.0.6f";
+char png_libpng_ver[12] = "1.0.6g";
 
 /* png_sig was changed to a function in version 1.0.5c */
 /* Place to hold the signature string for a PNG file. */
@@ -561,7 +561,7 @@
 png_get_copyright(png_structp png_ptr)
 {
    if (png_ptr != NULL || png_ptr == NULL)  /* silence compiler warning */
-   return ("\n libpng version 1.0.6f - April 14, 2000\n\
+   return ("\n libpng version 1.0.6g - April 24, 2000\n\
    Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\
    Copyright (c) 1996, 1997 Andreas Dilger\n\
    Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson\n");
@@ -579,8 +579,8 @@
 {
    /* Version of *.c files used when building libpng */
    if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
-      return("1.0.6f");
-   return("1.0.6f");
+      return("1.0.6g");
+   return("1.0.6g");
 }
 
 png_charp
@@ -617,3 +617,10 @@
    return 0;
 }
 #endif
+
+/* This function, added to libpng-1.0.6g, is untested. */
+int
+png_reset_zstream(png_structp png_ptr)
+{
+   return (inflateReset(&png_ptr->zstream));
+}
diff --git a/png.h b/png.h
index d4b9075..4688938 100644
--- a/png.h
+++ b/png.h
@@ -1,7 +1,7 @@
 
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.0.6f - April 14, 2000
+ * libpng version 1.0.6g - April 24, 2000
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
  * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
@@ -9,7 +9,7 @@
  * Authors and maintainers:
  *  libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
  *  libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
- *  libpng versions 0.97, January 1998, through 1.0.6f - April 14, 2000: Glenn
+ *  libpng versions 0.97, January 1998, through 1.0.6g - April 24, 2000: Glenn
  *  See also "Contributing Authors", below.
  *
  * Note about libpng version numbers:
@@ -47,7 +47,7 @@
  *    1.0.5e-r                 1.0.5e-r 10100  2.1.0.5e-r (not compatible)
  *    1.0.5s-v                 1.0.5s-v 10006  2.1.0.5s-v (compatible)
  *    1.0.6 (+ 3 patches)      1.0.6    10006  2.1.0.6
- *    1.0.6d-f                 1.0.6d-f 10007  2.1.0.6d-f
+ *    1.0.6d-g                 1.0.6d-g 10007  2.1.0.6d-g
  *    1.0.7                    1.0.7    10007  2.1.0.7    (still compatible)
  *
  *    Henceforth the source version will match the shared-library minor
@@ -73,7 +73,7 @@
  * Copyright (c) 1996, 1997 Andreas Dilger
  * (libpng versions 0.89c, June 1996, through 0.96, May 1997)
  * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
- * (libpng versions 0.97, January 1998, through 1.0.6f, April 14, 2000)
+ * (libpng versions 0.97, January 1998, through 1.0.6g, April 24, 2000)
  *
  * For the purposes of this copyright and license, "Contributing Authors"
  * is defined as the following set of individuals:
@@ -148,13 +148,13 @@
  * Y2K compliance in libpng:
  * =========================
  *
- *    April 14, 2000
+ *    April 24, 2000
  *
  *    Since the PNG Development group is an ad-hoc body, we can't make
  *    an official declaration.
  *
  *    This is your unofficial assurance that libpng from version 0.71 and
- *    upward through 1.0.6f are Y2K compliant.  It is my belief that earlier
+ *    upward through 1.0.6g 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
@@ -232,7 +232,7 @@
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.0.6f"
+#define PNG_LIBPNG_VER_STRING "1.0.6g"
 
 /* Careful here.  At one time, Guy wanted to use 082, but that would be octal.
  * We must not include leading zeros.
@@ -483,8 +483,6 @@
     * and initialize the appropriate fields below.
     */
 
-   png_uint_32 free_me;     /* flags items libpng is responsible for freeing */
-
 #if defined(PNG_gAMA_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED)
    /* The gAMA chunk describes the gamma characteristics of the system
     * on which the image was created, normally in the range [1.0, 2.5].
@@ -493,7 +491,6 @@
 #ifdef PNG_FLOATING_POINT_SUPPORTED
    float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */
 #endif
-   png_fixed_point int_gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */
 #endif
 
 #if defined(PNG_sRGB_SUPPORTED)
@@ -609,16 +606,6 @@
    float x_blue;
    float y_blue;
 #endif
-#ifdef PNG_FIXED_POINT_SUPPORTED
-   png_fixed_point int_x_white;
-   png_fixed_point int_y_white;
-   png_fixed_point int_x_red;
-   png_fixed_point int_y_red;
-   png_fixed_point int_x_green;
-   png_fixed_point int_y_green;
-   png_fixed_point int_x_blue;
-   png_fixed_point int_y_blue;
-#endif
 #endif
 
 #if defined(PNG_pCAL_SUPPORTED)
@@ -687,6 +674,24 @@
    /* Data valid if (valid & PNG_INFO_IDAT) non-zero */
    png_bytepp row_pointers;        /* the image bits */
 #endif
+
+#if defined(PNG_gAMA_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED)
+   png_fixed_point int_gamma; /* gamma of image, if (valid & PNG_INFO_gAMA) */
+#endif
+
+#if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED)
+   png_fixed_point int_x_white;
+   png_fixed_point int_y_white;
+   png_fixed_point int_x_red;
+   png_fixed_point int_y_red;
+   png_fixed_point int_x_green;
+   png_fixed_point int_y_green;
+   png_fixed_point int_x_blue;
+   png_fixed_point int_y_blue;
+#endif
+
+   png_uint_32 free_me;     /* flags items libpng is responsible for freeing */
+
 } png_info;
 
 typedef png_info FAR * png_infop;
@@ -881,14 +886,8 @@
    png_byte user_transform_channels; /* channels in user transformed pixels */
 #endif
 
-#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
-   png_voidp user_chunk_ptr;
-   png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
-#endif
-
    png_uint_32 mode;          /* tells us where we are in the PNG file */
    png_uint_32 flags;         /* flags indicating various things to libpng */
-   png_uint_32 free_me;       /* flags items libpng is responsible for freeing */
    png_uint_32 transformations; /* which transformations to perform */
 
    z_stream zstream;          /* pointer to decompression structure (below) */
@@ -962,7 +961,6 @@
    float gamma;          /* file gamma value */
    float screen_gamma;   /* screen gamma value (display_exponent) */
 #endif
-   png_fixed_point int_gamma;
 #endif
 
 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
@@ -1070,12 +1068,23 @@
    int num_chunk_list;
    png_bytep chunk_list;
 #endif
+
+#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
+   png_fixed_point int_gamma;
+#endif
+
+#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
+   png_voidp user_chunk_ptr;
+   png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
+#endif
+
+   png_uint_32 free_me;       /* flags items libpng is responsible for freeing */
 };
 
 /* This prevents a compiler error in png_get_copyright() in png.c if png.c
-and png.h are both at * version 1.0.6f
+and png.h are both at * version 1.0.6g
  */
-typedef png_structp version_1_0_6f;
+typedef png_structp version_1_0_6g;
 
 typedef png_struct FAR * FAR * png_structpp;
 
@@ -1114,6 +1123,15 @@
    PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
    png_error_ptr error_fn, png_error_ptr warn_fn));
 
+extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size)
+   PNGARG((png_structp png_ptr));
+
+extern PNG_EXPORT(void,png_set_compression_buffer_size)
+   PNGARG((png_structp png_ptr, png_uint_32 size));
+
+/* Reset the compression stream */
+extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr));
+
 #ifdef PNG_USER_MEM_SUPPORTED
 extern PNG_EXPORT(png_structp,png_create_read_struct_2)
    PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
@@ -2003,6 +2021,8 @@
    png_ptr, int keep, png_bytep chunk_list, int num_chunks));
 extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr,
    png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns));
+extern PNG_EXPORT(void, png_set_unknown_chunk_location)
+   PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location));
 extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp
    png_ptr, png_infop info_ptr, png_unknown_chunkpp entries));
 #endif
@@ -2058,7 +2078,7 @@
 extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
 
 #define PNG_HEADER_VERSION_STRING \
-   " libpng version 1.0.6f - April 14, 2000 (header)\n"
+   " libpng version 1.0.6g - April 24, 2000 (header)\n"
 
 #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
 /* With these routines we avoid an integer divide, which will be slower on
diff --git a/png_ptr.h b/png_ptr.h
new file mode 100644
index 0000000..bfd319a
--- /dev/null
+++ b/png_ptr.h
@@ -0,0 +1,221 @@
+struct png_struct_def
+{
+#ifdef PNG_SETJMP_SUPPORTED
+   jmp_buf jmpbuf;            /* used in png_error */
+#endif
+   png_error_ptr error_fn;    /* function for printing errors and aborting */
+   png_error_ptr warning_fn;  /* function for printing warnings */
+   png_voidp error_ptr;       /* user supplied struct for error functions */
+   png_rw_ptr write_data_fn;  /* function for writing output data */
+   png_rw_ptr read_data_fn;   /* function for reading input data */
+   png_voidp io_ptr;          /* ptr to application struct for I/O functions*/
+
+#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
+   png_user_transform_ptr read_user_transform_fn; /* user read transform */
+#endif
+
+#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
+   png_user_transform_ptr write_user_transform_fn; /* user write transform */
+#endif
+
+#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
+    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
+   png_voidp user_transform_ptr; /* user supplied struct for user transform */
+   png_byte user_transform_depth;    /* bit depth of user transformed pixels */
+   png_byte user_transform_channels; /* channels in user transformed pixels */
+#endif
+
+#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
+   png_voidp user_chunk_ptr;
+   png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
+#endif
+
+   png_uint_32 mode;          /* tells us where we are in the PNG file */
+   png_uint_32 flags;         /* flags indicating various things to libpng */
+   png_uint_32 transformations; /* which transformations to perform */
+
+   z_stream zstream;          /* pointer to decompression structure (below) */
+   png_bytep zbuf;            /* buffer for zlib */
+   png_size_t zbuf_size;      /* size of zbuf */
+   int zlib_level;            /* holds zlib compression level */
+   int zlib_method;           /* holds zlib compression method */
+   int zlib_window_bits;      /* holds zlib compression window bits */
+   int zlib_mem_level;        /* holds zlib compression memory level */
+   int zlib_strategy;         /* holds zlib compression strategy */
+
+   png_uint_32 width;         /* width of image in pixels */
+   png_uint_32 height;        /* height of image in pixels */
+   png_uint_32 num_rows;      /* number of rows in current pass */
+   png_uint_32 usr_width;     /* width of row at start of write */
+   png_uint_32 rowbytes;      /* size of row in bytes */
+   png_uint_32 irowbytes;     /* size of current interlaced row in bytes */
+   png_uint_32 iwidth;        /* width of current interlaced row in pixels */
+   png_uint_32 row_number;    /* current row in interlace pass */
+   png_bytep prev_row;        /* buffer to save previous (unfiltered) row */
+   png_bytep row_buf;         /* buffer to save current (unfiltered) row */
+   png_bytep sub_row;         /* buffer to save "sub" row when filtering */
+   png_bytep up_row;          /* buffer to save "up" row when filtering */
+   png_bytep avg_row;         /* buffer to save "avg" row when filtering */
+   png_bytep paeth_row;       /* buffer to save "Paeth" row when filtering */
+   png_row_info row_info;     /* used for transformation routines */
+
+   png_uint_32 idat_size;     /* current IDAT size for read */
+   png_uint_32 crc;           /* current chunk CRC value */
+   png_colorp palette;        /* palette from the input file */
+   png_uint_16 num_palette;   /* number of color entries in palette */
+   png_uint_16 num_trans;     /* number of transparency values */
+   png_byte chunk_name[5];    /* null-terminated name of current chunk */
+   png_byte compression;      /* file compression type (always 0) */
+   png_byte filter;           /* file filter type (always 0) */
+   png_byte interlaced;       /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
+   png_byte pass;             /* current interlace pass (0 - 6) */
+   png_byte do_filter;        /* row filter flags (see PNG_FILTER_ below ) */
+   png_byte color_type;       /* color type of file */
+   png_byte bit_depth;        /* bit depth of file */
+   png_byte usr_bit_depth;    /* bit depth of users row */
+   png_byte pixel_depth;      /* number of bits per pixel */
+   png_byte channels;         /* number of channels in file */
+   png_byte usr_channels;     /* channels at start of write */
+   png_byte sig_bytes;        /* magic bytes read/written from start of file */
+
+#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
+   png_uint_16 filler;           /* filler bytes for pixel expansion */
+#endif
+
+#if defined(PNG_READ_bKGD_SUPPORTED)
+   png_byte background_gamma_type;
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+   float background_gamma;
+#endif
+   png_color_16 background;   /* background color in screen gamma space */
+#  if defined(PNG_READ_GAMMA_SUPPORTED)
+     png_color_16 background_1; /* background normalized to gamma 1.0 */
+#  endif /* PNG_READ_GAMMA && PNG_READ_bKGD_SUPPORTED */
+#endif /* PNG_READ_bKGD_SUPPORTED */
+
+#if defined(PNG_WRITE_FLUSH_SUPPORTED)
+   png_flush_ptr output_flush_fn;/* Function for flushing output */
+   png_uint_32 flush_dist;    /* how many rows apart to flush, 0 - no flush */
+   png_uint_32 flush_rows;    /* number of rows written since last flush */
+#endif
+
+#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
+   int gamma_shift;      /* number of "insignificant" bits 16-bit gamma */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+   float gamma;          /* file gamma value */
+   float screen_gamma;   /* screen gamma value (display_exponent) */
+#endif
+#endif
+
+#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
+   png_bytep gamma_table;     /* gamma table for 8-bit depth files */
+   png_bytep gamma_from_1;    /* converts from 1.0 to screen */
+   png_bytep gamma_to_1;      /* converts from file to 1.0 */
+   png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
+   png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
+   png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
+#endif
+
+#if defined(PNG_READ_GAMMA_SUPPORTED) || defined (PNG_READ_sBIT_SUPPORTED)
+   png_color_8 sig_bit;       /* significant bits in each available channel */
+#endif
+
+#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
+   png_color_8 shift;         /* shift for significant bit tranformation */
+#endif
+
+#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
+ || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
+   png_bytep trans;           /* transparency values for paletted files */
+   png_color_16 trans_values; /* transparency values for non-paletted files */
+#endif
+
+   png_read_status_ptr read_row_fn;   /* called after each row is decoded */
+   png_write_status_ptr write_row_fn; /* called after each row is encoded */
+#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
+   png_progressive_info_ptr info_fn; /* called after header data fully read */
+   png_progressive_row_ptr row_fn;   /* called after each prog. row is decoded */
+   png_progressive_end_ptr end_fn;   /* called after image is complete */
+   png_bytep save_buffer_ptr;        /* current location in save_buffer */
+   png_bytep save_buffer;            /* buffer for previously read data */
+   png_bytep current_buffer_ptr;     /* current location in current_buffer */
+   png_bytep current_buffer;         /* buffer for recently used data */
+   png_uint_32 push_length;          /* size of current input chunk */
+   png_uint_32 skip_length;          /* bytes to skip in input data */
+   png_size_t save_buffer_size;      /* amount of data now in save_buffer */
+   png_size_t save_buffer_max;       /* total size of save_buffer */
+   png_size_t buffer_size;           /* total amount of available input data */
+   png_size_t current_buffer_size;   /* amount of data now in current_buffer */
+   int process_mode;                 /* what push library is currently doing */
+   int cur_palette;                  /* current push library palette index */
+
+#  if defined(PNG_READ_TEXT_SUPPORTED)
+     png_size_t current_text_size;   /* current size of text input data */
+     png_size_t current_text_left;   /* how much text left to read in input */
+     png_charp current_text;         /* current text chunk buffer */
+     png_charp current_text_ptr;     /* current location in current_text */
+#  endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_READ_TEXT_SUPPORTED */
+
+#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
+
+#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
+/* for the Borland special 64K segment handler */
+   png_bytepp offset_table_ptr;
+   png_bytep offset_table;
+   png_uint_16 offset_table_number;
+   png_uint_16 offset_table_count;
+   png_uint_16 offset_table_count_free;
+#endif
+
+#if defined(PNG_READ_DITHER_SUPPORTED)
+   png_bytep palette_lookup;         /* lookup table for dithering */
+   png_bytep dither_index;           /* index translation for palette files */
+#endif
+
+#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_READ_hIST_SUPPORTED)
+   png_uint_16p hist;                /* histogram */
+#endif
+
+#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
+   png_byte heuristic_method;        /* heuristic for row filter selection */
+   png_byte num_prev_filters;        /* number of weights for previous rows */
+   png_bytep prev_filters;           /* filter type(s) of previous row(s) */
+   png_uint_16p filter_weights;      /* weight(s) for previous line(s) */
+   png_uint_16p inv_filter_weights;  /* 1/weight(s) for previous line(s) */
+   png_uint_16p filter_costs;        /* relative filter calculation cost */
+   png_uint_16p inv_filter_costs;    /* 1/relative filter calculation cost */
+#endif
+
+#if defined(PNG_TIME_RFC1123_SUPPORTED)
+   png_charp time_buffer;            /* String to hold RFC 1123 time text */
+#endif
+
+#ifdef PNG_USER_MEM_SUPPORTED
+   png_voidp mem_ptr;                /* user supplied struct for mem functions */
+   png_malloc_ptr malloc_fn;         /* function for allocating memory */
+   png_free_ptr free_fn;             /* function for freeing memory */
+#endif
+
+#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
+   png_byte rgb_to_gray_status;
+   png_uint_16 rgb_to_gray_red_coeff;
+   png_uint_16 rgb_to_gray_green_coeff;
+   png_uint_16 rgb_to_gray_blue_coeff;
+#endif
+
+#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
+    defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
+   png_byte empty_plte_permitted;
+#endif
+
+#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
+   int num_chunk_list;
+   png_bytep chunk_list;
+#endif
+
+#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
+   png_fixed_point int_gamma;
+#endif
+
+   png_uint_32 free_me;       /* flags items libpng is responsible for freeing */
+};
diff --git a/pngasmrd.h b/pngasmrd.h
index e17994b..13eb609 100644
--- a/pngasmrd.h
+++ b/pngasmrd.h
@@ -1,6 +1,6 @@
 /* pngasmrd.h - assembler version of utilities to read a PNG file
  *
- * libpng 1.0.6f - April 14, 2000
+ * libpng 1.0.6g - April 24, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1999, 2000 Glenn Randers-Pehrson
  *
diff --git a/pngconf.h b/pngconf.h
index ded827a..1a47219 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,7 +1,7 @@
 
 /* pngconf.h - machine configurable file for libpng
  *
- * libpng 1.0.6f - April 14, 2000
+ * libpng 1.0.6g - April 24, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngerror.c b/pngerror.c
index fd606c0..f2ded30 100644
--- a/pngerror.c
+++ b/pngerror.c
@@ -1,7 +1,7 @@
 
 /* pngerror.c - stub functions for i/o and memory allocation
  *
- * libpng 1.0.6f - April 14, 2000
+ * libpng 1.0.6g - April 24, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pnggccrd.c b/pnggccrd.c
index a85ffcd..41e8a03 100644
--- a/pnggccrd.c
+++ b/pnggccrd.c
@@ -6,7 +6,7 @@
  *     and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm
  *     for Intel's performance analysis of the MMX vs. non-MMX code.
  *
- * libpng 1.0.6f - April 14, 2000
+ * libpng 1.0.6g - April 24, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998, Intel Corporation
  * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
@@ -137,6 +137,12 @@
 
 static int mmx_supported = 2;
 
+#ifdef PNG_USE_LOCAL_ARRAYS
+static const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
+static const int png_pass_inc[7]   = {8, 8, 4, 4, 2, 2, 1};
+static const int png_pass_width[7] = {8, 4, 4, 2, 2, 1, 1};
+#endif
+
 // djgpp adds its own underscores to global variables, so define them without:
 #ifdef __DJGPP__
 #  define _unmask      unmask
@@ -4494,7 +4500,7 @@
          break;
 
       default:
-         png_error(png_ptr, "Bad adaptive filter type");
+         png_error(png_ptr, "#103 Bad adaptive filter type");
          break;
    }
 }
diff --git a/pngget.c b/pngget.c
index c250e5e..1aed10f 100644
--- a/pngget.c
+++ b/pngget.c
@@ -1,7 +1,7 @@
 
 /* pngget.c - retrieval of values from info struct
  *
- * libpng 1.0.6f - April 14, 2000
+ * libpng 1.0.6g - April 24, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -801,3 +801,9 @@
 }
 #endif
 
+
+png_uint_32
+png_get_compression_buffer_size(png_structp png_ptr)
+{
+   return(png_ptr->zbuf_size);
+}
diff --git a/pngmem.c b/pngmem.c
index 0cfc89f..05ed9cc 100644
--- a/pngmem.c
+++ b/pngmem.c
@@ -1,7 +1,7 @@
 
 /* pngmem.c - stub functions for memory allocation
  *
- * libpng 1.0.6f - April 14, 2000
+ * libpng 1.0.6g - April 24, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngpread.c b/pngpread.c
index 18ea85b..73a9581 100644
--- a/pngpread.c
+++ b/pngpread.c
@@ -1,7 +1,7 @@
 
 /* pngpread.c - read a png file in push mode
  *
- * libpng 1.0.6f - April 14, 2000
+ * libpng 1.0.6g - April 24, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngread.c b/pngread.c
index 0b2df73..98095b3 100644
--- a/pngread.c
+++ b/pngread.c
@@ -1,7 +1,7 @@
 
 /* pngread.c - read a PNG file
  *
- * libpng 1.0.6f - April 14, 2000
+ * libpng 1.0.6g - April 24, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -641,7 +641,7 @@
  * 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.6f.
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6g.
  */
 
 void
@@ -690,7 +690,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.6f.
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6g.
  */
 void
 png_read_image(png_structp png_ptr, png_bytepp image)
diff --git a/pngrio.c b/pngrio.c
index ce9ade3..182a217 100644
--- a/pngrio.c
+++ b/pngrio.c
@@ -1,7 +1,7 @@
 
 /* pngrio.c - functions for data input
  *
- * libpng 1.0.6f - April 14, 2000
+ * libpng 1.0.6g - April 24, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngrtran.c b/pngrtran.c
index f442ef7..0bea51e 100644
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -1,7 +1,7 @@
 
 /* pngrtran.c - transforms the data in a row for PNG readers
  *
- * libpng 1.0.6f - April 14, 2000
+ * libpng 1.0.6g - April 24, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngrutil.c b/pngrutil.c
index fc89ede..693e064 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1,7 +1,7 @@
 
 /* pngrutil.c - utilities to read a PNG file
  *
- * libpng 1.0.6f - April 14, 2000
+ * libpng 1.0.6g - April 24, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngset.c b/pngset.c
index c4442a8..91d618d 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1,7 +1,7 @@
 
 /* pngset.c - storage of image information into info struct
  *
- * libpng 1.0.6f - April 14, 2000
+ * libpng 1.0.6g - April 24, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -693,6 +693,14 @@
     info_ptr->unknown_chunks_num += num_unknowns;
     info_ptr->free_me |= PNG_FREE_UNKN;
 }
+void
+png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,
+   int chunk, int location)
+{
+   if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < 
+         (int)info_ptr->unknown_chunks_num)
+      info_ptr->unknown_chunks[chunk].location = (png_byte)location;
+}
 #endif
 
 #if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
@@ -772,3 +780,14 @@
 }
 #endif
 
+
+void
+png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size)
+{
+    if(png_ptr->zbuf)
+       png_free(png_ptr, png_ptr->zbuf);
+    png_ptr->zbuf_size = (png_size_t)size;
+    png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size);
+    png_ptr->zstream.next_out = png_ptr->zbuf;
+    png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
+}
diff --git a/pngtest.c b/pngtest.c
index 87fca87..c903f7c 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -1,7 +1,7 @@
 
 /* pngtest.c - a simple test program to test libpng
  *
- * libpng 1.0.6f - April 14, 2000
+ * libpng 1.0.6g - April 24, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -893,7 +893,8 @@
             generated locations in write_info_ptr are wrong because we
             haven't written anything yet */
          for (i = 0; i < (png_size_t)num_unknowns; i++)
-           write_info_ptr->unknown_chunks[i].location = unknowns[i].location;
+           png_set_unknown_chunk_location(write_ptr, write_info_ptr, i,
+             unknowns[i].location);
       }
    }
 #endif
@@ -1007,8 +1008,8 @@
             generated locations in write_end_info_ptr are wrong because we
             haven't written the end_info yet */
          for (i = 0; i < (png_size_t)num_unknowns; i++)
-           write_end_info_ptr->unknown_chunks[i].location =
-              unknowns[i].location;
+           png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i,
+             unknowns[i].location);
       }
    }
 #endif
@@ -1344,4 +1345,4 @@
 }
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef version_1_0_6f your_png_h_is_not_version_1_0_6f;
+typedef version_1_0_6g your_png_h_is_not_version_1_0_6g;
diff --git a/pngtrans.c b/pngtrans.c
index 6d3fd60..d79d758 100644
--- a/pngtrans.c
+++ b/pngtrans.c
@@ -1,7 +1,7 @@
 
 /* pngtrans.c - transforms the data in a row (used by both readers and writers)
  *
- * libpng 1.0.6f - April 14, 2000
+ * libpng 1.0.6g - April 24, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngvcrd.c b/pngvcrd.c
index a0f1f42..e721dd6 100644
--- a/pngvcrd.c
+++ b/pngvcrd.c
@@ -2,7 +2,7 @@
  *
  * For Intel x86 CPU and Microsoft Visual C++ compiler
  *
- * libpng 1.0.6f - April 14, 2000
+ * libpng 1.0.6g - April 24, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998, Intel Corporation
  * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
diff --git a/pngwio.c b/pngwio.c
index 2701b79..6df4326 100644
--- a/pngwio.c
+++ b/pngwio.c
@@ -1,7 +1,7 @@
 
 /* pngwio.c - functions for data output
  *
- * libpng 1.0.6f - April 14, 2000
+ * libpng 1.0.6g - April 24, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngwrite.c b/pngwrite.c
index 266ff2f..a8f8a56 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -1,7 +1,7 @@
 
 /* pngwrite.c - general routines to write a PNG file
  *
- * libpng 1.0.6f - April 14, 2000
+ * libpng 1.0.6g - April 24, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngwtran.c b/pngwtran.c
index 2669eaa..4e1b78a 100644
--- a/pngwtran.c
+++ b/pngwtran.c
@@ -1,7 +1,7 @@
 
 /* pngwtran.c - transforms the data in a row for PNG writers
  *
- * libpng 1.0.6f - April 14, 2000
+ * libpng 1.0.6g - April 24, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngwutil.c b/pngwutil.c
index 4dd5ec3..aab0b38 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -1,7 +1,7 @@
 
 /* pngwutil.c - utilities to write a PNG file
  *
- * libpng 1.0.6f - April 14, 2000
+ * libpng 1.0.6g - April 24, 2000
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/scripts/makefile.beos b/scripts/makefile.beos
index 5f60531..f05aa24 100644
--- a/scripts/makefile.beos
+++ b/scripts/makefile.beos
@@ -31,7 +31,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.6f
+PNGMIN = 1.0.6g
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # where make install puts libpng.a, libpng.so*, and png.h
diff --git a/scripts/makefile.dec b/scripts/makefile.dec
index 39f780a..94af110 100644
--- a/scripts/makefile.dec
+++ b/scripts/makefile.dec
@@ -14,7 +14,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.6f
+PNGMIN = 1.0.6g
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 CC=cc
diff --git a/scripts/makefile.gcmmx b/scripts/makefile.gcmmx
index 5b65f40..a268712 100644
--- a/scripts/makefile.gcmmx
+++ b/scripts/makefile.gcmmx
@@ -34,7 +34,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.6f
+PNGMIN = 1.0.6g
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/makefile.linux b/scripts/makefile.linux
index 5339f9e..4d9aa9c 100644
--- a/scripts/makefile.linux
+++ b/scripts/makefile.linux
@@ -34,7 +34,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.6f
+PNGMIN = 1.0.6g
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/makefile.sco b/scripts/makefile.sco
index 7ed46ee..62cb0b0 100644
--- a/scripts/makefile.sco
+++ b/scripts/makefile.sco
@@ -25,7 +25,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.6f
+PNGMIN = 1.0.6g
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/makefile.sggcc b/scripts/makefile.sggcc
index 13f244e..a685831 100644
--- a/scripts/makefile.sggcc
+++ b/scripts/makefile.sggcc
@@ -19,8 +19,8 @@
 LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
 LDSHARED=gcc -shared
 
-VER=1.0.6f
-LIBS=libpng.so.1.0.6f
+VER=1.0.6g
+LIBS=libpng.so.1.0.6g
 SHAREDLIB=libpng.so
 libdir=$(prefix)/lib32
 
diff --git a/scripts/makefile.solaris b/scripts/makefile.solaris
index 826c69c..25b04c3 100644
--- a/scripts/makefile.solaris
+++ b/scripts/makefile.solaris
@@ -31,7 +31,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.6f
+PNGMIN = 1.0.6g
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/pngdef.pas b/scripts/pngdef.pas
index 084f490..112a435 100644
--- a/scripts/pngdef.pas
+++ b/scripts/pngdef.pas
@@ -3,7 +3,7 @@
 interface
 
 const
-  PNG_LIBPNG_VER_STRING = '1.0.6f';
+  PNG_LIBPNG_VER_STRING = '1.0.6g';
   PNG_LIBPNG_VER        =  10007;
 
 type