[devel] Imported from libpng-1.5.0beta03.tar
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9c314ba..341bcb8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -209,9 +209,9 @@
 # SET UP LINKS
 if(PNG_SHARED)
   set_target_properties(${PNG_LIB_NAME} PROPERTIES
-#   VERSION 14.${PNGLIB_RELEASE}.1.5.0beta02
-    VERSION 14.${PNGLIB_RELEASE}.0
-    SOVERSION 14
+#   VERSION 15.${PNGLIB_RELEASE}.1.5.0beta03
+    VERSION 15.${PNGLIB_RELEASE}.0
+    SOVERSION 15
     CLEAN_DIRECT_OUTPUT 1)
 endif()
 if(PNG_STATIC)
diff --git a/INSTALL b/INSTALL
index cec18d5..2b94e00 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
 
-Installing libpng version 1.5.0beta02 - February 8, 2010
+Installing libpng version 1.5.0beta03 - February 8, 2010
 
 On Unix/Linux and similar systems, you can simply type
 
@@ -46,7 +46,7 @@
 correspond to the version of zlib that's installed.
 
 You can rename the directories that you downloaded (they
-might be called "libpng-1.5.0beta02" or "libpng14" and "zlib-1.2.3"
+might be called "libpng-1.5.0beta03" or "libpng15" and "zlib-1.2.3"
 or "zlib123") so that you have directories called "zlib" and "libpng".
 
 Your directory structure should look like this:
diff --git a/LICENSE b/LICENSE
index c2ab116..216c21d 100644
--- a/LICENSE
+++ b/LICENSE
@@ -10,7 +10,7 @@
 
 This code is released under the libpng license.
 
-libpng versions 1.2.6, August 15, 2004, through 1.5.0beta02, February 8, 2010, are
+libpng versions 1.2.6, August 15, 2004, through 1.5.0beta03, February 8, 2010, are
 Copyright (c) 2004, 2006-2007 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
diff --git a/README b/README
index 5137be1..fdb3bbc 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README for libpng version 1.5.0beta02 - February 8, 2010 (shared library 14.0)
+README for libpng version 1.5.0beta03 - February 8, 2010 (shared library 15.0)
 See the note about version numbers near the top of png.h
 
 See INSTALL for instructions on how to install libpng.
@@ -185,9 +185,9 @@
        makefile.std     =>  Generic UNIX makefile (cc, creates static
                             libpng.a)
        makefile.elf     =>  Linux/ELF makefile symbol versioning,
-                            gcc, creates libpng14.so.14.1.5.0beta02)
+                            gcc, creates libpng15.so.15.1.5.0beta03)
        makefile.linux   =>  Linux/ELF makefile
