Imported from libpng-1.2.7beta2.tar
diff --git a/ANNOUNCE b/ANNOUNCE
index 73c332b..51e2e34 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,5 +1,5 @@
 
-Libpng 1.2.7beta1 - August 26, 2004
+Libpng 1.2.7beta2 - August 29, 2004
 
 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.
@@ -14,8 +14,14 @@
     PNG Spec (second edition) and the PNG ISO/IEC Standard.
   Added "test-dd" target in 15 makefiles, to run pngtest in DESTDIR.
   Fixed bug with "optimized window size" in the IDAT datastream.
+version 1.2.7beta1 [August 29, 2004]
+  Fixed bug with sCAL chunk and big-endian machines (David Munro).
+  Undid new code added in 1.2.6rc2 to update the color_type in
+    png_set_filler().
+  Added png_set_add_alpha() that updates color type.
 
 Send comments/corrections/commendations to
-png-implement@ccrc.wustl.edu or to glennrp@users.sourceforge.net
+png-implement@ccrc.wustl.edu (subscription required; write to
+majordomo@ccrc.wustl.edu) or to glennrp@users.sourceforge.net
 
 Glenn R-P
diff --git a/CHANGES b/CHANGES
index ae79332..52e47fb 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1316,6 +1316,7 @@
   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,
+  Revised libpng.txt to remove 1.2.x stuff from the 1.0.x distribution
 version 1.0.16rc2 and 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
@@ -1352,8 +1353,14 @@
     PNG Spec (second edition) and the PNG ISO/IEC Standard.
   Added "test-dd" target in 15 makefiles, to run pngtest in DESTDIR.
   Fixed bug with "optimized window size" in the IDAT datastream.
+version 1.2.7beta2 [August 29, 2004]
+  Fixed bug with sCAL chunk and big-endian machines (David Munro).
+  Undid new code added in 1.2.6rc2 to update the color_type in
+    png_set_filler().
+  Added png_set_add_alpha() that updates color type.
 
 Send comments/corrections/commendations to
-png-implement@ccrc.wustl.edu or to glennrp@users.sourceforge.net
+png-implement@ccrc.wustl.edu (subscription required; write to
+majordomo@ccrc.wustl.edu) or to glennrp@users.sourceforge.net
 
 Glenn R-P
diff --git a/INSTALL b/INSTALL
index 10bf571..b35d8a5 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
 
-Installing libpng version 1.2.7beta1 - August 26, 2004
+Installing libpng version 1.2.7beta2 - August 29, 2004
 
 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.2.7beta1" or "lpng109" and "zlib-1.2.1"
+might be called "libpng-1.2.7beta2" or "lpng109" and "zlib-1.2.1"
 or "zlib121") so that you have directories called "zlib" and "libpng".
 
 Your directory structure should look like this:
@@ -67,9 +67,9 @@
 
  makefile.std      =>  Generic UNIX makefile (cc, creates static libpng.a)
  makefile.linux    =>  Linux/ELF makefile
-                       (gcc, creates libpng12.so.0.1.2.7beta1)
+                       (gcc, creates libpng12.so.0.1.2.7beta2)
  makefile.gcmmx    =>  Linux/ELF makefile
-                       (gcc, creates libpng12.so.0.1.2.7beta1,
+                       (gcc, creates libpng12.so.0.1.2.7beta2,
                        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
@@ -91,12 +91,12 @@
  makefile.openbsd  =>  OpenBSD makefile
  makefile.sgi      =>  Silicon Graphics IRIX makefile (cc, creates static lib)
  makefile.sggcc    =>  Silicon Graphics (gcc,
-                       creates libpng12.so.0.1.2.7beta1)
+                       creates libpng12.so.0.1.2.7beta2)
  makefile.sunos    =>  Sun makefile
  makefile.solaris  =>  Solaris 2.X makefile (gcc,
-                       creates libpng12.so.0.1.2.7beta1)
+                       creates libpng12.so.0.1.2.7beta2)
  makefile.so9      =>  Solaris 9 makefile (gcc,
-                       creates libpng12.so.0.1.2.7beta1)
+                       creates libpng12.so.0.1.2.7beta2)
  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
diff --git a/KNOWNBUG b/KNOWNBUG
index 78a73d4..3d55d07 100644
--- a/KNOWNBUG
+++ b/KNOWNBUG
@@ -1,5 +1,5 @@
 
-Known bugs in libpng version 1.2.7beta1
+Known bugs in libpng version 1.2.7beta2
 
 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 70ba9a0..9ebe2c4 100644
--- a/LICENSE
+++ b/LICENSE
@@ -8,7 +8,7 @@
 If you modify libpng you may insert additional notices immediately following
 this sentence.
 
-libpng version 1.2.6, August 26, 2004, is
+libpng version 1.2.6, August 29, 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
@@ -106,4 +106,4 @@
 
 Glenn Randers-Pehrson
 glennrp@users.sourceforge.net