-                            (gcc, creates libpng14.so.14.1.5.0beta02)
+                            (gcc, creates libpng15.so.15.1.5.0beta03)
        makefile.gcc     =>  Generic makefile (gcc, creates static libpng.a)
        makefile.knr     =>  Archaic UNIX Makefile that converts files with
                             ansi2knr (Requires ansi2knr.c from
@@ -204,17 +204,17 @@
        makefile.intel   =>  Intel C/C++ version 4.0 and later
        makefile.mingw   =>  Mingw/gcc makefile
        makefile.netbsd  =>  NetBSD/cc makefile, makes libpng.so.
-       makefile.ne14bsd  =>  NetBSD/cc makefile, makes
-                            libpng14.so
+       makefile.ne15bsd  =>  NetBSD/cc makefile, makes
+                            libpng15.so
        makefile.openbsd =>  OpenBSD makefile
        makefile.sgi     =>  Silicon Graphics IRIX (cc, creates static lib)
        makefile.sggcc   =>  Silicon Graphics
-                            (gcc, creates libpng14.so.14.1.5.0beta02)
+                            (gcc, creates libpng15.so.15.1.5.0beta03)
        makefile.sunos   =>  Sun makefile
        makefile.solaris =>  Solaris 2.X makefile
-                            (gcc, creates libpng14.so.14.1.5.0beta02)
+                            (gcc, creates libpng15.so.15.1.5.0beta03)
        makefile.so9     =>  Solaris 9 makefile
-                            (gcc, creates libpng14.so.14.1.5.0beta02)
+                            (gcc, creates libpng15.so.15.1.5.0beta03)
        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/contrib/gregbook/Makefile.sgi b/contrib/gregbook/Makefile.sgi
index a736566..91623ac 100644
--- a/contrib/gregbook/Makefile.sgi
+++ b/contrib/gregbook/Makefile.sgi
@@ -23,9 +23,9 @@
 
 # macros --------------------------------------------------------------------
 
-PNGINC = -I/usr/local/include/libpng14
-PNGLIB = -L/usr/local/lib -lpng14	  # dynamically linked against libpng
-#PNGLIB = /usr/local/lib/libpng14.a # statically linked against libpng
+PNGINC = -I/usr/local/include/libpng15
+PNGLIB = -L/usr/local/lib -lpng15	  # dynamically linked against libpng
+#PNGLIB = /usr/local/lib/libpng15.a # statically linked against libpng
 # or:
 #PNGINC = -I../..
 #PNGLIB = -L../.. -lpng
diff --git a/contrib/gregbook/Makefile.unx b/contrib/gregbook/Makefile.unx
index ca86885..b52d8b6 100644
--- a/contrib/gregbook/Makefile.unx
+++ b/contrib/gregbook/Makefile.unx
@@ -26,14 +26,14 @@
 # macros --------------------------------------------------------------------
 
 #PNGDIR = /usr/local/lib
-#PNGINC = -I/usr/local/include/libpng14
-#PNGLIBd = -L$(PNGDIR) -lpng14 # dynamically linked, installed libpng
-#PNGLIBs = $(PNGDIR)/libpng14.a # statically linked, installed libpng
+#PNGINC = -I/usr/local/include/libpng15
+#PNGLIBd = -L$(PNGDIR) -lpng15 # dynamically linked, installed libpng
+#PNGLIBs = $(PNGDIR)/libpng15.a # statically linked, installed libpng
 # or:
 PNGDIR = ../..#	this one is for libpng-x.y.z/contrib/gregbook builds
 #PNGDIR = ../libpng
 PNGINC = -I$(PNGDIR)
-PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng14	# dynamically linked
+PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng15	# dynamically linked
 PNGLIBs = $(PNGDIR)/libpng.a		# statically linked, local libpng
 
 ZDIR = /usr/local/lib
diff --git a/libpng-1.5.0beta02.txt b/libpng-1.5.0beta03.txt
similarity index 99%
rename from libpng-1.5.0beta02.txt
rename to libpng-1.5.0beta03.txt
index 50638ff..6f262e9 100644
--- a/libpng-1.5.0beta02.txt
+++ b/libpng-1.5.0beta03.txt
@@ -1,6 +1,6 @@
 libpng.txt - A description on how to use and modify libpng
 
- libpng version 1.5.0beta02 - February 8, 2010
+ libpng version 1.5.0beta03 - February 8, 2010
  Updated and distributed by Glenn Randers-Pehrson
  <glennrp at users.sourceforge.net>
  Copyright (c) 1998-2009 Glenn Randers-Pehrson
@@ -11,7 +11,7 @@
 
  Based on:
 
- libpng versions 0.97, January 1998, through 1.5.0beta02 - February 8, 2010
+ libpng versions 0.97, January 1998, through 1.5.0beta03 - February 8, 2010
  Updated and distributed by Glenn Randers-Pehrson
  Copyright (c) 1998-2009 Glenn Randers-Pehrson
 
@@ -899,7 +899,7 @@
 As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was
 added.  It expands the sample depth without changing tRNS to alpha.
 
-As of libpng version 1.5.0beta02, not all possible expansions are supported.
+As of libpng version 1.5.0beta03, not all possible expansions are supported.
 
 In the following table, the 01 means grayscale with depth<8, 31 means
 indexed with depth<8, other numerals represent the color type, "T" means
@@ -3251,7 +3251,7 @@
 an official declaration.
 
 This is your unofficial assurance that libpng from version 0.71 and
-upward through 1.5.0beta02 are Y2K compliant.  It is my belief that earlier
+upward through 1.5.0beta03 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/libpng.3 b/libpng.3
index d8c1b26..f54c04c 100644
--- a/libpng.3
+++ b/libpng.3
@@ -1,6 +1,6 @@
 .TH LIBPNG 3 "February 8, 2010"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.5.0beta02
+libpng \- Portable Network Graphics (PNG) Reference Library 1.5.0beta03
 .SH SYNOPSIS
 \fI\fB
 
@@ -785,7 +785,7 @@
 .SH LIBPNG.TXT
 libpng.txt - A description on how to use and modify libpng
 
- libpng version 1.5.0beta02 - February 8, 2010
+ libpng version 1.5.0beta03 - February 8, 2010
  Updated and distributed by Glenn Randers-Pehrson
  <glennrp at users.sourceforge.net>
  Copyright (c) 1998-2009 Glenn Randers-Pehrson
@@ -796,7 +796,7 @@
 
  Based on:
 
- libpng versions 0.97, January 1998, through 1.5.0beta02 - February 8, 2010
+ libpng versions 0.97, January 1998, through 1.5.0beta03 - February 8, 2010
  Updated and distributed by Glenn Randers-Pehrson
  Copyright (c) 1998-2009 Glenn Randers-Pehrson
 
@@ -1684,7 +1684,7 @@
 As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was
 added.  It expands the sample depth without changing tRNS to alpha.
 
-As of libpng version 1.5.0beta02, not all possible expansions are supported.
+As of libpng version 1.5.0beta03, not all possible expansions are supported.
 
 In the following table, the 01 means grayscale with depth<8, 31 means
 indexed with depth<8, other numerals represent the color type, "T" means
@@ -4036,7 +4036,7 @@
 an official declaration.
 
 This is your unofficial assurance that libpng from version 0.71 and
-upward through 1.5.0beta02 are Y2K compliant.  It is my belief that earlier
+upward through 1.5.0beta03 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
@@ -4268,7 +4268,7 @@
 
 Thanks to Frank J. T. Wojcik for helping with the documentation.
 
-Libpng version 1.5.0beta02 - February 8, 2010:
+Libpng version 1.5.0beta03 - February 8, 2010:
 Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
 Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
 
@@ -4291,7 +4291,7 @@
 
 This code is released under the libpng license.
 
-libpng versions 1.2.6, August 15, 2004, through 1.5.0beta02, February 8, 2010, are
+libpng versions 1.2.6, August 15, 2004, through 1.5.0beta03, February 8, 2010, are
 Copyright (c) 2004,2006-2007 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
diff --git a/libpngpf.3 b/libpngpf.3
index e52339f..4433ff4 100644
--- a/libpngpf.3
+++ b/libpngpf.3
@@ -1,6 +1,6 @@
 .TH LIBPNGPF 3 "February 8, 2010"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.5.0beta02
+libpng \- Portable Network Graphics (PNG) Reference Library 1.5.0beta03
 (private functions)
 .SH SYNOPSIS
 \fB#include <png.h>\fP
diff --git a/png.c b/png.c
index 2da8fee..5f04544 100644
--- a/png.c
+++ b/png.c
@@ -18,7 +18,7 @@
 #include "pngpriv.h"
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef version_1_5_0beta02 Your_png_h_is_not_version_1_5_0beta02;
+typedef version_1_5_0beta03 Your_png_h_is_not_version_1_5_0beta03;
 
 /* Version information for C files.  This had better match the version
  * string defined in png.h.
@@ -552,13 +552,13 @@
 #else
 #ifdef __STDC__
    return ((png_charp) PNG_STRING_NEWLINE \
-     "libpng version 1.5.0beta02 - February 8, 2010" PNG_STRING_NEWLINE \
+     "libpng version 1.5.0beta03 - February 8, 2010" PNG_STRING_NEWLINE \
      "Copyright (c) 1998-2010 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
      "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
      "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
      PNG_STRING_NEWLINE);
 #else
-      return ((png_charp) "libpng version 1.5.0beta02 - February 8, 2010\
+      return ((png_charp) "libpng version 1.5.0beta03 - February 8, 2010\
       Copyright (c) 1998-2010 Glenn Randers-Pehrson\
       Copyright (c) 1996-1997 Andreas Dilger\
       Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.");
diff --git a/png.h b/png.h
index c2f5c53..02386d3 100644
--- a/png.h
+++ b/png.h
@@ -1,7 +1,7 @@
 
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.5.0beta02 - February 8, 2010
+ * libpng version 1.5.0beta03 - February 8, 2010
  * Copyright (c) 1998-2010 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.)
@@ -11,7 +11,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.5.0beta02 - February 8, 2010: Glenn
+ *  libpng versions 0.97, January 1998, through 1.5.0beta03 - February 8, 2010: Glenn
  *  See also "Contributing Authors", below.
  *
  * Note about libpng version numbers:
@@ -169,7 +169,7 @@
  *
  * This code is released under the libpng license.
  *
- * libpng versions 1.2.6, August 15, 2004, through 1.5.0beta02, February 8, 2010, are
+ * libpng versions 1.2.6, August 15, 2004, through 1.5.0beta03, February 8, 2010, are
  * Copyright (c) 2004, 2006-2010 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:
@@ -287,7 +287,7 @@
  *    an official declaration.
  *
  *    This is your unofficial assurance that libpng from version 0.71 and
- *    upward through 1.5.0beta02 are Y2K compliant.  It is my belief that earlier
+ *    upward through 1.5.0beta03 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
@@ -343,12 +343,12 @@
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.5.0beta02"
+#define PNG_LIBPNG_VER_STRING "1.5.0beta03"
 #define PNG_HEADER_VERSION_STRING \
-   " libpng version 1.5.0beta02 - February 8, 2010\n"
+   " libpng version 1.5.0beta03 - February 8, 2010\n"
 
-#define PNG_LIBPNG_VER_SONUM   14
-#define PNG_LIBPNG_VER_DLLNUM  14
+#define PNG_LIBPNG_VER_SONUM   15
+#define PNG_LIBPNG_VER_DLLNUM  15
 
 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
 #define PNG_LIBPNG_VER_MAJOR   1
@@ -358,7 +358,7 @@
  * PNG_LIBPNG_VER_STRING, omitting any leading zero:
  */
 
-#define PNG_LIBPNG_VER_BUILD  02
+#define PNG_LIBPNG_VER_BUILD  03
 
 /* Release Status */
 #define PNG_LIBPNG_BUILD_ALPHA    1
@@ -595,7 +595,23 @@
 #ifdef PNG_INTERNAL
 #include "pnginfo.h"
 #else
-typedef struct png_info_struct png_info;
+
+/* provide an incomplete structure-type-reference for png_info */
+
+# if 1 /* this works on FreeBSD but is not in the C language. */
+       /* gcc (GCC) 4.2.1 20070719  [FreeBSD] */
+       /* also on Sunos running gcc (GCC) 4.3.4 */
+typedef struct { ; } png_info;
+# endif
+
+# if 0 /* does not work on FreeBSD or SunOS. */
+typedef struct png_info;
+# endif
+
+# if 0 /* does not work on FreeBSD  or SunOS */
+struct png_info;
+# endif
+
 #endif
 
 typedef png_info FAR * png_infop;
@@ -792,7 +808,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_5_0beta02;
+typedef png_structp version_1_5_0beta03;
 
 typedef png_struct FAR * FAR * png_structpp;
 
diff --git a/pngconf.h b/pngconf.h
index a686788..88b6e5c 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,7 +1,7 @@
 
 /* pngconf.h - machine configurable file for libpng
  *
- * libpng version 1.5.0beta02 - February 8, 2010
+ * libpng version 1.5.0beta03 - February 8, 2010
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2010 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngpread.c b/pngpread.c
index 0d774ee..fad32b8 100644
--- a/pngpread.c
+++ b/pngpread.c
@@ -701,8 +701,13 @@
 
       new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256;
       old_buffer = png_ptr->save_buffer;
-      png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr,
+      png_ptr->save_buffer = (png_bytep)png_malloc_warn(png_ptr,
          (png_size_t)new_max);
+      if (png_ptr->save_buffer == NULL)
+      {
+        png_free(png_ptr, old_buffer);
+        png_error(png_ptr, "Insufficient memory for save_buffer");
+      }
       png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
       png_free(png_ptr, old_buffer);
       png_ptr->save_buffer_max = new_max;
diff --git a/pngpriv.h b/pngpriv.h
index 9ac98d9..1f85bb0 100644
--- a/pngpriv.h
+++ b/pngpriv.h
@@ -1,7 +1,7 @@
 
 /* pngpriv.h - private declarations for use inside libpng
  *
- * libpng version 1.5.0beta02 - February 8, 2010
+ * libpng version 1.5.0beta03 - February 8, 2010
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2010 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngrtran.c b/pngrtran.c
index f27a857..8481a20 100644
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -2349,14 +2349,14 @@
                   else
                   {
                      png_uint_16 red_1   = png_ptr->gamma_16_to_1[(red&0xff) >>
-                                  png_ptr->gamma_shift][red>>8];
+                         png_ptr->gamma_shift][red>>8];
                      png_uint_16 green_1 =
                          png_ptr->gamma_16_to_1[(green&0xff) >>
-                                  png_ptr->gamma_shift][green>>8];
+                         png_ptr->gamma_shift][green>>8];
                      png_uint_16 blue_1  = png_ptr->gamma_16_to_1[(blue&0xff) >>
-                                  png_ptr->gamma_shift][blue>>8];
+                         png_ptr->gamma_shift][blue>>8];
                      png_uint_16 gray16  = (png_uint_16)((rc*red_1 + gc*green_1
-                                  + bc*blue_1)>>15);
+                         + bc*blue_1)>>15);
                      w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
                          png_ptr->gamma_shift][gray16 >> 8];
                      rgb_error |= 1;
@@ -2405,7 +2405,7 @@
                   if (red != green || red != blue)
                      rgb_error |= 1;
                   *(dp++) =  png_ptr->gamma_from_1
-                             [(rc*red + gc*green + bc*blue)>>15];
+                      [(rc*red + gc*green + bc*blue)>>15];
                   *(dp++) = *(sp++);  /* alpha */
                }
             }
@@ -2454,7 +2454,7 @@
                      png_uint_16 blue_1  = png_ptr->gamma_16_to_1[(blue&0xff) >>
                          png_ptr->gamma_shift][blue>>8];
                      png_uint_16 gray16  = (png_uint_16)((rc * red_1
-                         + gc * green_1 + bc * blue_1)>>15);
+                        + gc * green_1 + bc * blue_1)>>15);
                      w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
                          png_ptr->gamma_shift][gray16 >> 8];
                      rgb_error |= 1;
@@ -2685,7 +2685,7 @@
                         {
                            png_byte p = (png_byte)((*sp >> shift) & 0x0f);
                            png_byte g = (png_byte)((gamma_table[p |
-                             (p << 4)] >> 4) & 0x0f);
+                               (p << 4)] >> 4) & 0x0f);
                            *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
                            *sp |= (png_byte)(g << shift);
                         }
@@ -2732,13 +2732,10 @@
                      for (i = 0; i < row_width; i++, sp++)
                      {
                         if (*sp == trans_color->gray)
-                        {
                            *sp = (png_byte)background->gray;
-                        }
+
                         else
-                        {
                            *sp = gamma_table[*sp];
-                        }
                      }
                   }
                   else
@@ -2748,9 +2745,7 @@
                      for (i = 0; i < row_width; i++, sp++)
                      {
                         if (*sp == trans_color->gray)
-                        {
                            *sp = (png_byte)background->gray;
-                        }
                      }
                   }
                   break;