-August 26, 2004
+August 29, 2004
diff --git a/README b/README
index 5fe7b67..7b8d7b1 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README for libpng version 1.2.7beta1 - August 26, 2004 (shared library 12.0)
+README for libpng version 1.2.7beta2 - August 29, 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.
@@ -104,7 +104,8 @@
 based in a large way on Guy's and Andreas' earlier work), and the PNG group.
 
 glennrp@users.sourceforge.net
-png-implement@ccrc.wustl.edu
+png-implement@ccrc.wustl.edu (subscription required; write to
+majordomo@ccrc.wustl.edu)
 
 You can't reach Guy, the original libpng author, at the addresses
 given in previous versions of this document.  He and Andreas will read mail
@@ -186,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 libpng12.so.0.1.2.7beta1)
+                            (gcc, creates libpng12.so.0.1.2.7beta2)
        makefile.gcmmx   =>  Linux/ELF makefile
-                            (gcc, creates libpng12.so.0.1.2.7beta1,
+                            (gcc, creates libpng12.so.0.1.2.7beta2,
                             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
@@ -209,12 +210,12 @@
        makefile.openbsd =>  OpenBSD makefile
        makefile.sgi     =>  Silicon Graphics IRIX (cc, creates static lib)
        makefile.sggcc   =>  Silicon Graphics
-                            (gcc, creates libpng12.so.0.1.2.7beta1)
+                            (gcc, creates libpng12.so.0.1.2.7beta2)
        makefile.sunos   =>  Sun makefile
        makefile.solaris =>  Solaris 2.X makefile
-                            (gcc, creates libpng12.so.0.1.2.7beta1)
+                            (gcc, creates libpng12.so.0.1.2.7beta2)
        makefile.so9     =>  Solaris 9 makefile
-                            (gcc, creates libpng12.so.0.1.2.7beta1)
+                            (gcc, creates libpng12.so.0.1.2.7beta2)
        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
diff --git a/Y2KINFO b/Y2KINFO
index 77d799e..881330f 100644
--- a/Y2KINFO
+++ b/Y2KINFO
@@ -1,13 +1,13 @@
    Y2K compliance in libpng:
    =========================
 
-      August 26, 2004
+      August 29, 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.2.7beta1 are Y2K compliant.  It is my belief that earlier
+      upward through 1.2.7beta2 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 1f168ac..b2b64fc 100755
--- a/configure
+++ b/configure
@@ -1,13 +1,13 @@
 #!/bin/sh
 echo "
   There is no \"configure\" script in this distribution of
-  libpng-1.2.7beta1.
+  libpng-1.2.7beta2.
 
   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.2.7beta1-config.tar.gz
+  libpng-1.2.7beta2-config.tar.gz
 "
 
diff --git a/example.c b/example.c
index fb1f5ed..ba0ecc5 100644
--- a/example.c
+++ b/example.c
@@ -742,6 +742,9 @@
    png_byte image[height][width*bytes_per_pixel];
    png_bytep row_pointers[height];
 
+   if (height > PNG_UINT_32_MAX/png_sizeof(png_bytep))
+     png_error (png_ptr, "Image is too tall to process in memory");
+
    for (k = 0; k < height; k++)
      row_pointers[k] = image + k*width*bytes_per_pixel;
 
diff --git a/libpng.3 b/libpng.3
index 415b776..8625def 100644
--- a/libpng.3
+++ b/libpng.3
@@ -1,6 +1,6 @@
-.TH LIBPNG 3 "August 26, 2004"
+.TH LIBPNG 3 "August 29, 2004"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.2.7beta1
+libpng \- Portable Network Graphics (PNG) Reference Library 1.2.7beta2
 .SH SYNOPSIS
 \fI\fB
 
@@ -402,6 +402,14 @@
 
 \fI\fB
 
+\fB#if \fI!defined(PNG_1_0_X)
+
+\fBvoid png_set_add_alpha (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP
+
+\fI\fB#endif
+
+\fI\fB
+
 \fBvoid png_set_background (png_structp \fP\fIpng_ptr\fP\fB, png_color_16p \fP\fIbackground_color\fP\fB, int \fP\fIbackground_gamma_code\fP\fB, int \fP\fIneed_expand\fP\fB, double \fIbackground_gamma\fP\fB);\fP
 
 \fI\fB
@@ -773,7 +781,7 @@
 .SH LIBPNG.TXT
 libpng.txt - A description on how to use and modify libpng
 
- libpng version 1.2.7beta1 - August 26, 2004
+ libpng version 1.2.7beta2 - August 29, 2004
  Updated and distributed by Glenn Randers-Pehrson
  <glennrp@users.sourceforge.net>
  Copyright (c) 1998-2004 Glenn Randers-Pehrson
@@ -1076,28 +1084,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 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
@@ -3471,127 +3479,126 @@
 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 VII.  MNG support
-%+%.SH VI.  MNG support
+.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 VII.  MNG support
 
 The MNG specification (available at http://www.libpng.org/pub/mng) allows
 certain extensions to PNG for PNG images that are embedded in MNG datastreams.
@@ -3616,8 +3623,7 @@
 them.  You may wish to consider using libmng (available at
 http://www.libmng.com) instead.
 
-%-%.SH VIII.  Changes to Libpng from version 0.88
-%+%.SH VII.  Changes to Libpng from version 0.88
+.SH VIII.  Changes to Libpng from version 0.88
 
 It should be noted that versions of libpng later than 0.96 are not
 distributed by the original libpng author, Guy Schalnat, nor by
@@ -3666,16 +3672,15 @@
 
    png_uint_32 application_vn = PNG_LIBPNG_VER;
 
-%-%.SH IX. Y2K Compliance in libpng
-%+%.SH VIII. Y2K Compliance in libpng
+.SH IX. Y2K Compliance in libpng
 
-August 26, 2004
+August 29, 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.2.7beta1 are Y2K compliant.  It is my belief that earlier
+upward through 1.2.7beta2 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
@@ -3818,7 +3823,7 @@
  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
- 1.2.7beta1          13    10207  12.so.0.1.2.7beta1
+ 1.2.7beta1-2        13    10207  12.so.0.1.2.7beta1-2
 
 Henceforth the source version will match the shared-library minor
 and patch numbers; the shared-library major version number will be
@@ -3874,13 +3879,14 @@
 
 Thanks to Frank J. T. Wojcik for helping with the documentation.
 
-Libpng version 1.2.7beta1 - August 26, 2004:
+Libpng version 1.2.7beta2 - August 29, 2004:
 Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
 Currently maintained by Glenn Randers-Pehrson (glennrp@users.sourceforge.net).
 
 Supported by the PNG development group
 .br
-(png-implement@ccrc.wustl.edu).
+png-implement@ccrc.wustl.edu (subscription required; write to
+majordomo@ccrc.wustl.edu).
 
 .SH COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
 
@@ -3891,7 +3897,7 @@
 If you modify libpng you may insert additional notices immediately following
 this sentence.
 
-libpng version 1.2.6, August 26, 2004, is
+libpng version 1.2.6, August 29, 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
@@ -3990,7 +3996,7 @@
 
 Glenn Randers-Pehrson
 glennrp@users.sourceforge.net
-August 26, 2004
+August 29, 2004
 
 .\" end of man page
 
diff --git a/libpng.txt b/libpng.txt
index b7f4688..7f01daa 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.2.7beta1 - August 26, 2004
+ libpng version 1.2.7beta2 - August 29, 2004
  Updated and distributed by Glenn Randers-Pehrson
  <glennrp@users.sourceforge.net>
  Copyright (c) 1998-2004 Glenn Randers-Pehrson
@@ -2893,13 +2893,13 @@
 
 IX. Y2K Compliance in libpng
 
-August 26, 2004
+August 29, 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.2.7beta1 are Y2K compliant.  It is my belief that earlier
+upward through 1.2.7beta2 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 33c3a36..c7cd4b9 100644
--- a/libpngpf.3
+++ b/libpngpf.3
@@ -1,6 +1,6 @@
-.TH LIBPNGPF 3 "August 26, 2004"
+.TH LIBPNGPF 3 "August 29, 2004"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.2.7beta1
+libpng \- Portable Network Graphics (PNG) Reference Library 1.2.7beta2
 (private functions)
 .SH SYNOPSIS
 \fB\fB#include <png.h>\fP\fP
diff --git a/png.5 b/png.5
index bc08156..198bd06 100644
--- a/png.5
+++ b/png.5
@@ -1,4 +1,4 @@
-.TH PNG 5 "August 26, 2004"
+.TH PNG 5 "August 29, 2004"
 .SH NAME
 png \- Portable Network Graphics (PNG) format
 .SH DESCRIPTION
diff --git a/png.c b/png.c
index 5db8fd9..52a5c05 100644
--- a/png.c
+++ b/png.c
@@ -1,7 +1,7 @@
 
 /* png.c - location for general purpose libpng functions
  *
- * libpng version 1.2.7beta1 - August 26, 2004
+ * libpng version 1.2.7beta2 - August 29, 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)
@@ -13,7 +13,7 @@
 #include "png.h"
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef version_1_2_7beta1 Your_png_h_is_not_version_1_2_7beta1;
+typedef version_1_2_7beta2 Your_png_h_is_not_version_1_2_7beta2;
 
 /* Version information for C files.  This had better match the version
  * string defined in png.h.  */
@@ -678,7 +678,7 @@
 png_get_copyright(png_structp png_ptr)
 {
    if (&png_ptr != NULL)  /* silence compiler warning about unused png_ptr */
-   return ((png_charp) "\n libpng version 1.2.7beta1 - August 26, 2004\n\
+   return ((png_charp) "\n libpng version 1.2.7beta2 - August 29, 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");
diff --git a/png.h b/png.h
index 8b4632f..1216a5d 100644
--- a/png.h
+++ b/png.h
@@ -1,6 +1,6 @@
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.2.7beta1 - August 26, 2004
+ * libpng version 1.2.7beta2 - August 29, 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.)
@@ -8,7 +8,7 @@
  * Authors and maintainers:
  *  libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
  *  libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
- *  libpng versions 0.97, January 1998, through 1.2.7beta1 - August 26, 2004: Glenn
+ *  libpng versions 0.97, January 1998, through 1.2.7beta2 - August 29, 2004: Glenn
  *  See also "Contributing Authors", below.
  *
  * Note about libpng version numbers:
@@ -101,7 +101,7 @@
  *    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
- *    1.2.7beta1              13    10207  12.so.0.1.2.7beta1
+ *    1.2.7beta1-2            13    10207  12.so.0.1.2.7beta1-2
  *
  *    Henceforth the source version will match the shared-library major
  *    and minor numbers; the shared-library major version number will be
@@ -131,7 +131,7 @@
  * If you modify libpng you may insert additional notices immediately following
  * this sentence.
  *
- * libpng versions 1.2.6, August 15, 2004, through 1.2.7beta1, August 26, 2004, are
+ * libpng versions 1.2.6, August 15, 2004, through 1.2.7beta2, August 29, 2004, are
  * Copyright (c) 2004 Glenn Randers-Pehrson, and are
  * distributed according to the same disclaimer and license as libpng-1.2.5
  * with the following individual added to the list of Contributing Authors:
@@ -243,13 +243,13 @@
  * Y2K compliance in libpng:
  * =========================
  *
- *    August 26, 2004
+ *    August 29, 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.2.7beta1 are Y2K compliant.  It is my belief that earlier
+ *    upward through 1.2.7beta2 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
@@ -305,9 +305,9 @@
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.2.7beta1"
+#define PNG_LIBPNG_VER_STRING "1.2.7beta2"
 #define PNG_HEADER_VERSION_STRING \
-   " libpng version 1.2.7beta1 - August 26, 2004 (header)\n"
+   " libpng version 1.2.7beta2 - August 29, 2004 (header)\n"
 
 #define PNG_LIBPNG_VER_SONUM   0
 #define PNG_LIBPNG_VER_DLLNUM  %DLLNUM%
@@ -319,7 +319,7 @@
 /* This should match the numeric part of the final component of
  * PNG_LIBPNG_VER_STRING, omitting any leading zero: */
 
-#define PNG_LIBPNG_VER_BUILD  1
+#define PNG_LIBPNG_VER_BUILD  2
 
 #define PNG_LIBPNG_BUILD_ALPHA    1
 #define PNG_LIBPNG_BUILD_BETA     2
@@ -1311,7 +1311,7 @@
 /* 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_2_7beta1;
+typedef png_structp version_1_2_7beta2;
 
 typedef png_struct FAR * FAR * png_structpp;
 
@@ -1483,12 +1483,17 @@
 #endif
 
 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
-/* Add a filler byte to 24-bit RGB images. */
+/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */
 extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr,
    png_uint_32 filler, int flags));
 /* The values of the PNG_FILLER_ defines should NOT be changed */
 #define PNG_FILLER_BEFORE 0
 #define PNG_FILLER_AFTER 1
+/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */
+#if !defined(PNG_1_0_X)
+extern PNG_EXPORT(void,png_set_add_alpha) PNGARG((png_structp png_ptr,
+   png_uint_32 filler, int flags));
+#endif
 #endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */
 
 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
@@ -2572,6 +2577,7 @@
 #define PNG_RGB_TO_GRAY_ERR  0x200000L
 #define PNG_RGB_TO_GRAY_WARN 0x400000L
 #define PNG_RGB_TO_GRAY      0x600000L  /* two bits, RGB_TO_GRAY_ERR|WARN */
+#define PNG_ADD_ALPHA       0x1000000L  /* Added to libpng-1.2.7 */
 
 /* flags for png_create_struct */
 #define PNG_STRUCT_PNG   0x0001
diff --git a/pngconf.h b/pngconf.h
index ee7252e..e5001ba 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,7 +1,7 @@
 
 /* pngconf.h - machine configurable file for libpng
  *
- * libpng version 1.2.7beta1 - August 26, 2004
+ * libpng version 1.2.7beta2 - August 29, 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)
diff --git a/pngerror.c b/pngerror.c
index 9ea4a0b..0c0ee6e 100644
--- a/pngerror.c
+++ b/pngerror.c
@@ -1,7 +1,7 @@
 
 /* pngerror.c - stub functions for i/o and memory allocation
  *
- * libpng version 1.2.7beta1 - August 26, 2004
+ * libpng version 1.2.7beta2 - August 29, 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)
diff --git a/pnggccrd.c b/pnggccrd.c
index 85bdaf6..24a7e3d 100644
--- a/pnggccrd.c
+++ b/pnggccrd.c
@@ -6,7 +6,7 @@
  *     and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm
  *     for Intel's performance analysis of the MMX vs. non-MMX code.
  *
- * libpng version 1.2.7beta1 - August 26, 2004
+ * libpng version 1.2.7beta2 - August 29, 2004
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2004 Glenn Randers-Pehrson
  * Copyright (c) 1998, Intel Corporation
diff --git a/pngget.c b/pngget.c
index 73087a4..2db6e7e 100644
--- a/pngget.c
+++ b/pngget.c
@@ -1,7 +1,7 @@
 
 /* pngget.c - retrieval of values from info struct
  *
- * libpng 1.2.7beta1 - August 26, 2004
+ * libpng 1.2.7beta2 - August 29, 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)
diff --git a/pngmem.c b/pngmem.c
index 996d74f..19ceed9 100644
--- a/pngmem.c
+++ b/pngmem.c
@@ -1,7 +1,7 @@
 
 /* pngmem.c - stub functions for memory allocation
  *
- * libpng version 1.2.7beta1 - August 26, 2004
+ * libpng version 1.2.7beta2 - August 29, 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)
diff --git a/pngpread.c b/pngpread.c
index f7c0f39..3c7730a 100644
--- a/pngpread.c
+++ b/pngpread.c
@@ -1,7 +1,7 @@
 
 /* pngpread.c - read a png file in push mode
  *
- * libpng version 1.2.7beta1 - August 26, 2004
+ * libpng version 1.2.7beta2 - August 29, 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)
diff --git a/pngread.c b/pngread.c
index 84158af..93bbca7 100644
--- a/pngread.c
+++ b/pngread.c
@@ -1,7 +1,7 @@
 
 /* pngread.c - read a PNG file
  *
- * libpng 1.2.7beta1 - August 26, 2004
+ * libpng 1.2.7beta2 - August 29, 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)
@@ -803,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.2.7beta1
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.7beta2
  */
 
 void PNGAPI
@@ -853,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.2.7beta1
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.7beta2
  */
 void PNGAPI
 png_read_image(png_structp png_ptr, png_bytepp image)
diff --git a/pngrio.c b/pngrio.c
index e5e2629..c9e9b38 100644
--- a/pngrio.c
+++ b/pngrio.c
@@ -1,7 +1,7 @@
 
 /* pngrio.c - functions for data input
  *
- * libpng 1.2.7beta1 - August 26, 2004
+ * libpng 1.2.7beta2 - August 29, 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)
diff --git a/pngrtran.c b/pngrtran.c
index ef29e4d..f13b540 100644
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -1,7 +1,7 @@
 
 /* pngrtran.c - transforms the data in a row for PNG readers
  *
- * libpng version 1.2.7beta1 - August 26, 2004
+ * libpng version  1.2.7beta2 - August 29, 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)
@@ -1135,8 +1135,10 @@
        (info_ptr->color_type == PNG_COLOR_TYPE_GRAY)))
    {
       info_ptr->channels++;
-#if 0 /* if adding a true alpha channel not just filler */
-      info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
+      /* if adding a true alpha channel not just filler */
+#if !defined(PNG_1_0_X)
+      if (png_ptr->transformations & PNG_ADD_ALPHA)
+        info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
 #endif
    }
 #endif
@@ -1927,7 +1929,6 @@
             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)
    {
@@ -2012,7 +2013,6 @@
             row_info->rowbytes = row_width * 8;
          }
       }
-      row_info->color_type |= PNG_COLOR_MASK_ALPHA;
    } /* COLOR_TYPE == RGB */
 }
 #endif
diff --git a/pngrutil.c b/pngrutil.c
index e5008ed..7ca5e72 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1,6 +1,6 @@
 /* pngrutil.c - utilities to read a PNG file
  *
- * libpng version 1.2.7beta1 - August 26, 2004
+ * libpng version 1.2.7beta2 - August 29, 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)
diff --git a/pngset.c b/pngset.c
index 1f9ab3e..2ca9593 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1,7 +1,7 @@
 
 /* pngset.c - storage of image information into info struct
  *
- * libpng 1.2.7beta1 - August 26, 2004
+ * libpng 1.2.7beta2 - August 29, 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)
diff --git a/pngtest.c b/pngtest.c
index f636e0b..7babc2e 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -1,7 +1,7 @@
 
 /* pngtest.c - a simple test program to test libpng
  *
- * libpng 1.2.7beta1 - August 26, 2004
+ * libpng 1.2.7beta2 - August 29, 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)
@@ -1551,4 +1551,4 @@
 }
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef version_1_2_7beta1 your_png_h_is_not_version_1_2_7beta1;
+typedef version_1_2_7beta2 your_png_h_is_not_version_1_2_7beta2;
diff --git a/pngtrans.c b/pngtrans.c
index bad9349..4256ae6 100644
--- a/pngtrans.c
+++ b/pngtrans.c
@@ -1,7 +1,7 @@
 
 /* pngtrans.c - transforms the data in a row (used by both readers and writers)
  *
- * libpng 1.2.7beta1 - August 26, 2004
+ * libpng  1.2.7beta2 - August 29, 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)
@@ -118,6 +118,18 @@
       png_ptr->usr_channels = 2;
    }
 }
+
+#if !defined(PNG_1_0_X)
+/* Added to libpng-1.2.7 */
+void PNGAPI
+png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
+{
+   png_debug(1, "in png_set_add_alpha\n");
+   png_set_filler(png_ptr, filler, filler_loc);
+   png_ptr->transformations |= PNG_ADD_ALPHA;
+}
+#endif
+
 #endif
 
 #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