@@ -2836,8 +2831,8 @@
                   for (i = 0; i < row_width; i++, sp += 3)
                   {
                      if (*sp == trans_color->red &&
-                        *(sp + 1) == trans_color->green &&
-                        *(sp + 2) == trans_color->blue)
+                         *(sp + 1) == trans_color->green &&
+                         *(sp + 2) == trans_color->blue)
                      {
                         *sp = (png_byte)background->red;
                         *(sp + 1) = (png_byte)background->green;
@@ -2858,7 +2853,7 @@
                      png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3));
                      png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5));
                      if (r == trans_color->red && g == trans_color->green &&
-                        b == trans_color->blue)
+                         b == trans_color->blue)
                      {
                         /* Background is already in screen gamma */
                         *sp = (png_byte)((background->red >> 8) & 0xff);
@@ -2893,7 +2888,7 @@
                      png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5));
 
                      if (r == trans_color->red && g == trans_color->green &&
-                        b == trans_color->blue)
+                         b == trans_color->blue)
                      {
                         *sp = (png_byte)((background->red >> 8) & 0xff);
                         *(sp + 1) = (png_byte)(background->red & 0xff);
@@ -2923,9 +2918,8 @@
                      png_uint_16 a = *(sp + 1);
 
                      if (a == 0xff)
-                     {
                         *dp = gamma_table[*sp];
-                     }
+
                      else if (a == 0)
                      {
                         /* Background is already in screen gamma */
@@ -2951,18 +2945,15 @@
                      png_byte a = *(sp + 1);
 
                      if (a == 0xff)
-                     {
                         *dp = *sp;
-                     }
+
 #ifdef PNG_READ_GAMMA_SUPPORTED
                      else if (a == 0)
-                     {
                         *dp = (png_byte)background->gray;
-                     }
+
                      else
-                     {
                         png_composite(*dp, *sp, a, background_1->gray);
-                     }
+
 #else
                      *dp = (png_byte)background->gray;
 #endif
@@ -3022,9 +3013,8 @@
                   {
                      png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3));
                      if (a == (png_uint_16)0xffff)
-                     {
                         png_memcpy(dp, sp, 2);
-                     }
+
 #ifdef PNG_READ_GAMMA_SUPPORTED
                      else if (a == 0)
 #else
@@ -3119,9 +3109,9 @@
                      {
                         png_composite(*dp, *sp, a, background->red);
                         png_composite(*(dp + 1), *(sp + 1), a,
-                           background->green);
+                            background->green);
                         png_composite(*(dp + 2), *(sp + 2), a,
-                           background->blue);
+                            background->blue);
                      }
                   }
                }