diff --git a/pngvcrd.c b/pngvcrd.c
index f93f3ef..3b8eb46 100644
--- a/pngvcrd.c
+++ b/pngvcrd.c
@@ -2,7 +2,7 @@
  *
  * For Intel x86 CPU and Microsoft Visual C++ compiler
  *
- * libpng version 1.2.7beta1 - August 26, 2004
+ * libpng version 1.2.7beta2 - August 29, 2004
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2004 Glenn Randers-Pehrson
  * Copyright (c) 1998, Intel Corporation
diff --git a/pngwio.c b/pngwio.c
index 1d10bfd..b770310 100644
--- a/pngwio.c
+++ b/pngwio.c
@@ -1,7 +1,7 @@
 
 /* pngwio.c - functions for data output
  *
- * libpng 1.2.7beta1 - August 26, 2004
+ * libpng 1.2.7beta2 - August 29, 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)
diff --git a/pngwrite.c b/pngwrite.c
index 5f07e4f..fc6f123 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -1,7 +1,7 @@
 
 /* pngwrite.c - general routines to write a PNG file
  *
- * libpng 1.2.7beta1 - August 26, 2004
+ * libpng 1.2.7beta2 - August 29, 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)
diff --git a/pngwtran.c b/pngwtran.c
index 356d147..91218ef 100644
--- a/pngwtran.c
+++ b/pngwtran.c
@@ -1,7 +1,7 @@
 
 /* pngwtran.c - transforms the data in a row for PNG writers
  *
- * libpng version 1.2.7beta1 - August 26, 2004
+ * libpng version 1.2.7beta2 - August 29, 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)
diff --git a/pngwutil.c b/pngwutil.c
index 63d19f1..c2f371d 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -1,7 +1,7 @@
 
 /* pngwutil.c - utilities to write a PNG file
  *
- * libpng version 1.2.7beta1 - August 26, 2004
+ * libpng version 1.2.7beta2 - August 29, 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)
@@ -1528,6 +1528,7 @@
 #endif
    png_size_t total_len;
    char wbuf[32], hbuf[32];
+   png_byte bunit = unit;
 
    png_debug(1, "in png_write_sCAL\n");
 
@@ -1548,7 +1549,7 @@
 
    png_debug1(3, "sCAL total length = %d\n", (int)total_len);
    png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len);
-   png_write_chunk_data(png_ptr, (png_bytep)&unit, 1);
+   png_write_chunk_data(png_ptr, (png_bytep)&bunit, 1);
    png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1);
    png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf));
 
@@ -1565,6 +1566,7 @@
 #endif
    png_size_t total_len;
    char wbuf[32], hbuf[32];
+   png_byte bunit = unit;
 
    png_debug(1, "in png_write_sCAL_s\n");
 
@@ -1574,7 +1576,7 @@
 
    png_debug1(3, "sCAL total length = %d\n", total_len);
    png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len);
-   png_write_chunk_data(png_ptr, (png_bytep)&unit, 1);
+   png_write_chunk_data(png_ptr, (png_bytep)&bunit, 1);
    png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1);
    png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf));
 
diff --git a/scripts/libpng-config-head.in b/scripts/libpng-config-head.in
index 30fe17d..72dce76 100755
--- a/scripts/libpng-config-head.in
+++ b/scripts/libpng-config-head.in
@@ -8,7 +8,7 @@
 
 # Modeled after libxml-config.
 
-version=1.2.7beta1
+version=1.2.7beta2
 prefix=""
 libdir=""
 libs=""
diff --git a/scripts/libpng.pc.in b/scripts/libpng.pc.in
index 10df7a2..557f888 100644
--- a/scripts/libpng.pc.in
+++ b/scripts/libpng.pc.in
@@ -6,6 +6,6 @@
 
 Name: libpng12
 Description: Loads and saves PNG files
-Version: 1.2.7beta1
+Version: 1.2.7beta2
 Libs: -L${libdir} -lpng12 -lz -lm
 Cflags: -I${includedir}/libpng12
diff --git a/scripts/makefile.32sunu b/scripts/makefile.32sunu
index c560372..b07beb6 100644
--- a/scripts/makefile.32sunu
+++ b/scripts/makefile.32sunu
@@ -33,7 +33,7 @@
 
 LIBNAME=libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.7beta1
+PNGMIN = 1.2.7beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/makefile.64sunu b/scripts/makefile.64sunu
index 0bbbe9b..476c4e5 100644
--- a/scripts/makefile.64sunu
+++ b/scripts/makefile.64sunu
@@ -33,7 +33,7 @@
 
 LIBNAME=libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.7beta1
+PNGMIN = 1.2.7beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/makefile.aix b/scripts/makefile.aix
index 0aa915c..3df9454 100644
--- a/scripts/makefile.aix
+++ b/scripts/makefile.aix
@@ -18,7 +18,7 @@
 
 LIBNAME=libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.7beta1
+PNGMIN = 1.2.7beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 prefix=/usr/local
diff --git a/scripts/makefile.beos b/scripts/makefile.beos
index c9fc0e4..4411177 100644
--- a/scripts/makefile.beos
+++ b/scripts/makefile.beos
@@ -12,7 +12,7 @@
 ZLIBINC=/usr/local/include
 
 PNGMAJ = 0
-PNGMIN = 1.2.7beta1
+PNGMIN = 1.2.7beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 ALIGN=
diff --git a/scripts/makefile.cygwin b/scripts/makefile.cygwin
index b0e9675..250e4fd 100644
--- a/scripts/makefile.cygwin
+++ b/scripts/makefile.cygwin
@@ -79,7 +79,7 @@
 LIBNAME = libpng12
 PNGMAJ = 0
 CYGDLL = 12
-PNGMIN = 1.2.7beta1
+PNGMIN = 1.2.7beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 SHAREDLIB=cygpng$(CYGDLL).dll
diff --git a/scripts/makefile.darwin b/scripts/makefile.darwin
index 330d7cc..8933200 100644
--- a/scripts/makefile.darwin
+++ b/scripts/makefile.darwin
@@ -23,7 +23,7 @@
 RANLIB=ranlib
 
 PNGMAJ = 0
-PNGMIN = 1.2.7beta1
+PNGMIN = 1.2.7beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng12
 
diff --git a/scripts/makefile.dec b/scripts/makefile.dec
index ca2fb08..a9b6d8e 100644
--- a/scripts/makefile.dec
+++ b/scripts/makefile.dec
@@ -32,7 +32,7 @@
 ZLIBINC=../zlib
 
 PNGMAJ = 0
-PNGMIN = 1.2.7beta1
+PNGMIN = 1.2.7beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng12
 
diff --git a/scripts/makefile.gcmmx b/scripts/makefile.gcmmx
index 29a8022..dd30dcb 100644
--- a/scripts/makefile.gcmmx
+++ b/scripts/makefile.gcmmx
@@ -15,7 +15,7 @@
 
 LIBNAME = libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.7beta1
+PNGMIN = 1.2.7beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 CC=gcc
diff --git a/scripts/makefile.hpgcc b/scripts/makefile.hpgcc
index 4ffacbd..cd704a8 100644
--- a/scripts/makefile.hpgcc
+++ b/scripts/makefile.hpgcc
@@ -41,7 +41,7 @@
 #RANLIB=echo
 
 PNGMAJ = 0
-PNGMIN = 1.2.7beta1
+PNGMIN = 1.2.7beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng12
 
diff --git a/scripts/makefile.hpux b/scripts/makefile.hpux
index 403387c..dc339dc 100644
--- a/scripts/makefile.hpux
+++ b/scripts/makefile.hpux
@@ -24,7 +24,7 @@
 RANLIB=ranlib
 
 PNGMAJ = 0
-PNGMIN = 1.2.7beta1
+PNGMIN = 1.2.7beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng12
 
diff --git a/scripts/makefile.linux b/scripts/makefile.linux
index 8ac478a..84944a9 100644
--- a/scripts/makefile.linux
+++ b/scripts/makefile.linux
@@ -5,7 +5,7 @@
 
 LIBNAME = libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.7beta1
+PNGMIN = 1.2.7beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 CC=gcc
diff --git a/scripts/makefile.ne12bsd b/scripts/makefile.ne12bsd
index 54ed006..6946fcf 100644
--- a/scripts/makefile.ne12bsd
+++ b/scripts/makefile.ne12bsd
@@ -13,7 +13,7 @@
 
 LIB=	png12
 SHLIB_MAJOR=	0
-SHLIB_MINOR=	1.2.7beta1
+SHLIB_MINOR=	1.2.7beta2
 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 8a16f58..a557ac7 100644
--- a/scripts/makefile.netbsd
+++ b/scripts/makefile.netbsd
@@ -13,7 +13,7 @@
 
 LIB=	png
 SHLIB_MAJOR=	3
-SHLIB_MINOR=	1.2.7beta1
+SHLIB_MINOR=	1.2.7beta2
 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 8f93502..010eb9a 100644
--- a/scripts/makefile.openbsd
+++ b/scripts/makefile.openbsd
@@ -7,7 +7,7 @@
 MANDIR= ${PREFIX}/man/cat
 
 SHLIB_MAJOR=	0
-SHLIB_MINOR=	1.2.7beta1
+SHLIB_MINOR=	1.2.7beta2
 
 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 0dc0320..bb0a55e 100644
--- a/scripts/makefile.sco
+++ b/scripts/makefile.sco
@@ -24,7 +24,7 @@
 RANLIB=echo
 
 PNGMAJ = 0
-PNGMIN = 1.2.7beta1
+PNGMIN = 1.2.7beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng12
 
diff --git a/scripts/makefile.sggcc b/scripts/makefile.sggcc
index 8761fe4..0778e71 100644
--- a/scripts/makefile.sggcc
+++ b/scripts/makefile.sggcc
@@ -18,7 +18,7 @@
 
 LIBNAME=libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.7beta1
+PNGMIN = 1.2.7beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 CC=gcc
 
diff --git a/scripts/makefile.sgi b/scripts/makefile.sgi
index acf7799..d0e73a9 100644
--- a/scripts/makefile.sgi
+++ b/scripts/makefile.sgi
@@ -5,7 +5,7 @@
 
 LIBNAME=libpng12
 PNGMAJ = 0
-PNGMIN = 1.2.7beta1
+PNGMIN = 1.2.7beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # Where make install puts libpng.a, libpng12.so, and libpng12/png.h
diff --git a/scripts/makefile.so9 b/scripts/makefile.so9
index feff9ad..2649eef 100644
--- a/scripts/makefile.so9
+++ b/scripts/makefile.so9
@@ -34,7 +34,7 @@
 RANLIB=echo
 
 PNGMAJ = 0
-PNGMIN = 1.2.7beta1
+PNGMIN = 1.2.7beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng12
 
diff --git a/scripts/makefile.solaris b/scripts/makefile.solaris
index 52a5d9a..794db1c 100644
--- a/scripts/makefile.solaris
+++ b/scripts/makefile.solaris
@@ -30,7 +30,7 @@
 RANLIB=echo
 
 PNGMAJ = 0
-PNGMIN = 1.2.7beta1
+PNGMIN = 1.2.7beta2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng12
 
diff --git a/scripts/pngos2.def b/scripts/pngos2.def
index 15d36e8..8590160 100644
--- a/scripts/pngos2.def
+++ b/scripts/pngos2.def
@@ -2,7 +2,7 @@
 ; PNG.LIB module definition file for OS/2
 ;----------------------------------------
 
-; Version 1.2.7beta1
+; Version 1.2.7beta2
 
 LIBRARY		PNG
 DESCRIPTION	"PNG image compression library for OS/2"
@@ -184,6 +184,34 @@
   png_convert_to_rfc1123
   png_set_invalid
 
+; Added at version 1.2.0:
+  png_mmx_support
+  png_permit_empty_plte
+  png_permit_mng_features
+  png_get_mmx_flagmask
+  png_get_asm_flagmask
+  png_get_asm_flags
+  png_get_mmx_bitdepth_threshold
+  png_get_mmx_rowbytes_threshold
+  png_set_asm_flags
+  png_init_mmx_flags
+
+; Added at version 1.2.2:
+  png_handle_as_unknown
+
+; Added at version 1.2.2 and deleted from 1.2.3:
+; png_zalloc
+; png_zfree
+
+; 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
+; Added at version 1.2.7
+  png_set_add_alpha
 
 ; These are not present when libpng is compiled with PNG_NO_GLOBAL_ARRAYS
   png_libpng_ver
diff --git a/scripts/pngw32.def b/scripts/pngw32.def
index f7bac62..40477f0 100644
--- a/scripts/pngw32.def
+++ b/scripts/pngw32.def
@@ -6,7 +6,7 @@
 DESCRIPTION "PNG image compression library for Windows"
 
 EXPORTS
-;Version 1.2.7beta1
+;Version 1.2.7beta2
   png_build_grayscale_palette  @1
   png_check_sig        @2
   png_chunk_error      @3
@@ -191,3 +191,37 @@
   png_write_init_3    @176
   png_info_init_3 @177
   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
+; MNG features
+  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
+; Strip error numbers
+  png_set_strip_error_numbers @193
+; Added at version 1.2.2
+  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
+; Added at version 1.2.7
+  png_set_add_alpha @199