@@ -3171,11 +3161,13 @@
                         x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];
                         *dp = (png_byte)((x >> 8) & 0xff);
                         *(dp + 1) = (png_byte)(x & 0xff);
+
                         v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)];
                         png_composite_16(w, v, a, background_1->green);
                         x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];
                         *(dp + 2) = (png_byte)((x >> 8) & 0xff);
                         *(dp + 3) = (png_byte)(x & 0xff);
+
                         v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)];
                         png_composite_16(w, v, a, background_1->blue);
                         x = gamma_16_from_1[(w & 0xff) >> gamma_shift][w >> 8];
@@ -3238,7 +3230,7 @@
          row_info->color_type &= ~PNG_COLOR_MASK_ALPHA;
          row_info->channels--;
          row_info->pixel_depth = (png_byte)(row_info->channels *
-            row_info->bit_depth);
+             row_info->bit_depth);
          row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
       }
    }
@@ -3295,10 +3287,12 @@
                   *sp = (png_byte)((v >> 8) & 0xff);
                   *(sp + 1) = (png_byte)(v & 0xff);
                   sp += 2;
+
                   v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
                   *sp = (png_byte)((v >> 8) & 0xff);
                   *(sp + 1) = (png_byte)(v & 0xff);
                   sp += 2;
+
                   v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
                   *sp = (png_byte)((v >> 8) & 0xff);
                   *(sp + 1) = (png_byte)(v & 0xff);
@@ -3317,10 +3311,13 @@
                {
                   *sp = gamma_table[*sp];
                   sp++;
+
                   *sp = gamma_table[*sp];
                   sp++;
+
                   *sp = gamma_table[*sp];
                   sp++;
+
                   sp++;
                }
             }
@@ -3333,10 +3330,12 @@
                   *sp = (png_byte)((v >> 8) & 0xff);
                   *(sp + 1) = (png_byte)(v & 0xff);
                   sp += 2;
+
                   v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
                   *sp = (png_byte)((v >> 8) & 0xff);
                   *(sp + 1) = (png_byte)(v & 0xff);
                   sp += 2;
+
                   v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
                   *sp = (png_byte)((v >> 8) & 0xff);
                   *(sp + 1) = (png_byte)(v & 0xff);
@@ -3465,8 +3464,10 @@
                {
                   if ((*sp >> shift) & 0x01)
                      *dp = 1;
+
                   else
                      *dp = 0;
+
                   if (shift == 7)
                   {
                      shift = 0;
@@ -3541,8 +3542,10 @@
                {
                   if ((int)(*sp) >= num_trans)
                      *dp-- = 0xff;
+
                   else
                      *dp-- = trans_alpha[*sp];
+
                   *dp-- = palette[*sp].blue;
                   *dp-- = palette[*sp].green;
                   *dp-- = palette[*sp].red;
@@ -3612,8 +3615,10 @@
                   {
                      if ((*sp >> shift) & 0x01)
                         *dp = 0xff;
+
                      else
                         *dp = 0;
+
                      if (shift == 7)
                      {
                         shift = 0;
diff --git a/pngtest.c b/pngtest.c
index 234623e..aac508a 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -1625,4 +1625,4 @@
 }
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef version_1_5_0beta02 your_png_h_is_not_version_1_5_0beta02;
+typedef version_1_5_0beta03 your_png_h_is_not_version_1_5_0beta03;
diff --git a/projects/visualc6/README.txt b/projects/visualc6/README.txt
index b650e9e..2fdc00b 100644
--- a/projects/visualc6/README.txt
+++ b/projects/visualc6/README.txt
@@ -33,9 +33,9 @@
 
 This project builds the libpng binaries as follows:
 
-* Win32_DLL_Release\libpng14.dll      DLL build
-* Win32_DLL_Debug\libpng14d.dll       DLL build (debug version)
-* Win32_DLL_VB\libpng14vb.dll         DLL build for Visual Basic, using stdcall
+* Win32_DLL_Release\libpng15.dll      DLL build
+* Win32_DLL_Debug\libpng15d.dll       DLL build (debug version)
+* Win32_DLL_VB\libpng15vb.dll         DLL build for Visual Basic, using stdcall
 * Win32_LIB_Release\libpng.lib        static build
 * Win32_LIB_Debug\libpngd.lib         static build (debug version)
 
diff --git a/projects/visualc6/libpng.dsp b/projects/visualc6/libpng.dsp
index 6704255..bf0e140 100644
--- a/projects/visualc6/libpng.dsp
+++ b/projects/visualc6/libpng.dsp
@@ -59,7 +59,7 @@
 # ADD BSC32 /nologo

 LINK32=link.exe

 # ADD BASE LINK32 /nologo /dll /machine:I386

-# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_Release\libpng14.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Release"

+# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_Release\libpng15.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Release"

 

 !ELSEIF  "$(CFG)" == "libpng - Win32 DLL Debug"

 

@@ -90,7 +90,7 @@
 # ADD BSC32 /nologo

 LINK32=link.exe

 # ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept

-# ADD LINK32 zlib1d.lib /nologo /dll /debug /machine:I386 /out:"Win32_DLL_Debug\libpng14d.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Debug"

+# ADD LINK32 zlib1d.lib /nologo /dll /debug /machine:I386 /out:"Win32_DLL_Debug\libpng15d.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Debug"

 

 !ELSEIF  "$(CFG)" == "libpng - Win32 DLL VB"

 

@@ -121,10 +121,10 @@
 # ADD BSC32 /nologo

 LINK32=link.exe

 # ADD BASE LINK32 /nologo /dll /machine:I386

-# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_VB\libpng14vb.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Release"

+# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_VB\libpng15vb.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Release"

 # Begin Special Build Tool

 OutDir=.\Win32_DLL_VB

-TargetName=libpng14vb

+TargetName=libpng15vb

 SOURCE="$(InputPath)"

 PostBuild_Cmds=echo    Deleting $(targetname) import library and export file (Not required for VB projects)	del $(outdir)\$(targetname).lib	del $(outdir)\$(targetname).exp

 # End Special Build Tool

diff --git a/projects/visualc6/pngtest.dsp b/projects/visualc6/pngtest.dsp
index d3cb068..0f5ca50 100644
--- a/projects/visualc6/pngtest.dsp
+++ b/projects/visualc6/pngtest.dsp
@@ -54,7 +54,7 @@
 # ADD BSC32 /nologo

 LINK32=link.exe

 # ADD BASE LINK32 /nologo /subsystem:console /machine:I386

-# ADD LINK32 Win32_DLL_Release\libpng14.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_Release\zlib1.lib /nologo /subsystem:console /machine:I386

+# ADD LINK32 Win32_DLL_Release\libpng15.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_Release\zlib1.lib /nologo /subsystem:console /machine:I386

 # Begin Special Build Tool

 OutDir=.\Win32_DLL_Release

 SOURCE="$(InputPath)"

@@ -86,7 +86,7 @@
 # ADD BSC32 /nologo

 LINK32=link.exe

 # ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept

-# ADD LINK32 Win32_DLL_Debug\libpng14d.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_Debug\zlib1d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept

+# ADD LINK32 Win32_DLL_Debug\libpng15d.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_Debug\zlib1d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept

 # Begin Special Build Tool

 OutDir=.\Win32_DLL_Debug

 SOURCE="$(InputPath)"

diff --git a/projects/visualc71/README.txt b/projects/visualc71/README.txt
index 7d51eed..7ef8b74 100644
--- a/projects/visualc71/README.txt
+++ b/projects/visualc71/README.txt
@@ -34,9 +34,9 @@
 
 This project builds the libpng binaries as follows:
 
-* Win32_DLL_Release\libpng14.dll      DLL build
-* Win32_DLL_Debug\libpng14d.dll       DLL build (debug version)
-* Win32_DLL_VB\libpng14vb.dll         DLL build for Visual Basic, using stdcall
+* Win32_DLL_Release\libpng15.dll      DLL build
+* Win32_DLL_Debug\libpng15d.dll       DLL build (debug version)
+* Win32_DLL_VB\libpng15vb.dll         DLL build for Visual Basic, using stdcall
 * Win32_LIB_Release\libpng.lib        static build
 * Win32_LIB_Debug\libpngd.lib         static build (debug version)
 
diff --git a/projects/visualc71/libpng.vcproj b/projects/visualc71/libpng.vcproj
index ce03e68..96e5199 100644
--- a/projects/visualc71/libpng.vcproj
+++ b/projects/visualc71/libpng.vcproj
@@ -30,7 +30,7 @@
 				Name="VCCustomBuildTool"/>

 			<Tool

 				Name="VCLinkerTool"

-				OutputFile="$(OutDir)/libpng14.dll"

+				OutputFile="$(OutDir)/libpng15.dll"

 				LinkIncremental="1"

 				ModuleDefinitionFile="..\..\scripts\pngwin.def"/>

 			<Tool

@@ -78,7 +78,7 @@
 				Name="VCCustomBuildTool"/>

 			<Tool

 				Name="VCLinkerTool"

-				OutputFile="$(OutDir)/libpng14d.dll"

+				OutputFile="$(OutDir)/libpng15d.dll"

 				ModuleDefinitionFile="..\..\scripts\pngwin.def"

 				GenerateDebugInformation="TRUE"/>

 			<Tool

@@ -126,7 +126,7 @@
 				Name="VCCustomBuildTool"/>

 			<Tool

 				Name="VCLinkerTool"

-				OutputFile="$(OutDir)/libpng14vb.dll"

+				OutputFile="$(OutDir)/libpng15vb.dll"

 				LinkIncremental="1"/>

 			<Tool

 				Name="VCMIDLTool"/>

diff --git a/projects/visualc71/pngtest.vcproj b/projects/visualc71/pngtest.vcproj
index a59585e..43bc3d3 100644
--- a/projects/visualc71/pngtest.vcproj
+++ b/projects/visualc71/pngtest.vcproj
@@ -130,7 +130,7 @@
 				Name="VCLinkerTool"

 				OutputFile="$(OutDir)/pngtest.exe"

 				LinkIncremental="1"

-				IgnoreDefaultLibraryNames="$(IntDir)\libpng14b.lib"

+				IgnoreDefaultLibraryNames="$(IntDir)\libpng15b.lib"

 				SubSystem="1"

 				TargetMachine="1"/>

 			<Tool

diff --git a/projects/xcode/libpng.xcodeproj/project.pbxproj b/projects/xcode/libpng.xcodeproj/project.pbxproj
index a5707b3..267f6bb 100644
--- a/projects/xcode/libpng.xcodeproj/project.pbxproj
+++ b/projects/xcode/libpng.xcodeproj/project.pbxproj
@@ -224,9 +224,9 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				COPY_PHASE_STRIP = NO;
-				DYLIB_COMPATIBILITY_VERSION = 14;
-				DYLIB_CURRENT_VERSION = 14;
-				FRAMEWORK_VERSION = 1.5.0beta02;
+				DYLIB_COMPATIBILITY_VERSION = 15;
+				DYLIB_CURRENT_VERSION = 15;
+				FRAMEWORK_VERSION = 1.5.0beta03;
 				GCC_PRECOMPILE_PREFIX_HEADER = NO;
 				GCC_PREFIX_HEADER = "";
 				INFOPLIST_FILE = Info.plist;
@@ -242,9 +242,9 @@
 		4FADC24408B4156D00ABE55E /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				DYLIB_COMPATIBILITY_VERSION = 14;
-				DYLIB_CURRENT_VERSION = 14;
-				FRAMEWORK_VERSION = 1.5.0beta02;
+				DYLIB_COMPATIBILITY_VERSION = 15;
+				DYLIB_CURRENT_VERSION = 15;
+				FRAMEWORK_VERSION = 1.5.0beta03;
 				GCC_PRECOMPILE_PREFIX_HEADER = NO;
 				GCC_PREFIX_HEADER = "";
 				INFOPLIST_FILE = Info.plist;