Bug 648690 - Update libpng to version 1.5.9 (upstream changes). r=joedrew
authorMax Stepin <newstop@gmail.com>
Sat, 03 Mar 2012 22:18:12 -0500
changeset 88218 17b1c6ad13bda5430c61a384e91f584cac7a634c
parent 88217 110d4d8841864168918a154f4ace281b130e4b4a
child 88219 a59316d3580c9fda223b6f9afc30ad4dc4529b72
push id573
push usertim.taubert@gmx.de
push dateMon, 05 Mar 2012 20:01:11 +0000
treeherderfx-team@ad37c208588d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoedrew
bugs648690
milestone13.0a1
Bug 648690 - Update libpng to version 1.5.9 (upstream changes). r=joedrew
media/libpng/CHANGES
media/libpng/LICENSE
media/libpng/MOZCHANGES
media/libpng/Makefile.in
media/libpng/README
media/libpng/apng.patch
media/libpng/libpng.txt
media/libpng/mozpngconf.h
media/libpng/png.c
media/libpng/png.h
media/libpng/pngconf.h
media/libpng/pngdebug.h
media/libpng/pngerror.c
media/libpng/pngget.c
media/libpng/pnginfo.h
media/libpng/pngmem.c
media/libpng/pngpread.c
media/libpng/pngpriv.h
media/libpng/pngread.c
media/libpng/pngrio.c
media/libpng/pngrtran.c
media/libpng/pngrutil.c
media/libpng/pngset.c
media/libpng/pngstruct.h
media/libpng/pngtrans.c
media/libpng/pngwio.c
media/libpng/pngwrite.c
media/libpng/pngwtran.c
media/libpng/pngwutil.c
--- a/media/libpng/CHANGES
+++ b/media/libpng/CHANGES
@@ -1,391 +1,410 @@
 #if 0
-libpng_changes(){ /*
 CHANGES - changes for libpng
 
-version 0.2
+Version 0.2
   added reader into png.h
   fixed small problems in stub file
 
-version 0.3
+Version 0.3
   added pull reader
   split up pngwrite.c to several files
   added pnglib.txt
   added example.c
   cleaned up writer, adding a few new transformations
   fixed some bugs in writer
   interfaced with zlib 0.5
   added K&R support
-  added check for 64 KB blocks for 16 bit machines
-
-version 0.4
+  added check for 64 KB blocks for 16-bit machines
+
+Version 0.4
   cleaned up code and commented code
   simplified time handling into png_time
   created png_color_16 and png_color_8 to handle color needs
   cleaned up color type defines
   fixed various bugs
   made various names more consistent
   interfaced with zlib 0.71
   cleaned up zTXt reader and writer (using zlib's Reset functions)
   split transformations into pngrtran.c and pngwtran.c
 
-version 0.5
+Version 0.5
   interfaced with zlib 0.8
   fixed many reading and writing bugs
   saved using 3 spaces instead of tabs
 
-version 0.6
+Version 0.6
   added png_large_malloc() and png_large_free()
   added png_size_t
   cleaned up some compiler warnings
   added png_start_read_image()
 
-version 0.7
+Version 0.7
   cleaned up lots of bugs
   finished dithering and other stuff
   added test program
   changed name from pnglib to libpng
 
-version 0.71 [June, 1995]
+Version 0.71 [June, 1995]
   changed pngtest.png for zlib 0.93
   fixed error in libpng.txt and example.c
 
-version 0.8
+Version 0.8
   cleaned up some bugs
   added png_set_filler()
   split up pngstub.c into pngmem.c, pngio.c, and pngerror.c
   added #define's to remove unwanted code
   moved png_info_init() to png.c
   added old_size into png_realloc()
   added functions to manually set filtering and compression info
   changed compression parameters based on image type
   optimized filter selection code
   added version info
   changed external functions passing floats to doubles (k&r problems?)
   put all the configurable stuff in pngconf.h
   enabled png_set_shift to work with paletted images on read
-  added png_read_update_info() - updates info structure with
-     transformations
-
-version 0.81 [August, 1995]
+  added png_read_update_info() - updates info structure with transformations
+
+Version 0.81 [August, 1995]
   incorporated Tim Wegner's medium model code (thanks, Tim)
 
-version 0.82 [September, 1995]
+Version 0.82 [September, 1995]
   [unspecified changes]
 
-version 0.85 [December, 1995]
+Version 0.85 [December, 1995]
   added more medium model code (almost everything's a far)
   added i/o, error, and memory callback functions
-  fixed some bugs (16 bit, 4 bit interlaced, etc.)
+  fixed some bugs (16-bit, 4-bit interlaced, etc.)
   added first run progressive reader (barely tested)
 
-version 0.86 [January, 1996]
+Version 0.86 [January, 1996]
   fixed bugs
   improved documentation
 
-version 0.87 [January, 1996]
+Version 0.87 [January, 1996]
   fixed medium model bugs
   fixed other bugs introduced in 0.85 and 0.86
   added some minor documentation
 
-version 0.88 [January, 1996]
+Version 0.88 [January, 1996]
   fixed progressive bugs
   replaced tabs with spaces
   cleaned up documentation
   added callbacks for read/write and warning/error functions
 
-version 0.89 [July, 1996]
-  added new initialization API to make libpng work better with shared libs
-     we now have png_create_read_struct(), png_create_write_struct(),
-     png_create_info_struct(), png_destroy_read_struct(), and
-     png_destroy_write_struct() instead of the separate calls to
-     malloc and png_read_init(), png_info_init(), and png_write_init()
-  changed warning/error callback functions to fix bug - this means you
-     should use the new initialization API if you were using the old
-     png_set_message_fn() calls, and that the old API no longer exists
-     so that people are aware that they need to change their code
-  changed filter selection API to allow selection of multiple filters
-     since it didn't work in previous versions of libpng anyways
-  optimized filter selection code
-  fixed png_set_background() to allow using an arbitrary RGB color for
-     paletted images
-  fixed gamma and background correction for paletted images, so
-     png_correct_palette is not needed unless you are correcting an
-     external palette (you will need to #define PNG_CORRECT_PALETTE_SUPPORTED
-     in pngconf.h) - if nobody uses this, it may disappear in the future.
-  fixed bug with Borland 64K memory allocation (Alexander Lehmann)
-  fixed bug in interlace handling (Smarasderagd, I think)
-  added more error checking for writing and image to reduce invalid files
-  separated read and write functions so that they won't both be linked
-     into a binary when only reading or writing functionality is used
-  new pngtest image also has interlacing and zTXt
-  updated documentation to reflect new API
-
-version 0.90 [January, 1997]
-  made CRC errors/warnings on critical and ancillary chunks configurable
+Version 0.89 [July, 1996]
+  Added new initialization API to make libpng work better with shared libs
+    we now have png_create_read_struct(), png_create_write_struct(),
+    png_create_info_struct(), png_destroy_read_struct(), and
+    png_destroy_write_struct() instead of the separate calls to
+    malloc and png_read_init(), png_info_init(), and png_write_init()
+  Changed warning/error callback functions to fix bug - this means you
+    should use the new initialization API if you were using the old
+    png_set_message_fn() calls, and that the old API no longer exists
+    so that people are aware that they need to change their code
+  Changed filter selection API to allow selection of multiple filters
+    since it didn't work in previous versions of libpng anyways
+  Optimized filter selection code
+  Fixed png_set_background() to allow using an arbitrary RGB color for
+    paletted images
+  Fixed gamma and background correction for paletted images, so
+    png_correct_palette is not needed unless you are correcting an
+    external palette (you will need to #define PNG_CORRECT_PALETTE_SUPPORTED
+    in pngconf.h) - if nobody uses this, it may disappear in the future.
+  Fixed bug with Borland 64K memory allocation (Alexander Lehmann)
+  Fixed bug in interlace handling (Smarasderagd, I think)
+  Added more error checking for writing and image to reduce invalid files
+  Separated read and write functions so that they won't both be linked
+    into a binary when only reading or writing functionality is used
+  New pngtest image also has interlacing and zTXt
+  Updated documentation to reflect new API
+
+Version 0.90 [January, 1997]
+  Made CRC errors/warnings on critical and ancillary chunks configurable
   libpng will use the zlib CRC routines by (compile-time) default
-  changed DOS small/medium model memory support - needs zlib 1.04 (Tim Wegner)
-  added external C++ wrapper statements to png.h (Gilles Dauphin)
-  allow PNG file to be read when some or all of file signature has already
-     been read from the beginning of the stream.  ****This affects the size
-     of info_struct and invalidates all programs that use a shared libpng****
-  fixed png_filler() declarations
-  fixed? background color conversions
-  fixed order of error function pointers to match documentation
-  current chunk name is now available in png_struct to reduce the number
-     of nearly identical error messages (will simplify multi-lingual
-     support when available)
-  try to get ready for unknown-chunk callback functions:
-     - previously read critical chunks are flagged, so the chunk handling
-       routines can determine if the chunk is in the right place
-     - 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
-  changed parameter type of png_set_filler(...filler...) from png_byte
-     to png_uint_32
-  added test for MACOS to ensure that both math.h and fp.h are not #included
-  added macros for libpng to be compiled as a Windows DLL (Andreas Kupries)
-  added "packswap" transformation, which changes the endianness of
-     packed-pixel bytes (Kevin Bracey)
-  added "strip_alpha" transformation, which removes the alpha channel of
-     input images without using it (not necessarily a good idea)
-  added "swap_alpha" transformation, which puts the alpha channel in front
-     of the color bytes instead of after
-  removed all implicit variable tests which assume NULL == 0 (I think)
-  changed several variables to "png_size_t" to show 16/32-bit limitations
-  added new pCAL chunk read/write support
-  added experimental filter selection weighting (Greg Roelofs)
-  removed old png_set_rgbx() and png_set_xrgb() functions that have been
+  Changed DOS small/medium model memory support - needs zlib 1.04 (Tim Wegner)
+  Added external C++ wrapper statements to png.h (Gilles Dauphin)
+  Allow PNG file to be read when some or all of file signature has already
+    been read from the beginning of the stream.  ****This affects the size
+    of info_struct and invalidates all programs that use a shared libpng****
+  Fixed png_filler() declarations
+  Fixed? background color conversions
+  Fixed order of error function pointers to match documentation
+  Current chunk name is now available in png_struct to reduce the number
+    of nearly identical error messages (will simplify multi-lingual
+    support when available)
+  Try to get ready for unknown-chunk callback functions:
+    - previously read critical chunks are flagged, so the chunk handling
+      routines can determine if the chunk is in the right place
+    - 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
+  Changed parameter type of png_set_filler(...filler...) from png_byte
+    to png_uint_32
+  Added test for MACOS to ensure that both math.h and fp.h are not #included
+  Added macros for libpng to be compiled as a Windows DLL (Andreas Kupries)
+  Added "packswap" transformation, which changes the endianness of
+    packed-pixel bytes (Kevin Bracey)
+  Added "strip_alpha" transformation, which removes the alpha channel of
+    input images without using it (not necessarily a good idea)
+  Added "swap_alpha" transformation, which puts the alpha channel in front
+    of the color bytes instead of after
+  Removed all implicit variable tests which assume NULL == 0 (I think)
+  Changed several variables to "png_size_t" to show 16/32-bit limitations
+  Added new pCAL chunk read/write support
+  Added experimental filter selection weighting (Greg Roelofs)
+  Removed old png_set_rgbx() and png_set_xrgb() functions that have been
      obsolete for about 2 years now (use png_set_filler() instead)
-  added macros to read 16- and 32-bit ints directly from buffer, to be
-     used only on those systems that support it (namely PowerPC and 680x0)
-     With some testing, this may become the default for MACOS/PPC systems.
-  only calculate CRC on data if we are going to use it
-  added macros for zTXt compression type PNG_zTXt_COMPRESSION_???
-  added macros for simple libpng debugging output selectable at compile time
-  removed PNG_READ_END_MODE in progressive reader (Smarasderagd)
-  more description of info_struct in libpng.txt and png.h
-  more instructions in example.c
-  more chunk types tested in pngtest.c
-  renamed pngrcb.c to pngset.c, and all png_read_<chunk> functions to be
-     png_set_<chunk>.  We now have corresponding png_get_<chunk>
-     functions in pngget.c to get information in info_ptr.  This isolates
-     the application from the internal organization of png_info_struct
-     (good for shared library implementations).
-
-version 0.96 [May, 1997]
-  fixed serious bug with < 8bpp images introduced in 0.95
-  fixed 256-color transparency bug (Greg Roelofs)
-  fixed up documentation (Greg Roelofs, Laszlo Nyul)
-  fixed "error" in pngconf.h for Linux setjmp() behaviour
-  fixed DOS medium model support (Tim Wegner)
-  fixed png_check_keyword() for case with error in static string text
-  added read of CRC after IEND chunk for embedded PNGs (Laszlo Nyul)
-  added typecasts to quiet compiler errors
-  added more debugging info
-
-version 0.97 [January, 1998]
-  removed PNG_USE_OWN_CRC capability
-  relocated png_set_crc_action from pngrutil.c to pngrtran.c
-  fixed typecasts of "new_key", etc. (Andreas Dilger)
-  added RFC 1152 [sic] date support
-  fixed bug in gamma handling of 4-bit grayscale
-  added 2-bit grayscale gamma handling (Glenn R-P)
-  added more typecasts. 65536L becomes (png_uint_32)65536L, etc. (Glenn R-P)
-  minor corrections in libpng.txt
-  added simple sRGB support (Glenn R-P)
-  easier conditional compiling, e.g. define PNG_READ/WRITE_NOT_FULLY_SUPPORTED;
-     all configurable options can be selected from command-line instead
-     of having to edit pngconf.h (Glenn R-P)
-  fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P)
-  added more conditions for png_do_background, to avoid changing
-     black pixels to background when a background is supplied and
-     no pixels are transparent
-  repaired PNG_NO_STDIO behaviour
-  tested NODIV support and made it default behaviour (Greg Roelofs)
-  added "-m" option and PNGTEST_DEBUG_MEMORY to pngtest (John Bowler)
-  regularized version numbering scheme and bumped shared-library major
-     version number to 2 to avoid problems with libpng 0.89 apps (Greg Roelofs)
-
-version 0.98 [January, 1998]
-  cleaned up some typos in libpng.txt and in code documentation
-  fixed memory leaks in pCAL chunk processing (Glenn R-P and John Bowler)
-  cosmetic change "display_gamma" to "screen_gamma" in pngrtran.c
-  changed recommendation about file_gamma for PC images to .51 from .45,
-     in example.c and libpng.txt, added comments to distinguish between
-     screen_gamma, viewing_gamma, and display_gamma.
-  changed all references to RFC1152 to read RFC1123 and changed the
-     PNG_TIME_RFC1152_SUPPORTED macro to PNG_TIME_RFC1123_SUPPORTED
-  added png_invert_alpha capability (Glenn R-P -- suggestion by Jon Vincent)
-  changed srgb_intent from png_byte to int to avoid compiler bugs
-
-version 0.99 [January 30, 1998]
-  free info_ptr->text instead of end_info_ptr->text in pngread.c (John Bowler)
-  fixed a longstanding "packswap" bug in pngtrans.c
-  fixed some inconsistencies in pngconf.h that prevented compiling with
-     PNG_READ_GAMMA_SUPPORTED and PNG_READ_hIST_SUPPORTED undefined
-  fixed some typos and made other minor rearrangement of libpng.txt (Andreas)
-  changed recommendation about file_gamma for PC images to .50 from .51 in
-     example.c and libpng.txt, and changed file_gamma for sRGB images to .45
-  added a number of functions to access information from the png structure
-     png_get_image_height(), etc. (Glenn R-P, suggestion by Brad Pettit)
-  added TARGET_MACOS similar to zlib-1.0.8
-  define PNG_ALWAYS_EXTERN when __MWERKS__ && WIN32 are defined
-  added type casting to all png_malloc() function calls
-version 0.99a [January 31, 1998]
+  Added macros to read 16- and 32-bit ints directly from buffer, to be
+    used only on those systems that support it (namely PowerPC and 680x0)
+    With some testing, this may become the default for MACOS/PPC systems.
+  Only calculate CRC on data if we are going to use it
+  Added macros for zTXt compression type PNG_zTXt_COMPRESSION_???
+  Added macros for simple libpng debugging output selectable at compile time
+  Removed PNG_READ_END_MODE in progressive reader (Smarasderagd)
+  More description of info_struct in libpng.txt and png.h
+  More instructions in example.c
+  More chunk types tested in pngtest.c
+  Renamed pngrcb.c to pngset.c, and all png_read_<chunk> functions to be
+    png_set_<chunk>.  We now have corresponding png_get_<chunk>
+    functions in pngget.c to get information in info_ptr.  This isolates
+    the application from the internal organization of png_info_struct
+    (good for shared library implementations).
+
+Version 0.96 [May, 1997]
+  Fixed serious bug with < 8bpp images introduced in 0.95
+  Fixed 256-color transparency bug (Greg Roelofs)
+  Fixed up documentation (Greg Roelofs, Laszlo Nyul)
+  Fixed "error" in pngconf.h for Linux setjmp() behavior
+  Fixed DOS medium model support (Tim Wegner)
+  Fixed png_check_keyword() for case with error in static string text
+  Added read of CRC after IEND chunk for embedded PNGs (Laszlo Nyul)
+  Added typecasts to quiet compiler errors
+  Added more debugging info
+
+Version 0.97 [January, 1998]
+  Removed PNG_USE_OWN_CRC capability
+  Relocated png_set_crc_action from pngrutil.c to pngrtran.c
+  Fixed typecasts of "new_key", etc. (Andreas Dilger)
+  Added RFC 1152 [sic] date support
+  Fixed bug in gamma handling of 4-bit grayscale
+  Added 2-bit grayscale gamma handling (Glenn R-P)
+  Added more typecasts. 65536L becomes (png_uint_32)65536L, etc. (Glenn R-P)
+  Minor corrections in libpng.txt
+  Added simple sRGB support (Glenn R-P)
+  Easier conditional compiling, e.g.,
+    define PNG_READ/WRITE_NOT_FULLY_SUPPORTED;
+    all configurable options can be selected from command-line instead
+    of having to edit pngconf.h (Glenn R-P)
+  Fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P)
+  Added more conditions for png_do_background, to avoid changing
+    black pixels to background when a background is supplied and
+    no pixels are transparent
+  Repaired PNG_NO_STDIO behavior
+  Tested NODIV support and made it default behavior (Greg Roelofs)
+  Added "-m" option and PNGTEST_DEBUG_MEMORY to pngtest (John Bowler)
+  Regularized version numbering scheme and bumped shared-library major
+    version number to 2 to avoid problems with libpng 0.89 apps
+    (Greg Roelofs)
+
+Version 0.98 [January, 1998]
+  Cleaned up some typos in libpng.txt and in code documentation
+  Fixed memory leaks in pCAL chunk processing (Glenn R-P and John Bowler)
+  Cosmetic change "display_gamma" to "screen_gamma" in pngrtran.c
+  Changed recommendation about file_gamma for PC images to .51 from .45,
+    in example.c and libpng.txt, added comments to distinguish between
+    screen_gamma, viewing_gamma, and display_gamma.
+  Changed all references to RFC1152 to read RFC1123 and changed the
+    PNG_TIME_RFC1152_SUPPORTED macro to PNG_TIME_RFC1123_SUPPORTED
+  Added png_invert_alpha capability (Glenn R-P -- suggestion by Jon Vincent)
+  Changed srgb_intent from png_byte to int to avoid compiler bugs
+
+Version 0.99 [January 30, 1998]
+  Free info_ptr->text instead of end_info_ptr->text in pngread.c (John Bowler)
+  Fixed a longstanding "packswap" bug in pngtrans.c
+  Fixed some inconsistencies in pngconf.h that prevented compiling with
+    PNG_READ_GAMMA_SUPPORTED and PNG_READ_hIST_SUPPORTED undefined
+  Fixed some typos and made other minor rearrangement of libpng.txt (Andreas)
+  Changed recommendation about file_gamma for PC images to .50 from .51 in
+    example.c and libpng.txt, and changed file_gamma for sRGB images to .45
+  Added a number of functions to access information from the png structure
+    png_get_image_height(), etc. (Glenn R-P, suggestion by Brad Pettit)
+  Added TARGET_MACOS similar to zlib-1.0.8
+  Define PNG_ALWAYS_EXTERN when __MWERKS__ && WIN32 are defined
+  Added type casting to all png_malloc() function calls
+
+Version 0.99a [January 31, 1998]
   Added type casts and parentheses to all returns that return a value.(Tim W.)
-version 0.99b [February 4, 1998]
+
+Version 0.99b [February 4, 1998]
   Added type cast png_uint_32 on malloc function calls where needed.
   Changed type of num_hist from png_uint_32 to int (same as num_palette).
   Added checks for rowbytes overflow, in case png_size_t is less than 32 bits.
   Renamed makefile.elf to makefile.lnx.
-version 0.99c [February 7, 1998]
+
+Version 0.99c [February 7, 1998]
   More type casting.  Removed erroneous overflow test in pngmem.c.
   Added png_buffered_memcpy() and png_buffered_memset(), apply them to rowbytes.
   Added UNIX manual pages libpng.3 (incorporating libpng.txt) and  png.5.
-version 0.99d [February 11, 1998]
+
+Version 0.99d [February 11, 1998]
   Renamed "far_to_near()" "png_far_to_near()"
   Revised libpng.3
   Version 99c "buffered" operations didn't work as intended.  Replaced them
     with png_memcpy_check() and png_memset_check().
   Added many "if (png_ptr == NULL) return" to quell compiler warnings about
     unused png_ptr, mostly in pngget.c and pngset.c.
   Check for overlength tRNS chunk present when indexed-color PLTE is read.
   Cleaned up spelling errors in libpng.3/libpng.txt
   Corrected a problem with png_get_tRNS() which returned undefined trans array
-version 0.99e [February 28, 1998]
+
+Version 0.99e [February 28, 1998]
   Corrected png_get_tRNS() again.
   Add parentheses for easier reading of pngget.c, fixed "||" should be "&&".
   Touched up example.c to make more of it compileable, although the entire
     file still can't be compiled (Willem van Schaik)
   Fixed a bug in png_do_shift() (Bryan Tsai)
   Added a space in png.h prototype for png_write_chunk_start()
   Replaced pngtest.png with one created with zlib 1.1.1
   Changed pngtest to report PASS even when file size is different (Jean-loup G.)
   Corrected some logic errors in png_do_invert_alpha() (Chris Patterson)
-version 0.99f [March 5, 1998]
+
+Version 0.99f [March 5, 1998]
   Corrected a bug in pngpread() introduced in version 99c (Kevin Bracey)
   Moved makefiles into a "scripts" directory, and added INSTALL instruction file
   Added makefile.os2 and pngos2.def (A. Zabolotny) and makefile.s2x (W. Sebok)
   Added pointers to "note on libpng versions" in makefile.lnx and README
   Added row callback feature when reading and writing nonprogressive rows
-     and added a test of this feature in pngtest.c
+    and added a test of this feature in pngtest.c
   Added user transform callbacks, with test of the feature in pngtest.c
-version 0.99g [March 6, 1998, morning]
+
+Version 0.99g [March 6, 1998, morning]
   Minor changes to pngtest.c to suppress compiler warnings.
   Removed "beta" language from documentation.
-version 0.99h [March 6, 1998, evening]
+
+Version 0.99h [March 6, 1998, evening]
   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
+    and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro
   Added user transform capability
 
-version 1.00 [March 7, 1998]
+Version 1.00 [March 7, 1998]
   Changed several typedefs in pngrutil.c
   Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik)
-  replaced "while(1)" with "for(;;)"
-  added PNGARG() to prototypes in pngtest.c and removed some prototypes
-  updated some of the makefiles (Tom Lane)
-  changed some typedefs (s_start, etc.) in pngrutil.c
-  fixed dimensions of "short_months" array in pngwrite.c
+  Replaced "while(1)" with "for(;;)"
+  Added PNGARG() to prototypes in pngtest.c and removed some prototypes
+  Updated some of the makefiles (Tom Lane)
+  Changed some typedefs (s_start, etc.) in pngrutil.c
+  Fixed dimensions of "short_months" array in pngwrite.c
   Replaced ansi2knr.c with the one from jpeg-v6
 
-version 1.0.0 [March 8, 1998]
+Version 1.0.0 [March 8, 1998]
   Changed name from 1.00 to 1.0.0 (Adam Costello)
   Added smakefile.ppc (with SCOPTIONS.ppc) for Amiga PPC (Andreas Kleinert)
-version 1.0.0a [March 9, 1998]
+
+Version 1.0.0a [March 9, 1998]
   Fixed three bugs in pngrtran.c to make gamma+background handling consistent
-  (Greg Roelofs)
+    (Greg Roelofs)
   Changed format of the PNG_LIBPNG_VER integer to xyyzz instead of xyz
-  for major, minor, and bugfix releases.  This is 10001. (Adam Costello,
-  Tom Lane)
+    for major, minor, and bugfix releases.  This is 10001. (Adam Costello,
+    Tom Lane)
   Make months range from 1-12 in png_convert_to_rfc1123
-version 1.0.0b [March 13, 1998]
+
+Version 1.0.0b [March 13, 1998]
   Quieted compiler complaints about two empty "for" loops in pngrutil.c
   Minor changes to makefile.s2x
   Removed #ifdef/#endif around a png_free() in pngread.c
 
-version 1.0.1 [March 14, 1998]
+Version 1.0.1 [March 14, 1998]
   Changed makefile.s2x to reduce security risk of using a relative pathname
   Fixed some typos in the documentation (Greg).
   Fixed a problem with value of "channels" returned by png_read_update_info()
-version 1.0.1a [April 21, 1998]
+
+Version 1.0.1a [April 21, 1998]
   Optimized Paeth calculations by replacing abs() function calls with intrinsics
   plus other loop optimizations. Improves avg decoding speed by about 20%.
   Commented out i386istic "align" compiler flags in makefile.lnx.
   Reduced the default warning level in some makefiles, to make them consistent.
   Removed references to IJG and JPEG in the ansi2knr.c copyright statement.
   Fixed a bug in png_do_strip_filler with XXRRGGBB => RRGGBB transformation.
   Added grayscale and 16-bit capability to png_do_read_filler().
   Fixed a bug in pngset.c, introduced in version 0.99c, that sets rowbytes
     too large when writing an image with bit_depth < 8 (Bob Dellaca).
   Corrected some bugs in the experimental weighted filtering heuristics.
   Moved a misplaced pngrutil code block that truncates tRNS if it has more
     than num_palette entries -- test was done before num_palette was defined.
   Fixed a png_convert_to_rfc1123() bug that converts day 31 to 0 (Steve Eddins).
-  Changed compiler flags in makefile.wat for better optimization (Pawel Mrochen).
-version 1.0.1b [May 2, 1998]
+  Changed compiler flags in makefile.wat for better optimization
+    (Pawel Mrochen).
+
+Version 1.0.1b [May 2, 1998]
   Relocated png_do_gray_to_rgb() within png_do_read_transformations() (Greg).
   Relocated the png_composite macros from pngrtran.c to png.h (Greg).
   Added makefile.sco (contributed by Mike Hopkirk).
   Fixed two bugs (missing definitions of "istop") introduced in libpng-1.0.1a.
   Fixed a bug in pngrtran.c that would set channels=5 under some circumstances.
-  More work on the Paeth-filtering, achieving imperceptible speedup (A Kleinert).
-  More work on loop optimization which may help when compiled with C++ compilers.
+  More work on the Paeth-filtering, achieving imperceptible speedup
+    (A Kleinert).
+  More work on loop optimization which may help when compiled with C++
+    compilers.
   Added warnings when people try to use transforms they've defined out.
   Collapsed 4 "i" and "c" loops into single "i" loops in pngrtran and pngwtran.
   Revised paragraph about png_set_expand() in libpng.txt and libpng.3 (Greg)
-version 1.0.1c [May 11, 1998]
+
+Version 1.0.1c [May 11, 1998]
   Fixed a bug in pngrtran.c (introduced in libpng-1.0.1a) where the masks for
     filler bytes should have been 0xff instead of 0xf.
   Added max_pixel_depth=32 in pngrutil.c when using FILLER with palette images.
   Moved PNG_WRITE_WEIGHTED_FILTER_SUPPORTED and PNG_WRITE_FLUSH_SUPPORTED
     out of the PNG_WRITE_TRANSFORMS_NOT_SUPPORTED block of pngconf.h
   Added "PNG_NO_WRITE_TRANSFORMS" etc., as alternatives for *_NOT_SUPPORTED,
     for consistency, in pngconf.h
   Added individual "ifndef PNG_NO_[CAPABILITY]" in pngconf.h to make it easier
     to remove unwanted capabilities via the compile line
   Made some corrections to grammar (which, it's) in documentation (Greg).
   Corrected example.c, use of row_pointers in png_write_image().
-version 1.0.1d [May 24, 1998]
+
+Version 1.0.1d [May 24, 1998]
   Corrected several statements that used side effects illegally in pngrutil.c
     and pngtrans.c, that were introduced in version 1.0.1b
   Revised png_read_rows() to avoid repeated if-testing for NULL (A Kleinert)
   More corrections to example.c, use of row_pointers in png_write_image()
     and png_read_rows().
   Added pngdll.mak and pngdef.pas to scripts directory, contributed by
     Bob Dellaca, to make a png32bd.dll with Borland C++ 4.5
   Fixed error in example.c with png_set_text: num_text is 3, not 2 (Guido V.)
   Changed several loops from count-down to count-up, for consistency.
-version 1.0.1e [June 6, 1998]
+
+Version 1.0.1e [June 6, 1998]
   Revised libpng.txt and libpng.3 description of png_set_read|write_fn(), and
     added warnings when people try to set png_read_fn and png_write_fn in
     the same structure.
   Added a test such that png_do_gamma will be done when num_trans==0
     for truecolor images that have defined a background.  This corrects an
     error that was introduced in libpng-0.90 that can cause gamma processing
     to be skipped.
   Added tests in png.h to include "trans" and "trans_values" in structures
     when PNG_READ_BACKGROUND_SUPPORTED or PNG_READ_EXPAND_SUPPORTED is defined.
   Add png_free(png_ptr->time_buffer) in png_destroy_read_struct()
   Moved png_convert_to_rfc_1123() from pngwrite.c to png.c
   Added capability for user-provided malloc_fn() and free_fn() functions,
     and revised pngtest.c to demonstrate their use, replacing the
     PNGTEST_DEBUG_MEM feature.
   Added makefile.w32, for Microsoft C++ 4.0 and later (Tim Wegner).
 
-version 1.0.2 [June 14, 1998]
+Version 1.0.2 [June 14, 1998]
   Fixed two bugs in makefile.bor .
-version 1.0.2a [December 30, 1998]
+
+Version 1.0.2a [December 30, 1998]
   Replaced and extended code that was removed from png_set_filler() in 1.0.1a.
   Fixed a bug in png_do_filler() that made it fail to write filler bytes in
     the left-most pixel of each row (Kevin Bracey).
   Changed "static pngcharp tIME_string" to "static char tIME_string[30]"
     in pngtest.c (Duncan Simpson).
   Fixed a bug in pngtest.c that caused pngtest to try to write a tIME chunk
     even when no tIME chunk was present in the source file.
   Fixed a problem in pngrutil.c: gray_to_rgb didn't always work with 16-bit.
@@ -397,31 +416,34 @@ version 1.0.2a [December 30, 1998]
   Changed "bad adaptive filter type" from error to warning in pngrutil.c .
   Fixed a documentation error about default filtering with 8-bit indexed-color.
   Separated the PNG_NO_STDIO macro into PNG_NO_STDIO and PNG_NO_CONSOLE_IO
     (L. Peter Deutsch).
   Added png_set_rgb_to_gray() and png_get_rgb_to_gray_status() functions.
   Added png_get_copyright() and png_get_header_version() functions.
   Revised comments on png_set_progressive_read_fn() in libpng.txt and example.c
   Added information about debugging in libpng.txt and libpng.3 .
-  Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and makefile.sco.
+  Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and
+    makefile.sco.
   Removed lines after Dynamic Dependencies" in makefile.aco .
   Revised makefile.dec to make a shared library (Jeremie Petit).
   Removed trailing blanks from all files.
-version 1.0.2a [January 6, 1999]
+
+Version 1.0.2a [January 6, 1999]
   Removed misplaced #endif and #ifdef PNG_NO_EXTERN near the end of png.h
   Added "if" tests to silence complaints about unused png_ptr in png.h and png.c
   Changed "check_if_png" function in example.c to return true (nonzero) if PNG.
   Changed libpng.txt to demonstrate png_sig_cmp() instead of png_check_sig()
     which is obsolete.
 
-version 1.0.3 [January 14, 1999]
+Version 1.0.3 [January 14, 1999]
   Added makefile.hux, for Hewlett Packard HPUX 10.20 and 11.00 (Jim Rice)
   Added a statement of Y2K compliance in png.h, libpng.3, and Y2KINFO.
-version 1.0.3a [August 12, 1999]
+
+Version 1.0.3a [August 12, 1999]
   Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning
      if an attempt is made to read an interlaced image when it's not supported.
   Added check if png_ptr->trans is defined before freeing it in pngread.c
   Modified the Y2K statement to include versions back to version 0.71
   Fixed a bug in the check for valid IHDR bit_depth/color_types in pngrutil.c
   Modified makefile.wat (added -zp8 flag, ".symbolic", changed some comments)
   Replaced leading blanks with tab characters in makefile.hux
   Changed "dworkin.wustl.edu" to "ccrc.wustl.edu" in various documents.
@@ -438,117 +460,131 @@ version 1.0.3a [August 12, 1999]
     user_depth, and user_channels into the png_struct, and a function
     png_get_user_transform_ptr() to retrieve the pointer (Chris Nokleberg)
   Added function png_set_empty_plte_permitted() to make libpng useable
     in MNG applications.
   Corrected the typedef for png_free_ptr in png.h (Jesse Jones).
   Correct gamma with srgb is 45455 instead of 45000 in pngrutil.c, to be
     consistent with PNG-1.2, and allow variance of 500 before complaining.
   Added assembler code contributed by Intel in file pngvcrd.c and modified
-    makefile.w32 to use it (Nirav Chhatrapati, INTEL Corporation, Gilles Vollant)
+    makefile.w32 to use it (Nirav Chhatrapati, INTEL Corporation,
+    Gilles Vollant)
   Changed "ln -s -f" to "ln -f -s" in the makefiles to make Solaris happy.
   Added some aliases for png_set_expand() in pngrtran.c, namely
     png_set_expand_PLTE(), png_set_expand_depth(), and png_set_expand_tRNS()
     (Greg Roelofs, in "PNG: The Definitive Guide").
   Added makefile.beo for BEOS on X86, contributed by Sander Stok.
-version 1.0.3b [August 26, 1999]
+
+Version 1.0.3b [August 26, 1999]
   Replaced 2147483647L several places with PNG_MAX_UINT macro, defined in png.h
   Changed leading blanks to tabs in all makefiles.
   Define PNG_USE_PNGVCRD in makefile.w32, to get MMX assembler code.
   Made alternate versions of  png_set_expand() in pngrtran.c, namely
     png_set_gray_1_2_4_to_8, png_set_palette_to_rgb, and png_set_tRNS_to_alpha
     (Greg Roelofs, in "PNG: The Definitive Guide").  Deleted the 1.0.3a aliases.
   Relocated start of 'extern "C"' block in png.h so it doesn't include pngconf.h
   Revised calculation of num_blocks in pngmem.c to avoid a potentially
     negative shift distance, whose results are undefined in the C language.
   Added a check in pngset.c to prevent writing multiple tIME chunks.
   Added a check in pngwrite.c to detect invalid small window_bits sizes.
-version 1.0.3d [September 4, 1999]
+
+Version 1.0.3d [September 4, 1999]
   Fixed type casting of igamma in pngrutil.c
   Added new png_expand functions to scripts/pngdef.pas and pngos2.def
   Added a demo read_user_transform_fn that examines the row filters in pngtest.c
 
-version 1.0.4 [September 24, 1999]
+Version 1.0.4 [September 24, 1999]
   Define PNG_ALWAYS_EXTERN in pngconf.h if __STDC__ is defined
   Delete #define PNG_INTERNAL and include "png.h" from pngasmrd.h
   Made several minor corrections to pngtest.c
   Renamed the makefiles with longer but more user friendly extensions.
   Copied the PNG copyright and license to a separate LICENSE file.
   Revised documentation, png.h, and example.c to remove reference to
     "viewing_gamma" which no longer appears in the PNG specification.
   Revised pngvcrd.c to use MMX code for interlacing only on the final pass.
   Updated pngvcrd.c to use the faster C filter algorithms from libpng-1.0.1a
   Split makefile.win32vc into two versions, makefile.vcawin32 (uses MMX
     assembler code) and makefile.vcwin32 (doesn't).
   Added a CPU timing report to pngtest.c (enabled by defining PNGTEST_TIMING)
   Added a copy of pngnow.png to the distribution.
-version 1.0.4a [September 25, 1999]
+
+Version 1.0.4a [September 25, 1999]
   Increase max_pixel_depth in pngrutil.c if a user transform needs it.
   Changed several division operations to right-shifts in pngvcrd.c
-version 1.0.4b [September 30, 1999]
+
+Version 1.0.4b [September 30, 1999]
   Added parentheses in line 3732 of pngvcrd.c
   Added a comment in makefile.linux warning about buggy -O3 in pgcc 2.95.1
-version 1.0.4c [October 1, 1999]
+
+Version 1.0.4c [October 1, 1999]
   Added a "png_check_version" function in png.c and pngtest.c that will generate
     a helpful compiler error if an old png.h is found in the search path.
   Changed type of png_user_transform_depth|channels from int to png_byte.
-version 1.0.4d [October 6, 1999]
+
+Version 1.0.4d [October 6, 1999]
   Changed 0.45 to 0.45455 in png_set_sRGB()
   Removed unused PLTE entries from pngnow.png
   Re-enabled some parts of pngvcrd.c (png_combine_row) that work properly.
-version 1.0.4e [October 10, 1999]
+
+Version 1.0.4e [October 10, 1999]
   Fixed sign error in pngvcrd.c (Greg Roelofs)
   Replaced some instances of memcpy with simple assignments in pngvcrd (GR-P)
-version 1.0.4f [October 15, 1999]
+
+Version 1.0.4f [October 15, 1999]
   Surrounded example.c code with #if 0 .. #endif to prevent people from
     inadvertently trying to compile it.
   Changed png_get_header_version() from a function to a macro in png.h
   Added type casting mostly in pngrtran.c and pngwtran.c
   Removed some pointless "ptr = NULL" in pngmem.c
   Added a "contrib" directory containing the source code from Greg's book.
 
-version 1.0.5 [October 15, 1999]
+Version 1.0.5 [October 15, 1999]
   Minor editing of the INSTALL and README files.
-version 1.0.5a [October 23, 1999]
+
+Version 1.0.5a [October 23, 1999]
   Added contrib/pngsuite and contrib/pngminus (Willem van Schaik)
   Fixed a typo in the png_set_sRGB() function call in example.c (Jan Nijtmans)
   Further optimization and bugfix of pngvcrd.c
   Revised pngset.c so that it does not allocate or free memory in the user's
     text_ptr structure.  Instead, it makes its own copy.
   Created separate write_end_info_struct in pngtest.c for a more severe test.
   Added code in pngwrite.c to free info_ptr->text[i].key to stop a memory leak.
-version 1.0.5b [November 23, 1999]
+
+Version 1.0.5b [November 23, 1999]
   Moved PNG_FLAG_HAVE_CHUNK_HEADER, PNG_FLAG_BACKGROUND_IS_GRAY and
     PNG_FLAG_WROTE_tIME from flags to mode.
   Added png_write_info_before_PLTE() function.
   Fixed some typecasting in contrib/gregbook/*.c
   Updated scripts/makevms.com and added makevms.com to contrib/gregbook
     and contrib/pngminus (Martin Zinser)
-version 1.0.5c [November 26, 1999]
+
+Version 1.0.5c [November 26, 1999]
   Moved png_get_header_version from png.h to png.c, to accommodate ansi2knr.
   Removed all global arrays (according to PNG_NO_GLOBAL_ARRAYS macro), to
     accommodate making DLL's: Moved usr_png_ver from global variable to function
     png_get_header_ver() in png.c.  Moved png_sig to png_sig_bytes in png.c and
     eliminated use of png_sig in pngwutil.c.  Moved the various png_CHNK arrays
     into pngtypes.h.  Eliminated use of global png_pass arrays.  Declared the
     png_CHNK and png_pass arrays to be "const".  Made the global arrays
     available to applications (although none are used in libpng itself) when
     PNG_NO_GLOBAL_ARRAYS is not defined or when PNG_GLOBAL_ARRAYS is defined.
   Removed some extraneous "-I" from contrib/pngminus/makefile.std
   Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2.
   Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3
-version 1.0.5d [November 29, 1999]
+
+Version 1.0.5d [November 29, 1999]
   Add type cast (png_const_charp) two places in png.c
   Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays.
   Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available
     to applications a macro "PNG_USE_LOCAL_ARRAYS".
   comment out (with #ifdef) all the new declarations when
     PNG_USE_GLOBAL_ARRAYS is defined.
   Added PNG_EXPORT_VAR macro to accommodate making DLL's.
-version 1.0.5e [November 30, 1999]
+
+Version 1.0.5e [November 30, 1999]
   Added iCCP, iTXt, and sPLT support; added "lang" member to the png_text
     structure; refactored the inflate/deflate support to make adding new chunks
     with trailing compressed parts easier in the future, and added new functions
     png_free_iCCP, png_free_pCAL, png_free_sPLT, png_free_text, png_get_iCCP,
     png_get_spalettes, png_set_iCCP, png_set_spalettes (Eric S. Raymond).
   NOTE: Applications that write text chunks MUST define png_text->lang
     before calling png_set_text(). It must be set to NULL if you want to
     write tEXt or zTXt chunks.  If you want your application to be able to
@@ -559,101 +595,115 @@ version 1.0.5e [November 30, 1999]
       #endif
 
   Changed png_get_oFFs() and png_set_oFFs() to use signed rather than unsigned
     offsets (Eric S. Raymond).
   Combined PNG_READ_cHNK_SUPPORTED and PNG_WRITE_cHNK_SUPPORTED macros into
     PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED
     macros, leaving the separate macros also available.
   Removed comments on #endifs at the end of many short, non-nested #if-blocks.
-version 1.0.5f [December 6, 1999]
+
+Version 1.0.5f [December 6, 1999]
   Changed makefile.solaris to issue a warning about potential problems when
     the ucb "ld" is in the path ahead of the ccs "ld".
   Removed "- [date]" from the "synopsis" line in libpng.3 and libpngpf.3.
   Added sCAL chunk support (Eric S. Raymond).
-version 1.0.5g [December 7, 1999]
+
+Version 1.0.5g [December 7, 1999]
   Fixed "png_free_spallettes" typo in png.h
   Added code to handle new chunks in pngpread.c
   Moved PNG_CHNK string macro definitions outside of PNG_NO_EXTERN block
   Added "translated_key" to png_text structure and png_write_iTXt().
   Added code in pngwrite.c to work around a newly discovered zlib bug.
-version 1.0.5h [December 10, 1999]
+
+Version 1.0.5h [December 10, 1999]
   NOTE: regarding the note for version 1.0.5e, the following must also
     be included in your code:
         png_text[i].translated_key = NULL;
   Unknown chunk handling is now supported.
   Option to eliminate all floating point support was added.  Some new
     fixed-point functions such as png_set_gAMA_fixed() were added.
   Expanded tabs and removed trailing blanks in source files.
-version 1.0.5i [December 13, 1999]
+
+Version 1.0.5i [December 13, 1999]
   Added some type casts to silence compiler warnings.
   Renamed "png_free_spalette" to "png_free_spalettes" for consistency.
   Removed leading blanks from a #define in pngvcrd.c
   Added some parameters to the new png_set_keep_unknown_chunks() function.
   Added a test for up->location != 0 in the first instance of writing
     unknown chunks in pngwrite.c
   Changed "num" to "i" in png_free_spalettes() and png_free_unknowns() to
     prevent recursion.
   Added png_free_hIST() function.
   Various patches to fix bugs in the sCAL and integer cHRM processing,
     and to add some convenience macros for use with sCAL.
-version 1.0.5j [December 21, 1999]
+
+Version 1.0.5j [December 21, 1999]
   Changed "unit" parameter of png_write_sCAL from png_byte to int, to work
     around buggy compilers.
   Added new type "png_fixed_point" for integers that hold float*100000 values
   Restored backward compatibility of tEXt/zTXt chunk processing:
     Restored the first four members of png_text to the same order as v.1.0.5d.
     Added members "lang_key" and "itxt_length" to png_text struct.  Set
     text_length=0 when "text" contains iTXt data.  Use the "compression"
     member to distinguish among tEXt/zTXt/iTXt types.  Added
     PNG_ITXT_COMPRESSION_NONE (1) and PNG_ITXT_COMPRESSION_zTXt(2) macros.
     The "Note" above, about backward incompatibility of libpng-1.0.5e, no
     longer applies.
   Fixed png_read|write_iTXt() to read|write parameters in the right order,
     and to write the iTXt chunk after IDAT if it appears in the end_ptr.
   Added pnggccrd.c, version of pngvcrd.c Intel assembler for gcc (Greg Roelofs)
   Reversed the order of trying to write floating-point and fixed-point gAMA.
-version 1.0.5k [December 27, 1999]
+
+Version 1.0.5k [December 27, 1999]
   Added many parentheses, e.g., "if (a && b & c)" becomes "if (a && (b & c))"
   Added png_handle_as_unknown() function (Glenn)
   Added png_free_chunk_list() function and chunk_list and num_chunk_list members
     of png_ptr.
   Eliminated erroneous warnings about multiple sPLT chunks and sPLT-after-PLTE.
   Fixed a libpng-1.0.5h bug in pngrutil.c that was issuing erroneous warnings
     about ignoring incorrect gAMA with sRGB (gAMA was in fact not ignored)
   Added png_free_tRNS(); png_set_tRNS() now malloc's its own trans array (ESR).
   Define png_get_int_32 when oFFs chunk is supported as well as when pCAL is.
   Changed type of proflen from png_int_32 to png_uint_32 in png_get_iCCP().
-version 1.0.5l [January 1, 2000]
+
+Version 1.0.5l [January 1, 2000]
   Added functions png_set_read_user_chunk_fn() and png_get_user_chunk_ptr()
     for setting a callback function to handle unknown chunks and for
     retrieving the associated user pointer (Glenn).
-version 1.0.5m [January 7, 2000]
+
+Version 1.0.5m [January 7, 2000]
   Added high-level functions png_read_png(), png_write_png(), png_free_pixels().
-version 1.0.5n [January 9, 2000]
+
+Version 1.0.5n [January 9, 2000]
   Added png_free_PLTE() function, and modified png_set_PLTE() to malloc its
     own memory for info_ptr->palette.  This makes it safe for the calling
     application to free its copy of the palette any time after it calls
     png_set_PLTE().
-version 1.0.5o [January 20, 2000]
+
+Version 1.0.5o [January 20, 2000]
   Cosmetic changes only (removed some trailing blanks and TABs)
-version 1.0.5p [January 31, 2000]
+
+Version 1.0.5p [January 31, 2000]
   Renamed pngdll.mak to makefile.bd32
   Cosmetic changes in pngtest.c
-version 1.0.5q [February 5, 2000]
+
+Version 1.0.5q [February 5, 2000]
   Relocated the makefile.solaris warning about PATH problems.
   Fixed pngvcrd.c bug by pushing/popping registers in mmxsupport (Bruce Oberg)
   Revised makefile.gcmmx
   Added PNG_SETJMP_SUPPORTED, PNG_SETJMP_NOT_SUPPORTED, and PNG_ABORT() macros
-version 1.0.5r [February 7, 2000]
+
+Version 1.0.5r [February 7, 2000]
   Removed superfluous prototype for png_get_itxt from png.h
   Fixed a bug in pngrtran.c that improperly expanded the background color.
   Return *num_text=0 from png_get_text() when appropriate, and fix documentation
     of png_get_text() in libpng.txt/libpng.3.
-version 1.0.5s [February 18, 2000]
+
+Version 1.0.5s [February 18, 2000]
   Added "png_jmp_env()" macro to pngconf.h, to help people migrate to the
     new error handler that's planned for the next libpng release, and changed
     example.c, pngtest.c, and contrib programs to use this macro.
   Revised some of the DLL-export macros in pngconf.h (Greg Roelofs)
   Fixed a bug in png_read_png() that caused it to fail to expand some images
     that it should have expanded.
   Fixed some mistakes in the unused and undocumented INCH_CONVERSIONS functions
     in pngget.c
@@ -662,81 +712,90 @@ version 1.0.5s [February 18, 2000]
     backward compatibility with version 1.0.5.  Added some remarks about
     that in example.c.  Added "free_me" member to info_ptr and png_ptr
     and added png_free_data() function.
   Updated makefile.linux and makefile.gccmmx to make directories conditionally.
   Made cosmetic changes to pngasmrd.h
   Added png_set_rows() and png_get_rows(), for use with png_read|write_png().
   Modified png_read_png() to allocate info_ptr->row_pointers only if it
     hasn't already been allocated.
-version 1.0.5t [March 4, 2000]
+
+Version 1.0.5t [March 4, 2000]
   Changed png_jmp_env() migration aiding macro to png_jmpbuf().
   Fixed "interlace" typo (should be "interlaced") in contrib/gregbook/read2-x.c
   Fixed bug with use of PNG_BEFORE_IHDR bit in png_ptr->mode, introduced when
     PNG_FLAG_HAVE_CHUNK_HEADER was moved into png_ptr->mode in version 1.0.5b
   Files in contrib/gregbook were revised to use png_jmpbuf() and to select
     a 24-bit visual if one is available, and to allow abbreviated options.
   Files in contrib/pngminus were revised to use the png_jmpbuf() macro.
   Removed spaces in makefile.linux and makefile.gcmmx, introduced in 1.0.5s
-version 1.0.5u [March 5, 2000]
+
+Version 1.0.5u [March 5, 2000]
   Simplified the code that detects old png.h in png.c and pngtest.c
   Renamed png_spalette (_p, _pp) to png_sPLT_t (_tp, _tpp)
   Increased precision of rgb_to_gray calculations from 8 to 15 bits and
     added png_set_rgb_to_gray_fixed() function.
   Added makefile.bc32 (32-bit Borland C++, C mode)
-version 1.0.5v [March 11, 2000]
+
+Version 1.0.5v [March 11, 2000]
   Added some parentheses to the png_jmpbuf macro definition.
   Updated references to the zlib home page, which has moved to freesoftware.com.
   Corrected bugs in documentation regarding png_read_row() and png_write_row().
   Updated documentation of png_rgb_to_gray calculations in libpng.3/libpng.txt.
   Renamed makefile.borland,turboc3 back to makefile.bor,tc3 as in version 1.0.3,
     revised borland makefiles; added makefile.ibmvac3 and makefile.gcc (Cosmin)
 
-version 1.0.6 [March 20, 2000]
+Version 1.0.6 [March 20, 2000]
   Minor revisions of makefile.bor, libpng.txt, and gregbook/rpng2-win.c
   Added makefile.sggcc (SGI IRIX with gcc)
-version 1.0.6d [April 7, 2000]
+
+Version 1.0.6d [April 7, 2000]
   Changed sprintf() to strcpy() in png_write_sCAL_s() to work without STDIO
   Added data_length parameter to png_decompress_chunk() function
   Revised documentation to remove reference to abandoned png_free_chnk functions
   Fixed an error in png_rgb_to_gray_fixed()
   Revised example.c, usage of png_destroy_write_struct().
   Renamed makefile.ibmvac3 to makefile.ibmc, added libpng.icc IBM project file
   Added a check for info_ptr->free_me&PNG_FREE_TEXT when freeing text in png.c
   Simplify png_sig_bytes() function to remove use of non-ISO-C strdup().
-version 1.0.6e [April 9, 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)
   Minor revisions of libpng.txt/libpng.3.
   Check for existing data and free it if the free_me flag is set, in png_set_*()
     and png_handle_*().
   Only define PNG_WEIGHTED_FILTERS_SUPPORTED when PNG_FLOATING_POINT_SUPPORTED
     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.
-version 1.0.6f [April 14, 2000]
+
+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 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]
+
+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).
-version 1.0.6h [April 24, 2000]
+
+Version 1.0.6h [April 24, 2000]
   Changed shared library so-number pattern from 2.x.y.z to xy.z (this builds
     libpng.so.10 & libpng.so.10.6h instead of libpng.so.2 & libpng.so.2.1.0.6h)
     This is a temporary change for test purposes.
-version 1.0.6i [May 2, 2000]
+
+Version 1.0.6i [May 2, 2000]
   Rearranged some members at the end of png_info and png_struct, to put
     unknown_chunks_num and free_me within the original size of the png_structs
     and free_me, png_read_user_fn, and png_free_fn within the original png_info,
     because some old applications allocate the structs directly instead of
     using png_create_*().
   Added documentation of user memory functions in libpng.txt/libpng.3
   Modified png_read_png so that it will use user_allocated row_pointers
     if present, unless free_me directs that it be freed, and added description
@@ -751,118 +810,134 @@ version 1.0.6i [May 2, 2000]
     directly as authors were instructed to do in libpng-0.88 and earlier,
     instead of using png_create_*().
   Added modes PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT which
     can be used to detect codes that directly allocate the structs, and
     code to check these modes in png_read_init() and png_write_init() and
     generate a libpng error if the modes aren't set and PNG_LEGACY_SUPPORTED
     was not defined.
   Added makefile.intel and updated makefile.watcom (Pawel Mrochen)
-version 1.0.6j [May 3, 2000]
+
+Version 1.0.6j [May 3, 2000]
   Overloaded png_read_init() and png_write_init() with macros that convert
     calls to png_read_init_2() or png_write_init_2() that check the version
     and structure sizes.
-version 1.0.7beta11 [May 7, 2000]
+
+Version 1.0.7beta11 [May 7, 2000]
   Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes
     which are no longer used.
   Eliminated the three new members of png_text when PNG_LEGACY_SUPPORTED is
     defined or when neither PNG_READ_iTXt_SUPPORTED nor PNG_WRITE_iTXT_SUPPORTED
     is defined.
   Made PNG_NO_READ|WRITE_iTXt the default setting, to avoid memory
     overrun when old applications fill the info_ptr->text structure directly.
   Added PNGAPI macro, and added it to the definitions of all exported functions.
   Relocated version macro definitions ahead of the includes of zlib.h and
     pngconf.h in png.h.
-version 1.0.7beta12 [May 12, 2000]
+
+Version 1.0.7beta12 [May 12, 2000]
   Revised pngset.c to avoid a problem with expanding the png_debug macro.
   Deleted some extraneous defines from pngconf.h
   Made PNG_NO_CONSOLE_IO the default condition when PNG_BUILD_DLL is defined.
   Use MSC _RPTn debugging instead of fprintf if _MSC_VER is defined.
   Added png_access_version_number() function.
   Check for mask&PNG_FREE_CHNK (for TEXT, SCAL, PCAL) in png_free_data().
   Expanded libpng.3/libpng.txt information about png_data_freer().
-version 1.0.7beta14 [May 17, 2000] (beta13 was not published)
+
+Version 1.0.7beta14 [May 17, 2000] (beta13 was not published)
   Changed pnggccrd.c and pngvcrd.c to handle bad adaptive filter types as
     warnings instead of errors, as pngrutil.c does.
   Set the PNG_INFO_IDAT valid flag in png_set_rows() so png_write_png()
     will actually write IDATs.
   Made the default PNG_USE_LOCAL_ARRAYS depend on PNG_DLL instead of WIN32.
   Make png_free_data() ignore its final parameter except when freeing data
     that can have multiple instances (text, sPLT, unknowns).
   Fixed a new bug in png_set_rows().
   Removed info_ptr->valid tests from png_free_data(), as in version 1.0.5.
   Added png_set_invalid() function.
   Fixed incorrect illustrations of png_destroy_write_struct() in example.c.
-version 1.0.7beta15 [May 30, 2000]
+
+Version 1.0.7beta15 [May 30, 2000]
   Revised the deliberately erroneous Linux setjmp code in pngconf.h to produce
     fewer error messages.
   Rearranged checks for Z_OK to check the most likely path first in pngpread.c
     and pngwutil.c.
   Added checks in pngtest.c for png_create_*() returning NULL, and mentioned
     in libpng.txt/libpng.3 the need for applications to check this.
   Changed names of png_default_*() functions in pngtest to pngtest_*().
   Changed return type of png_get_x|y_offset_*() from png_uint_32 to png_int_32.
   Fixed some bugs in the unused PNG_INCH_CONVERSIONS functions in pngget.c
   Set each pointer to NULL after freeing it in png_free_data().
   Worked around a problem in pngconf.h; AIX's strings.h defines an "index"
-    macro that conflicts with libpng's png_color_16.index. (Dimitri Papadapoulos)
+    macro that conflicts with libpng's png_color_16.index. (Dimitri
+    Papadapoulos)
   Added "msvc" directory with MSVC++ project files (Simon-Pierre Cadieux).
-version 1.0.7beta16 [June 4, 2000]
+
+Version 1.0.7beta16 [June 4, 2000]
   Revised the workaround of AIX string.h "index" bug.
   Added a check for overlength PLTE chunk in pngrutil.c.
   Added PNG_NO_POINTER_INDEXING macro to use array-indexing instead of pointer
     indexing in pngrutil.c and pngwutil.c to accommodate a buggy compiler.
   Added a warning in png_decompress_chunk() when it runs out of data, e.g.
     when it tries to read an erroneous PhotoShop iCCP chunk.
   Added PNG_USE_DLL macro.
   Revised the copyright/disclaimer/license notice.
   Added contrib/msvctest directory
-version 1.0.7rc1 [June 9, 2000]
+
+Version 1.0.7rc1 [June 9, 2000]
   Corrected the definition of PNG_TRANSFORM_INVERT_ALPHA  (0x0400 not 0x0200)
   Added contrib/visupng directory (Willem van Schaik)
-version 1.0.7beta18 [June 23, 2000]
+
+Version 1.0.7beta18 [June 23, 2000]
   Revised PNGAPI definition, and pngvcrd.c to work with __GCC__
     and do not redefine PNGAPI if it is passed in via a compiler directive.
   Revised visupng/PngFile.c to remove returns from within the Try block.
   Removed leading underscores from "_PNG_H" and "_PNG_SAVE_BSD_SOURCE" macros.
   Updated contrib/visupng/cexcept.h to version 1.0.0.
   Fixed bugs in pngwrite.c and pngwutil.c that prevented writing iCCP chunks.
-version 1.0.7rc2 [June 28, 2000]
+
+Version 1.0.7rc2 [June 28, 2000]
   Updated license to include disclaimers required by UCITA.
   Fixed "DJBPP" typo in pnggccrd.c introduced in beta18.
 
-version 1.0.7 [July 1, 2000]
+Version 1.0.7 [July 1, 2000]
   Revised the definition of "trans_values" in libpng.3/libpng.txt
-version 1.0.8beta1 [July 8, 2000]
+
+Version 1.0.8beta1 [July 8, 2000]
   Added png_free(png_ptr, key) two places in pngpread.c to stop memory leaks.
   Changed PNG_NO_STDIO to PNG_NO_CONSOLE_IO, several places in pngrutil.c and
      pngwutil.c.
   Changed PNG_EXPORT_VAR to use PNG_IMPEXP, in pngconf.h.
   Removed unused "#include <assert.h>" from png.c
   Added WindowsCE support.
   Revised pnggccrd.c to work with gcc-2.95.2 and in the Cygwin environment.
-version 1.0.8beta2 [July 10, 2000]
+
+Version 1.0.8beta2 [July 10, 2000]
   Added project files to the wince directory and made further revisions
      of pngtest.c, pngrio.c, and pngwio.c in support of WindowsCE.
-version 1.0.8beta3 [July 11, 2000]
+
+Version 1.0.8beta3 [July 11, 2000]
   Only set the PNG_FLAG_FREE_TRNS or PNG_FREE_TRNS flag in png_handle_tRNS()
      for indexed-color input files to avoid potential double-freeing trans array
      under some unusual conditions; problem was introduced in version 1.0.6f.
   Further revisions to pngtest.c and files in the wince subdirectory.
-version 1.0.8beta4 [July 14, 2000]
+
+Version 1.0.8beta4 [July 14, 2000]
   Added the files pngbar.png and pngbar.jpg to the distribution.
   Added makefile.cygwin, and cygwin support in pngconf.h
   Added PNG_NO_ZALLOC_ZERO macro (makes png_zalloc skip zeroing memory)
-version 1.0.8rc1 [July 16, 2000]
+
+Version 1.0.8rc1 [July 16, 2000]
   Revised png_debug() macros and statements to eliminate compiler warnings.
 
-version 1.0.8 [July 24, 2000]
+Version 1.0.8 [July 24, 2000]
   Added png_flush() in pngwrite.c, after png_write_IEND().
   Updated makefile.hpux to build a shared library.
-version 1.0.9beta1 [November 10, 2000]
+
+Version 1.0.9beta1 [November 10, 2000]
   Fixed typo in scripts/makefile.hpux
   Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser)
   Fixed seqence-point bug in contrib/pngminus/png2pnm (Martin Zinser)
   Changed "cdrom.com" in documentation to "libpng.org"
   Revised pnggccrd.c to get it all working, and updated makefile.gcmmx (Greg).
   Changed type of "params" from voidp to png_voidp in png_read|write_png().
   Make sure PNGAPI and PNG_IMPEXP are defined in pngconf.h.
   Revised the 3 instances of WRITEFILE in pngtest.c.
@@ -871,370 +946,437 @@ version 1.0.9beta1 [November 10, 2000]
   Revised makefile.dec to define and use LIBPATH and INCPATH
   Increased size of global png_libpng_ver[] array from 12 to 18 chars.
   Made global png_libpng_ver[], png_sig[] and png_pass_*[] arrays const.
   Removed duplicate png_crc_finish() from png_handle_bKGD() function.
   Added a warning when application calls png_read_update_info() multiple times.
   Revised makefile.cygwin
   Fixed bugs in iCCP support in pngrutil.c and pngwutil.c.
   Replaced png_set_empty_plte_permitted() with png_permit_mng_features().
-version 1.0.9beta2 [November 19, 2000]
+
+Version 1.0.9beta2 [November 19, 2000]
   Renamed the "dll" subdirectory "projects".
   Added borland project files to "projects" subdirectory.
   Set VS_FF_PRERELEASE and VS_FF_PATCHED flags in msvc/png.rc when appropriate.
   Add error message in png_set_compression_buffer_size() when malloc fails.
-version 1.0.9beta3 [November 23, 2000]
+
+Version 1.0.9beta3 [November 23, 2000]
   Revised PNG_LIBPNG_BUILD_TYPE macro in png.h, used in the msvc project.
   Removed the png_flush() in pngwrite.c that crashes some applications
     that don't set png_output_flush_fn.
   Added makefile.macosx and makefile.aix to scripts directory.
-version 1.0.9beta4 [December 1, 2000]
+
+Version 1.0.9beta4 [December 1, 2000]
   Change png_chunk_warning to png_warning in png_check_keyword().
   Increased the first part of msg buffer from 16 to 18 in png_chunk_error().
-version 1.0.9beta5 [December 15, 2000]
+
+Version 1.0.9beta5 [December 15, 2000]
   Added support for filter method 64 (for PNG datastreams embedded in MNG).
-version 1.0.9beta6 [December 18, 2000]
+
+Version 1.0.9beta6 [December 18, 2000]
   Revised png_set_filter() to accept filter method 64 when appropriate.
   Added new PNG_HAVE_PNG_SIGNATURE bit to png_ptr->mode and use it to
     help prevent applications from using MNG features in PNG datastreams.
   Added png_permit_mng_features() function.
   Revised libpng.3/libpng.txt.  Changed "filter type" to "filter method".
-version 1.0.9rc1 [December 23, 2000]
+
+Version 1.0.9rc1 [December 23, 2000]
   Revised test for PNG_HAVE_PNG_SIGNATURE in pngrutil.c
   Fixed error handling of unknown compression type in png_decompress_chunk().
   In pngconf.h, define __cdecl when _MSC_VER is defined.
-version 1.0.9beta7 [December 28, 2000]
+
+Version 1.0.9beta7 [December 28, 2000]
   Changed PNG_TEXT_COMPRESSION_zTXt to PNG_COMPRESSION_TYPE_BASE several places.
   Revised memory management in png_set_hIST and png_handle_hIST in a backward
     compatible manner.  PLTE and tRNS were revised similarly.
   Revised the iCCP chunk reader to ignore trailing garbage.
-version 1.0.9beta8 [January 12, 2001]
+
+Version 1.0.9beta8 [January 12, 2001]
   Moved pngasmrd.h into pngconf.h.
   Improved handling of out-of-spec garbage iCCP chunks generated by PhotoShop.
-version 1.0.9beta9 [January 15, 2001]
+
+Version 1.0.9beta9 [January 15, 2001]
   Added png_set_invalid, png_permit_mng_features, and png_mmx_supported to
     wince and msvc project module definition files.
   Minor revision of makefile.cygwin.
   Fixed bug with progressive reading of narrow interlaced images in pngpread.c
-version 1.0.9beta10 [January 16, 2001]
+
+Version 1.0.9beta10 [January 16, 2001]
   Do not typedef png_FILE_p in pngconf.h when PNG_NO_STDIO is defined.
   Fixed "png_mmx_supported" typo in project definition files.
-version 1.0.9beta11 [January 19, 2001]
+
+Version 1.0.9beta11 [January 19, 2001]
   Updated makefile.sgi to make shared library.
   Removed png_mmx_support() function and disabled PNG_MNG_FEATURES_SUPPORTED
     by default, for the benefit of DLL forward compatibility.  These will
     be re-enabled in version 1.2.0.
-version 1.0.9rc2 [January 22, 2001]
+
+Version 1.0.9rc2 [January 22, 2001]
   Revised cygwin support.
 
-version 1.0.9 [January 31, 2001]
+Version 1.0.9 [January 31, 2001]
   Added check of cygwin's ALL_STATIC in pngconf.h
   Added "-nommx" parameter to contrib/gregbook/rpng2-win and rpng2-x demos.
-version 1.0.10beta1 [March 14, 2001]
+
+Version 1.0.10beta1 [March 14, 2001]
   Revised makefile.dec, makefile.sgi, and makefile.sggcc; added makefile.hpgcc.
   Reformatted libpng.3 to eliminate bad line breaks.
   Added checks for _mmx_supported in the read_filter_row function of pnggccrd.c
   Added prototype for png_mmx_support() near the top of pnggccrd.c
   Moved some error checking from png_handle_IHDR to png_set_IHDR.
   Added PNG_NO_READ_SUPPORTED and PNG_NO_WRITE_SUPPORTED macros.
   Revised png_mmx_support() function in pnggccrd.c
   Restored version 1.0.8 PNG_WRITE_EMPTY_PLTE_SUPPORTED behavior in pngwutil.c
   Fixed memory leak in contrib/visupng/PngFile.c
   Fixed bugs in png_combine_row() in pnggccrd.c and pngvcrd.c (C version)
   Added warnings when retrieving or setting gamma=0.
   Increased the first part of msg buffer from 16 to 18 in png_chunk_warning().
-version 1.0.10rc1 [March 23, 2001]
+
+Version 1.0.10rc1 [March 23, 2001]
   Changed all instances of memcpy, strcpy, and strlen to png_memcpy, png_strcpy,
     and png_strlen.
   Revised png_mmx_supported() function in pnggccrd.c to return proper value.
   Fixed bug in progressive reading (pngpread.c) with small images (height < 8).
 
-version 1.0.10 [March 30, 2001]
+Version 1.0.10 [March 30, 2001]
   Deleted extraneous space (introduced in 1.0.9) from line 42 of makefile.cygwin
   Added beos project files (Chris Herborth)
-version 1.0.11beta1 [April 3, 2001]
+
+Version 1.0.11beta1 [April 3, 2001]
   Added type casts on several png_malloc() calls (Dimitri Papadapoulos).
   Removed a no-longer needed AIX work-around from pngconf.h
   Changed several "//" single-line comments to C-style in pnggccrd.c
-version 1.0.11beta2 [April 11, 2001]
+
+Version 1.0.11beta2 [April 11, 2001]
   Removed PNGAPI from several functions whose prototypes did not have PNGAPI.
   Updated scripts/pngos2.def
-version 1.0.11beta3 [April 14, 2001]
+
+Version 1.0.11beta3 [April 14, 2001]
   Added checking the results of many instances of png_malloc() for NULL
-version 1.0.11beta4 [April 20, 2001]
+
+Version 1.0.11beta4 [April 20, 2001]
   Undid the changes from version 1.0.11beta3.  Added a check for NULL return
     from user's malloc_fn().
   Removed some useless type casts of the NULL pointer.
   Added makefile.netbsd
 
-version 1.0.11 [April 27, 2001]
+Version 1.0.11 [April 27, 2001]
   Revised makefile.netbsd
-version 1.0.12beta1 [May 14, 2001]
+
+Version 1.0.12beta1 [May 14, 2001]
   Test for Windows platform in pngconf.h when including malloc.h (Emmanuel Blot)
   Updated makefile.cygwin and handling of Cygwin's ALL_STATIC in pngconf.h
   Added some never-to-be-executed code in pnggccrd.c to quiet compiler warnings.
   Eliminated the png_error about apps using png_read|write_init().  Instead,
     libpng will reallocate the png_struct and info_struct if they are too small.
     This retains future binary compatibility for old applications written for
     libpng-0.88 and earlier.
-version 1.2.0beta1 [May 6, 2001]
+
+Version 1.2.0beta1 [May 6, 2001]
   Bumped DLLNUM to 2.
   Re-enabled PNG_MNG_FEATURES_SUPPORTED and enabled PNG_ASSEMBLER_CODE_SUPPORTED
     by default.
   Added runtime selection of MMX features.
   Added png_set_strip_error_numbers function and related macros.
-version 1.2.0beta2 [May 7, 2001]
+
+Version 1.2.0beta2 [May 7, 2001]
   Finished merging 1.2.0beta1 with version 1.0.11
   Added a check for attempts to read or write PLTE in grayscale PNG datastreams.
-version 1.2.0beta3 [May 17, 2001]
+
+Version 1.2.0beta3 [May 17, 2001]
   Enabled user memory function by default.
   Modified png_create_struct so it passes user mem_ptr to user memory allocator.
   Increased png_mng_features flag from png_byte to png_uint_32.
   Bumped shared-library (so-number) and dll-number to 3.
-version 1.2.0beta4 [June 23, 2001]
+
+Version 1.2.0beta4 [June 23, 2001]
   Check for missing profile length field in iCCP chunk and free chunk_data
      in case of truncated iCCP chunk.
   Bumped shared-library number to 3 in makefile.sgi and makefile.sggcc
   Bumped dll-number from 2 to 3 in makefile.cygwin
   Revised contrib/gregbook/rpng*-x.c to avoid a memory leak and to exit cleanly
      if user attempts to run it on an 8-bit display.
   Updated contrib/gregbook
   Use png_malloc instead of png_zalloc to allocate palette in pngset.c
   Updated makefile.ibmc
   Added some typecasts to eliminate gcc 3.0 warnings.  Changed prototypes
      of png_write_oFFS width and height from png_uint_32 to png_int_32.
   Updated example.c
   Revised prototypes for png_debug_malloc and png_debug_free in pngtest.c
-version 1.2.0beta5 [August 8, 2001]
+
+Version 1.2.0beta5 [August 8, 2001]
   Revised contrib/gregbook
   Revised makefile.gcmmx
   Revised pnggccrd.c to conditionally compile some thread-unsafe code only
      when PNG_THREAD_UNSAFE_OK is defined.
   Added tests to prevent pngwutil.c from writing a bKGD or tRNS chunk with
      value exceeding 2^bit_depth-1
   Revised makefile.sgi and makefile.sggcc
   Replaced calls to fprintf(stderr,...) with png_warning() in pnggccrd.c
   Removed restriction that do_invert_mono only operate on 1-bit opaque files
 
-version 1.2.0 [September 1, 2001]
+Version 1.2.0 [September 1, 2001]
   Changed a png_warning() to png_debug() in pnggccrd.c
   Fixed contrib/gregbook/rpng-x.c, rpng2-x.c to avoid crash with XFreeGC().
-version 1.2.1beta1 [October 19, 2001]
+
+Version 1.2.1beta1 [October 19, 2001]
   Revised makefile.std in contrib/pngminus
   Include background_1 in png_struct regardless of gamma support.
   Revised makefile.netbsd and makefile.macosx, added makefile.darwin.
   Revised example.c to provide more details about using row_callback().
-version 1.2.1beta2 [October 25, 2001]
+
+Version 1.2.1beta2 [October 25, 2001]
   Added type cast to each NULL appearing in a function call, except for
     WINCE functions.
   Added makefile.so9.
-version 1.2.1beta3 [October 27, 2001]
+
+Version 1.2.1beta3 [October 27, 2001]
   Removed type casts from all NULLs.
   Simplified png_create_struct_2().
-version 1.2.1beta4 [November 7, 2001]
+
+Version 1.2.1beta4 [November 7, 2001]
   Revised png_create_info_struct() and png_creat_struct_2().
   Added error message if png_write_info() was omitted.
   Type cast NULLs appearing in function calls when _NO_PROTO or
     PNG_TYPECAST_NULL is defined.
-version 1.2.1rc1 [November 24, 2001]
+
+Version 1.2.1rc1 [November 24, 2001]
   Type cast NULLs appearing in function calls except when PNG_NO_TYPECAST_NULL
     is defined.
   Changed typecast of "size" argument to png_size_t in pngmem.c calls to
     the user malloc_fn, to agree with the prototype in png.h
   Added a pop/push operation to pnggccrd.c, to preserve Eflag (Maxim Sobolev)
   Updated makefile.sgi to recognize LIBPATH and INCPATH.
   Updated various makefiles so "make clean" does not remove previous major
     version of the shared library.
-version 1.2.1rc2 [December 4, 2001]
+
+Version 1.2.1rc2 [December 4, 2001]
   Always allocate 256-entry internal palette, hist, and trans arrays, to
     avoid out-of-bounds memory reference caused by invalid PNG datastreams.
   Added a check for prefix_length > data_length in iCCP chunk handler.
 
-version 1.2.1 [December 7, 2001]
+Version 1.2.1 [December 7, 2001]
   None.
-version 1.2.2beta1 [February 22, 2002]
+
+Version 1.2.2beta1 [February 22, 2002]
   Fixed a bug with reading the length of iCCP profiles (Larry Reeves).
   Revised makefile.linux, makefile.gcmmx, and makefile.sgi to generate
     libpng.a, libpng12.so (not libpng.so.3), and libpng12/png.h
   Revised makefile.darwin to remove "-undefined suppress" option.
   Added checks for gamma and chromaticity values over 21474.83, which exceed
     the limit for PNG unsigned 32-bit integers when encoded.
   Revised calls to png_create_read_struct() and png_create_write_struct()
     for simpler debugging.
   Revised png_zalloc() so zlib handles errors (uses PNG_FLAG_MALLOC_NULL_MEM_OK)
-version 1.2.2beta2 [February 23, 2002]
+
+Version 1.2.2beta2 [February 23, 2002]
   Check chunk_length and idat_size for invalid (over PNG_MAX_UINT) lengths.
   Check for invalid image dimensions in png_get_IHDR.
   Added missing "fi;" in the install target of the SGI makefiles.
   Added install-static to all makefiles that make shared libraries.
   Always do gamma compensation when image is partially transparent.
-version 1.2.2beta3 [March 7, 2002]
+
+Version 1.2.2beta3 [March 7, 2002]
   Compute background.gray and background_1.gray even when color_type is RGB
     in case image gets reduced to gray later.
   Modified shared-library makefiles to install pkgconfig/libpngNN.pc.
   Export (with PNGAPI) png_zalloc, png_zfree, and png_handle_as_unknown
   Removed unused png_write_destroy_info prototype from png.h
   Eliminated incorrect use of width_mmx from pnggccrd.c in pixel_bytes == 8 case
   Added install-shared target to all makefiles that make shared libraries.
   Stopped a double free of palette, hist, and trans when not using free_me.
   Added makefile.32sunu for Sun Ultra 32 and makefile.64sunu for Sun Ultra 64.
-version 1.2.2beta4 [March 8, 2002]
+
+Version 1.2.2beta4 [March 8, 2002]
   Compute background.gray and background_1.gray even when color_type is RGB
     in case image gets reduced to gray later (Jason Summers).
   Relocated a misplaced /bin/rm in the "install-shared" makefile targets
   Added PNG_1_0_X macro which can be used to build a 1.0.x-compatible library.
-version 1.2.2beta5 [March 26, 2002]
+
+Version 1.2.2beta5 [March 26, 2002]
   Added missing PNGAPI to several function definitions.
   Check for invalid bit_depth or color_type in png_get_IHDR(), and
     check for missing PLTE or IHDR in png_push_read_chunk() (Matthias Clasen).
   Revised iTXt support to accept NULL for lang and lang_key.
   Compute gamma for color components of background even when color_type is gray.
   Changed "()" to "{}" in scripts/libpng.pc.in.
   Revised makefiles to put png.h and pngconf.h only in $prefix/include/libpngNN
   Revised makefiles to make symlink to libpng.so.NN in addition to libpngNN.so
-version 1.2.2beta6 [March 31, 2002]
-version 1.0.13beta1 [March 31, 2002]
+
+Version 1.2.2beta6 [March 31, 2002]
+
+Version 1.0.13beta1 [March 31, 2002]
   Prevent png_zalloc() from trying to memset memory that it failed to acquire.
   Add typecasts of PNG_MAX_UINT in pngset_cHRM_fixed() (Matt Holgate).
   Ensure that the right function (user or default) is used to free the
     png_struct after an error in png_create_read_struct_2().
-version 1.2.2rc1 [April 7, 2002]
-version 1.0.13rc1 [April 7, 2002]
+
+Version 1.2.2rc1 [April 7, 2002]
+
+Version 1.0.13rc1 [April 7, 2002]
   Save the ebx register in pnggccrd.c (Sami Farin)
   Add "mem_ptr = png_ptr->mem_ptr" in png_destroy_write_struct() (Paul Gardner).
   Updated makefiles to put headers in include/libpng and remove old include/*.h.
 
-version 1.2.2 [April 15, 2002]
-version 1.0.13 [April 15, 2002]
+Version 1.2.2 [April 15, 2002]
+
+Version 1.0.13 [April 15, 2002]
   Revised description of png_set_filter() in libpng.3/libpng.txt.
   Revised makefile.netbsd and added makefile.neNNbsd and makefile.freebsd
-version 1.0.13patch01 [April 17, 2002]
-version 1.2.2patch01 [April 17, 2002]
-  Changed ${PNGMAJ}.${PNGVER} bug to ${PNGVER} in makefile.sgi and makefile.sggcc
-  Fixed VER -> PNGVER typo in makefile.macosx and added install-static to install
+
+Version 1.0.13patch01 [April 17, 2002]
+
+Version 1.2.2patch01 [April 17, 2002]
+  Changed ${PNGMAJ}.${PNGVER} bug to ${PNGVER} in makefile.sgi and
+    makefile.sggcc
+  Fixed VER -> PNGVER typo in makefile.macosx and added install-static to
+    install
   Added install: target to makefile.32sunu and makefile.64sunu
-version 1.0.13patch03 [April 18, 2002]
-version 1.2.2patch03 [April 18, 2002]
+
+Version 1.0.13patch03 [April 18, 2002]
+
+Version 1.2.2patch03 [April 18, 2002]
   Revised 15 makefiles to link libpng.a to libpngNN.a and the include libpng
   subdirectory to libpngNN subdirectory without the full pathname.
   Moved generation of libpng.pc from "install" to "all" in 15 makefiles.
-version 1.2.3rc1 [April 28, 2002]
+
+Version 1.2.3rc1 [April 28, 2002]
   Added install-man target to 15 makefiles (Dimitri Papadopolous-Orfanos).
   Added $(DESTDIR) feature to 24 makefiles (Tim Mooney)
   Fixed bug with $prefix, should be $(prefix) in makefile.hpux.
   Updated cygwin-specific portion of pngconf.h and revised makefile.cygwin
   Added a link from libpngNN.pc to libpng.pc in 15 makefiles.
   Added links from include/libpngNN/*.h to include/*.h in 24 makefiles.
   Revised makefile.darwin to make relative links without full pathname.
   Added setjmp() at the end of png_create_*_struct_2() in case user forgets
     to put one in their application.
   Restored png_zalloc() and png_zfree() prototypes to version 1.2.1 and
     removed them from module definition files.
-version 1.2.3rc2 [May 1, 2002]
+
+Version 1.2.3rc2 [May 1, 2002]
   Fixed bug in reporting number of channels in pngget.c and pngset.c,
     that was introduced in version 1.2.2beta5.
   Exported png_zalloc(), png_zfree(), png_default_read(), png_default_write(),
     png_default_flush(), and png_push_fill_buffer() and included them in
     module definition files.
   Added "libpng.pc" dependency to the "install-shared" target in 15 makefiles.
-version 1.2.3rc3 [May 1, 2002]
+
+Version 1.2.3rc3 [May 1, 2002]
   Revised prototype for png_default_flush()
   Remove old libpng.pc and libpngNN.pc before installing new ones.
-version 1.2.3rc4 [May 2, 2002]
+
+Version 1.2.3rc4 [May 2, 2002]
   Typos in *.def files (png_default_read|write -> png_default_read|write_data)
   In makefiles, changed rm libpng.NN.pc to rm libpngNN.pc
-  Added libpng-config and libpngNN-config and modified makefiles to install them.
+  Added libpng-config and libpngNN-config and modified makefiles to install
+    them.
   Changed $(MANPATH) to $(DESTDIR)$(MANPATH) in makefiles
   Added "Win32 DLL VB" configuration to projects/msvc/libpng.dsp
-version 1.2.3rc5 [May 11, 2002]
+
+Version 1.2.3rc5 [May 11, 2002]
   Changed "error" and "message" in prototypes to "error_message" and
     "warning_message" to avoid namespace conflict.
   Revised 15 makefiles to build libpng-config from libpng-config-*.in
   Once more restored png_zalloc and png_zfree to regular nonexported form.
   Restored png_default_read|write_data, png_default_flush, png_read_fill_buffer
-    to nonexported form, but with PNGAPI, and removed them from module def files.
-version 1.2.3rc6 [May 14, 2002]
+    to nonexported form, but with PNGAPI, and removed them from module def
+    files.
+
+Version 1.2.3rc6 [May 14, 2002]
   Removed "PNGAPI" from png_zalloc() and png_zfree() in png.c
   Changed "Gz" to "Gd" in projects/msvc/libpng.dsp and zlib.dsp.
   Removed leftover libpng-config "sed" script from four makefiles.
   Revised libpng-config creating script in 16 makefiles.
 
-version 1.2.3 [May 22, 2002]
+Version 1.2.3 [May 22, 2002]
   Revised libpng-config target in makefile.cygwin.
   Removed description of png_set_mem_fn() from documentation.
   Revised makefile.freebsd.
   Minor cosmetic changes to 15 makefiles, e.g., $(DI) = $(DESTDIR)/$(INCDIR).
   Revised projects/msvc/README.txt
   Changed -lpng to -lpngNN in LDFLAGS in several makefiles.
-version 1.2.4beta1 [May 24, 2002]
+
+Version 1.2.4beta1 [May 24, 2002]
   Added libpng.pc and libpng-config to "all:" target in 16 makefiles.
   Fixed bug in 16 makefiles: $(DESTDIR)/$(LIBPATH) to $(DESTDIR)$(LIBPATH)
   Added missing "\" before closing double quote in makefile.gcmmx.
   Plugged various memory leaks; added png_malloc_warn() and png_set_text_2()
     functions.
-version 1.2.4beta2 [June 25, 2002]
+
+Version 1.2.4beta2 [June 25, 2002]
   Plugged memory leak of png_ptr->current_text (Matt Holgate).
   Check for buffer overflow before reading CRC in pngpread.c (Warwick Allison)
   Added -soname to the loader flags in makefile.dec, makefile.sgi, and
     makefile.sggcc.
   Added "test-installed" target to makefile.linux, makefile.gcmmx,
     makefile.sgi, and makefile.sggcc.
-version 1.2.4beta3 [June 28, 2002]
+
+Version 1.2.4beta3 [June 28, 2002]
   Plugged memory leak of row_buf in pngtest.c when there is a png_error().
   Detect buffer overflow in pngpread.c when IDAT is corrupted with extra data.
   Added "test-installed" target to makefile.32sunu, makefile.64sunu,
     makefile.beos, makefile.darwin, makefile.dec, makefile.macosx,
     makefile.solaris, makefile.hpux, makefile.hpgcc, and makefile.so9.
-version 1.2.4rc1 and 1.0.14rc1 [July 2, 2002]
+
+Version 1.2.4rc1 and 1.0.14rc1 [July 2, 2002]
   Added "test-installed" target to makefile.cygwin and makefile.sco.
   Revised pnggccrd.c to be able to back out version 1.0.x via PNG_1_0_X macro.
 
-version 1.2.4 and 1.0.14 [July 8, 2002]
+Version 1.2.4 and 1.0.14 [July 8, 2002]
   Changed png_warning() to png_error() when width is too large to process.
-version 1.2.4patch01 [July 20, 2002]
+
+Version 1.2.4patch01 [July 20, 2002]
   Revised makefile.cygwin to use DLL number 12 instead of 13.
-version 1.2.5beta1 [August 6, 2002]
+
+Version 1.2.5beta1 [August 6, 2002]
   Added code to contrib/gregbook/readpng2.c to ignore unused chunks.
   Replaced toucan.png in contrib/gregbook (it has been corrupt since 1.0.11)
   Removed some stray *.o files from contrib/gregbook.
   Changed png_error() to png_warning() about "Too much data" in pngpread.c
     and about "Extra compressed data" in pngrutil.c.
   Prevent png_ptr->pass from exceeding 7 in png_push_finish_row().
   Updated makefile.hpgcc
   Updated png.c and pnggccrd.c handling of return from png_mmx_support()
-version 1.2.5beta2 [August 15, 2002]
+
+Version 1.2.5beta2 [August 15, 2002]
   Only issue png_warning() about "Too much data" in pngpread.c when avail_in
     is nonzero.
   Updated makefiles to install a separate libpng.so.3 with its own rpath.
-version 1.2.5rc1 and 1.0.15rc1 [August 24, 2002]
+
+Version 1.2.5rc1 and 1.0.15rc1 [August 24, 2002]
   Revised makefiles to not remove previous minor versions of shared libraries.
-version 1.2.5rc2 and 1.0.15rc2 [September 16, 2002]
+
+Version 1.2.5rc2 and 1.0.15rc2 [September 16, 2002]
   Revised 13 makefiles to remove "-lz" and "-L$(ZLIBLIB)", etc., from shared
     library loader directive.
   Added missing "$OBJSDLL" line to makefile.gcmmx.
   Added missing "; fi" to makefile.32sunu.
-version 1.2.5rc3 and 1.0.15rc3 [September 18, 2002]
+
+Version 1.2.5rc3 and 1.0.15rc3 [September 18, 2002]
   Revised libpng-config script.
 
-version 1.2.5 and 1.0.15 [October 3, 2002]
+Version 1.2.5 and 1.0.15 [October 3, 2002]
   Revised makefile.macosx, makefile.darwin, makefile.hpgcc, and makefile.hpux,
     and makefile.aix.
   Relocated two misplaced PNGAPI lines in pngtest.c
-version 1.2.6beta1 [October 22, 2002]
+
+Version 1.2.6beta1 [October 22, 2002]
   Commented out warning about uninitialized mmx_support in pnggccrd.c.
   Changed "IBMCPP__" flag to "__IBMCPP__" in pngconf.h.
   Relocated two more misplaced PNGAPI lines in pngtest.c
   Fixed memory overrun bug in png_do_read_filler() with 16-bit datastreams,
     introduced in version 1.0.2.
   Revised makefile.macosx, makefile.dec, makefile.aix, and makefile.32sunu.
-version 1.2.6beta2 [November 1, 2002]
+
+Version 1.2.6beta2 [November 1, 2002]
   Added libpng-config "--ldopts" output.
   Added "AR=ar" and "ARFLAGS=rc" and changed "ar rc" to "$(AR) $(ARFLAGS)"
     in makefiles.
-version 1.2.6beta3 [July 18, 2004]
+
+Version 1.2.6beta3 [July 18, 2004]
   Reverted makefile changes from version 1.2.6beta2 and some of the changes
     from version 1.2.6beta1; these will be postponed until version 1.2.7.
     Version 1.2.6 is going to be a simple bugfix release.
   Changed the one instance of "ln -sf" to "ln -f -s" in each Sun makefile.
   Fixed potential overrun in pngerror.c by using strncpy instead of memcpy.
   Added "#!/bin/sh" at the top of configure, for recognition of the
     'x' flag under Cygwin (Cosmin).
   Optimized vacuous tests that silence compiler warnings, in png.c (Cosmin).
@@ -1277,17 +1419,18 @@ version 1.2.6beta3 [July 18, 2004]
   Moved projects/visualc6/png32ms.def to scripts/pngw32.def,
     and projects/visualc6/png.rc to scripts/pngw32.rc (Cosmin).
   Added projects/visualc6/pngtest.dsp; removed contrib/msvctest/ (Cosmin).
   Changed line endings to DOS style in cbuilder5 and visualc6 files, even
     in the tar.* distributions (Cosmin).
   Updated contrib/visupng/VisualPng.dsp (Cosmin).
   Updated contrib/visupng/cexcept.h to version 2.0.0 (Cosmin).
   Added a separate distribution with "configure" and supporting files (Junichi).
-version 1.2.6beta4 [July 28, 2004]
+
+Version 1.2.6beta4 [July 28, 2004]
   Added user ability to change png_size_t via a PNG_SIZE_T macro.
   Added png_sizeof() and png_convert_size() functions.
   Added PNG_SIZE_MAX (maximum value of a png_size_t variable.
   Added check in png_malloc_default() for (size_t)size != (png_uint_32)size
     which would indicate an overflow.
   Changed sPLT failure action from png_error to png_warning and abandon chunk.
   Changed sCAL and iCCP failures from png_error to png_warning and abandon.
   Added png_get_uint_31(png_ptr, buf) function.
@@ -1299,130 +1442,147 @@ version 1.2.6beta4 [July 28, 2004]
   Revised "clobber list" in pnggccrd.c so it will compile under gcc-3.4.
   Revised Borland portion of png_malloc() to return NULL or issue
     png_error() according to setting of PNG_FLAG_MALLOC_NULL_MEM_OK.
   Added PNG_NO_SEQUENTIAL_READ_SUPPORTED macro to conditionally remove
     sequential read support.
   Added some "#if PNG_WRITE_SUPPORTED" blocks.
   Added #ifdef to remove some redundancy in png_malloc_default().
   Use png_malloc instead of png_zalloc to allocate the pallete.
-version 1.0.16rc1 and 1.2.6rc1 [August 4, 2004]
+
+Version 1.0.16rc1 and 1.2.6rc1 [August 4, 2004]
   Fixed buffer overflow vulnerability in png_handle_tRNS()
   Fixed integer arithmetic overflow vulnerability in png_read_png().
   Fixed some harmless bugs in png_handle_sBIT, etc, that would cause
     duplicate chunk types to go undetected.
   Fixed some timestamps in the -config version
   Rearranged order of processing of color types in png_handle_tRNS().
   Added ROWBYTES macro to calculate rowbytes without integer overflow.
   Updated makefile.darwin and removed makefile.macosx from scripts directory.
   Imposed default one million column, one-million row limits on the image
     dimensions, and added png_set_user_limits() function to override them.
   Revised use of PNG_SET_USER_LIMITS_SUPPORTED macro.
   Fixed wrong cast of returns from png_get_user_width|height_max().
   Changed some "keep the compiler happy" from empty statements to returns,
   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]
+
+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
     png_malloc_default() which is not supposed to be exported.
   Fixed off-by-one error in one of the conversions to PNG_ROWBYTES() in
     pngpread.c.  Bug was introduced in 1.2.6rc1.
   Fixed bug in RGB to RGBX transformation introduced in 1.2.6rc1.
   Fixed old bug in RGB to Gray transformation.
   Fixed problem with 64-bit compilers by casting arguments to abs()
     to png_int_32.
   Changed "ln -sf" to "ln -f -s" in three makefiles (solaris, sco, so9).
   Changed "HANDLE_CHUNK_*" to "PNG_HANDLE_CHUNK_*" (Cosmin)
   Added "-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)" to 15 *NIX makefiles.
   Added code to update the row_info->colortype in png_do_read_filler() (MSB).
-version 1.0.16rc3 and 1.2.6rc3 [August 9, 2004]
+
+Version 1.0.16rc3 and 1.2.6rc3 [August 9, 2004]
   Eliminated use of "abs()" in testing cHRM and gAMA values, to avoid
     trouble with some 64-bit compilers.  Created PNG_OUT_OF_RANGE() macro.
   Revised documentation of png_set_keep_unknown_chunks().
   Check handle_as_unknown status in pngpread.c, as in pngread.c previously.
   Moved  "PNG_HANDLE_CHUNK_*" macros out of PNG_INTERNAL section of png.h
   Added "rim" definitions for CONST4 and CONST6 in pnggccrd.c
-version 1.0.16rc4 and 1.2.6rc4 [August 10, 2004]
+
+Version 1.0.16rc4 and 1.2.6rc4 [August 10, 2004]
   Fixed mistake in pngtest.c introduced in 1.2.6rc2 (declaration of
     "pinfo" was out of place).
-version 1.0.16rc5 and 1.2.6rc5 [August 10, 2004]
+
+Version 1.0.16rc5 and 1.2.6rc5 [August 10, 2004]
   Moved  "PNG_HANDLE_CHUNK_*" macros out of PNG_ASSEMBLER_CODE_SUPPORTED
      section of png.h where they were inadvertently placed in version rc3.
 
-version 1.2.6 and 1.0.16 [August 15, 2004]
+Version 1.2.6 and 1.0.16 [August 15, 2004]
   Revised pngtest so memory allocation testing is only done when PNG_DEBUG==1.
-version 1.2.7beta1 [August 26, 2004]
+
+Version 1.2.7beta1 [August 26, 2004]
   Removed unused pngasmrd.h file.
   Removed references to uu.net for archived files.  Added references to
     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, that
     causes libpng to write PNG files with incorrect zlib header bytes.
-version 1.2.7beta2 [August 28, 2004]
+
+Version 1.2.7beta2 [August 28, 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.
-version 1.0.17rc1 and 1.2.7rc1 [September 4, 2004]
+
+Version 1.0.17rc1 and 1.2.7rc1 [September 4, 2004]
   Revised png_set_strip_filler() to not remove alpha if color_type has alpha.
 
-version 1.2.7 and 1.0.17 [September 12, 2004]
+Version 1.2.7 and 1.0.17 [September 12, 2004]
   Added makefile.hp64
   Changed projects/msvc/png32ms.def to scripts/png32ms.def in makefile.cygwin
-version 1.2.8beta1 [November 1, 2004]
+
+Version 1.2.8beta1 [November 1, 2004]
   Fixed bug in png_text_compress() that would fail to complete a large block.
   Fixed bug, introduced in libpng-1.2.7, that overruns a buffer during
     strip alpha operation in png_do_strip_filler().
   Added PNG_1_2_X definition in pngconf.h
   Use #ifdef to comment out png_info_init in png.c and png_read_init in
     pngread.c (as of 1.3.0)
-version 1.2.8beta2 [November 2, 2004]
+
+Version 1.2.8beta2 [November 2, 2004]
   Reduce color_type to a nonalpha type after strip alpha operation in
     png_do_strip_filler().
-version 1.2.8beta3 [November 3, 2004]
+
+Version 1.2.8beta3 [November 3, 2004]
   Revised definitions of PNG_MAX_UINT_32, PNG_MAX_SIZE, and PNG_MAXSUM
-version 1.2.8beta4 [November 12, 2004]
+
+Version 1.2.8beta4 [November 12, 2004]
   Fixed (again) definition of PNG_LIBPNG_VER_DLLNUM in png.h (Cosmin).
   Added PNG_LIBPNG_BUILD_PRIVATE in png.h (Cosmin).
   Set png_ptr->zstream.data_type to Z_BINARY, to avoid unnecessary detection
     of data type in deflate (Cosmin).
   Deprecated but continue to support SPECIALBUILD and PRIVATEBUILD in favor of
     PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING.
-version 1.2.8beta5 [November 20, 2004]
+
+Version 1.2.8beta5 [November 20, 2004]
   Use png_ptr->flags instead of png_ptr->transformations to pass
     PNG_STRIP_ALPHA info to png_do_strip_filler(), to preserve ABI
     compatibility.
   Revised handling of SPECIALBUILD, PRIVATEBUILD,
     PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING.
-version 1.2.8rc1 [November 24, 2004]
+
+Version 1.2.8rc1 [November 24, 2004]
   Moved handling of BUILD macros from pngconf.h to png.h
   Added definition of PNG_LIBPNG_BASE_TYPE in png.h, inadvertently
     omitted from beta5.
   Revised scripts/pngw32.rc
   Despammed mailing addresses by masking "@" with "at".
   Inadvertently installed a supposedly faster test version of pngrutil.c
-version 1.2.8rc2 [November 26, 2004]
+
+Version 1.2.8rc2 [November 26, 2004]
   Added two missing "\" in png.h
   Change tests in pngread.c and pngpread.c to
     if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA))
        png_do_read_transformations(png_ptr);
-version 1.2.8rc3 [November 28, 2004]
+
+Version 1.2.8rc3 [November 28, 2004]
   Reverted pngrutil.c to version libpng-1.2.8beta5.
   Added scripts/makefile.elf with supporting code in pngconf.h for symbol
     versioning (John Bowler).
-version 1.2.8rc4 [November 29, 2004]
+
+Version 1.2.8rc4 [November 29, 2004]
   Added projects/visualc7 (Simon-pierre).
-version 1.2.8rc5 [November 29, 2004]
+
+Version 1.2.8rc5 [November 29, 2004]
   Fixed new typo in scripts/pngw32.rc
 
-version 1.2.8 [December 3, 2004]
+Version 1.2.8 [December 3, 2004]
   Removed projects/visualc7, added projects/visualc71.
 
-version 1.2.9beta1 [February 21, 2006]
-
+Version 1.2.9beta1 [February 21, 2006]
   Initialized some structure members in pngwutil.c to avoid gcc-4.0.0 complaints
   Revised man page and libpng.txt to make it clear that one should not call
     png_read_end or png_write_end after png_read_png or png_write_png.
   Updated references to png-mng-implement mailing list.
   Fixed an incorrect typecast in pngrutil.c
   Added PNG_NO_READ_SUPPORTED conditional for making a write-only library.
   Added PNG_NO_WRITE_INTERLACING_SUPPORTED conditional.
   Optimized alpha-inversion loops in pngwtran.c
@@ -1434,419 +1594,416 @@ version 1.2.9beta1 [February 21, 2006]
   Optimized zlib window flag (CINFO) in contrib/pngsuite/*.png (Cosmin).
   Updated scripts/makefile.bc32 for Borland C++ 5.6 (Cosmin).
   Exported png_get_uint_32, png_save_uint_32, png_get_uint_16, png_save_uint_16,
     png_get_int_32, png_save_int_32, png_get_uint_31 (Cosmin).
   Added type cast (png_byte) in png_write_sCAL() (Cosmin).
   Fixed scripts/makefile.cygwin (Christian Biesinger, Cosmin).
   Default iTXt support was inadvertently enabled.
 
-version 1.2.9beta2 [February 21, 2006]
-
+Version 1.2.9beta2 [February 21, 2006]
   Check for png_rgb_to_gray and png_gray_to_rgb read transformations before
     checking for png_read_dither in pngrtran.c
   Revised checking of chromaticity limits to accommodate extended RGB
     colorspace (John Denker).
   Changed line endings in some of the project files to CRLF, even in the
     "Unix" tar distributions (Cosmin).
   Made png_get_int_32 and png_save_int_32 always available (Cosmin).
   Updated scripts/pngos2.def, scripts/pngw32.def and projects/wince/png32ce.def
     with the newly exported functions.
   Eliminated distributions without the "configure" script.
   Updated INSTALL instructions.
 
-version 1.2.9beta3 [February 24, 2006]
-
+Version 1.2.9beta3 [February 24, 2006]
   Fixed CRCRLF line endings in contrib/visupng/VisualPng.dsp
   Made libpng.pc respect EXEC_PREFIX (D. P. Kreil, J. Bowler)
   Removed reference to pngasmrd.h from Makefile.am
   Renamed CHANGES to ChangeLog.
   Renamed LICENSE to COPYING.
   Renamed ANNOUNCE to NEWS.
   Created AUTHORS file.
 
-version 1.2.9beta4 [March 3, 2006]
-
+Version 1.2.9beta4 [March 3, 2006]
   Changed definition of PKGCONFIG from $prefix/lib to $libdir in configure.ac
   Reverted to filenames LICENSE and ANNOUNCE; removed AUTHORS and COPYING.
   Removed newline from the end of some error and warning messages.
   Removed test for sqrt() from configure.ac and configure.
   Made swap tables in pngtrans.c PNG_CONST (Carlo Bramix).
   Disabled default iTXt support that was inadvertently enabled in
     libpng-1.2.9beta1.
   Added "OS2" to list of systems that don't need underscores, in pnggccrd.c
   Removed libpng version and date from *.c files.
 
-version 1.2.9beta5 [March 4, 2006]
+Version 1.2.9beta5 [March 4, 2006]
   Removed trailing blanks from source files.
   Put version and date of latest change in each source file, and changed
     copyright year accordingly.
   More cleanup of configure.ac, Makefile.am, and associated scripts.
   Restored scripts/makefile.elf which was inadvertently deleted.
 
-version 1.2.9beta6 [March 6, 2006]
+Version 1.2.9beta6 [March 6, 2006]
   Fixed typo (RELEASE) in configuration files.
 
-version 1.2.9beta7 [March 7, 2006]
+Version 1.2.9beta7 [March 7, 2006]
   Removed libpng.vers and libpng.sym from libpng12_la_SOURCES in Makefile.am
   Fixed inconsistent #ifdef's around png_sig_bytes() and png_set_sCAL_s()
     in png.h.
   Updated makefile.elf as suggested by debian.
   Made cosmetic changes to some makefiles, adding LN_SF and other macros.
   Made some makefiles accept "exec_prefix".
 
-version 1.2.9beta8 [March 9, 2006]
+Version 1.2.9beta8 [March 9, 2006]
   Fixed some "#if defined (..." which should be "#if defined(..."
     Bug introduced in libpng-1.2.8.
   Fixed inconsistency in definition of png_default_read_data()
   Restored blank that was lost from makefile.sggcc "clean" target in beta7.
   Revised calculation of "current" and "major" for irix in ltmain.sh
   Changed "mkdir" to "MKDIR_P" in some makefiles.
   Separated PNG_EXPAND and PNG_EXPAND_tRNS.
   Added png_set_expand_gray_1_2_4_to_8() and deprecated
     png_set_gray_1_2_4_to_8() which also expands tRNS to alpha.
 
-version 1.2.9beta9 [March 10, 2006]
+Version 1.2.9beta9 [March 10, 2006]
   Include "config.h" in pngconf.h when available.
   Added some checks for NULL png_ptr or NULL info_ptr (timeless)
 
-version 1.2.9beta10 [March 20, 2006]
+Version 1.2.9beta10 [March 20, 2006]
   Removed extra CR from contrib/visualpng/VisualPng.dsw (Cosmin)
   Made pnggccrd.c PIC-compliant (Christian Aichinger).
   Added makefile.mingw (Wolfgang Glas).
   Revised pngconf.h MMX checking.
 
-version 1.2.9beta11 [March 22, 2006]
+Version 1.2.9beta11 [March 22, 2006]
   Fixed out-of-order declaration in pngwrite.c that was introduced in beta9
   Simplified some makefiles by using LIBSO, LIBSOMAJ, and LIBSOVER macros.
 
-version 1.2.9rc1 [March 31, 2006]
+Version 1.2.9rc1 [March 31, 2006]
   Defined PNG_USER_PRIVATEBUILD when including "pngusr.h" (Cosmin).
   Removed nonsensical assertion check from pngtest.c (Cosmin).
 
-version 1.2.9 [April 14, 2006]
+Version 1.2.9 [April 14, 2006]
   Revised makefile.beos and added "none" selector in ltmain.sh
 
-version 1.2.10beta1 [April 15, 2006]
+Version 1.2.10beta1 [April 15, 2006]
   Renamed "config.h" to "png_conf.h" and revised Makefile.am to add
     -DPNG_BUILDING_LIBPNG to compile directive, and modified pngconf.h
     to include png_conf.h only when PNG_BUILDING_LIBPNG is defined.
 
-version 1.2.10beta2 [April 15, 2006]
+Version 1.2.10beta2 [April 15, 2006]
   Manually updated Makefile.in and configure.  Changed png_conf.h.in
     back to config.h.
 
-version 1.2.10beta3 [April 15, 2006]
+Version 1.2.10beta3 [April 15, 2006]
   Change png_conf.h back to config.h in pngconf.h.
 
-version 1.2.10beta4 [April 16, 2006]
+Version 1.2.10beta4 [April 16, 2006]
   Change PNG_BUILDING_LIBPNG to PNG_CONFIGURE_LIBPNG in config/Makefile*.
 
-version 1.2.10beta5 [April 16, 2006]
+Version 1.2.10beta5 [April 16, 2006]
   Added a configure check for compiling assembler code in pnggccrd.c
 
-version 1.2.10beta6 [April 17, 2006]
+Version 1.2.10beta6 [April 17, 2006]
   Revised the configure check for pnggccrd.c
   Moved -DPNG_CONFIGURE_LIBPNG into @LIBPNG_DEFINES@
   Added @LIBPNG_DEFINES@ to arguments when building libpng.sym
 
-version 1.2.10beta7 [April 18, 2006]
+Version 1.2.10beta7 [April 18, 2006]
   Change "exec_prefix=$prefix" to "exec_prefix=$(prefix)" in makefiles.
 
-version 1.2.10rc1 [April 19, 2006]
+Version 1.2.10rc1 [April 19, 2006]
   Ensure pngconf.h doesn't define both PNG_USE_PNGGCCRD and PNG_USE_PNGVCRD
   Fixed "LN_FS" typo in makefile.sco and makefile.solaris.
 
-version 1.2.10rc2 [April 20, 2006]
+Version 1.2.10rc2 [April 20, 2006]
   Added a backslash between -DPNG_CONFIGURE_LIBPNG and -DPNG_NO_ASSEMBLER_CODE
    in configure.ac and configure
   Made the configure warning about versioned symbols less arrogant.
 
-version 1.2.10rc3 [April 21, 2006]
+Version 1.2.10rc3 [April 21, 2006]
   Added a note in libpng.txt that png_set_sig_bytes(8) can be used when
     writing an embedded PNG without the 8-byte signature.
   Revised makefiles and configure to avoid making links to libpng.so.*
 
-version 1.2.10 [April 23, 2006]
+Version 1.2.10 [April 23, 2006]
   Reverted configure to "rc2" state.
 
-version 1.2.11beta1 [May 31, 2006]
+Version 1.2.11beta1 [May 31, 2006]
   scripts/libpng.pc.in contained "configure" style version info and would
     not work with makefiles.
   The shared-library makefiles were linking to libpng.so.0 instead of
     libpng.so.3 compatibility as the library.
 
-version 1.2.11beta2 [June 2, 2006]
+Version 1.2.11beta2 [June 2, 2006]
   Increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid
     buffer overflow.
   Fixed bug in example.c (png_set_palette_rgb -> png_set_palette_to_rgb)
 
-version 1.2.11beta3 [June 5, 2006]
+Version 1.2.11beta3 [June 5, 2006]
   Prepended "#! /bin/sh" to ltmail.sh and contrib/pngminus/*.sh (Cosmin).
   Removed the accidental leftover Makefile.in~ (Cosmin).
   Avoided potential buffer overflow and optimized buffer in
     png_write_sCAL(), png_write_sCAL_s() (Cosmin).
   Removed the include directories and libraries from CFLAGS and LDFLAGS
     in scripts/makefile.gcc (Nelson A. de Oliveira, Cosmin).
 
-version 1.2.11beta4 [June 6, 2006]
+Version 1.2.11beta4 [June 6, 2006]
   Allow zero-length IDAT chunks after the entire zlib datastream, but not
     after another intervening chunk type.
 
-version 1.0.19rc1, 1.2.11rc1 [June 13, 2006]
+Version 1.0.19rc1, 1.2.11rc1 [June 13, 2006]
   Deleted extraneous square brackets from [config.h] in configure.ac
 
-version 1.0.19rc2, 1.2.11rc2 [June 14, 2006]
+Version 1.0.19rc2, 1.2.11rc2 [June 14, 2006]
   Added prototypes for PNG_INCH_CONVERSIONS functions to png.h
   Revised INSTALL and autogen.sh
   Fixed typo in several makefiles (-W1 should be -Wl)
   Added typedef for png_int_32 and png_uint_32 on 64-bit systems.
 
-version 1.0.19rc3, 1.2.11rc3 [June 15, 2006]
+Version 1.0.19rc3, 1.2.11rc3 [June 15, 2006]
   Removed the new typedefs for 64-bit systems (delay until version 1.4.0)
   Added one zero element to png_gamma_shift[] array in pngrtran.c to avoid
     reading out of bounds.
 
-version 1.0.19rc4, 1.2.11rc4 [June 15, 2006]
+Version 1.0.19rc4, 1.2.11rc4 [June 15, 2006]
   Really removed the new typedefs for 64-bit systems.
 
-version 1.0.19rc5, 1.2.11rc5 [June 22, 2006]
+Version 1.0.19rc5, 1.2.11rc5 [June 22, 2006]
   Removed png_sig_bytes entry from scripts/pngw32.def
 
-version 1.0.19, 1.2.11 [June 26, 2006]
+Version 1.0.19, 1.2.11 [June 26, 2006]
   None.
 
-version 1.0.20, 1.2.12 [June 27, 2006]
+Version 1.0.20, 1.2.12 [June 27, 2006]
   Really increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid
     buffer overflow.
 
-version 1.2.13beta1 [October 2, 2006]
+Version 1.2.13beta1 [October 2, 2006]
   Removed AC_FUNC_MALLOC from configure.ac
   Work around Intel-Mac compiler bug by setting PNG_NO_MMX_CODE in pngconf.h
   Change "logical" to "bitwise" throughout documentation.
-  Detect and fix attempt to write wrong iCCP profile length.
-
-version 1.0.21, 1.2.13 [November 14, 2006]
+  Detect and fix attempt to write wrong iCCP profile length (CVE-2006-7244)
+
+Version 1.0.21, 1.2.13 [November 14, 2006]
   Fix potential buffer overflow in sPLT chunk handler.
   Fix Makefile.am to not try to link to noexistent files.
   Check all exported functions for NULL png_ptr.
 
-version 1.2.14beta1 [November 17, 2006]
+Version 1.2.14beta1 [November 17, 2006]
   Relocated three misplaced tests for NULL png_ptr.
   Built Makefile.in with automake-1.9.6 instead of 1.9.2.
   Build configure with autoconf-2.60 instead of 2.59
 
-version 1.2.14beta2 [November 17, 2006]
+Version 1.2.14beta2 [November 17, 2006]
   Added some typecasts in png_zalloc().
 
-version 1.2.14rc1 [November 20, 2006]
+Version 1.2.14rc1 [November 20, 2006]
   Changed "strtod" to "png_strtod" in pngrutil.c
 
-version 1.0.22, 1.2.14    [November 27, 2006]
+Version 1.0.22, 1.2.14    [November 27, 2006]
   Added missing "$(srcdir)" in Makefile.am and Makefile.in
 
-version 1.2.15beta1 [December 3, 2006]
+Version 1.2.15beta1 [December 3, 2006]
   Generated configure with autoconf-2.61 instead of 2.60
   Revised configure.ac to update libpng.pc and libpng-config.
 
-version 1.2.15beta2 [December 3, 2006]
+Version 1.2.15beta2 [December 3, 2006]
   Always export MMX asm functions, just stubs if not building pnggccrd.c
 
-version 1.2.15beta3 [December 4, 2006]
+Version 1.2.15beta3 [December 4, 2006]
   Add "png_bytep" typecast to profile while calculating length in pngwutil.c
 
-version 1.2.15beta4 [December 7, 2006]
+Version 1.2.15beta4 [December 7, 2006]
   Added scripts/CMakeLists.txt
   Changed PNG_NO_ASSEMBLER_CODE to PNG_NO_MMX_CODE in scripts, like 1.4.0beta
 
-version 1.2.15beta5 [December 7, 2006]
+Version 1.2.15beta5 [December 7, 2006]
   Changed some instances of PNG_ASSEMBLER_* to PNG_MMX_* in pnggccrd.c
   Revised scripts/CMakeLists.txt
 
-version 1.2.15beta6 [December 13, 2006]
+Version 1.2.15beta6 [December 13, 2006]
   Revised scripts/CMakeLists.txt and configure.ac
 
-version 1.2.15rc1 [December 18, 2006]
+Version 1.2.15rc1 [December 18, 2006]
   Revised scripts/CMakeLists.txt
 
-version 1.2.15rc2 [December 21, 2006]
+Version 1.2.15rc2 [December 21, 2006]
   Added conditional #undef jmpbuf in pngtest.c to undo #define in AIX headers.
   Added scripts/makefile.nommx
 
-version 1.2.15rc3 [December 25, 2006]
+Version 1.2.15rc3 [December 25, 2006]
   Fixed shared library numbering error that was introduced in 1.2.15beta6.
 
-version 1.2.15rc4 [December 27, 2006]
+Version 1.2.15rc4 [December 27, 2006]
   Fixed handling of rgb_to_gray when png_ptr->color.gray isn't set.
 
-version 1.2.15rc5 [December 31, 2006]
+Version 1.2.15rc5 [December 31, 2006]
   Revised handling of rgb_to_gray.
 
-version 1.2.15 [January 5, 2007]
+Version 1.2.15 [January 5, 2007]
   Added some (unsigned long) typecasts in pngtest.c to avoid printing errors.
 
-version 1.2.16beta1 [January 6, 2007]
+Version 1.2.16beta1 [January 6, 2007]
   Fix bugs in makefile.nommx
 
-version 1.2.16beta2 [January 16, 2007]
+Version 1.2.16beta2 [January 16, 2007]
   Revised scripts/CMakeLists.txt
 
-version 1.2.16 [January 31, 2007]
+Version 1.2.16 [January 31, 2007]
   No changes.
 
-version 1.2.17beta1 [March 6, 2007]
+Version 1.2.17beta1 [March 6, 2007]
   Revised scripts/CMakeLists.txt to install both shared and static libraries.
   Deleted a redundant line from pngset.c.
 
-version 1.2.17beta2 [April 26, 2007]
+Version 1.2.17beta2 [April 26, 2007]
   Relocated misplaced test for png_ptr == NULL in pngpread.c
   Change "==" to "&" for testing PNG_RGB_TO_GRAY_ERR & PNG_RGB_TO_GRAY_WARN
     flags.
   Changed remaining instances of PNG_ASSEMBLER_* to PNG_MMX_*
   Added pngerror() when write_IHDR fails in deflateInit2().
   Added "const" to some array declarations.
   Mention examples of libpng usage in the libpng*.txt and libpng.3 documents.
 
-version 1.2.17rc1 [May 4, 2007]
+Version 1.2.17rc1 [May 4, 2007]
   No changes.
 
-version 1.2.17rc2 [May 8, 2007]
+Version 1.2.17rc2 [May 8, 2007]
   Moved several PNG_HAVE_* macros out of PNG_INTERNAL because applications
     calling set_unknown_chunk_location() need them.
   Changed transformation flag from PNG_EXPAND_tRNS to PNG_EXPAND in
     png_set_expand_gray_1_2_4_to_8().
   Added png_ptr->unknown_chunk to hold working unknown chunk data, so it
     can be free'ed in case of error.  Revised unknown chunk handling in
     pngrutil.c and pngpread.c to use this structure.
 
-version 1.2.17rc3 [May 8, 2007]
+Version 1.2.17rc3 [May 8, 2007]
   Revised symbol-handling in configure script.
 
-version 1.2.17rc4 [May 10, 2007]
+Version 1.2.17rc4 [May 10, 2007]
   Revised unknown chunk handling to avoid storing unknown critical chunks.
 
-version 1.0.25 [May 15, 2007]
-version 1.2.17 [May 15, 2007]
+Version 1.0.25 [May 15, 2007]
+Version 1.2.17 [May 15, 2007]
   Added "png_ptr->num_trans=0" before error return in png_handle_tRNS,
     to eliminate a vulnerability (CVE-2007-2445, CERT VU#684664)
 
-version 1.0.26 [May 15, 2007]
-version 1.2.18 [May 15, 2007]
+Version 1.0.26 [May 15, 2007]
+Version 1.2.18 [May 15, 2007]
   Reverted the libpng-1.2.17rc3 change to symbol-handling in configure script
 
-version 1.2.19beta1 [May 18, 2007]
+Version 1.2.19beta1 [May 18, 2007]
   Changed "const static" to "static PNG_CONST" everywhere, mostly undoing
     change of libpng-1.2.17beta2.  Changed other "const" to "PNG_CONST"
   Changed some handling of unused parameters, to avoid compiler warnings.
     "if (unused == NULL) return;" becomes "unused = unused".
 
-version 1.2.19beta2 [May 18, 2007]
+Version 1.2.19beta2 [May 18, 2007]
   Only use the valid bits of tRNS value in png_do_expand() (Brian Cartier)
 
-version 1.2.19beta3 [May 19, 2007]
+Version 1.2.19beta3 [May 19, 2007]
   Add some "png_byte" typecasts in png_check_keyword() and write new_key
   instead of key in zTXt chunk (Kevin Ryde).
 
-version 1.2.19beta4 [May 21, 2007]
+Version 1.2.19beta4 [May 21, 2007]
   Add png_snprintf() function and use it in place of sprint() for improved
     defense against buffer overflows.
 
-version 1.2.19beta5 [May 21, 2007]
+Version 1.2.19beta5 [May 21, 2007]
   Fixed png_handle_tRNS() to only use the valid bits of tRNS value.
   Changed handling of more unused parameters, to avoid compiler warnings.
   Removed some PNG_CONST in pngwutil.c to avoid compiler warnings.
 
-version 1.2.19beta6 [May 22, 2007]
+Version 1.2.19beta6 [May 22, 2007]
   Added some #ifdef PNG_MMX_CODE_SUPPORTED where needed in pngvcrd.c
   Added a special "_MSC_VER" case that defines png_snprintf to _snprintf
 
-version 1.2.19beta7 [May 22, 2007]
+Version 1.2.19beta7 [May 22, 2007]
   Squelched png_squelch_warnings() in pnggccrd.c and added
     an #ifdef PNG_MMX_CODE_SUPPORTED block around the declarations that caused
     the warnings that png_squelch_warnings was squelching.
 
-version 1.2.19beta8 [May 22, 2007]
+Version 1.2.19beta8 [May 22, 2007]
   Removed __MMX__ from test in pngconf.h.
 
-version 1.2.19beta9 [May 23, 2007]
+Version 1.2.19beta9 [May 23, 2007]
   Made png_squelch_warnings() available via PNG_SQUELCH_WARNINGS macro.
   Revised png_squelch_warnings() so it might work.
   Updated makefile.sgcc and makefile.solaris; added makefile.solaris-x86.
 
-version 1.2.19beta10 [May 24, 2007]
+Version 1.2.19beta10 [May 24, 2007]
   Resquelched png_squelch_warnings(), use "__attribute__((used))" instead.
 
-version 1.4.0beta1 [April 20, 2006]
+Version 1.4.0beta1 [April 20, 2006]
   Enabled iTXt support (changes png_struct, thus requires so-number change).
   Cleaned up PNG_ASSEMBLER_CODE_SUPPORTED vs PNG_MMX_CODE_SUPPORTED
   Eliminated PNG_1_0_X and PNG_1_2_X macros.
   Removed deprecated functions png_read_init, png_write_init, png_info_init,
     png_permit_empty_plte, png_set_gray_1_2_4_to_8, png_check_sig, and
     removed the deprecated macro PNG_MAX_UINT.
   Moved "PNG_INTERNAL" parts of png.h and pngconf.h into pngintrn.h
   Removed many WIN32_WCE #ifdefs (Cosmin).
   Reduced dependency on C-runtime library when on Windows (Simon-Pierre)
   Replaced sprintf() with png_sprintf() (Simon-Pierre)
 
-version 1.4.0beta2 [April 20, 2006]
+Version 1.4.0beta2 [April 20, 2006]
   Revised makefiles and configure to avoid making links to libpng.so.*
   Moved some leftover MMX-related defines from pngconf.h to pngintrn.h
   Updated scripts/pngos2.def, pngw32.def, and projects/wince/png32ce.def
 
-version 1.4.0beta3 [May 10, 2006]
+Version 1.4.0beta3 [May 10, 2006]
   Updated scripts/pngw32.def to comment out MMX functions.
   Added PNG_NO_GET_INT_32 and PNG_NO_SAVE_INT_32 macros.
   Scripts/libpng.pc.in contained "configure" style version info and would
     not work with makefiles.
   Revised pngconf.h and added pngconf.h.in, so makefiles and configure can
     pass defines to libpng and applications.
 
-version 1.4.0beta4 [May 11, 2006]
+Version 1.4.0beta4 [May 11, 2006]
   Revised configure.ac, Makefile.am, and many of the makefiles to write
     their defines in pngconf.h.
 
-version 1.4.0beta5 [May 15, 2006]
+Version 1.4.0beta5 [May 15, 2006]
   Added a missing semicolon in Makefile.am and Makefile.in
   Deleted extraneous square brackets from configure.ac
 
-version 1.4.0beta6 [June 2, 2006]
+Version 1.4.0beta6 [June 2, 2006]
   Increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid
     buffer overflow.
   Changed sonum from 0 to 1.
   Removed unused prototype for png_check_sig() from png.h
 
-version 1.4.0beta7 [June 16, 2006]
+Version 1.4.0beta7 [June 16, 2006]
   Exported png_write_sig (Cosmin).
   Optimized buffer in png_handle_cHRM() (Cosmin).
   Set pHYs = 2835 x 2835 pixels per meter, and added
     sCAL = 0.352778e-3 x 0.352778e-3 meters, in pngtest.png (Cosmin).
   Added png_set_benign_errors(), png_benign_error(), png_chunk_benign_error().
   Added typedef for png_int_32 and png_uint_32 on 64-bit systems.
   Added "(unsigned long)" typecast on png_uint_32 variables in printf lists.
 
-version 1.4.0beta8 [June 22, 2006]
+Version 1.4.0beta8 [June 22, 2006]
   Added demonstration of user chunk support in pngtest.c, to support the
     public sTER chunk and a private vpAg chunk.
 
-version 1.4.0beta9 [July 3, 2006]
+Version 1.4.0beta9 [July 3, 2006]
   Removed ordinals from scripts/pngw32.def and removed png_info_int and
     png_set_gray_1_2_4_to_8 entries.
   Inline call of png_get_uint_32() in png_get_uint_31().
   Use png_get_uint_31() to get vpAg width and height in pngtest.c
   Removed WINCE and Netware projects.
   Removed standalone Y2KINFO file.
 
-version 1.4.0beta10 [July 12, 2006]
+Version 1.4.0beta10 [July 12, 2006]
   Eliminated automatic copy of pngconf.h to pngconf.h.in from configure and
     some makefiles, because it was not working reliably.  Instead, distribute
     pngconf.h.in along with pngconf.h and cause configure and some of the
     makefiles to update pngconf.h from pngconf.h.in.
   Added pngconf.h to DEPENDENCIES in Makefile.am
 
-version 1.4.0beta11 [August 19, 2006]
+Version 1.4.0beta11 [August 19, 2006]
   Removed AC_FUNC_MALLOC from configure.ac.
   Added a warning when writing iCCP profile with mismatched profile length.
   Patched pnggccrd.c to assemble on x86_64 platforms.
   Moved chunk header reading into a separate function png_read_chunk_header()
     in pngrutil.c.  The chunk header (len+sig) is now serialized in a single
     operation (Cosmin).
   Implemented support for I/O states. Added png_ptr member io_state, and
     functions png_get_io_chunk_name() and png_get_io_state() in pngget.c
@@ -1881,431 +2038,431 @@ version 1.4.0beta11 [August 19, 2006]
     updated the scripts and the Visual C++ projects accordingly (Cosmin).
   Removed circular references between pngconf.h and pngconf.h.in in
     scripts/makefile.vc*win32 (Cosmin).
   Removing trailing '.' from the warning and error messages (Cosmin).
   Added pngdefs.h that is built by makefile or configure, instead of
     pngconf.h.in (Glenn).
   Detect and fix attempt to write wrong iCCP profile length.
 
-version 1.4.0beta12 [October 19, 2006]
+Version 1.4.0beta12 [October 19, 2006]
   Changed "logical" to "bitwise" in the documentation.
   Work around Intel-Mac compiler bug by setting PNG_NO_MMX_CODE in pngconf.h
   Add a typecast to stifle compiler warning in pngrutil.c
 
-version 1.4.0beta13 [November 10, 2006]
+Version 1.4.0beta13 [November 10, 2006]
   Fix potential buffer overflow in sPLT chunk handler.
   Fix Makefile.am to not try to link to noexistent files.
 
-version 1.4.0beta14 [November 15, 2006]
+Version 1.4.0beta14 [November 15, 2006]
   Check all exported functions for NULL png_ptr.
 
-version 1.4.0beta15 [November 17, 2006]
+Version 1.4.0beta15 [November 17, 2006]
   Relocated two misplaced tests for NULL png_ptr.
   Built Makefile.in with automake-1.9.6 instead of 1.9.2.
   Build configure with autoconf-2.60 instead of 2.59
   Add "install: all" in Makefile.am so "configure; make install" will work.
 
-version 1.4.0beta16 [November 17, 2006]
+Version 1.4.0beta16 [November 17, 2006]
   Added a typecast in png_zalloc().
 
-version 1.4.0beta17 [December 4, 2006]
+Version 1.4.0beta17 [December 4, 2006]
   Changed "new_key[79] = '\0';" to "(*new_key)[79] = '\0';" in pngwutil.c
   Add "png_bytep" typecast to profile while calculating length in pngwutil.c
 
-version 1.4.0beta18 [December 7, 2006]
+Version 1.4.0beta18 [December 7, 2006]
   Added scripts/CMakeLists.txt
 
-version 1.4.0beta19 [May 16, 2007]
+Version 1.4.0beta19 [May 16, 2007]
   Revised scripts/CMakeLists.txt
   Rebuilt configure and Makefile.in with newer tools.
   Added conditional #undef jmpbuf in pngtest.c to undo #define in AIX headers.
   Added scripts/makefile.nommx
 
-version 1.4.0beta20 [July 9, 2008]
+Version 1.4.0beta20 [July 9, 2008]
   Moved several PNG_HAVE_* macros from pngpriv.h to png.h because applications
     calling set_unknown_chunk_location() need them.
   Moved several macro definitions from pngpriv.h to pngconf.h
   Merge with changes to the 1.2.X branch, as of 1.2.30beta04.
   Deleted all use of the MMX assembler code and Intel-licensed optimizations.
   Revised makefile.mingw
 
-version 1.4.0beta21 [July 21, 2008]
+Version 1.4.0beta21 [July 21, 2008]
   Moved local array "chunkdata" from pngrutil.c to the png_struct, so
     it will be freed by png_read_destroy() in case of a read error (Kurt
     Christensen).
 
-version 1.4.0beta22 [July 21, 2008]
+Version 1.4.0beta22 [July 21, 2008]
   Change "purpose" and "buffer" to png_ptr->chunkdata to avoid memory leaking.
 
-version 1.4.0beta23 [July 22, 2008]
+Version 1.4.0beta23 [July 22, 2008]
   Change "chunkdata = NULL" to "png_ptr->chunkdata = NULL" several places in
     png_decompress_chunk().
 
-version 1.4.0beta24 [July 25, 2008]
+Version 1.4.0beta24 [July 25, 2008]
   Change all remaining "chunkdata" to "png_ptr->chunkdata" in
     png_decompress_chunk(), and remove "chunkdata" from parameter list.
   Put a call to png_check_chunk_name() in png_read_chunk_header().
   Revised png_check_chunk_name() to reject a name with a lowercase 3rd byte.
   Removed two calls to png_check_chunk_name() occuring later in the process.
   Define PNG_NO_ERROR_NUMBERS by default in pngconf.h
 
-version 1.4.0beta25 [July 30, 2008]
+Version 1.4.0beta25 [July 30, 2008]
   Added a call to png_check_chunk_name() in pngpread.c
   Reverted png_check_chunk_name() to accept a name with a lowercase 3rd byte.
   Added png_push_have_buffer() function to pngpread.c
   Eliminated PNG_BIG_ENDIAN_SUPPORTED and associated png_get_* macros.
   Made inline expansion of png_get_*() optional with PNG_USE_READ_MACROS.
   Eliminated all PNG_USELESS_TESTS and PNG_CORRECT_PALETTE_SUPPORTED code.
   Synced contrib directory and configure files with libpng-1.2.30beta06.
   Eliminated no-longer-used pngdefs.h (but it's still built in the makefiles)
   Relocated a misplaced "#endif /* PNG_NO_WRITE_FILTER */" in pngwutil.c
 
-version 1.4.0beta26 [August 4, 2008]
+Version 1.4.0beta26 [August 4, 2008]
   Removed png_push_have_buffer() function in pngpread.c.  It increased the
     compiled library size slightly.
   Changed "-Wall" to "-W -Wall" in the CFLAGS in all makefiles (Cosmin Truta)
   Declared png_ptr "volatile" in pngread.c and pngwrite.c to avoid warnings.
   Updated contrib/visupng/cexcept.h to version 2.0.1
   Added PNG_LITERAL_CHARACTER macros for #, [, and ].
 
-version 1.4.0beta27 [August 5, 2008]
+Version 1.4.0beta27 [August 5, 2008]
   Revised usage of PNG_LITERAL_SHARP in pngerror.c.
   Moved newline character from individual png_debug messages into the
     png_debug macros.
   Allow user to #define their own png_debug, png_debug1, and png_debug2.
 
-version 1.4.0beta28 [August 5, 2008]
+Version 1.4.0beta28 [August 5, 2008]
   Revised usage of PNG_LITERAL_SHARP in pngerror.c.
   Added PNG_STRING_NEWLINE macro
 
-version 1.4.0beta29 [August 9, 2008]
+Version 1.4.0beta29 [August 9, 2008]
   Revised usage of PNG_STRING_NEWLINE to work on non-ISO compilers.
   Added PNG_STRING_COPYRIGHT macro.
   Added non-ISO versions of png_debug macros.
 
-version 1.4.0beta30 [August 14, 2008]
+Version 1.4.0beta30 [August 14, 2008]
   Added premultiplied alpha feature (Volker Wiendl).
 
-version 1.4.0beta31 [August 18, 2008]
+Version 1.4.0beta31 [August 18, 2008]
   Moved png_set_premultiply_alpha from pngtrans.c to pngrtran.c
   Removed extra crc check at the end of png_handle_cHRM().  Bug introduced
     in libpng-1.4.0beta20.
 
-version 1.4.0beta32 [August 19, 2008]
+Version 1.4.0beta32 [August 19, 2008]
   Added PNG_WRITE_FLUSH_SUPPORTED block around new png_flush() call.
   Revised PNG_NO_STDIO version of png_write_flush()
 
-version 1.4.0beta33 [August 20, 2008]
+Version 1.4.0beta33 [August 20, 2008]
   Added png_get|set_chunk_cache_max() to limit the total number of sPLT,
     text, and unknown chunks that can be stored.
 
-version 1.4.0beta34 [September 6, 2008]
+Version 1.4.0beta34 [September 6, 2008]
   Shortened tIME_string to 29 bytes in pngtest.c
   Fixed off-by-one error introduced in png_push_read_zTXt() function in
     libpng-1.2.30beta04/pngpread.c (Harald van Dijk)
 
-version 1.4.0beta35 [October 6, 2008]
+Version 1.4.0beta35 [October 6, 2008]
   Changed "trans_values" to "trans_color".
   Changed so-number from 0 to 14.  Some OS do not like 0.
   Revised makefile.darwin to fix shared library numbering.
   Change png_set_gray_1_2_4_to_8() to png_set_expand_gray_1_2_4_to_8()
     in example.c (debian bug report)
 
-version 1.4.0beta36 [October 25, 2008]
+Version 1.4.0beta36 [October 25, 2008]
   Sync with tEXt vulnerability fix in libpng-1.2.33rc02.
 
-version 1.4.0beta37 [November 13, 2008]
+Version 1.4.0beta37 [November 13, 2008]
   Added png_check_cHRM in png.c and moved checking from pngget.c, pngrutil.c,
     and pngwrite.c
 
-version 1.4.0beta38 [November 22, 2008]
+Version 1.4.0beta38 [November 22, 2008]
   Added check for zero-area RGB cHRM triangle in png_check_cHRM() and
     png_check_cHRM_fixed().
 
-version 1.4.0beta39 [November 23, 2008]
+Version 1.4.0beta39 [November 23, 2008]
   Revised png_warning() to write its message on standard output by default
     when warning_fn is NULL.
 
-version 1.4.0beta40 [November 24, 2008]
+Version 1.4.0beta40 [November 24, 2008]
   Eliminated png_check_cHRM().  Instead, always use png_check_cHRM_fixed().
   In png_check_cHRM_fixed(), ensure white_y is > 0, and removed redundant
     check for all-zero coordinates that is detected by the triangle check.
 
-version 1.4.0beta41 [November 26, 2008]
+Version 1.4.0beta41 [November 26, 2008]
   Fixed string vs pointer-to-string error in png_check_keyword().
   Rearranged test expressions in png_check_cHRM_fixed() to avoid internal
     overflows.
   Added PNG_NO_CHECK_cHRM conditional.
 
-version 1.4.0beta42, 43 [December 1, 2008]
+Version 1.4.0beta42, 43 [December 1, 2008]
   Merge png_debug with version 1.2.34beta04.
 
-version 1.4.0beta44 [December 6, 2008]
+Version 1.4.0beta44 [December 6, 2008]
   Removed redundant check for key==NULL before calling png_check_keyword()
     to ensure that new_key gets initialized and removed extra warning
     (Merge with version 1.2.34beta05 -- Arvan Pritchard).
 
-version 1.4.0beta45 [December 9, 2008]
+Version 1.4.0beta45 [December 9, 2008]
   In png_write_png(), respect the placement of the filler bytes in an earlier
     call to png_set_filler() (Jim Barry).
 
-version 1.4.0beta46 [December 10, 2008]
+Version 1.4.0beta46 [December 10, 2008]
   Undid previous change and added PNG_TRANSFORM_STRIP_FILLER_BEFORE and
     PNG_TRANSFORM_STRIP_FILLER_AFTER conditionals and deprecated
     PNG_TRANSFORM_STRIP_FILLER (Jim Barry).
 
-version 1.4.0beta47 [December 15, 2008]
+Version 1.4.0beta47 [December 15, 2008]
   Support for dithering was disabled by default, because it has never
     been well tested and doesn't work very well.  The code has not
     been removed, however, and can be enabled by building libpng with
     PNG_READ_DITHER_SUPPORTED defined.
 
-version 1.4.0beta48 [February 14, 2009]
+Version 1.4.0beta48 [February 14, 2009]
   Added new exported function png_calloc().
   Combined several instances of png_malloc(); png_memset() into png_calloc().
   Removed prototype for png_freeptr() that was added in libpng-1.4.0beta24
     but was never defined.
 
-version 1.4.0beta49 [February 28, 2009]
+Version 1.4.0beta49 [February 28, 2009]
   Added png_fileno() macro to pngconf.h, used in pngwio.c
   Corrected order of #ifdef's in png_debug definition in png.h
   Fixed bug introduced in libpng-1.4.0beta48 with the memset arguments
     for pcal_params.
   Fixed order of #ifdef directives in the png_debug defines in png.h
     (bug introduced in libpng-1.2.34/1.4.0beta29).
   Revised comments in png_set_read_fn() and png_set_write_fn().
 
-version 1.4.0beta50 [March 18, 2009]
+Version 1.4.0beta50 [March 18, 2009]
   Use png_calloc() instead of png_malloc() to allocate big_row_buf when
     reading an interlaced file, to avoid a possible UMR.
   Undid revision of PNG_NO_STDIO version of png_write_flush().  Users
     having trouble with fflush() can build with PNG_NO_WRITE_FLUSH defined
     or supply their own flush_fn() replacement.
   Revised libpng*.txt and png.h documentation about use of png_write_flush()
     and png_set_write_fn().
   Removed fflush() from pngtest.c.
   Added "#define PNG_NO_WRITE_FLUSH" to contrib/pngminim/encoder/pngusr.h
 
-version 1.4.0beta51 [March 21, 2009]
+Version 1.4.0beta51 [March 21, 2009]
   Removed new png_fileno() macro from pngconf.h .
 
-version 1.4.0beta52 [March 27, 2009]
+Version 1.4.0beta52 [March 27, 2009]
   Relocated png_do_chop() ahead of building gamma tables in pngrtran.c
     This avoids building 16-bit gamma tables unnecessarily.
   Removed fflush() from pngtest.c.
   Added "#define PNG_NO_WRITE_FLUSH" to contrib/pngminim/encoder/pngusr.h
   Added a section on differences between 1.0.x and 1.2.x to libpng.3/libpng.txt
 
-version 1.4.0beta53 [April 1, 2009]
+Version 1.4.0beta53 [April 1, 2009]
   Removed some remaining MMX macros from pngpriv.h
   Fixed potential memory leak of "new_name" in png_write_iCCP() (Ralph Giles)
 
-version 1.4.0beta54 [April 13, 2009]
+Version 1.4.0beta54 [April 13, 2009]
   Added "ifndef PNG_SKIP_SETJMP_CHECK" block in pngconf.h to allow
     application code writers to bypass the check for multiple inclusion
     of setjmp.h when they know that it is safe to ignore the situation.
   Eliminated internal use of setjmp() in pngread.c and pngwrite.c
   Reordered ancillary chunks in pngtest.png to be the same as what
     pngtest now produces, and made some cosmetic changes to pngtest output.
   Eliminated deprecated png_read_init_3() and png_write_init_3() functions.
 
-version 1.4.0beta55 [April 15, 2009]
+Version 1.4.0beta55 [April 15, 2009]
   Simplified error handling in pngread.c and pngwrite.c by putting
     the new png_read_cleanup() and png_write_cleanup() functions inline.
 
-version 1.4.0beta56 [April 25, 2009]
+Version 1.4.0beta56 [April 25, 2009]
   Renamed "user_chunk_data" to "my_user_chunk_data" in pngtest.c to suppress
     "shadowed declaration" warning from gcc-4.3.3.
   Renamed "gamma" to "png_gamma" in pngset.c to avoid "shadowed declaration"
     warning about a global "gamma" variable in math.h on some platforms.
 
-version 1.4.0beta57 [May 2, 2009]
+Version 1.4.0beta57 [May 2, 2009]
   Removed prototype for png_freeptr() that was added in libpng-1.4.0beta24
     but was never defined (again).
   Rebuilt configure scripts with autoconf-2.63 instead of 2.62
   Removed pngprefs.h and MMX from makefiles
 
-version 1.4.0beta58 [May 14, 2009]
+Version 1.4.0beta58 [May 14, 2009]
   Changed pngw32.def to pngwin.def in makefile.mingw (typo was introduced
     in beta57).
   Clarified usage of sig_bit versus sig_bit_p in example.c (Vincent Torri)
 
-version 1.4.0beta59 [May 15, 2009]
+Version 1.4.0beta59 [May 15, 2009]
   Reformated sources in libpng style (3-space intentation, comment format)
   Fixed typo in libpng docs (PNG_FILTER_AVE should be PNG_FILTER_AVG)
   Added sections about the git repository and our coding style to the
     documentation
   Relocated misplaced #endif in pngwrite.c, sCAL chunk handler.
 
-version 1.4.0beta60 [May 19, 2009]
+Version 1.4.0beta60 [May 19, 2009]
   Conditionally compile png_read_finish_row() which is not used by
     progressive readers.
   Added contrib/pngminim/preader to demonstrate building minimal progressive
     decoder, based on contrib/gregbook with embedded libpng and zlib.
 
-version 1.4.0beta61 [May 20, 2009]
+Version 1.4.0beta61 [May 20, 2009]
   In contrib/pngminim/*, renamed "makefile.std" to "makefile", since there
     is only one makefile in those directories, and revised the README files
     accordingly.
   More reformatting of comments, mostly to capitalize sentences.
 
-version 1.4.0beta62 [June 2, 2009]
+Version 1.4.0beta62 [June 2, 2009]
   Added "#define PNG_NO_WRITE_SWAP" to contrib/pngminim/encoder/pngusr.h
     and "define PNG_NO_READ_SWAP" to decoder/pngusr.h and preader/pngusr.h
   Reformatted several remaining "else statement" into two lines.
   Added a section to the libpng documentation about using png_get_io_ptr()
     in configure scripts to detect the presence of libpng.
 
-version 1.4.0beta63 [June 15, 2009]
+Version 1.4.0beta63 [June 15, 2009]
   Revised libpng*.txt and libpng.3 to mention calling png_set_IHDR()
     multiple times and to specify the sample order in the tRNS chunk,
     because the ISO PNG specification has a typo in the tRNS table.
   Changed several PNG_UNKNOWN_CHUNK_SUPPORTED to
     PNG_HANDLE_AS_UNKNOWN_SUPPORTED, to make the png_set_keep mechanism
     available for ignoring known chunks even when not saving unknown chunks.
   Adopted preference for consistent use of "#ifdef" and "#ifndef" versus
     "#if defined()" and "if !defined()" where possible.
 
-version 1.4.0beta64 [June 24, 2009]
+Version 1.4.0beta64 [June 24, 2009]
   Eliminated PNG_LEGACY_SUPPORTED code.
   Moved the various unknown chunk macro definitions outside of the
      PNG_READ|WRITE_ANCILLARY_CHUNK_SUPPORTED blocks.
 
-version 1.4.0beta65 [June 26, 2009]
+Version 1.4.0beta65 [June 26, 2009]
   Added a reference to the libpng license in each file.
 
-version 1.4.0beta66 [June 27, 2009]
+Version 1.4.0beta66 [June 27, 2009]
   Refer to the libpng license instead of the libpng license in each file.
 
-version 1.4.0beta67 [July 6, 2009]
+Version 1.4.0beta67 [July 6, 2009]
   Relocated INVERT_ALPHA within png_read_png() and png_write_png().
   Added high-level API transform PNG_TRANSFORM_GRAY_TO_RGB.
   Added an "xcode" project to the projects directory (Alam Arias).
 
-version 1.4.0beta68 [July 19, 2009]
+Version 1.4.0beta68 [July 19, 2009]
   Avoid some tests in filter selection in pngwutil.c
 
-version 1.4.0beta69 [July 25, 2009]
+Version 1.4.0beta69 [July 25, 2009]
   Simplified the new filter-selection test.  This runs faster in the
     common "PNG_ALL_FILTERS" and PNG_FILTER_NONE cases.
   Removed extraneous declaration from the new call to png_read_gray_to_rgb()
     (bug introduced in libpng-1.4.0beta67).
   Fixed up xcode project (Alam Arias)
   Added a prototype for png_64bit_product() in png.c
 
-version 1.4.0beta70 [July 27, 2009]
+Version 1.4.0beta70 [July 27, 2009]
   Avoid a possible NULL dereference in debug build, in png_set_text_2().
     (bug introduced in libpng-0.95, discovered by Evan Rouault)
 
-version 1.4.0beta71 [July 29, 2009]
+Version 1.4.0beta71 [July 29, 2009]
   Rebuilt configure scripts with autoconf-2.64.
 
-version 1.4.0beta72 [August 1, 2009]
+Version 1.4.0beta72 [August 1, 2009]
   Replaced *.tar.lzma with *.tar.xz in distribution.  Get the xz codec
     from <http://tukaani.org/xz>.
 
-version 1.4.0beta73 [August 1, 2009]
+Version 1.4.0beta73 [August 1, 2009]
   Reject attempt to write iCCP chunk with negative embedded profile length
-    (JD Chen)
-
-version 1.4.0beta74 [August 8, 2009]
+    (JD Chen) (CVE-2009-5063).
+
+Version 1.4.0beta74 [August 8, 2009]
   Changed png_ptr and info_ptr member "trans" to "trans_alpha".
 
-version 1.4.0beta75 [August 21, 2009]
+Version 1.4.0beta75 [August 21, 2009]
   Removed an extra png_debug() recently added to png_write_find_filter().
   Fixed incorrect #ifdef in pngset.c regarding unknown chunk support.
 
-version 1.4.0beta76 [August 22, 2009]
+Version 1.4.0beta76 [August 22, 2009]
   Moved an incorrectly located test in png_read_row() in pngread.c
 
-version 1.4.0beta77 [August 27, 2009]
+Version 1.4.0beta77 [August 27, 2009]
   Removed lpXYZ.tar.bz2 (with CRLF), KNOWNBUG, libpng-x.y.z-KNOWNBUG.txt,
     and the "noconfig" files from the distribution.
   Moved CMakeLists.txt from scripts into the main libpng directory.
   Various bugfixes and improvements to CMakeLists.txt (Philip Lowman)
 
-version 1.4.0beta78 [August 31, 2009]
+Version 1.4.0beta78 [August 31, 2009]
   Converted all PNG_NO_* tests to PNG_*_SUPPORTED everywhere except pngconf.h
   Eliminated PNG_NO_FREE_ME and PNG_FREE_ME_SUPPORTED macros.
   Use png_malloc plus a loop instead of png_calloc() to initialize
     row_pointers in png_read_png().
 
-version 1.4.0beta79 [September 1, 2009]
+Version 1.4.0beta79 [September 1, 2009]
   Eliminated PNG_GLOBAL_ARRAYS and PNG_LOCAL_ARRAYS; always use local arrays.
   Eliminated PNG_CALLOC_SUPPORTED macro and always provide png_calloc().
 
-version 1.4.0beta80 [September 17, 2009]
+Version 1.4.0beta80 [September 17, 2009]
   Removed scripts/libpng.icc
   Changed typecast of filler from png_byte to png_uint_16 in png_set_filler().
     (Dennis Gustafsson)
   Fixed typo introduced in beta78 in pngtest.c ("#if def " should be "#ifdef ")
 
-version 1.4.0beta81 [September 23, 2009]
+Version 1.4.0beta81 [September 23, 2009]
   Eliminated unused PNG_FLAG_FREE_* defines from pngpriv.h
   Expanded TAB characters in pngrtran.c
   Removed PNG_CONST from all "PNG_CONST PNG_CHNK" declarations to avoid
     compiler complaints about doubly declaring things "const".
   Changed all "#if [!]defined(X)" to "if[n]def X" where possible.
   Eliminated unused png_ptr->row_buf_size
 
-version 1.4.0beta82 [September 25, 2009]
+Version 1.4.0beta82 [September 25, 2009]
   Moved redundant IHDR checking into new png_check_IHDR() in png.c
     and report all errors found in the IHDR data.
   Eliminated useless call to png_check_cHRM() from pngset.c
 
-version 1.4.0beta83 [September 25, 2009]
+Version 1.4.0beta83 [September 25, 2009]
   Revised png_check_IHDR() to eliminate bogus complaint about filter_type.
 
-version 1.4.0beta84 [September 30, 2009]
+Version 1.4.0beta84 [September 30, 2009]
   Fixed some inconsistent indentation in pngconf.h
   Revised png_check_IHDR() to add a test for width variable less than 32-bit.
 
-version 1.4.0beta85 [October 1, 2009]
+Version 1.4.0beta85 [October 1, 2009]
   Revised png_check_IHDR() again, to check info_ptr members instead of
     the contents of the returned parameters.
 
-version 1.4.0beta86 [October 9, 2009]
+Version 1.4.0beta86 [October 9, 2009]
   Updated the "xcode" project (Alam Arias).
   Eliminated a shadowed declaration of "pp" in png_handle_sPLT().
 
-version 1.4.0rc01 [October 19, 2009]
+Version 1.4.0rc01 [October 19, 2009]
   Trivial cosmetic changes.
 
-version 1.4.0beta87 [October 30, 2009]
+Version 1.4.0beta87 [October 30, 2009]
   Moved version 1.4.0 back into beta.
 
-version 1.4.0beta88 [October 30, 2009]
+Version 1.4.0beta88 [October 30, 2009]
   Revised libpng*.txt section about differences between 1.2.x and 1.4.0
     because most of the new features have now been ported back to 1.2.41
 
-version 1.4.0beta89 [November 1, 2009]
+Version 1.4.0beta89 [November 1, 2009]
   More bugfixes and improvements to CMakeLists.txt (Philip Lowman)
   Removed a harmless extra png_set_invert_alpha() from pngwrite.c
   Apply png_user_chunk_cache_max within png_decompress_chunk().
   Merged libpng-1.2.41.txt with libpng-1.4.0.txt where appropriate.
 
-version 1.4.0beta90 [November 2, 2009]
+Version 1.4.0beta90 [November 2, 2009]
   Removed all remaining WIN32_WCE #ifdefs except those involving the
     time.h "tm" structure
 
-version 1.4.0beta91 [November 3, 2009]
+Version 1.4.0beta91 [November 3, 2009]
   Updated scripts/pngw32.def and projects/wince/png32ce.def
   Copied projects/wince/png32ce.def to the scripts directory.
   Added scripts/makefile.wce
   Patched ltmain.sh for wince support.
   Added PNG_CONVERT_tIME_SUPPORTED macro.
 
-version 1.4.0beta92 [November 4, 2009]
+Version 1.4.0beta92 [November 4, 2009]
   Make inclusion of time.h in pngconf.h depend on PNG_CONVERT_tIME_SUPPORTED
   Make #define PNG_CONVERT_tIME_SUPPORTED depend on PNG_WRITE_tIME_SUPPORTED
   Revised libpng*.txt to describe differences from 1.2.40 to 1.4.0 (instead
     of differences from 1.2.41 to 1.4.0)
 
-version 1.4.0beta93 [November 7, 2009]
+Version 1.4.0beta93 [November 7, 2009]
   Added PNG_DEPSTRUCT, PNG_DEPRECATED, PNG_USE_RESULT, PNG_NORETURN, and
     PNG_ALLOCATED macros to detect deprecated direct access to the
     png_struct or info_struct members and other deprecated usage in
     applications (John Bowler).
   Updated scripts/makefile* to add "-DPNG_CONFIGURE_LIBPNG" to CFLAGS,
     to prevent warnings about direct access to png structs by libpng
     functions while building libpng.  They need to be tested, especially
     those using compilers other than gcc.
@@ -2318,518 +2475,1346 @@ version 1.4.0beta93 [November 7, 2009]
   Removed three direct references to read_info_ptr members in pngtest.c
     that were detected by the new PNG_DEPSTRUCT macro.
   Moved the png_debug macro definitions and the png_read_destroy(),
     png_write_destroy() and png_far_to_near() prototypes from png.h
     to pngpriv.h (John Bowler)
   Moved the synopsis lines for png_read_destroy(), png_write_destroy()
     png_debug(), png_debug1(), and png_debug2() from libpng.3 to libpngpf.3.
 
-version 1.4.0beta94 [November 9, 2009]
+Version 1.4.0beta94 [November 9, 2009]
   Removed the obsolete, unused pnggccrd.c and pngvcrd.c files.
   Updated CMakeLists.txt to add "-DPNG_CONFIGURE_LIBPNG" to the definitions.
   Removed dependency of pngtest.o on pngpriv.h in the makefiles.
   Only #define PNG_DEPSTRUCT, etc. in pngconf.h if not already defined.
 
-version 1.4.0beta95 [November 10, 2009]
+Version 1.4.0beta95 [November 10, 2009]
   Changed png_check_sig() to !png_sig_cmp() in contrib programs.
   Added -DPNG_CONFIGURE_LIBPNG to contrib/pngminm/*/makefile
   Changed png_check_sig() to !png_sig_cmp() in contrib programs.
   Corrected the png_get_IHDR() call in contrib/gregbook/readpng2.c
   Changed pngminim/*/gather.sh to stop trying to remove pnggccrd.c and pngvcrd.c
   Added dependency on pngpriv.h in contrib/pngminim/*/makefile
 
-version 1.4.0beta96 [November 12, 2009]
+Version 1.4.0beta96 [November 12, 2009]
   Renamed scripts/makefile.wce to scripts/makefile.cegcc
   Revised Makefile.am to use libpng.sys while building libpng.so
     so that only PNG_EXPORT functions are exported.
   Removed the deprecated png_check_sig() function/macro.
   Removed recently removed function names from scripts/*.def
   Revised pngtest.png to put chunks in the same order written by pngtest
     (evidently the same change made in libpng-1.0beta54 was lost).
   Added PNG_PRIVATE macro definition in pngconf.h for possible future use.
 
-version 1.4.0beta97 [November 13, 2009]
+Version 1.4.0beta97 [November 13, 2009]
   Restored pngtest.png to the libpng-1.4.0beta7 version.
   Removed projects/beos and netware.txt; no one seems to be supporting them.
   Revised Makefile.in
 
-version 1.4.0beta98 [November 13, 2009]
+Version 1.4.0beta98 [November 13, 2009]
   Added the "xcode" project to zip distributions,
   Fixed a typo in scripts/pngwin.def introduced in beta97.
 
-version 1.4.0beta99 [November 14, 2009]
+Version 1.4.0beta99 [November 14, 2009]
   Moved libpng-config.in and libpng.pc-configure.in out of the scripts
     directory, to libpng-config.in and libpng-pc.in, respectively, and
     modified Makefile.am and configure.ac accordingly.  Now "configure"
     needs nothing from the "scripts" directory.
   Avoid redefining PNG_CONST in pngconf.h
 
-version 1.4.0beta100 [November 14, 2009]
+Version 1.4.0beta100 [November 14, 2009]
   Removed ASM builds from projects/visualc6 and projects/visualc71
   Removed scripts/makefile.nommx and makefile.vcawin32
   Revised CMakeLists.txt to account for new location of libpng-config.in
     and libpng-pc.in
   Updated INSTALL to reflect removal and relocation of files.
 
-version 1.4.0beta101 [November 14, 2009]
+Version 1.4.0beta101 [November 14, 2009]
   Restored the binary files (*.jpg, *.png, some project files) that were
     accidentally deleted from the zip and 7z distributions when the xcode
     project was added.
 
-version 1.4.0beta102 [November 18, 2009]
+Version 1.4.0beta102 [November 18, 2009]
   Added libpng-config.in and libpng-pc.in to the zip and 7z distributions.
   Fixed a typo in projects/visualc6/pngtest.dsp, introduced in beta100.
   Moved descriptions of makefiles and other scripts out of INSTALL into
     scripts/README.txt
   Updated the copyright year in scripts/pngwin.rc from 2006 to 2009.
 
-version 1.4.0beta103 [November 21, 2009]
+Version 1.4.0beta103 [November 21, 2009]
   Removed obsolete comments about ASM from projects/visualc71/README_zlib.txt
   Align row_buf on 16-byte boundary in memory.
   Restored the PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED guard around the call
     to png_flush() after png_write_IEND().  See 1.4.0beta32, 1.4.0beta50
     changes above and 1.2.30, 1.2.30rc01 and rc03 in 1.2.41 CHANGES.  Someone
     needs this feature.
   Make the 'png_jmpbuf' macro expand to a call that records the correct
     longjmp function as well as returning a pointer to the setjmp
     jmp_buf buffer, and marked direct access to jmpbuf 'deprecated'.
     (John Bowler)
 
-version 1.4.0beta104 [November 22, 2009]
+Version 1.4.0beta104 [November 22, 2009]
   Removed png_longjmp_ptr from scripts/*.def and libpng.3
   Rebuilt configure scripts with autoconf-2.65
 
-version 1.4.0beta105 [November 25, 2009]
+Version 1.4.0beta105 [November 25, 2009]
   Use fast integer PNG_DIVIDE_BY_255() or PNG_DIVIDE_BY_65535()
     to accomplish alpha premultiplication when
     PNG_READ_COMPOSITE_NODIV_SUPPORTED is defined.
   Changed "/255" to "/255.0" in background calculations to make it clear
     that the 255 is used as a double.
 
-version 1.4.0beta106 [November 27, 2009]
+Version 1.4.0beta106 [November 27, 2009]
   Removed premultiplied alpha feature.
 
-version 1.4.0beta107 [December 4, 2009]
+Version 1.4.0beta107 [December 4, 2009]
   Updated README
   Added "#define PNG_NO_PEDANTIC_WARNINGS" in the libpng source files.
   Removed "-DPNG_CONFIGURE_LIBPNG" from the makefiles and projects.
   Revised scripts/makefile.netbsd, makefile.openbsd, and makefile.sco
     to put png.h and pngconf.h in $prefix/include, like the other scripts,
     instead of in $prefix/include/libpng.  Also revised makefile.sco
-    to put them in $prefix/include/libpng14 instead of in
-    $prefix/include/libpng/libpng14.
-
-version 1.4.0beta108 [December 11, 2009]
+    to put them in $prefix/include/libpng15 instead of in
+    $prefix/include/libpng/libpng15.
+
+Version 1.4.0beta108 [December 11, 2009]
   Removed leftover "-DPNG_CONFIGURE_LIBPNG" from contrib/pngminim/*/makefile
   Relocated png_do_chop() to its original position in pngrtran.c; the
     change in version 1.2.41beta08 caused transparency to be handled wrong
     in some 16-bit datastreams (Yusaku Sugai).
 
-version 1.4.0beta109 [December 13, 2009]
+Version 1.4.0beta109 [December 13, 2009]
   Added "bit_depth" parameter to the private png_build_gamma_table() function.
   Pass bit_depth=8 to png_build_gamma_table() when bit_depth is 16 but the
     PNG_16_TO_8 transform has been set, to avoid unnecessary build of 16-bit
     tables.
 
-version 1.4.0rc02 [December 20, 2009]
+Version 1.4.0rc02 [December 20, 2009]
   Declared png_cleanup_needed "volatile" in pngread.c and pngwrite.c
 
-version 1.4.0rc03 [December 22, 2009]
+Version 1.4.0rc03 [December 22, 2009]
   Renamed libpng-pc.in back to libpng.pc.in and revised CMakeLists.txt
     (revising the change in 1.4.0beta99)
 
-version 1.4.0rc04 [December 25, 2009]
+Version 1.4.0rc04 [December 25, 2009]
   Swapped PNG_UNKNOWN_CHUNKS_SUPPORTED and PNG_HANDLE_AS_UNKNOWN_SUPPORTED
     in pngset.c to be consistent with other changes in version 1.2.38.
 
-version 1.4.0rc05 [December 25, 2009]
+Version 1.4.0rc05 [December 25, 2009]
   Changed "libpng-pc.in" to "libpng.pc.in" in configure.ac, configure, and
     Makefile.in to be consistent with changes in libpng-1.4.0rc03
 
-version 1.4.0rc06 [December 29, 2009]
+Version 1.4.0rc06 [December 29, 2009]
   Reverted the gamma_table changes from libpng-1.4.0beta109.
   Fixed some indentation errors.
 
-version 1.4.0rc07 [January 1, 2010]
+Version 1.4.0rc07 [January 1, 2010]
   Revised libpng*.txt and libpng.3 about 1.2.x->1.4.x differences.
   Use png_calloc() instead of png_malloc(); png_memset() in pngrutil.c
   Update copyright year to 2010.
 
-version 1.4.0rc08 [January 2, 2010]
+Version 1.4.0rc08 [January 2, 2010]
   Avoid deprecated references to png_ptr-io_ptr and png_ptr->error_ptr
     in pngtest.c
 
-version 1.4.0 [January 3, 2010]
+Version 1.4.0 [January 3, 2010]
   No changes.
 
-version 1.4.1beta01 [January 8, 2010]
+Version 1.4.1beta01 [January 8, 2010]
   Updated CMakeLists.txt for consistent indentation and to avoid an
     unclosed if-statement warning (Philip Lowman).
   Revised Makefile.am and Makefile.in to remove references to Y2KINFO,
     KNOWNBUG, and libpng.la (Robert Schwebel).
   Revised the makefiles to install the same files and symbolic
     links as configure, except for libpng.la and libpng14.la.
   Make png_set|get_compression_buffer_size() available even when
     PNG_WRITE_SUPPORTED is not enabled.
   Revised Makefile.am and Makefile.in to simplify their maintenance.
   Revised scripts/makefile.linux to install a link to libpng14.so.14.1
 
-version 1.4.1beta02 [January 9, 2010]
+Version 1.4.1beta02 [January 9, 2010]
   Revised the rest of the makefiles to install a link to libpng14.so.14.1
 
-version 1.4.1beta03 [January 10, 2010]
+Version 1.4.1beta03 [January 10, 2010]
   Removed png_set_premultiply_alpha() from scripts/*.def
 
-version 1.4.1rc01 [January 16, 2010]
+Version 1.4.1rc01 [January 16, 2010]
   No changes.
 
-version 1.4.1beta04 [January 23, 2010]
+Version 1.4.1beta04 [January 23, 2010]
   Revised png_decompress_chunk() to improve speed and memory usage when
     decoding large chunks.
   Added png_set|get_chunk_malloc_max() functions.
 
-version 1.4.1beta05 [January 26, 2010]
+Version 1.4.1beta05 [January 26, 2010]
   Relocated "int k" declaration in pngtest.c to minimize its scope.
 
-version 1.4.1beta06 [January 28, 2010]
+Version 1.4.1beta06 [January 28, 2010]
   Revised png_decompress_chunk() to use a two-pass method suggested by
     John Bowler.
 
-version 1.4.1beta07 [February 6, 2010]
+Version 1.4.1beta07 [February 6, 2010]
   Folded some long lines in the source files.
   Added defineable PNG_USER_CHUNK_CACHE_MAX, PNG_USER_CHUNK_MALLOC_MAX,
     and a PNG_USER_LIMITS_SUPPORTED flag.
   Eliminated use of png_ptr->irowbytes and reused the slot in png_ptr as
     png_ptr->png_user_chunk_malloc_max.
   Revised png_push_save_buffer() to do fewer but larger png_malloc() calls.
 
-version 1.4.1beta08 [February 6, 2010]
+Version 1.4.1beta08 [February 6, 2010]
   Minor cleanup and updating of dates and copyright year.
 
-version 1.4.1beta09 [February 7, 2010]
+Version 1.5.0beta01 [February 7, 2010]
+  Moved declaration of png_struct into private pngstruct.h and png_info
+    into pnginfo.h
+
+Version 1.4.1beta09 and 1.5.0beta02 [February 7, 2010]
   Reverted to original png_push_save_buffer() code.
 
-version 1.4.1beta10 [February 9, 2010]
-  Return allocated "old_buffer" in png_push_save_buffer() before calling
-    png_error(), to avoid a potential memory leak.
-
-version 1.4.1beta11 [February 12, 2010]
-  Relocated misplaced closing curley bracket in png_decompress_chunk().
-  Removed unused "buffer_size" variable from png_decompress_chunk().
+Version 1.4.1beta10 and 1.5.0beta03 [February 8, 2010]
+  Return allocated "old_buffer" in png_push_save_buffer() before
+    calling png_error(), to avoid a potential memory leak.
+  Updated configure script to use SO number 15.
+
+Version 1.5.0beta04 [February 9, 2010]
+  Removed malformed "incomplete struct declaration" of png_info from png.h
+
+Version 1.5.0beta05 [February 12, 2010]
+  Removed PNG_DEPSTRUCT markup in pngstruct.h and pnginfo.h, and undid the
+    linewrapping that it entailed.
+  Revised comments in pngstruct.h and pnginfo.h and added pointers to
+    the libpng license.
+  Changed PNG_INTERNAL to PNG_EXPOSE_INTERNAL_STRUCTURES
   Removed the cbuilder5 project, which has not been updated to 1.4.0.
-  Complete rewrite of two-pass png_decompress_chunk() by John Bowler.
-
-version 1.4.1beta12 [February 14, 2010]
-  Fixed type declaration of png_get_user_malloc_max() in pngget.c (Daisuke
+
+Version 1.4.1beta12 and 1.5.0beta06 [February 14, 2010]
+  Fixed type declaration of png_get_chunk_malloc_max() in pngget.c (Daisuke
     Nishikawa)
 
-version 1.4.1rc02 [January 18, 2010]
-  No changes.
-
-version 1.4.1rc03 [February 19, 2010]
+Version 1.5.0beta07 [omitted]
+
+Version 1.5.0beta08 [February 19, 2010]
+  Changed #ifdef PNG_NO_STDIO_SUPPORTED to #ifdef PNG_NO_CONSOLE_IO_SUPPORTED
+    wherever png_snprintf() is used to construct error and warning messages.
   Noted in scripts/makefile.mingw that it expects to be run under MSYS.
   Removed obsolete unused MMX-querying support from contrib/gregbook
+  Added exported png_longjmp() function.
   Removed the AIX redefinition of jmpbuf in png.h
-  Define _ALL_SOURCE in configure.ac, makefile.aix, and CMakeLists.txt
-    when using AIX compiler.
-
-version 1.4.1rc04 [February 19, 2010]
+  Added -D_ALLSOURCE in configure.ac, makefile.aix, and CMakeLists.txt
+    when building on AIX.
+
+Version 1.5.0beta09 [February 19, 2010]
+  Removed -D_ALLSOURCE from configure.ac, makefile.aix, and CMakeLists.txt.
+  Changed the name of png_ptr->jmpbuf to png_ptr->png_jmpbuf in pngstruct.h
+
+Version 1.5.0beta10 [February 25, 2010]
   Removed unused gzio.c from contrib/pngminim gather and makefile scripts
-
-version 1.4.1 [February 25, 2010]
-
-version 1.4.2beta01 [April 1, 2010]
-  Conditionally compile an "else" statement in png_decompress_chunk().
+  Removed replacement error handlers from contrib/gregbook.  Because of
+    the new png_longjmp() function they are no longer needed.
+
+Version 1.5.0beta11 [March 6, 2010]
+  Removed checking for already-included setjmp.h from pngconf.h
+  Fixed inconsistent indentations and made numerous cosmetic changes.
+  Revised the "SEE ALSO" style of libpng.3, libpngpf.3, and png.5
+
+Version 1.5.0beta12 [March 9, 2010]
+  Moved "#include png.h" inside pngpriv.h and removed "#include png.h" from
+    the source files, along with "#define PNG_EXPOSE_INTERNAL_STRUCTURES"
+    and "#define PNG_NO_PEDANTIC_WARNINGS" (John Bowler).
+  Created new pngdebug.h and moved debug definitions there.
+
+Version 1.5.0beta13 [March 10, 2010]
+  Protect pngstruct.h, pnginfo.h, and pngdebug.h from being included twice.
+  Revise the "#ifdef" blocks in png_inflate() so it will compile when neither
+    PNG_USER_CHUNK_MALLOC_MAX nor PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
+    is defined.
+  Removed unused png_measure_compressed_chunk() from pngpriv.h and libpngpf.3
+  Moved the 'config.h' support from pngconf.h to pngpriv.h
+  Removed PNGAPI from the png_longjmp_ptr typedef.
+  Eliminated dependence of pngtest.c on the private pngdebug.h file.
+  Make all png_debug macros into *unterminated* statements or
+    expressions (i.e. a trailing ';' must always be added) and correct
+    the format statements in various png_debug messages.
+
+Version 1.5.0beta14 [March 14, 2010]
+  Removed direct access to png_ptr->io_ptr from the Windows code in pngtest.c
+  Revised Makefile.am to account for recent additions and replacements.
+  Corrected CE and OS/2 DEF files (scripts/png*def) for symbols removed and
+    added ordinal numbers to the Windows DEF file and corrected the duplicated
+    ordinal numbers on CE symbols that are commented out.
+  Added back in export symbols that can be present in the Windows build but
+    are disabled by default.
+  PNG_EXPORT changed to include an 'ordinal' field for DEF file generation.
+    PNG_CALLBACK added to make callback definitions uniform.  PNGAPI split
+    into PNGCAPI (base C form), PNGAPI (exports) and PNGCBAPI (callbacks),
+    and appropriate changes made to all files.  Cygwin builds re-hinged to
+    allow procedure call standard changes and to remove the need for the DEF
+    file (fixes build on Cygwin).
+  Enabled 'attribute' warnings that are relevant to library APIs and callbacks.
+  Changed rules for generation of the various symbol files and added a new
+    rule for a DEF file (which is also added to the distribution).
+  Updated the symbol file generation to stop it adding spurious spaces
+    to EOL (coming from preprocessor macro expansion).  Added a facility
+    to join tokens in the output and rewrite *.dfn to use this.
+  Eliminated scripts/*.def in favor of libpng.def; updated projects/visualc71
+    and removed scripts/makefile.cygwin.
+  Made PNG_BUILD_DLL safe: it can be set whenever a DLL is being built.
+  Removed the include of sys/types.h - apparently unnecessary now on the
+    platforms on which it happened (all but Mac OS and RISC OS).
+  Moved the Mac OS test into pngpriv.h (the only place it is used.)
+
+Version 1.5.0beta15 [March 17, 2010]
+  Added symbols.chk target to Makefile.am to validate the symbols in png.h
+    against the new DEF file scripts/symbols.def.
+  Changed the default DEF file back to pngwin.def.
+  Removed makefile.mingw.
+  Eliminated PNG_NO_EXTERN and PNG_ALL_EXTERN
+
+Version 1.5.0beta16 [April 1, 2010]
+  Make png_text_struct independent of PNG_iTXt_SUPPORTED, so that
+    fields are initialized in all configurations.  The READ/WRITE
+    macros (PNG_(READ|WRITE)_iTXt_SUPPORTED) still function as
+    before to disable code to actually read or write iTXt chunks
+    and iTXt_SUPPORTED can be used to detect presence of either
+    read or write support (but it is probably better to check for
+    the one actually required - read or write.)
+  Combined multiple png_warning() calls for a single error.
   Restored the macro definition of png_check_sig().
 
-version 1.4.2rc01 [April 10, 2010]
-  No changes.
-
-version 1.4.2rc02 [April 16, 2010]
+Version 1.5.0beta17 [April 17, 2010]
+  Added some "(long)" typecasts to printf calls in png_handle_cHRM().
   Documented the fact that png_set_dither() was disabled since libpng-1.4.0.
   Reenabled png_set_dither() but renamed it to png_set_quantize() to reflect
     more accurately what it actually does.  At the same time, renamed
     the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros to
     PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS.
-
-version 1.4.2rc03 [April 24, 2010]
   Added some "(long)" typecasts to printf calls in png_handle_cHRM().
+  Freeze build-time only configuration in the build.
+    In all prior versions of libpng most configuration options
+    controlled by compiler #defines had to be repeated by the
+    application code that used libpng.  This patch changes this
+    so that compilation options that can only be changed at build
+    time are frozen in the build.  Options that are compiler
+    dependent (and those that are system dependent) are evaluated
+    each time - pngconf.h holds these.  Options that can be changed
+    per-file in the application are in png.h.  Frozen options are
+    in the new installed header file pnglibconf.h (John Bowler)
+  Removed the xcode project because it has not been updated to work
+    with libpng-1.5.0.
+  Removed the ability to include optional pngusr.h
+
+Version 1.5.0beta18 [April 17, 2010]
+  Restored the ability to include optional pngusr.h
+  Moved replacements for png_error() and png_warning() from the
+    contrib/pngminim project to pngerror.c, for use when warnings or
+    errors are disabled via PNG_NO_WARN or PNG_NO_ERROR_TEXT, to avoid
+    storing unneeded error/warning text.
+  Updated contrib/pngminim project to work with the new pnglibconf.h
+  Added some PNG_NO_* defines to contrib/pngminim/*/pngusr.h to save space.
+
+Version 1.5.0beta19 [April 24, 2010]
+  Added PNG_{READ,WRITE}_INT_FUNCTIONS_SUPPORTED.  This allows the functions
+    to read and write ints to be disabled independently of PNG_USE_READ_MACROS,
+    which allows libpng to be built with the functions even though the default
+    is to use the macros - this allows applications to choose at app build
+    time whether or not to use macros (previously impossible because the
+    functions weren't in the default build.)
+  Changed Windows calling convention back to __cdecl for API functions.
+    For Windows/x86 platforms only:
+      __stdcall is no longer needed for Visual Basic, so libpng-1.5.0 uses
+      __cdecl throughout (both API functions and callbacks) on Windows/x86
+      platforms.
+  Replaced visualc6 and visualc71 projects with new vstudio project
   Relaxed the overly-restrictive permissions of some files.
 
-version 1.4.2rc04 [April 28, 2010]
-  Added the "vstudio" project to replace "visualc6" and "visualc71" which
-    will be removed from libpng-1.5.0.
-  Demonstrate in example.c that lang_key should be initialized.
+Version 1.5.0beta20 [April 24, 2010]
+  Relaxed more overly-restrictive permissions of some files.
+
+Version 1.5.0beta21 [April 27, 2010]
+  Removed some unwanted binary bytes and changed CRLF to NEWLINE in the new
+    vstudio project files, and some trivial editing of some files in the
+    scripts directory.
   Set PNG_NO_READ_BGR, PNG_NO_IO_STATE, and PNG_NO_TIME_RFC1123 in
     contrib/pngminim/decoder/pngusr.h to make a smaller decoder application.
 
-version 1.4.2rc05 [April 29, 2010]
-  Include png_reset_zstream() in png.c only when PNG_READ_SUPPORTED is defined.
-  Removed dummy_inflate.c and uncompr.c from contrib/pngminim/encoder
+Version 1.5.0beta22 [April 28, 2010]
+  Fixed dependencies of GET_INT_32 - it does not require READ_INT_FUNCTIONS
+    because it has a macro equivalent.
+  Improved the options.awk script; added an "everything off" option.
+  Revised contrib/pngminim to use the "everything off" option in pngusr.dfa.
+
+Version 1.5.0beta23 [April 29, 2010]
+  Corrected PNG_REMOVED macro to take five arguments.
+    The macro was documented with two arguments (name,ordinal), however
+    the symbol checking .dfn files assumed five arguments.  The five
+    argument form seems more useful so it is changed to that.
   Corrected PNG_UNKNOWN_CHUNKS_SUPPORTED to PNG_HANDLE_AS_UNKNOWN_SUPPORTED
     in gregbook/readpng2.c
   Corrected protection of png_get_user_transform_ptr. The API declaration in
     png.h is removed if both READ and WRITE USER_TRANSFORM are turned off
     but was left defined in pngtrans.c
-
-version 1.4.2rc06 [May 3, 2010]
-  Moved declarations of umsg[] inside the proper #ifdef blocks in pngrutil.c
-
-version 1.4.2 [May 6, 2010]
-
-version 1.4.3beta01 [June 18, 2010]
-  Added missing quotation marks in the aix block of configure.ac
-  The new "vstudio" project was missing from the zip and 7z distributions.
+  Added logunsupported=1 to cause pnglibconf.h to document disabled options.
+    This makes the installed pnglibconf.h more readable but causes no
+    other change.  The intention is that users of libpng will find it
+    easier to understand if an API they need is missing.
+  Include png_reset_zstream() in png.c only when PNG_READ_SUPPORTED is defined.
+  Removed dummy_inflate.c from contrib/pngminim/encoder
+  Removed contrib/pngminim/*/gather.sh; gathering is now done in the makefile.
+
+Version 1.5.0beta24 [May 7, 2010]
+  Use bitwise "&" instead of arithmetic mod in pngrutil.c calculation of the
+    offset of the png_ptr->rowbuf pointer into png_ptr->big_row_buf.
+  Added more blank lines for readability.
+
+Version 1.5.0beta25 [June 18, 2010]
   In pngpread.c: png_push_have_row() add check for new_row > height
-
-version 1.4.3beta02 [June 18, 2010]
   Removed the now-redundant check for out-of-bounds new_row from example.c
 
-version 1.4.3beta03 [June 18, 2010]
-  In pngpread.c: png_push_finish_row() add check for too many rows.
-
-version 1.4.3beta04 [June 19, 2010]
+Version 1.5.0beta26 [June 18, 2010]
   In pngpread.c: png_push_process_row() add check for too many rows.
-  Removed the checks added in beta01 and beta03, as they are now redundant.
-
-version 1.4.3beta05 [June 20, 2010]
+
+Version 1.5.0beta27 [June 18, 2010]
+  Removed the check added in beta25 as it is now redundant.
+
+Version 1.5.0beta28 [June 20, 2010]
   Rewrote png_process_IDAT_data to consistently treat extra data as warnings
     and handle end conditions more cleanly.
-  Removed the new (beta04) check in png_push_process_row().
-
-version 1.4.3rc01 [June 21, 2010]
-  Revised some comments in png_process_IDAT_data().
-
-version 1.4.3rc02 [June 22, 2010]
-  Changed char *msg to PNG_CONST char *msg in pngrutil.c
+  Removed the new (beta26) check in png_push_process_row().
+
+Version 1.5.0beta29 [June 21, 2010]
+  Revised scripts/options.awk to work on Sunos (but still doesn't work)
+  Added comment to options.awk and contrib/pngminim/*/makefile to try nawk.
+
+Version 1.5.0beta30 [June 22, 2010]
   Stop memory leak when reading a malformed sCAL chunk.
+
+Version 1.5.0beta31 [June 26, 2010]
+  Revised pngpread.c patch of beta28 to avoid an endless loop.
   Removed some trailing blanks.
 
-version 1.4.3rc03 [June 23, 2010]
-  Revised pngpread.c patch of beta05 to avoid an endless loop.
-
-version 1.4.3 [June 26, 2010]
-  Updated some of the "last changed" dates.
-
-version 1.4.4beta01 [July 12, 2010]
-  Removed extraneous new_push_process_row.c file.
-  Revised the "SEE ALSO" style of libpng.3, libpngpf.3, and png.5
-  Removed some newly-added TAB characters from pngpread.c.
-  Fixed some indentation in pngpread.c and pngrutil.c
+Version 1.5.0beta32 [June 26, 2010]
+  Removed leftover scripts/options.patch and scripts/options.rej
+
+Version 1.5.0beta33 [July 6, 3010]
+  Made FIXED and FLOATING options consistent in the APIs they enable and
+    disable.  Corrected scripts/options.awk to handle both command line
+    options and options specified in the .dfa files.
+  Changed char *msg to PNG_CONST char *msg in pngrutil.c
+  Make png_set_sRGB_gAMA_and_cHRM set values using either the fixed or
+    floating point APIs, but not both.
+  Reversed patch to remove error handler when the jmp_buf is stored in the
+    main program structure, not the png_struct.
+    The error handler is needed because the default handler in libpng will
+    always use the jmp_buf in the library control structure; this is never
+    set.  The gregbook code is a useful example because, even though it
+    uses setjmp/longjmp, it shows how error handling can be implemented
+    using control mechanisms not directly supported by libpng.  The
+    technique will work correctly with mechanisms such as Microsoft
+    Structure Exceptions or C++ exceptions (compiler willing - note that gcc
+    does not by default support interworking of C and C++ error handling.)
+  Reverted changes to call png_longjmp in contrib/gregbook where it is not
+    appropriate.  If mainprog->jmpbuf is used by setjmp, then png_longjmp
+    cannot be used.
   Changed "extern PNG_EXPORT" to "PNG_EXPORT" in png.h (Jan Nijtmans)
   Changed "extern" to "PNG_EXTERN" in pngpriv.h (except for the 'extern "C" {')
-  Put "#ifndef PNG_EXTERN, #endif" around "#define PNG_EXTERN" in pngpriv.h
-
-version 1.4.4beta02 [July 24, 2010]
+
+Version 1.5.0beta34 [July 12, 2010]
+  Put #ifndef PNG_EXTERN, #endif around the define PNG_EXTERN in pngpriv.h
+
+Version 1.5.0beta35 [July 24, 2010]
+  Removed some newly-added TAB characters.
   Added -DNO_PNG_SNPRINTF to CFLAGS in scripts/makefile.dj2
   Moved the definition of png_snprintf() outside of the enclosing
     #ifdef blocks in pngconf.h
-  Added a special case typedef of png_longjmp_ptr for WATCOM.
-
-version 1.4.4beta03 [July 24, 2010]
-  Removed reference to cbuilder5/* from Makefile.in and Makefile.am
-  Eliminated the new special case typedef of png_longjmp_ptr for WATCOM
-    and made a special case "#define PNGAPI" in pngconf.h instead.
-
-version 1.4.4beta04 [July 31, 2010]
-  Updated the read macros and functions from 1.5.0beta38.
-
-version 1.4.4beta05 [August 6, 2010]
-  Updated projects/visualc71 so it can find scripts/pnglibconf.h
-  Removed unused png_mem_* defines from pngconf.h.
+
+Version 1.5.0beta36 [July 29, 2010]
+  Patches by John Bowler:
+  Fixed point APIs are now supported throughout (no missing APIs).
+  Internal fixed point arithmetic support exists for all internal floating
+    point operations.
+  sCAL validates the floating point strings it is passed.
+  Safe, albeit rudimentary, Watcom support is provided by PNG_API_RULE==2
+  Two new APIs exist to get the number of passes without turning on the
+    PNG_INTERLACE transform and to get the number of rows in the current
+    pass.
+  A new test program, pngvalid.c, validates the gamma code.
+  Errors in the 16-bit gamma correction (overflows) have been corrected.
+  cHRM chunk testing is done consistently (previously the floating point
+    API bypassed it, because the test really didn't work on FP, now the test
+    is performed on the actual values to be stored in the PNG file so it
+    works in the FP case too.)
+  Most floating point APIs now simply call the fixed point APIs after
+    converting the values to the fixed point form used in the PNG file.
+  The standard headers no longer include zlib.h, which is currently only
+    required for pngstruct.h and can therefore be internal.
+  Revised png_get_int_32 to undo the PNG two's complement representation of
+    negative numbers.
+
+Version 1.5.0beta37 [July 30, 2010]
+  Added a typecast in png_get_int_32() in png.h and pngrutil.h to avoid
+    a compiler warning.
+  Replaced oFFs 0,0 with oFFs -10,20 in pngtest.png
+
+Version 1.5.0beta38 [July 31, 2010]
+  Implemented remaining "_fixed" functions.
+  Corrected a number of recently introduced warnings mostly resulting from
+    safe but uncast assignments to shorter integers.  Also added a zlib
+    VStudio release library project because the latest zlib Official Windows
+    build does not include such a thing.
+  Revised png_get_int_16() to be similar to png_get_int_32().
+  Restored projects/visualc71.
+
+Version 1.5.0beta39 [August 2, 2010]
+  VisualC/GCC warning fixes, VisualC build fixes
+  The changes include support for function attributes in VC in addition to
+    those already present in GCC - necessary because without these some
+    warnings are unavoidable.  Fixes include signed/unsigned fixes in
+    pngvalid and checks with gcc -Wall -Wextra -Wunused.
+  VC requires function attributes on function definitions as well as
+    declarations, PNG_FUNCTION has been added to enable this and the
+    relevant function definitions changed.
+
+Version 1.5.0beta40 [August 6, 2010]
   Correct use of _WINDOWS_ in pngconf.h
-
-version 1.4.4beta06 [August 11, 2010]
+  Removed png_mem_ #defines; they are no longer used.
+  Added the sRGB chunk to pngtest.png
+
+Version 1.5.0beta41 [August 11, 2010]
+  Added the cHRM chunk to pngtest.png
   Don't try to use version-script with cygwin/mingw.
   Revised contrib/gregbook to work under cygwin/mingw.
 
-version 1.4.4beta07 [August 26, 2010]
-  Updated prebuilt aclocal.m4 and ltmain.sh
+Version 1.5.0beta42 [August 18, 2010]
   Add .dll.a to the list of extensions to be symlinked by Makefile.am (Yaakov)
+  Made all API functions that have const arguments and constant string
+    literal pointers declare them (John Bowler).
+
+Version 1.5.0beta43 [August 20, 2010]
+  Removed spurious tabs, shorten long lines (no source change)
+    Also added scripts/chkfmt to validate the format of all the files that can
+    reasonably be validated (it is suggested to run "make distclean" before
+    checking, because some machine generated files have long lines.)
+  Reformatted the CHANGES file to be more consistent throughout.
+  Made changes to address various issues identified by GCC, mostly
+    signed/unsigned and shortening problems on assignment but also a few
+    difficult to optimize (for GCC) loops.
+  Fixed non-GCC fixed point builds.  In png.c a declaration was misplaced
+    in an earlier update.  Fixed to declare the auto variables at the head.
+  Use cexcept.h in pngvalid.c.
+
+Version 1.5.0beta44 [August 24, 2010]
   Updated CMakeLists.txt to use CMAKE_INSTALL_LIBDIR variable; useful for
     installing libpng in /usr/lib64 (Funda Wang).
   Revised CMakeLists.txt to put the man pages in share/man/man* not man/man*
   Revised CMakeLists.txt to make symlinks instead of copies when installing.
   Changed PNG_LIB_NAME from pngNN to libpngNN in CMakeLists.txt (Philip Lowman)
-  Moved "#include pngusr.h" ahead of PNG_USER_PRIVATEBUILD test in pngconf.h
-  Eliminated a deprecated reference to png_ptr->io_ptr in pngtest.c
-  Eliminated new unnecessary #if tests regarding the sCAL chunk from pngrutil.c
-
-version 1.4.4beta08 [September 2, 2010]
-  Updated the xcode project to work with libpng-1.4.x and added iOS targets
-    for simulator and device (Philippe Hausler).
-
-version 1.4.4rc01 [September 10, 2010]
-  No changes.
-
-version 1.4.4rc02 [September 13, 2010]
-  Revised CMakeLists.txt (Philip Lowman).
-
-version 1.4.4rc03 [September 14, 2010]
-  Removed an extraneous close-double-quote from CMakeLists.txt
-  Eliminated another deprecated reference to png_ptr->io_ptr in pngtest.c
-
-version 1.4.4rc04 [September 16, 2010]
-  Fixed indentation and removed debugging message from CMakeLists.txt
+  Implemented memory checks within pngvalid
+  Reformatted/rearranged pngvalid.c to assist use of progressive reader.
+  Check interlaced images in pngvalid
+  Clarified pngusr.h comments in pnglibconf.dfa
+  Simplified the pngvalid error-handling code now that cexcept.h is in place.
+  Implemented progressive reader in pngvalid.c for standard tests
+  Implemented progressive read in pngvalid.c gamma tests
+  Turn on progressive reader in pngvalid.c by default and tidy code.
+
+Version 1.5.0beta45 [August 26, 2010]
+  Added an explicit make step to projects/vstudio for pnglibconf.h
+    Also corrected zlib.vcxproj into which Visual Studio had introduced
+    what it calls an "authoring error".  The change to make pnglibconf.h
+    simply copies the file; in the future it may actually generate the
+    file from scripts/pnglibconf.dfa as the other build systems do.
+  Changed pngvalid to work when floating point APIs are disabled
+  Renamed the prebuilt scripts/pnglibconf.h to scripts/pnglibconf.h.prebuilt
+  Supply default values for PNG_USER_PRIVATEBUILD and PNG_USER_DLLFNAME_POSTFIX
+    in pngpriv.h in case the user neglected to define them in their pngusr.h
+
+Version 1.5.0beta46 [August 28, 2010]
+  Added new private header files to libpng_sources in CMakeLists.txt
+  Added PNG_READ_16BIT, PNG_WRITE_16BIT, and PNG_16BIT options.
+  Added reference to scripts/pnglibconf.h.prebuilt in the visualc71 project.
+
+Version 1.5.0beta47 [September 11, 2010]
+  Fixed a number of problems with 64-bit compilation reported by Visual
+    Studio 2010 (John Bowler).
+
+Version 1.5.0beta48 [October 4, 2010]
+  Updated CMakeLists.txt (Philip Lowman).
   Revised autogen.sh to recognize and use $AUTOCONF, $AUTOMAKE, $AUTOHEADER,
     $AUTOPOINT, $ACLOCAL and $LIBTOOLIZE
-
-version 1.4.4rc05 [September 20, 2010]
-  Rebuilt configure scripts with automake-1.11.1 instead of automake-1.11.
-  Removed unused mkinstalldirs file.
-
-version 1.4.4 [September 23, 2010]
-  No changes.
-
-version 1.4.5beta01 [September 25, 2010]
-  Fixed possible configure.ac bug introduced in version 1.4.4rc05.
-  Rebuilt configure scripts with autoconf-2.68 instead of autoconf-2.65
-
-version 1.4.5beta02 [October 5, 2010]
-  Reverted configure scripts to autoconf-2.65
   Fixed problem with symbols creation in Makefile.am which was assuming that
-    all versions of cpp write to standard output by default (Martin Banky). The
+    all versions of ccp write to standard output by default (Martin Banky). The
     bug was introduced in libpng-1.2.9beta5.
-
-version 1.4.5beta03 [October 8, 2010]
-  Wrapped long lines in CMakeLists.txt and introduced ${libpng_public_hdrs}
-  Undid Makefile.am revision of 1.4.5beta02.
-
-version 1.4.5beta04 [November 8, 2010]
+  Removed unused mkinstalldirs.
+
+Version 1.5.0beta49 [October 8, 2010]
+  Undid Makefile.am revision of 1.5.0beta48.
+
+Version 1.5.0beta50 [October 14, 2010]
+  Revised Makefile.in to account for mkinstalldirs being removed.
+  Added some "(unsigned long)" typecasts in printf statements in pngvalid.c.
+  Suppressed a compiler warning in png_handle_sPLT().
   Check for out-of-range text compression mode in png_set_text().
 
-version 1.4.5rc01 [November 19, 2010]
-  No changes.
-
-version 1.4.5beta05 [November 20, 2010]
+Version 1.5.0beta51 [October 15, 2010]
+  Changed embedded dates to "(PENDING RELEASE) in beta releases (and future
+    rc releases) to minimize the difference between releases.
+
+Version 1.5.0beta52 [October 16, 2010]
+  Restored some of the embedded dates (in png.h, png.c, documentation, etc.)
+
+Version 1.5.0beta53 [October 18, 2010]
+  Updated INSTALL to mention using "make maintainer-clean" and to remove
+    obsolete statement about a custom ltmain.sh
+  Disabled "color-tests" by default in Makefile.am so it will work with
+    automake versions earlier than 1.11.1
+  Use document name "libpng-manual.txt" instead of "libpng-<version>.txt"
+    to simplify version differences.
+  Removed obsolete remarks about setjmp handling from INSTALL.
+  Revised and renamed the typedef in png.h and png.c that was designed
+    to catch library and header mismatch.
+
+Version 1.5.0beta54 [November 10, 2010]
+  Require 48 bytes, not 64 bytes, for big_row_buf in overflow checks.
+  Used a consistent structure for the pngget.c functions.
+
+Version 1.5.0beta55 [November 21, 2010]
   Revised png_get_uint_32, png_get_int_32, png_get_uint_16 (Cosmin)
   Moved reading of file signature into png_read_sig (Cosmin)
   Fixed atomicity of chunk header serialization (Cosmin)
   Added test for io_state in pngtest.c (Cosmin)
   Added "#!/bin/sh" at the top of contrib/pngminim/*/gather.sh scripts.
-
-version 1.4.5beta06 [November 21, 2010]
-  Restored the parentheses in pngrutil.c; they are needed when the
-    png_get_*int_*() functions are compiled (i.e., when PNG_USE_READ_MACROS
-    is not defined).
-  Make the "png_get_uint_16" macro return a png_uint_32 in libpng-1.4 for API
-    compatibility.
   Changes to remove gcc warnings (John Bowler)
     Certain optional gcc warning flags resulted in warnings in libpng code.
     With these changes only -Wconversion and -Wcast-qual cannot be turned on.
     Changes are trivial rearrangements of code.  -Wconversion is not possible
     for pngrutil.c (because of the widespread use of += et al on variables
     smaller than (int) or (unsigned int)) and -Wcast-qual is not possible
     with pngwio.c and pngwutil.c because the 'write' callback and zlib
     compression both fail to declare their input buffers with 'const'.
 
-version 1.4.5beta07 [November 25, 2010]
-  Reverted png_get_uint_16 macro to beta05 and added comment about the
-    potential API incompatibility.
-
-version 1.4.5rc02 [December 2, 2010]
+Version 1.5.0beta56 [December 7, 2010]
+  Added the private PNG_UNUSED() macro definition in pngpriv.h.
+  Added some commentary about PNG_EXPORT in png.h and pngconf.h
+  Revised PNG_EXPORT() macro and added PNG_EXPORTA() macro, with the
+    objective of simplifying and improving the cosmetic appearance of png.h.
+  Fixed some incorrect "=" macro names in pnglibconf.dfa
+  Included documentation of changes in 1.5.0 from 1.4.x in libpng-manual.txt
+
+Version 1.5.0beta57 [December 9, 2010]
+  Documented the pngvalid gamma error summary with additional comments and
+    print statements.
+  Improved missing symbol handling in checksym.awk; symbols missing in both
+    the old and new files can now be optionally ignored, treated as errors
+    or warnings.
+  Removed references to pngvcrd.c and pnggccrd.c from the vstudio project.
+  Updated "libpng14" to "libpng15" in the visualc71 project.
+  Enabled the strip16 tests in pngvalid.`
+  Don't display test results (except PASS/FAIL) when running "make test".
+    Instead put them in pngtest-log.txt
+  Added "--with-zprefix=<string>" to configure.ac
+  Updated the prebuilt configuration files to autoconf version 2.68
+
+Version 1.5.0beta58 [December 19, 2010]
+  Fixed interlace image handling and add test cases (John Bowler)
+  Fixed the clean rule in Makefile.am to remove pngtest-log.txt
+  Made minor changes to work around warnings in gcc 3.4
+
+Version 1.5.0rc01 [December 27, 2010]
   No changes.
 
-version 1.4.5rc03 [December 3, 2010]
-  Added missing vstudio/*/*.vcxproj files to the zip and 7z distributions.
-
-version 1.4.5 [December 9, 2010]
-  Removed PNG_NO_WRITE_GAMMA from pngminim/encoder/pngusr.h
-
-version 1.4.6beta01 [December 29, 2010]
+Version 1.5.0rc02 [December 27, 2010]
+  Eliminated references to the scripts/*.def files in project/visualc71.
+
+Version 1.5.0rc03 [December 28, 2010]
+  Eliminated scripts/*.def and revised Makefile.am accordingly
+
+Version 1.5.0rc04 [December 29, 2010]
   Fixed bug in background transformation handling in pngrtran.c (it was
     looking for the flag in png_ptr->transformations instead of in
     png_ptr->flags) (David Raymond).
 
-version 1.4.6beta02 [January 14, 2011]
-  Fixed misspelled macros in contrib/pngminim (Cosmin).
-  Updated CMakeLists.txt (Clifford Yapp).
-
-version 1.4.6beta03 [January 14, 2011]
-  Fixed some typecasts in png_debug statements (Cosmin).
-
-version 1.4.6beta04 [January 22, 2011]
+Version 1.5.0rc05 [December 31, 2010]
+  Fixed typo in a comment in CMakeLists.txt (libpng14 => libpng15) (Cosmin)
+
+Version 1.5.0rc06 [January 4, 2011]
+  Changed the new configure option "zprefix=string" to "zlib-prefix=string"
+
+Version 1.5.0rc07 [January 4, 2011]
+  Updated copyright year.
+
+Version 1.5.0 [January 6, 2011]
+  No changes.
+
+version 1.5.1beta01 [January 8, 2011]
+  Added description of png_set_crc_action() to the manual.
+  Added a note in the manual that the type of the iCCP profile was changed
+    from png_charpp to png_bytepp in png_get_iCCP().  This change happened
+    in version 1.5.0beta36 but is not noted in the CHANGES.  Similarly,
+    it was changed from png_charpp to png_const_bytepp in png_set_iCCP().
+  Ensure that png_rgb_to_gray ignores palette mapped images, if libpng
+    internally happens to call it with one, and fixed a failure to handle
+    palette mapped images correctly.  This fixes CVE-2690.
+
+Version 1.5.1beta02 [January 14, 2011]
+  Fixed a bug in handling of interlaced images (bero at arklinux.org).
+  Updated CMakeLists.txt (Clifford Yapp)
+
+Version 1.5.1beta03 [January 14, 2011]
+  Fixed typecasting of some png_debug() statements (Cosmin)
+
+Version 1.5.1beta04 [January 16, 2011]
   Updated documentation of png_set|get_tRNS() (Thomas Klausner).
-  Added png_const_structp and png_const_infop types, and used them in
-    prototypes for most png_get_*() functions.
+  Mentioned in the documentation that applications must #include "zlib.h"
+    if they need access to anything in zlib.h, and that a number of
+    macros such as png_memset() are no longer accessible by applications.
+  Corrected pngvalid gamma test "sample" function to access all of the color
+    samples of each pixel, instead of sampling the red channel three times.
+  Prefixed variable names index, div, exp, gamma with "png_" to avoid "shadow"
+    warnings, and (mistakenly) changed png_exp() to exp().
+
+Version 1.5.1beta05 [January 16, 2011]
+  Changed variable names png_index, png_div, png_exp, and png_gamma to
+    char_index, divisor, exp_b10, and gamma_val, respectively, and
+    changed exp() back to png_exp().
+
+Version 1.5.1beta06 [January 20, 2011]
+  Prevent png_push_crc_skip() from hanging while reading an unknown chunk
+    or an over-large compressed zTXt chunk with the progressive reader.
+  Eliminated more GCC "shadow" warnings.
+  Revised png_fixed() in png.c to avoid compiler warning about reaching the
+    end without returning anything.
+
+Version 1.5.1beta07 [January 22, 2011]
   In the manual, describe the png_get_IHDR() arguments in the correct order.
-  Ported change in png_do_rgb_to_gray() from libpng-1.5.1, to make
-    it more robust against internal libpng coding errors.
-
-version 1.4.6beta05 [January 23, 2011]
-
-  Updated the synopses in the manual to reflect recent changes.
-  Fixed a typo in the *.def files and deleted entries that are now
-    declared in pngpriv.h
-
-version 1.4.6beta06 [March 19, 2011]
-  Updated contrib/pngsuite/README to add the word "modify".
-  Added the private PNG_UNUSED() macro definition in pngconf.h.
-
-version 1.4.6beta07 [March 22, 2011]
-  ifdef out mask arrays in pngread.c when interlacing is not supported.
-  Added attribute definition (warnings) for MSC_VER >= 1300 in pngconf.h
-  Added -D_CRT_SECURE_NO_DEPRECATE to CFLAGS in makefile.vcwin32
+  Added const_png_structp and const_png_infop types, and used them in
+    prototypes for most png_get_*() functions.
+
+Version 1.5.1beta08 [January 23, 2011]
+  Added png_get_io_chunk_type() and deprecated png_get_io_chunk_name()
+  Added synopses for the IO_STATE functions and other missing synopses
+    to the manual. Removed the synopses from libpngpf.3 because they
+    were out of date and no longer useful.  Better information can be
+    obtained by reading the prototypes and comments in pngpriv.h
+  Attempted to fix cpp on Solaris with S. Studio 12 cc, fix build
+    Added a make macro DFNCPP that is a CPP that will accept the tokens in
+    a .dfn file and adds configure stuff to test for such a CPP.  ./configure
+    should fail if one is not available.
+  Corrected const_png_ in png.h to png_const_ to avoid polluting the namespace.
+  Added png_get_current_row_number and png_get_current_pass_number for the
+    benefit of the user transform callback.
+  Added png_process_data_pause and png_process_data_skip for the benefit of
+    progressive readers that need to stop data processing or want to optimize
+    skipping of unread data (e.g., if the reader marks a chunk to be skipped.)
+
+Version 1.5.1beta09 [January 24, 2011]
+  Enhanced pngvalid, corrected an error in gray_to_rgb, corrected doc error.
+    pngvalid contains tests of transforms, which tests are currently disabled
+    because they are incompletely tested.  gray_to_rgb was failing to expand
+    the bit depth for smaller bit depth images; this seems to be a long
+    standing error and resulted, apparently, in invalid output
+    (CVE-2011-0408, CERT VU#643140).  The documentation did not accurately
+    describe what libpng really does when converting RGB to gray.
+
+Version 1.5.1beta10 [January 27, 2010]
+  Fixed incorrect examples of callback prototypes in the manual, that were
+    introduced in libpng-1.0.0.
+  In addition the order of the png_get_uint macros with respect to the
+    relevant function definitions has been reversed.  This helps the
+    preprocessing of the symbol files be more robust.  Furthermore, the
+    symbol file preprocessing now uses -DPNG_NO_USE_READ_MACROS even when
+    the library may actually be built with PNG_USE_READ_MACROS; this stops
+    the read macros interfering with the symbol file format.
+  Made the manual, synopses, and function prototypes use the function
+    argument names file_gamma, int_file_gamma, and srgb_intent consistently.
+
+Version 1.5.1beta11 [January 28, 2011]
+  Changed PNG_UNUSED from "param=param;" to "{if(param){}}".
+  Corrected local variable type in new API png_process_data_skip()
+    The type was self-evidently incorrect but only causes problems on 64-bit
+    architectures.
+  Added transform tests to pngvalid and simplified the arguments.
+
+Version 1.5.1rc01 [January 29, 2011]
+  No changes.
+
+Version 1.5.1rc02 [January 31, 2011]
+  Added a request in the manual that applications do not use "png_" or
+    "PNG_" to begin any of their own symbols.
+  Changed PNG_UNUSED to "(void)param;" and updated the commentary in pngpriv.h
+
+Version 1.5.1 [February 3, 2011]
+  No changes.
+
+Version 1.5.2beta01 [February 13, 2011]
+  More -Wshadow fixes for older gcc compilers.  Older gcc versions apparently
+    check formal parameters names in function declarations (as well as
+    definitions) to see if they match a name in the global namespace.
+  Revised PNG_EXPORTA macro to not use an empty parameter, to accommodate the
+    old VisualC++ preprocessor.
+  Turned on interlace handling in png_read_png().
+  Fixed gcc pendantic warnings.
+  Handle longjmp in Cygwin.
+  Fixed png_get_current_row_number() in the interlaced case.
+  Cleaned up ALPHA flags and transformations.
+  Implemented expansion to 16 bits.
+
+Version 1.5.2beta02 [February 19, 2011]
   Fixed mistake in the descriptions of user read_transform and write_transform
     function prototypes in the manual.  The row_info struct is png_row_infop.
-  Added a request in the manual that applications do not use "png_" or
-    "PNG_" to begin any of their own symbols.
-  Fixed incorrect examples of callback prototypes in the manual, that were
-    introduced in libpng-1.0.0.
-  Removed "strip" from contrib/pngminim/*/makefile.
+  Reverted png_get_current_row_number() to previous (1.5.2beta01) behavior.
+  Corrected png_get_current_row_number documentation
+  Fixed the read/write row callback documentation.
+    This documents the current behavior, where the callback is called after
+    every row with information pertaining to the next row.
+
+Version 1.5.2beta03 [March 3, 2011]
+  Fixed scripts/makefile.vcwin32
+  Updated contrib/pngsuite/README to add the word "modify".
+  Define PNG_ALLOCATED to blank when _MSC_VER<1300.
+
+Version 1.5.2rc01 [March 19, 2011]
+  Define remaining attributes to blank when MSC_VER<1300.
+  ifdef out mask arrays in pngread.c when interlacing is not supported.
+
+Version 1.5.2rc02 [March 22, 2011]
+  Added a hint to try CPP=/bin/cpp if "cpp -E" fails in scripts/pnglibconf.mak
+    and in contrib/pngminim/*/makefile, eg., on SunOS 5.10, and removed "strip"
+    from the makefiles.
   Fixed a bug (present since libpng-1.0.7) that makes png_handle_sPLT() fail
     to compile when PNG_NO_POINTER_INDEXING is defined (Chubanov Kirill)
 
-version 1.4.6rc01 [March 31, 2011]
-  No changes.
-
-version 1.4.6rc02 [April 6, 2011]
-  Improved the optimization of the zlib CMF byte (see libpng-1.2.6beta03).
-
-version 1.4.6 [April 8, 2011]
+Version 1.5.2rc03 [March 24, 2011]
+  Don't include standard header files in png.h while building the symbol table,
+    to avoid cpp failure on SunOS (introduced PNG_BUILDING_SYMBOL_TABLE macro).
+
+Version 1.5.2 [March 31, 2011]
   No changes.
 
-version 1.4.7rc01 [April 9, 2011]
-  Relocated misplaced new declarations in pngwutil.c.
-
-version 1.4.7 [April 9, 2011]
-  Disabled PNG_PEDANTIC_WARNINGS for all MSC versions as in libpng-1.4.5.
-
-version 1.4.8beta01 [June 4, 2011]
-  Undef "_ALL_SOURCE" for AIX, to prevent "jmpbuf" from being redefined.
-  Copied png_debug macros from pngpriv.h into pngtest.c and removed
-    "#include pngpriv.h" from pngtest.c, to avoid setting a bad example.
+Version 1.5.3beta01 [April 1, 2011]
+  Re-initialize the zlib compressor before compressing non-IDAT chunks.
+  Added API functions (png_set_text_compression_level() and four others) to
+    set parameters for zlib compression of non-IDAT chunks.
+
+Version 1.5.3beta02 [April 3, 2011]
+  Updated scripts/symbols.def with new API functions.
+  Only compile the new zlib re-initializing code when text or iCCP is
+    supported, using PNG_WRITE_COMPRESSED_TEXT_SUPPORTED macro.
+  Improved the optimization of the zlib CMF byte (see libpng-1.2.6beta03).
+  Optimize the zlib CMF byte in non-IDAT compressed chunks
+
+Version 1.5.3beta03 [April 16, 2011]
+  Fixed gcc -ansi -pedantic compile. A strict ANSI system does not have
+    snprintf, and the "__STRICT_ANSI__" detects that condition more reliably
+    than __STDC__ (John Bowler).
+  Removed the PNG_PTR_NORETURN attribute because it too dangerous. It tells
+    the compiler that a user supplied callback (the error handler) does not
+    return, yet there is no guarantee in practice that the application code
+    will correctly implement the error handler because the compiler only
+    issues a warning if there is a mistake (John Bowler).
+  Removed the no-longer-used PNG_DEPSTRUCT macro.
+  Updated the zlib version to 1.2.5 in the VStudio project.
+  Fixed 64-bit builds where png_uint_32 is smaller than png_size_t in
+    pngwutil.c (John Bowler).
+  Fixed bug with stripping the filler or alpha channel when writing, that
+    was introduced in libpng-1.5.2beta01 (bug report by Andrew Church).
+
+Version 1.5.3beta04 [April 27, 2011]
+  Updated pngtest.png with the new zlib CMF optimization.
+  Cleaned up conditional compilation code and of background/gamma handling
+    Internal changes only except a new option to avoid compiling the
+    png_build_grayscale_palette API (which is not used at all internally.)
+    The main change is to move the transform tests (READ_TRANSFORMS,
+    WRITE_TRANSFORMS) up one level to the caller of the APIs.  This avoids
+    calls to spurious functions if all transforms are disabled and slightly
+    simplifies those functions.  Pngvalid modified to handle this.
+    A minor change is to stop the strip_16 and expand_16 interfaces from
+    disabling each other; this allows the future alpha premultiplication
+    code to use 16-bit intermediate values while still producing 8-bit output.
+    png_do_background and png_do_gamma have been simplified to take a single
+    pointer to the png_struct rather than pointers to every item required
+    from the png_struct. This makes no practical difference to the internal
+    code.
+  A serious bug in the pngvalid internal routine 'standard_display_init' has
+    been fixed - this failed to initialize the red channel and accidentally
+    initialized the alpha channel twice.
+  Changed png_struct jmp_buf member name from png_jmpbuf to tmp_jmpbuf to
+    avoid a possible clash with the png_jmpbuf macro on some platforms.
+
+Version 1.5.3beta05 [May 6, 2011]
+  Added the "_POSIX_SOURCE" feature test macro to ensure libpng sees the
+    correct API. _POSIX_SOURCE is defined in pngpriv.h, pngtest.c and
+    pngvalid.c to ensure that POSIX conformant systems disable non-POSIX APIs.
+  Removed png_snprintf and added formatted warning messages.  This change adds
+    internal APIs to allow png_warning messages to have parameters without
+    requiring the host OS to implement snprintf.  As a side effect the
+    dependency of the tIME-supporting RFC1132 code on stdio is removed and
+    PNG_NO_WARNINGS does actually work now.
   Pass "" instead of '\0' to png_default_error() in png_err().  This mistake
-    was introduced in libpng-1.2.20beta01.
+    was introduced in libpng-1.2.20beta01.  This fixes CVE-2011-2691.
+  Added PNG_WRITE_OPTIMIZE_CMF_SUPPORTED macro to make the zlib "CMF" byte
+    optimization configureable.
+  IDAT compression failed if preceded by a compressed text chunk (bug
+    introduced in libpng-1.5.3beta01-02).  This was because the attempt to
+    reset the zlib stream in png_write_IDAT happened after the first IDAT
+    chunk had been deflated - much too late.  In this change internal
+    functions were added to claim/release the z_stream and, hopefully, make
+    the code more robust.  Also deflateEnd checking is added - previously
+    libpng would ignore an error at the end of the stream.
+
+Version 1.5.3beta06 [May 8, 2011]
+  Removed the -D_ALL_SOURCE from definitions for AIX in CMakeLists.txt
+  Implemented premultiplied alpha support: png_set_alpha_mode API
+
+Version 1.5.3beta07 [May 11, 2011]
+  Added expand_16 support to the high level interface.
+  Added named value and 'flag' gamma support to png_set_gamma.  Made a minor
+    change from the previous (unreleased) ABI/API to hide the exact value used
+    for Macs - it's not a good idea to embed this in the ABI!
+  Moved macro definitions for PNG_HAVE_IHDR, PNG_HAVE_PLTE, and PNG_AFTER_IDAT
+    from pngpriv.h to png.h because they must be visible to applications
+    that call png_set_unknown_chunks().
   Check for up->location !PNG_AFTER_IDAT when writing unknown chunks
     before IDAT.
-  Ported bugfix in pngrtran.c from 1.5.3: when expanding a paletted image,
-    always expand to RGBA if transparency is present.
-
-version 1.4.8beta02 [June 5, 2011]
-  Ported bugfix in pngrtran.c from 1.5.3: Ensure coefficients are OK for
-    png_rgb_to_gray_fixed().
-
-version 1.4.8beta03 [June 6, 2011]
-  Check for integer overflow in png_set_rgb_to_gray().
-
-version 1.4.8beta04 [June 7, 2011]
+
+Version 1.5.3beta08 [May 16, 2011]
+  Improved "pngvalid --speed" to exclude more of pngvalid from the time.
+  Documented png_set_alpha_mode(), other changes in libpng.3/libpng-manual.txt
+  The cHRM chunk now sets the defaults for png_set_rgb_to_gray() (when negative
+    parameters are supplied by the caller), while in the absence of cHRM
+    sRGB/Rec 709 values are still used.  This introduced a divide-by-zero
+    bug in png_handle_cHRM().
+  The bKGD chunk no longer overwrites the background value set by
+    png_set_background(), allowing the latter to be used before the file
+    header is read. It never performed any useful function to override
+    the default anyway.
+  Added memory overwrite and palette image checks to pngvalid.c
+    Previously palette image code was poorly checked. Since the transformation
+    code has a special palette path in most cases this was a severe weakness.
+  Minor cleanup and some extra checking in pngrutil.c and pngrtran.c. When
+    expanding an indexed image, always expand to RGBA if transparency is
+    present.
+
+Version 1.5.3beta09 [May 17, 2011]
+  Reversed earlier 1.5.3 change of transformation order; move png_expand_16
+    back where it was.  The change doesn't work because it requires 16-bit
+    gamma tables when the code only generates 8-bit ones.  This fails
+    silently; the libpng code just doesn't do any gamma correction.  Moving
+    the tests back leaves the old, inaccurate, 8-bit gamma calculations, but
+    these are clearly better than none!
+
+Version 1.5.3beta10 [May 20, 2011]
+
+  png_set_background() and png_expand_16() did not work together correctly.
+    This problem is present in 1.5.2; if png_set_background is called with
+    need_expand false and the matching 16 bit color libpng erroneously just
+    treats it as an 8-bit color because of where png_do_expand_16 is in the
+    transform list.  This simple fix reduces the supplied colour to 8-bits,
+    so it gets smashed, but this is better than the current behavior.
+  Added tests for expand16, more fixes for palette image tests to pngvalid.
+    Corrects the code for palette image tests and disables attempts to
+    validate palette colors.
+
+Version 1.5.3rc01 [June 3, 2011]
+  No changes.
+
+Version 1.5.3rc02 [June 8, 2011]
   Fixed uninitialized memory read in png_format_buffer() (Bug report by
-    Frank Busse, related to CVE-2004-0421).
-
-version 1.4.8beta05 [June 19, 2011]
-  Fixed error in "ACCURATE" 16-to-8 scaling (John Bowler).
-  Check for sCAL chunk too short.
-
-version 1.4.8rc01 [June 30, 2011]
+    Frank Busse, CVE-2011-2501, related to CVE-2004-0421).
+
+Version 1.5.3beta11 [June 11, 2011]
+  Fixed png_handle_sCAL which is broken in 1.5. This fixes CVE 2011-2692.
+  Added sCAL to pngtest.png
+  Revised documentation about png_set_user_limits() to say that it also affects
+    png writing.
+  Revised handling of png_set_user_limits() so that it can increase the
+    limit beyond the PNG_USER_WIDTH|HEIGHT_MAX; previously it could only
+    reduce it.
+  Make the 16-to-8 scaling accurate. Dividing by 256 with no rounding is
+    wrong (high by one) 25% of the time. Dividing by 257 with rounding is
+    wrong in 128 out of 65536 cases. Getting the right answer all the time
+    without division is easy.
+  Added "_SUPPORTED" to the PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION macro.
+  Added projects/owatcom, an IDE project for OpenWatcom to replace
+    scripts/makefile.watcom.  This project works with OpenWatcom 1.9. The
+    IDE autogenerates appropriate makefiles (libpng.mk) for batch processing.
+    The project is configurable, unlike the Visual Studio project, so long
+    as the developer has an awk.
+  Changed png_set_gAMA to limit the gamma value range so that the inverse
+    of the stored value cannot overflow the fixed point representation,
+    and changed other things OpenWatcom warns about.
+  Revised pngvalid.c to test PNG_ALPHA_MODE_SUPPORTED correctly. This allows
+    pngvalid to build when ALPHA_MODE is not supported, which is required if
+    it is to build on libpng 1.4.
+  Removed string/memory macros that are no longer used and are not
+    necessarily fully supportable, particularly png_strncpy and png_snprintf.
+  Added log option to pngvalid.c and attempted to improve gamma messages.
+
+Version 1.5.3 [omitted]
+  People found the presence of a beta release following an rc release
+    to be confusing; therefore we bump the version to libpng-1.5.4beta01
+    and there will be no libpng-1.5.3 release.
+
+Version 1.5.4beta01 [June 14, 2011]
+  Made it possible to undefine PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
+    to get the same (inaccurate) output as libpng-1.5.2 and earlier.
+  Moved definitions of PNG_HAVE_IHDR, PNG_AFTER_IDAT, and PNG_HAVE_PLTE
+    outside of an unknown-chunk block in png.h because they are also
+    needed for other uses.
+
+Version 1.5.4beta02 [June 14, 2011]
+  Fixed and clarified LEGACY 16-to-8 scaling code.
+  Added png_set_chop_16() API, to match inaccurate results from previous
+    libpng versions.
+  Removed the ACCURATE and LEGACY options (they are no longer useable)
+  Use the old scaling method for background if png_set_chop_16() was
+    called.
+  Made png_set_chop_16() API removeable by disabling PNG_CHOP_16_TO_8_SUPPORTED
+
+Version 1.5.4beta03 [June 15, 2011]
+  Fixed a problem in png_do_expand_palette() exposed by optimization in
+    1.5.3beta06
+  Also removed a spurious and confusing "trans" member ("trans") from png_info.
+  The palette expand optimization prevented expansion to an intermediate RGBA
+    form if tRNS was present but alpha was marked to be stripped; this exposed
+    a check for tRNS in png_do_expand_palette() which is inconsistent with the
+    code elsewhere in libpng.
+  Correction to the expand_16 code; removed extra instance of
+    png_set_scale_16_to_8 from pngpriv.h
+
+Version 1.5.4beta04 [June 16, 2011]
+  Added a missing "#ifdef PNG_READ_BACKGROUND_SUPPORTED/#endif" in pngrtran.c
+  Added PNG_TRANSFORM_CHOP_16 to the high-level read transforms.
+  Made PNG_READ_16_TO_8_ACCURATE_SCALE configurable again.  If this is
+    not enabled, png_set_strip_16() and png_do_scale_16_to_8() aren't built.
+  Revised contrib/visupng, gregbook, and pngminim to demonstrate chop_16_to_8
+
+Version 1.5.4beta05 [June 16, 2011]
+  Renamed png_set_strip_16() to png_set_scale_16() and renamed
+    png_set_chop_16() to png_set_strip(16) in an attempt to minimize the
+    behavior changes between libpng14 and libpng15.
+
+Version 1.5.4beta06 [June 18, 2011]
+  Fixed new bug that was causing both strip_16 and scale_16 to be applied.
+
+Version 1.5.4beta07 [June 19, 2011]
+  Fixed pngvalid, simplified macros, added checking for 0 in sCAL.
+    The ACCURATE scale macro is no longer defined in 1.5 - call the
+    png_scale_16_to_8 API.  Made sure that PNG_READ_16_TO_8 is still defined
+    if the png_strip_16_to_8 API is present.  png_check_fp_number now
+    maintains some state so that positive, negative and zero values are
+    identified.  sCAL uses these to be strictly spec conformant.
+
+Version 1.5.4beta08 [June 23, 2011]
+  Fixed pngvalid if ACCURATE_SCALE is defined.
+  Updated scripts/pnglibconf.h.prebuilt.
+
+Version 1.5.4rc01 [June 30, 2011]
+  Define PNG_ALLOCATED to "restrict" only if MSC_VER >= 1400.
+
+Version 1.5.4 [July 7, 2011]
+  No changes.
+
+Version 1.5.5beta01 [July 13, 2011]
+  Fixed some typos and made other minor changes in the manual.
+  Updated contrib/pngminus/makefile.std (Samuli Souminen)
+
+Version 1.5.5beta02 [July 14, 2011]
+  Revised Makefile.am and Makefile.in to look in the right directory for
+    pnglibconf.h.prebuilt
+
+Version 1.5.5beta03 [July 27, 2011]
+  Enabled compilation with g++ compiler.  This compiler does not recognize
+    the file extension, so it always compiles with C++ rules.  Made minor
+    changes to pngrutil.c to cast results where C++ expects it but C does not.
+  Minor editing of libpng.3 and libpng-manual.txt.
+
+Version 1.5.5beta04 [July 29, 2011]
+  Revised CMakeLists.txt (Clifford Yapp)
+  Updated commentary about the png_rgb_to_gray() default coefficients
+    in the manual and in pngrtran.c
+
+Version 1.5.5beta05 [August 17, 2011]
+  Prevent unexpected API exports from non-libpng DLLs on Windows.  The "_DLL"
+    is removed from the test of whether a DLL is being built (this erroneously
+    caused the libpng APIs to be marked as DLL exports in static builds under
+    Microsoft Visual Studio).  Almost all of the libpng building configuration
+    is moved from pngconf.h to pngpriv.h, but PNG_DLL_EXPORT remains in
+    pngconf.h, though, so that it is colocated with the import definition (it
+    is no longer used anywhere in the installed headers).  The VStudio project
+    definitions have been cleaned up: "_USRDLL" has been removed from the
+    static library builds (this was incorrect), and PNG_USE_DLL has been added
+    to pngvalid to test the functionality (pngtest does not supply it,
+    deliberately).  The spurious "_EXPORTS" has been removed from the
+    libpng build (all these errors were a result of copy/paste between project
+    configurations.)
+  Added new types and internal functions for CIE RGB end point handling to
+    pngpriv.h (functions yet to be implemented).
+
+Version 1.5.5beta06 [August 26, 2011]
+  Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set in CMakeLists.txt
+    (Clifford Yap)
+  Fixes to rgb_to_gray and cHRM XYZ APIs (John Bowler):
+    The rgb_to_gray code had errors when combined with gamma correction.
+    Some pixels were treated as true grey when they weren't and such pixels
+    and true grey ones were not gamma corrected (the original value of the
+    red component was used instead).  APIs to get and set cHRM using color
+    space end points have been added and the rgb_to_gray code that defaults
+    based on cHRM, and the divide-by-zero bug in png_handle_cHRM (CERT
+    VU#477046, CVE-2011-3328, introduced in 1.5.4) have been corrected.
+  A considerable number of tests has been added to pngvalid for the
+    rgb_to_gray transform.
+  Arithmetic errors in rgb_to_gray whereby the calculated gray value was
+    truncated to the bit depth rather than rounded have been fixed except in
+    the 8-bit non-gamma-corrected case (where consistency seems more important
+    than correctness.)  The code still has considerable inaccuracies in the
+    8-bit case because 8-bit linear arithmetic is used.
+
+Version 1.5.5beta07 [September 7, 2011]
+  Added "$(ARCH)" option to makefile.darwin
+  Added SunOS support to configure.ac and Makefile.am
+  Changed png_chunk_benign_error() to png_warning() in png.c, in
+    png_XYZ_from_xy_checked().
+
+Version 1.5.5beta08 [September 10, 2011]
+  Fixed 64-bit compilation errors (gcc). The errors fixed relate
+    to conditions where types that are 32 bits in the GCC 32-bit
+    world (uLong and png_size_t) become 64 bits in the 64-bit
+    world.  This produces potential truncation errors which the
+    compiler correctly flags.
+  Relocated new HAVE_SOLARIS_LD definition in configure.ac
+  Constant changes for 64-bit compatibility (removal of L suffixes). The
+    16-bit cases still use "L" as we don't have a 16-bit test system.
+
+Version 1.5.5rc01 [September 15, 2011]
+  Removed "L" suffixes in pngpriv.h
+
+Version 1.5.5 [September 22, 2011]
   No changes.
 
-version 1.4.8 [July 7, 2011]
+Version 1.5.6beta01 [September 22, 2011]
+  Fixed some 64-bit type conversion warnings in pngrtran.c
+  Moved row_info from png_struct to a local variable.
+  The various interlace mask arrays have been made into arrays of
+    bytes and made PNG_CONST and static (previously some arrays were
+    marked PNG_CONST and some weren't).
+  Additional checks have been added to the transform code to validate the
+    pixel depths after the transforms on both read and write.
+  Removed some redundant code from pngwrite.c, in png_destroy_write_struct().
+  Changed chunk reading/writing code to use png_uint_32 instead of png_byte[4].
+    This removes the need to allocate temporary strings for chunk names on
+    the stack in the read/write code.  Unknown chunk handling still uses the
+    string form because this is exposed in the API.
+
+Version 1.5.6beta02 [September 26, 2011]
+  Added a note in the manual the png_read_update_info() must be called only
+    once with a particular info_ptr.
+  Fixed a typo in the definition of the new PNG_STRING_FROM_CHUNK(s,c) macro.
+
+Version 1.5.6beta03 [September 28, 2011]
+  Revised test-pngtest.sh to report FAIL when pngtest fails.
+  Added "--strict" option to pngtest, to report FAIL when the failure is
+    only because the resulting valid files are different.
+  Revised CMakeLists.txt to work with mingw and removed some material from
+    CMakeLists.txt that is no longer useful in libpng-1.5.
+
+Version 1.5.6beta04 [October 5, 2011]
+  Fixed typo in Makefile.in and Makefile.am ("-M Wl" should be "-M -Wl")."
+
+Version 1.5.6beta05 [October 12, 2011]
+  Speed up png_combine_row() for interlaced images. This reduces the generality
+    of the code, allowing it to be optimized for Adam7 interlace.  The masks
+    passed to png_combine_row() are now generated internally, avoiding
+    some code duplication and localizing the interlace handling somewhat.
+  Align png_struct::row_buf - previously it was always unaligned, caused by
+    a bug in the code that attempted to align it; the code needs to subtract
+    one from the pointer to take account of the filter byte prepended to
+    each row.
+  Optimized png_combine_row() when rows are aligned. This gains a small
+    percentage for 16-bit and 32-bit pixels in the typical case where the
+    output row buffers are appropriately aligned. The optimization was not
+    previously possible because the png_struct buffer was always misaligned.
+  Fixed bug in png_write_chunk_header() debug print, introduced in 1.5.6beta01.
+
+Version 1.5.6beta06 [October 17, 2011]
+  Removed two redundant tests for unitialized row.
+  Fixed a relatively harmless memory overwrite in compressed text writing
+    with a 1 byte zlib buffer.
+  Add ability to call png_read_update_info multiple times to pngvalid.c.
+  Fixes for multiple calls to png_read_update_info. These fixes attend to
+    most of the errors revealed in pngvalid, however doing the gamma work
+    twice results in inaccuracies that can't be easily fixed.  There is now
+    a warning in the code if this is going to happen.
+  Turned on multiple png_read_update_info in pngvalid transform tests.
+  Prevent libpng from overwriting unused bits at the end of the image when
+    it is not byte aligned, while reading. Prior to libpng-1.5.6 libpng would
+    overwrite the partial byte at the end of each row if the row width was not
+    an exact multiple of 8 bits and the image is not interlaced.
+
+Version 1.5.6beta07 [October 21, 2011]
+  Made png_ptr->prev_row an aligned pointer into png_ptr->big_prev_row
+    (Mans Rullgard).
+
+Version 1.5.6rc01 [October 26, 2011]
+  Changed misleading "Missing PLTE before cHRM" warning to "Out of place cHRM"
+
+Version 1.5.6rc02 [October 27, 2011]
+  Added LSR() macro to defend against buggy compilers that evaluate non-taken
+    code branches and complain about out-of-range shifts.
+
+Version 1.5.6rc03 [October 28, 2011]
+  Renamed the LSR() macro to PNG_LSR() and added PNG_LSL() macro.
+  Fixed compiler warnings with Intel and MSYS compilers. The logical shift
+    fix for Microsoft Visual C is required by other compilers, so this
+    enables that fix for all compilers when using compile-time constants.
+    Under MSYS 'byte' is a name declared in a system header file, so we
+    changed the name of a local variable to avoid the warnings that result.
+  Added #define PNG_ALIGN_TYPE PNG_ALIGN_NONE to contrib/pngminim/*/pngusr.h
+
+Version 1.5.6 [November 3, 2011]
   No changes.
 
-Send comments/corrections/commendations to glennrp at users.sourceforge.net
-or to png-mng-implement at lists.sf.net (subscription required; visit
-https://lists.sourceforge.net/lists/listinfo/png-mng-implement).
+Version 1.5.7beta01 [November 4, 2011]
+  Added support for ARM processor (Mans Rullgard)
+  Fixed bug in pngvalid on early allocation failure; fixed type cast in
+    pngmem.c; pngvalid would attempt to call png_error() if the allocation
+    of a png_struct or png_info failed. This would probably have led to a
+    crash.  The pngmem.c implementation of png_malloc() included a cast
+    to png_size_t which would fail on large allocations on 16-bit systems.
+  Fix for the preprocessor of the Intel C compiler. The preprocessor
+    splits adjacent @ signs with a space; this changes the concatentation
+    token from @-@-@ to PNG_JOIN; that should work with all compiler
+    preprocessors.
+  Paeth filter speed improvements from work by Siarhei Siamashka. This
+    changes the 'Paeth' reconstruction function to improve the GCC code
+    generation on x86. The changes are only part of the suggested ones;
+    just the changes that definitely improve speed and remain simple.
+    The changes also slightly increase the clarity of the code.
+
+Version 1.5.7beta02 [November 11, 2011]
+  Check compression_type parameter in png_get_iCCP and remove spurious
+    casts. The compression_type parameter is always assigned to, so must
+    be non-NULL. The cast of the profile length potentially truncated the
+    value unnecessarily on a 16-bit int system, so the cast of the (byte)
+    compression type to (int) is specified by ANSI-C anyway.
+  Fixed FP division by zero in pngvalid.c; the 'test_pixel' code left
+    the sBIT fields in the test pixel as 0, which resulted in a floating
+    point division by zero which was irrelevant but causes systems where
+    FP exceptions cause a crash. Added code to pngvalid to turn on FP
+    exceptions if the appropriate glibc support is there to ensure this is
+    tested in the future.
+  Updated scripts/pnglibconf.mak and scripts/makefile.std to handle the
+    new PNG_JOIN macro.
+  Added versioning to pnglibconf.h comments.
+  Simplified read/write API initial version; basic read/write tested on
+    a variety of images, limited documentation (in the header file.)
+  Installed more accurate linear to sRGB conversion tables. The slightly
+    modified tables reduce the number of 16-bit values that
+    convert to an off-by-one 8-bit value.  The "makesRGB.c" code that was used
+    to generate the tables is now in a contrib/sRGBtables sub-directory.
+
+Version 1.5.7beta03 [November 17, 2011]
+  Removed PNG_CONST from the sRGB table declarations in pngpriv.h and png.c
+  Added run-time detection of NEON support.
+  Added contrib/libtests; includes simplified API test and timing test and
+    a color conversion utility for rapid checking of failed 'pngstest' results.
+  Multiple transform bug fixes plus a work-round for double gamma correction.
+    libpng does not support more than one transform that requires linear data
+    at once - if this is tried typically the results is double gamma
+    correction. Since the simplified APIs can need rgb to gray combined with
+    a compose operation it is necessary to do one of these outside the main
+    libpng transform code. This check-in also contains fixes to various bugs
+    in the simplified APIs themselves and to some bugs in compose and rgb to
+    gray (on palette) itself.
+  Fixes for C++ compilation using g++ When libpng source is compiled
+    using g++. The compiler imposes C++ rules on the C source; thus it
+    is desireable to make the source work with either C or C++ rules
+    without throwing away useful error information.  This change adds
+    png_voidcast to allow C semantic (void*) cases or the corresponding
+    C++ static_cast operation, as appropriate.
+  Added --noexecstack to assembler file compilation. GCC does not set
+    this on assembler compilation, even though it does on C compilation.
+    This creates security issues if assembler code is enabled; the
+    work-around is to set it by default in the flags for $(CCAS)
+  Work around compilers that don't support declaration of const data. Some
+    compilers fault 'extern const' data declarations (because the data is
+    not initialized); this turns on const-ness only for compilers where
+    this is known to work.
+
+Version 1.5.7beta04 [November 17, 2011]
+  Since the gcc driver does not recognize the --noexecstack flag, we must
+    use the -Wa prefix to have it passed through to the assembler.
+    Also removed a duplicate setting of this flag.
+  Added files that were omitted from the libpng-1.5.7beta03 zip distribution.
+
+Version 1.5.7beta05 [November 25, 2011]
+  Removed "zTXt" from warning in generic chunk decompression function.
+  Validate time settings passed to pngset() and png_convert_to_rfc1123()
+    (Frank Busse).
+  Added MINGW support to CMakeLists.txt
+  Reject invalid compression flag or method when reading the iTXt chunk.
+  Backed out 'simplified' API changes. The API seems too complex and there
+    is a lack of consensus or enthusiasm for the proposals.  The API also
+    reveals significant bugs inside libpng (double gamma correction and the
+    known bug of being unable to retrieve a corrected palette). It seems
+    better to wait until the bugs, at least, are corrected.
+  Moved pngvalid.c into contrib/libtests
+  Rebuilt Makefile.in, configure, etc., with autoconf-2.68
+
+Version 1.5.7rc01 [December 1, 2011]
+  Replaced an "#if" with "#ifdef" in pngrtran.c
+  Revised #if PNG_DO_BC block in png.c (use #ifdef and add #else)
+
+Version 1.5.7rc02 [December 5, 2011]
+  Revised project files and contrib/pngvalid/pngvalid.c to account for
+    the relocation of pngvalid into contrib/libtests.
+  Revised pngconf.h to use " __declspec(restrict)" only when MSC_VER >= 1400,
+    as in libpng-1.5.4.
+  Put CRLF line endings in the owatcom project files.
+
+Version 1.5.7rc03 [December 7, 2011]
+  Updated CMakeLists.txt to account for the relocation of pngvalid.c
+
+Version 1.5.7 [December 15, 2011]
+  Minor fixes to pngvalid.c for gcc 4.6.2 compatibility to remove warnings
+    reported by earlier versions.
+
+Version 1.5.8beta01 [January 15, 2011]
+  Removed '#include config.h"' from contrib/libtests/pngvalid.c.  It's not
+    needed and causes trouble for VPATH building.
+  Moved AC_MSG_CHECKING([if libraries can be versioned]) later to the proper
+    location in configure.ac (Gilles Espinasse).
+  Fix bug in pngerror.c: some long warnings were being improperly truncated
+    (CVE-2011-3464, bug introduced in libpng-1.5.3beta05).
+
+Version 1.5.8rc01 [January 21, 2012]
+  No changes.
+
+Version 1.5.8rc02 [January 25, 2012]
+  Fixed Min/GW uninstall to remove libpng.dll.a
+  Conditionalize the install rules for MINGW and CYGWIN in CMakeLists.txt
+
+Version 1.5.8 [February 1, 2012]
+  No changes.
+
+Version 1.5.9beta01 [February 3, 2012]
+  Rebuilt configure scripts in the tar distributions.
+
+Version 1.5.9beta02 [February 16, 2012]
+  Removed two unused definitions from scripts/pnglibconf.h.prebuilt
+  Removed some unused arrays (with #ifdef) from png_read_push_finish_row().
+  Removed tests for no-longer-used *_EMPTY_PLTE_SUPPORTED from pngstruct.h
+
+Version 1.5.9rc01 [February 17, 2012]
+  Fixed CVE-2011-3026 buffer overrun bug.  Deal more correctly with the test
+    on iCCP chunk length. Also removed spurious casts that may hide problems
+    on 16-bit systems.
+
+Version 1.5.9 [February 18, 2012]
+  No changes.
+
+Send comments/corrections/commendations to png-mng-implement at lists.sf.net
+(subscription required; visit
+https://lists.sourceforge.net/lists/listinfo/png-mng-implement
+to subscribe)
+or to glennrp at users.sourceforge.net
 
 Glenn R-P
-*/ }
 #endif
--- a/media/libpng/LICENSE
+++ b/media/libpng/LICENSE
@@ -5,18 +5,18 @@ included in the libpng distribution, the
 
 COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
 
 If you modify libpng you may insert additional notices immediately following
 this sentence.
 
 This code is released under the libpng license.
 
-libpng versions 1.2.6, August 15, 2004, through 1.4.8, July 7, 2011, are
-Copyright (c) 2004, 2006-2010 Glenn Randers-Pehrson, and are
+libpng versions 1.2.6, August 15, 2004, through 1.5.9, February 18, 2012, are
+Copyright (c) 2004, 2006-2011 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
 
    Cosmin Truta
 
 libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
 Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
 distributed according to the same disclaimer and license as libpng-1.0.6
@@ -103,9 +103,9 @@ boxes and the like:
 Also, the PNG logo (in PNG format, of course) is supplied in the
 files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
 
 Libpng is OSI Certified Open Source Software.  OSI Certified Open Source is a
 certification mark of the Open Source Initiative.
 
 Glenn Randers-Pehrson
 glennrp at users.sourceforge.net
-July 7, 2011
+February 18, 2012
--- a/media/libpng/MOZCHANGES
+++ b/media/libpng/MOZCHANGES
@@ -1,11 +1,13 @@
 
 Changes made to pristine png source by mozilla.org developers.
 
+2012/02/19  -- Synced with libpng-1.5.9 (bug #648690).
+
 2011/07/20  -- Synced with libpng-1.4.8 (bug #669863).
 
 2011/04/08  -- Synced with libpng-1.4.7 (bug #624133).
 
 2010/06/30  -- Synced with libpng-1.4.3 (bug #564792).
 
 2010/02/26  -- Synced with libpng-1.4.1 (bug #544747).
 
--- a/media/libpng/Makefile.in
+++ b/media/libpng/Makefile.in
@@ -54,17 +54,17 @@ CSRCS		= \
 		png.c \
 		pngerror.c \
 		pngget.c \
 		pngmem.c \
 		pngset.c \
 		pngtrans.c \
 		$(NULL)
 
-# These files enable support for reading/writting PNGs
+# These files enable support for reading/writing PNGs
 CSRCS		+= \
 		pngpread.c \
 		pngread.c \
 		pngrio.c \
 		pngrtran.c \
 		pngrutil.c \
 		pngwio.c \
 		pngwrite.c \
--- a/media/libpng/README
+++ b/media/libpng/README
@@ -1,9 +1,9 @@
-README for libpng version 1.4.8 - July 7, 2011 (shared library 14.0)
+README for libpng version 1.5.9 - February 18, 2012 (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.
 
 Libpng comes in several distribution formats.  Get libpng-*.tar.gz,
 libpng-*.tar.xz or libpng-*.tar.bz2 if you want UNIX-style line endings
 in the text files, or lpng*.zip if you want DOS-style line endings.
 
@@ -53,17 +53,17 @@ the library action on the detection of c
 to set different actions based on whether the CRC error occurred in a
 critical or an ancillary chunk.
 
 The changes made to the library, and bugs fixed are based on discussions
 on the PNG-implement mailing list and not on material submitted
 privately to Guy, Andreas, or Glenn.  They will forward any good
 suggestions to the list.
 
-For a detailed description on using libpng, read libpng.txt.  For
+For a detailed description on using libpng, read libpng-manual.txt.  For
 examples of libpng in a program, see example.c and pngtest.c.  For usage
 information and restrictions (what little they are) on libpng, see
 png.h.  For a description on using zlib (the compression library used by
 libpng) and zlib's restrictions, see zlib.h
 
 I have included a general makefile, as well as several machine and
 compiler specific ones, but you may have to modify one for your own needs.
 
@@ -133,23 +133,27 @@ Files in this distribution:
       ANNOUNCE      =>  Announcement of this version, with recent changes
       CHANGES       =>  Description of changes between libpng versions
       KNOWNBUG      =>  List of known bugs and deficiencies
       LICENSE       =>  License to use and redistribute libpng
       README        =>  This file
       TODO          =>  Things not implemented in the current library
       Y2KINFO       =>  Statement of Y2K compliance
       example.c     =>  Example code for using libpng functions
-      libpng.3      =>  manual page for libpng (includes libpng.txt)
-      libpng.txt    =>  Description of libpng and its functions
+      libpng.3      =>  manual page for libpng (includes libpng-manual.txt)
+      libpng-manual.txt  =>  Description of libpng and its functions
       libpngpf.3    =>  manual page for libpng's private functions
       png.5         =>  manual page for the PNG format
       png.c         =>  Basic interface functions common to library
-      png.h         =>  Library function and interface declarations
-      pngconf.h     =>  System specific library configuration
+      png.h         =>  Library function and interface declarations (public)
+      pngpriv.h     =>  Library function and interface declarations (private)
+      pngconf.h     =>  System specific library configuration (public)
+      pngstruct.h   =>  png_struct declaration (private)
+      pnginfo.h     =>  png_info struct declaration (private)
+      pngdebug.h    =>  debugging macros (private)
       pngerror.c    =>  Error/warning message I/O functions
       pngget.c      =>  Functions for retrieving info from struct
       pngmem.c      =>  Memory handling functions
       pngbar.png    =>  PNG logo, 88x31
       pngnow.png    =>  PNG logo, 98x31
       pngpread.c    =>  Progressive reading functions
       pngread.c     =>  Read data/helper high-level functions
       pngrio.c      =>  Lowest-level data read I/O functions
@@ -168,82 +172,26 @@ Files in this distribution:
                             Greg Roelofs' "PNG: The Definitive Guide",
                             O'Reilly, 1999
        msvctest     =>  Builds and runs pngtest using a MSVC workspace
        pngminus     =>  Simple pnm2png and png2pnm programs
        pngsuite     =>  Test images
        visupng      =>  Contains a MSVC workspace for VisualPng
       projects      =>  Contains project files and workspaces for
                         building a DLL
-       c5builder        =>  Contains a Borland workspace for building
+       cbuilder5        =>  Contains a Borland workspace for building
                             libpng and zlib
        visualc6         =>  Contains a Microsoft Visual C++ (MSVC)
                             workspace for building libpng and zlib
+       visualc71        =>  Contains a Microsoft Visual C++ (MSVC)
+                            workspace for building libpng and zlib
+       xcode            =>  Contains an Apple xcode
+                            workspace for building libpng and zlib
       scripts       =>  Directory containing scripts for building libpng:
-       descrip.mms      =>  VMS makefile for MMS or MMK
-       makefile.std     =>  Generic UNIX makefile (cc, creates static
-                            libpng.a)
-       makefile.elf     =>  Linux/ELF makefile symbol versioning,
-                            (gcc, creates libpng14.so.14.1.4.8)
-       makefile.linux   =>  Linux/ELF makefile
-                            (gcc, creates libpng14.so.14.1.4.8)
-       makefile.gcc     =>  Generic makefile (gcc, creates static libpng.a)
-       makefile.knr     =>  Archaic UNIX Makefile that converts files with
-                            ansi2knr (Requires ansi2knr.c from
-                            ftp://ftp.cs.wisc.edu/ghost)
-       makefile.aix     =>  AIX makefile
-       makefile.cygwin  =>  Cygwin/gcc makefile
-       makefile.darwin  =>  Darwin makefile
-       makefile.dec     =>  DEC Alpha UNIX makefile
-       makefile.freebsd =>  FreeBSD makefile
-       makefile.hpgcc   =>  HPUX makefile using gcc
-       makefile.hpux    =>  HPUX (10.20 and 11.00) makefile
-       makefile.hp64    =>  HPUX (10.20 and 11.00) makefile, 64 bit
-       makefile.ibmc    =>  IBM C/C++ version 3.x for Win32 and OS/2 (static)
-       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.openbsd =>  OpenBSD makefile
-       makefile.sgi     =>  Silicon Graphics IRIX (cc, creates static lib)
-       makefile.sggcc   =>  Silicon Graphics
-                            (gcc, creates libpng14.so.14.1.4.8)
-       makefile.sunos   =>  Sun makefile
-       makefile.solaris =>  Solaris 2.X makefile
-                            (gcc, creates libpng14.so.14.1.4.8)
-       makefile.so9     =>  Solaris 9 makefile
-                            (gcc, creates libpng14.so.14.1.4.8)
-       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
-       makefile.mips    =>  MIPS makefile
-       makefile.acorn   =>  Acorn makefile
-       makefile.amiga   =>  Amiga makefile
-       smakefile.ppc    =>  AMIGA smakefile for SAS C V6.58/7.00 PPC
-                            compiler (Requires SCOPTIONS, copied from
-                            scripts/SCOPTIONS.ppc)
-       makefile.atari   =>  Atari makefile
-       makefile.beos    =>  BEOS makefile for X86
-       makefile.bor     =>  Borland makefile (uses bcc)
-       makefile.bc32    =>  32-bit Borland C++ (all modules compiled in C mode)
-       makefile.tc3     =>  Turbo C 3.0 makefile
-       makefile.dj2     =>  DJGPP 2 makefile
-       makefile.msc     =>  Microsoft C makefile
-       makefile.vcwin32 =>  makefile for Microsoft Visual C++ 4.0 and
-                            later (does not use assembler code)
-       makefile.os2     =>  OS/2 Makefile (gcc and emx, requires pngos2.def)
-       png32ce.def      =>  module definition for makefile.cegccg
-       pngos2.def       =>  OS/2 module definition file used by
-                            makefile.os2
-       pngwin.def       =>  module definition file used by
-                            makefile.cygwin and makefile.mingw
-       makefile.watcom  =>  Watcom 10a+ Makefile, 32-bit flat memory model
-       makevms.com      =>  VMS build script
-       SCOPTIONS.ppc    =>  Used with smakefile.ppc
+                            (see scripts/README.txt for the list of scripts)
 
 Good luck, and happy coding.
 
 -Glenn Randers-Pehrson (current maintainer, since 1998)
  Internet: glennrp at users.sourceforge.net
 
 -Andreas Eric Dilger (former maintainer, 1996-1997)
  Internet: adilger at enel.ucalgary.ca
new file mode 100644
--- /dev/null
+++ b/media/libpng/apng.patch
@@ -0,0 +1,1844 @@
+diff -up8 png.h png.h
+--- png.h	2012-02-18 15:31:14 -0500
++++ png.h	2012-02-19 16:08:36 -0500
+@@ -417,24 +417,18 @@
+ /* Careful here.  At one time, Guy wanted to use 082, but that would be octal.
+  * We must not include leading zeros.
+  * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
+  * version 1.0.0 was mis-numbered 100 instead of 10000).  From
+  * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release
+  */
+ #define PNG_LIBPNG_VER 10509 /* 1.5.9 */
+ 
+-/* Library configuration: these options cannot be changed after
+- * the library has been built.
+- */
+-#ifndef PNGLCONF_H
+-    /* If pnglibconf.h is missing, you can
+-     * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h
+-     */
+-#   include "pnglibconf.h"
++#ifndef MOZPNGCONF_H
++#   include "mozpngconf.h"
+ #endif
+ 
+ #ifndef PNG_VERSION_INFO_ONLY
+ #  ifndef PNG_BUILDING_SYMBOL_TABLE
+   /*
+    *   Standard header files (not needed for the version info or while
+    *   building symbol table -- see scripts/pnglibconf.dfa)
+    */
+@@ -534,16 +528,27 @@ extern "C" {
+  * Otherwise the calls are mapped to png_error.
+  */
+ 
+ /* Section 2: type definitions, including structures and compile time
+  * constants.
+  * See pngconf.h for base types that vary by machine/system
+  */
+ 
++#ifdef PNG_APNG_SUPPORTED
++/* dispose_op flags from inside fcTL */
++#define PNG_DISPOSE_OP_NONE        0x00
++#define PNG_DISPOSE_OP_BACKGROUND  0x01
++#define PNG_DISPOSE_OP_PREVIOUS    0x02
++
++/* blend_op flags from inside fcTL */
++#define PNG_BLEND_OP_SOURCE        0x00
++#define PNG_BLEND_OP_OVER          0x01
++#endif /* PNG_APNG_SUPPORTED */
++
+ /* This triggers a compiler error in png.c, if png.c and png.h
+  * do not agree upon the version number.
+  */
+ typedef char* png_libpng_version_1_5_9;
+ 
+ /* Three color definitions.  The order of the red, green, and blue, (and the
+  * exact size) is not important, although the size of the fields need to
+  * be png_byte or png_uint_16 (as defined below).
+@@ -817,16 +822,20 @@ typedef png_info FAR * FAR * png_infopp;
+ #define PNG_INFO_oFFs 0x0100
+ #define PNG_INFO_tIME 0x0200
+ #define PNG_INFO_pCAL 0x0400
+ #define PNG_INFO_sRGB 0x0800   /* GR-P, 0.96a */
+ #define PNG_INFO_iCCP 0x1000   /* ESR, 1.0.6 */
+ #define PNG_INFO_sPLT 0x2000   /* ESR, 1.0.6 */
+ #define PNG_INFO_sCAL 0x4000   /* ESR, 1.0.6 */
+ #define PNG_INFO_IDAT 0x8000   /* ESR, 1.0.6 */
++#ifdef PNG_APNG_SUPPORTED
++#define PNG_INFO_acTL 0x10000
++#define PNG_INFO_fcTL 0x20000
++#endif
+ 
+ /* This is used for the transformation routines, as some of them
+  * change these values for the row.  It also should enable using
+  * the routines for other purposes.
+  */
+ typedef struct png_row_info_struct
+ {
+    png_uint_32 width;    /* width of row */
+@@ -862,16 +871,20 @@ typedef PNG_CALLBACK(void, *png_flush_pt
+ typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32,
+     int));
+ typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32,
+     int));
+ 
+ #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
+ typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop));
+ typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop));
++#ifdef PNG_APNG_SUPPORTED
++typedef PNG_CALLBACK(void, *png_progressive_frame_ptr, (png_structp,
++    png_uint_32));
++#endif
+ 
+ /* The following callback receives png_uint_32 row_number, int pass for the
+  * png_bytep data of the row.  When transforming an interlaced image the
+  * row number is the row number within the sub-image of the interlace pass, so
+  * the value will increase to the height of the sub-image (not the full image)
+  * then reset to 0 for the next pass.
+  *
+  * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to
+@@ -2632,26 +2645,99 @@ PNG_EXPORT(207, void, png_save_uint_16, 
+        ((unsigned int)(*((buf) + 1)))))
+ 
+ #  define png_get_int_32(buf) \
+      ((png_int_32)((*(buf) & 0x80) \
+       ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \
+       : (png_int_32)png_get_uint_32(buf)))
+ #endif
+ 
++#ifdef PNG_APNG_SUPPORTED
++PNG_EXPORT(234, png_uint_32, png_get_acTL, (png_structp png_ptr,
++   png_infop info_ptr, png_uint_32 *num_frames, png_uint_32 *num_plays));
++
++PNG_EXPORT(235, png_uint_32, png_set_acTL, (png_structp png_ptr,
++   png_infop info_ptr, png_uint_32 num_frames, png_uint_32 num_plays));
++
++PNG_EXPORT(236, png_uint_32, png_get_num_frames, (png_structp png_ptr,
++   png_infop info_ptr));
++
++PNG_EXPORT(237, png_uint_32, png_get_num_plays, (png_structp png_ptr,
++   png_infop info_ptr));
++
++PNG_EXPORT(238, png_uint_32, png_get_next_frame_fcTL,
++   (png_structp png_ptr, png_infop info_ptr, png_uint_32 *width,
++   png_uint_32 *height, png_uint_32 *x_offset, png_uint_32 *y_offset,
++   png_uint_16 *delay_num, png_uint_16 *delay_den, png_byte *dispose_op,
++   png_byte *blend_op));
++
++PNG_EXPORT(239, png_uint_32, png_set_next_frame_fcTL,
++   (png_structp png_ptr, png_infop info_ptr, png_uint_32 width,
++   png_uint_32 height, png_uint_32 x_offset, png_uint_32 y_offset,
++   png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
++   png_byte blend_op));
++
++PNG_EXPORT(240, png_uint_32, png_get_next_frame_width,
++   (png_structp png_ptr, png_infop info_ptr));
++PNG_EXPORT(241, png_uint_32, png_get_next_frame_height,
++   (png_structp png_ptr, png_infop info_ptr));
++PNG_EXPORT(242, png_uint_32, png_get_next_frame_x_offset,
++   (png_structp png_ptr, png_infop info_ptr));
++PNG_EXPORT(243, png_uint_32, png_get_next_frame_y_offset,
++   (png_structp png_ptr, png_infop info_ptr));
++PNG_EXPORT(244, png_uint_16, png_get_next_frame_delay_num,
++   (png_structp png_ptr, png_infop info_ptr));
++PNG_EXPORT(245, png_uint_16, png_get_next_frame_delay_den,
++   (png_structp png_ptr, png_infop info_ptr));
++PNG_EXPORT(246, png_byte, png_get_next_frame_dispose_op,
++   (png_structp png_ptr, png_infop info_ptr));
++PNG_EXPORT(247, png_byte, png_get_next_frame_blend_op,
++   (png_structp png_ptr, png_infop info_ptr));
++PNG_EXPORT(248, png_byte, png_get_first_frame_is_hidden,
++   (png_structp png_ptr, png_infop info_ptr));
++PNG_EXPORT(249, png_uint_32, png_set_first_frame_is_hidden,
++   (png_structp png_ptr, png_infop info_ptr, png_byte is_hidden));
++
++#ifdef PNG_READ_APNG_SUPPORTED
++PNG_EXPORT(250, void, png_read_frame_head, (png_structp png_ptr,
++   png_infop info_ptr));
++#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
++PNG_EXPORT(251, void, png_set_progressive_frame_fn, (png_structp png_ptr,
++   png_progressive_frame_ptr frame_info_fn,
++   png_progressive_frame_ptr frame_end_fn));
++#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
++#endif /* PNG_READ_APNG_SUPPORTED */
++
++#ifdef PNG_WRITE_APNG_SUPPORTED
++PNG_EXPORT(252, void, png_write_frame_head, (png_structp png_ptr,
++   png_infop info_ptr, png_bytepp row_pointers,
++   png_uint_32 width, png_uint_32 height,
++   png_uint_32 x_offset, png_uint_32 y_offset,
++   png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
++   png_byte blend_op));
++
++PNG_EXPORT(253, void, png_write_frame_tail, (png_structp png_ptr,
++   png_infop info_ptr));
++#endif /* PNG_WRITE_APNG_SUPPORTED */
++#endif /* PNG_APNG_SUPPORTED */
++
+ /* Maintainer: Put new public prototypes here ^, in libpng.3, and project
+  * defs
+  */
+ 
+ /* The last ordinal number (this is the *last* one already used; the next
+  * one to use is one more than this.)  Maintainer, remember to add an entry to
+  * scripts/symbols.def as well.
+  */
+ #ifdef PNG_EXPORT_LAST_ORDINAL
++#ifdef PNG_APNG_SUPPORTED
++  PNG_EXPORT_LAST_ORDINAL(253);
++#else
+   PNG_EXPORT_LAST_ORDINAL(233);
++#endif /* PNG_APNG_SUPPORTED */
+ #endif
+ 
+ #ifdef __cplusplus
+ }
+ #endif
+ 
+ #endif /* PNG_VERSION_INFO_ONLY */
+ /* Do not put anything past this line */
+diff -up8 pngget.c pngget.c
+--- pngget.c	2012-02-18 15:31:14 -0500
++++ pngget.c	2012-02-19 16:02:28 -0500
+@@ -1116,9 +1116,171 @@ png_get_io_chunk_type (png_const_structp
+ png_const_bytep PNGAPI
+ png_get_io_chunk_name (png_structp png_ptr)
+ {
+    PNG_CSTRING_FROM_CHUNK(png_ptr->io_chunk_string, png_ptr->chunk_name);
+    return png_ptr->io_chunk_string;
+ }
+ #endif /* ?PNG_IO_STATE_SUPPORTED */
+ 
++#ifdef PNG_APNG_SUPPORTED
++png_uint_32 PNGAPI
++png_get_acTL(png_structp png_ptr, png_infop info_ptr,
++             png_uint_32 *num_frames, png_uint_32 *num_plays)
++{
++    png_debug1(1, "in %s retrieval function", "acTL");
++
++    if (png_ptr != NULL && info_ptr != NULL &&
++        (info_ptr->valid & PNG_INFO_acTL) &&
++        num_frames != NULL && num_plays != NULL)
++    {
++        *num_frames = info_ptr->num_frames;
++        *num_plays = info_ptr->num_plays;
++        return (1);
++    }
++
++    return (0);
++}
++
++png_uint_32 PNGAPI
++png_get_num_frames(png_structp png_ptr, png_infop info_ptr)
++{
++    png_debug(1, "in png_get_num_frames()");
++
++    if (png_ptr != NULL && info_ptr != NULL)
++        return (info_ptr->num_frames);
++    return (0);
++}
++
++png_uint_32 PNGAPI
++png_get_num_plays(png_structp png_ptr, png_infop info_ptr)
++{
++    png_debug(1, "in png_get_num_plays()");
++
++    if (png_ptr != NULL && info_ptr != NULL)
++        return (info_ptr->num_plays);
++    return (0);
++}
++
++png_uint_32 PNGAPI
++png_get_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
++             png_uint_32 *width, png_uint_32 *height,
++             png_uint_32 *x_offset, png_uint_32 *y_offset,
++             png_uint_16 *delay_num, png_uint_16 *delay_den,
++             png_byte *dispose_op, png_byte *blend_op)
++{
++    png_debug1(1, "in %s retrieval function", "fcTL");
++
++    if (png_ptr != NULL && info_ptr != NULL &&
++        (info_ptr->valid & PNG_INFO_fcTL) &&
++        width != NULL && height != NULL &&
++        x_offset != NULL && x_offset != NULL &&
++        delay_num != NULL && delay_den != NULL &&
++        dispose_op != NULL && blend_op != NULL)
++    {
++        *width = info_ptr->next_frame_width;
++        *height = info_ptr->next_frame_height;
++        *x_offset = info_ptr->next_frame_x_offset;
++        *y_offset = info_ptr->next_frame_y_offset;
++        *delay_num = info_ptr->next_frame_delay_num;
++        *delay_den = info_ptr->next_frame_delay_den;
++        *dispose_op = info_ptr->next_frame_dispose_op;
++        *blend_op = info_ptr->next_frame_blend_op;
++        return (1);
++    }
++
++    return (0);
++}
++
++png_uint_32 PNGAPI
++png_get_next_frame_width(png_structp png_ptr, png_infop info_ptr)
++{
++    png_debug(1, "in png_get_next_frame_width()");
++
++    if (png_ptr != NULL && info_ptr != NULL)
++        return (info_ptr->next_frame_width);
++    return (0);
++}
++
++png_uint_32 PNGAPI
++png_get_next_frame_height(png_structp png_ptr, png_infop info_ptr)
++{
++    png_debug(1, "in png_get_next_frame_height()");
++
++    if (png_ptr != NULL && info_ptr != NULL)
++        return (info_ptr->next_frame_height);
++    return (0);
++}
++
++png_uint_32 PNGAPI
++png_get_next_frame_x_offset(png_structp png_ptr, png_infop info_ptr)
++{
++    png_debug(1, "in png_get_next_frame_x_offset()");
++
++    if (png_ptr != NULL && info_ptr != NULL)
++        return (info_ptr->next_frame_x_offset);
++    return (0);
++}
++
++png_uint_32 PNGAPI
++png_get_next_frame_y_offset(png_structp png_ptr, png_infop info_ptr)
++{
++    png_debug(1, "in png_get_next_frame_y_offset()");
++
++    if (png_ptr != NULL && info_ptr != NULL)
++        return (info_ptr->next_frame_y_offset);
++    return (0);
++}
++
++png_uint_16 PNGAPI
++png_get_next_frame_delay_num(png_structp png_ptr, png_infop info_ptr)
++{
++    png_debug(1, "in png_get_next_frame_delay_num()");
++
++    if (png_ptr != NULL && info_ptr != NULL)
++        return (info_ptr->next_frame_delay_num);
++    return (0);
++}
++
++png_uint_16 PNGAPI
++png_get_next_frame_delay_den(png_structp png_ptr, png_infop info_ptr)
++{
++    png_debug(1, "in png_get_next_frame_delay_den()");
++
++    if (png_ptr != NULL && info_ptr != NULL)
++        return (info_ptr->next_frame_delay_den);
++    return (0);
++}
++
++png_byte PNGAPI
++png_get_next_frame_dispose_op(png_structp png_ptr, png_infop info_ptr)
++{
++    png_debug(1, "in png_get_next_frame_dispose_op()");
++
++    if (png_ptr != NULL && info_ptr != NULL)
++        return (info_ptr->next_frame_dispose_op);
++    return (0);
++}
++
++png_byte PNGAPI
++png_get_next_frame_blend_op(png_structp png_ptr, png_infop info_ptr)
++{
++    png_debug(1, "in png_get_next_frame_blend_op()");
++
++    if (png_ptr != NULL && info_ptr != NULL)
++        return (info_ptr->next_frame_blend_op);
++    return (0);
++}
++
++png_byte PNGAPI
++png_get_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr)
++{
++    png_debug(1, "in png_first_frame_is_hidden()");
++
++    if (png_ptr != NULL)
++       return (png_byte)(png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN);
++
++    PNG_UNUSED(info_ptr)
++
++    return 0;
++}
++#endif /* PNG_APNG_SUPPORTED */
+ #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
+diff -up8 pnginfo.h pnginfo.h
+--- pnginfo.h	2012-02-18 15:31:14 -0500
++++ pnginfo.h	2012-02-19 16:02:28 -0500
+@@ -260,10 +260,23 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
+ 
+ #ifdef PNG_INFO_IMAGE_SUPPORTED
+    /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)
+       non-zero */
+    /* Data valid if (valid & PNG_INFO_IDAT) non-zero */
+    png_bytepp row_pointers;        /* the image bits */
+ #endif
+ 
++#ifdef PNG_APNG_SUPPORTED
++   png_uint_32 num_frames; /* including default image */
++   png_uint_32 num_plays;
++   png_uint_32 next_frame_width;
++   png_uint_32 next_frame_height;
++   png_uint_32 next_frame_x_offset;
++   png_uint_32 next_frame_y_offset;
++   png_uint_16 next_frame_delay_num;
++   png_uint_16 next_frame_delay_den;
++   png_byte next_frame_dispose_op;
++   png_byte next_frame_blend_op;
++#endif
++
+ };
+ #endif /* PNGINFO_H */
+diff -up8 pngpread.c pngpread.c
+--- pngpread.c	2012-02-18 15:31:14 -0500
++++ pngpread.c	2012-02-19 16:02:28 -0500
+@@ -233,16 +233,119 @@ png_push_read_chunk(png_structp png_ptr,
+       png_crc_read(png_ptr, chunk_tag, 4);
+       png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
+       png_check_chunk_name(png_ptr, png_ptr->chunk_name);
+       png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
+    }
+ 
+    chunk_name = png_ptr->chunk_name;
+ 
++#ifdef PNG_READ_APNG_SUPPORTED
++   if (png_ptr->num_frames_read > 0 &&
++       png_ptr->num_frames_read < info_ptr->num_frames)
++   {
++      if (chunk_name == png_IDAT)
++      {
++         /* Discard trailing IDATs for the first frame */
++         if (png_ptr->mode & PNG_HAVE_fcTL || png_ptr->num_frames_read > 1)
++            png_error(png_ptr, "out of place IDAT");
++
++         if (png_ptr->push_length + 4 > png_ptr->buffer_size)
++         {
++            png_push_save_buffer(png_ptr);
++            return;
++         }
++
++         png_push_crc_skip(png_ptr, png_ptr->push_length);
++         png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
++         return;
++      }
++      else if (chunk_name == png_fdAT)
++      {
++         if (png_ptr->buffer_size < 4)
++         {
++            png_push_save_buffer(png_ptr);
++            return;
++         }
++
++         png_ensure_sequence_number(png_ptr, 4);
++
++         if (!(png_ptr->mode & PNG_HAVE_fcTL))
++         {
++            /* Discard trailing fdATs for frames other than the first */
++            if (png_ptr->num_frames_read < 2)
++               png_error(png_ptr, "out of place fdAT");
++
++            if (png_ptr->push_length + 4 > png_ptr->buffer_size)
++            {
++               png_push_save_buffer(png_ptr);
++               return;
++            }
++
++            png_push_crc_skip(png_ptr, png_ptr->push_length);
++            png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
++            return;
++         }
++
++         else
++         {
++            /* frame data follows */
++            png_ptr->idat_size = png_ptr->push_length - 4;
++            png_ptr->mode |= PNG_HAVE_IDAT;
++            png_ptr->process_mode = PNG_READ_IDAT_MODE;
++
++            return;
++         }
++      }
++
++      else if (chunk_name == png_fcTL)
++      {
++         if (png_ptr->push_length + 4 > png_ptr->buffer_size)
++         {
++            png_push_save_buffer(png_ptr);
++            return;
++         }
++
++         png_read_reset(png_ptr);
++         png_ptr->mode &= ~PNG_HAVE_fcTL;
++
++         png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
++
++         if (!(png_ptr->mode & PNG_HAVE_fcTL))
++            png_error(png_ptr, "missing required fcTL chunk");
++
++         png_read_reinit(png_ptr, info_ptr);
++         png_progressive_read_reset(png_ptr);
++
++         if (png_ptr->frame_info_fn != NULL)
++            (*(png_ptr->frame_info_fn))(png_ptr, png_ptr->num_frames_read);
++
++         png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
++
++         return;
++      }
++
++      else
++      {
++         if (png_ptr->push_length + 4 > png_ptr->buffer_size)
++         {
++            png_push_save_buffer(png_ptr);
++            return;
++         }
++         png_warning(png_ptr, "Skipped (ignored) a chunk "
++                              "between APNG chunks");
++         png_push_crc_skip(png_ptr, png_ptr->push_length);
++         png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
++         return;
++      }
++
++      return;
++   }
++#endif /* PNG_READ_APNG_SUPPORTED */
++
+    if (chunk_name == png_IDAT)
+    {
+       /* This is here above the if/else case statement below because if the
+        * unknown handling marks 'IDAT' as unknown then the IDAT handling case is
+        * completely skipped.
+        *
+        * TODO: there must be a better way of doing this.
+        */
+@@ -336,16 +439,20 @@ png_push_read_chunk(png_structp png_ptr,
+          if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
+             if (png_ptr->push_length == 0)
+                return;
+ 
+          if (png_ptr->mode & PNG_AFTER_IDAT)
+             png_benign_error(png_ptr, "Too many IDATs found");
+       }
+ 
++#ifdef PNG_READ_APNG_SUPPORTED
++      png_have_info(png_ptr, info_ptr);
++#endif
++
+       png_ptr->idat_size = png_ptr->push_length;
+       png_ptr->mode |= PNG_HAVE_IDAT;
+       png_ptr->process_mode = PNG_READ_IDAT_MODE;
+       png_push_have_info(png_ptr, info_ptr);
+       png_ptr->zstream.avail_out =
+           (uInt) PNG_ROWBYTES(png_ptr->pixel_depth,
+           png_ptr->iwidth) + 1;
+       png_ptr->zstream.next_out = png_ptr->row_buf;
+@@ -568,16 +675,39 @@ png_push_read_chunk(png_structp png_ptr,
+          png_push_save_buffer(png_ptr);
+          return;
+       }
+ 
+       png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
+    }
+ 
+ #endif
++
++#ifdef PNG_READ_APNG_SUPPORTED
++   else if (chunk_name == png_acTL)
++   {
++      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
++      {
++         png_push_save_buffer(png_ptr);
++         return;
++      }
++      png_handle_acTL(png_ptr, info_ptr, png_ptr->push_length);
++   }
++
++   else if (chunk_name == png_fcTL)
++   {
++      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
++      {
++         png_push_save_buffer(png_ptr);
++         return;
++      }
++      png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
++   }
++#endif /* PNG_READ_APNG_SUPPORTED */
++
+    else
+    {
+       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
+       {
+          png_push_save_buffer(png_ptr);
+          return;
+       }
+       png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
+@@ -767,40 +897,91 @@ void /* PRIVATE */
+ png_push_read_IDAT(png_structp png_ptr)
+ {
+    if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
+    {
+       png_byte chunk_length[4];
+       png_byte chunk_tag[4];
+ 
+       /* TODO: this code can be commoned up with the same code in push_read */
++#ifdef PNG_READ_APNG_SUPPORTED
++      if (png_ptr->buffer_size < 12)
++#else
+       if (png_ptr->buffer_size < 8)
++#endif
+       {
+          png_push_save_buffer(png_ptr);
+          return;
+       }
+ 
+       png_push_fill_buffer(png_ptr, chunk_length, 4);
+       png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
+       png_reset_crc(png_ptr);
+       png_crc_read(png_ptr, chunk_tag, 4);
+       png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
+       png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
+ 
++#ifdef PNG_READ_APNG_SUPPORTED
++      if (png_ptr->chunk_name != png_fdAT && png_ptr->num_frames_read > 0)
++      {
++          if (png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)
++          {
++              png_ptr->process_mode = PNG_READ_CHUNK_MODE;
++              if (png_ptr->frame_end_fn != NULL)
++                 (*(png_ptr->frame_end_fn))(png_ptr, png_ptr->num_frames_read);
++              png_ptr->num_frames_read++;
++              return;
++          }
++          else
++          {
++              if (png_ptr->chunk_name == png_IEND)
++                  png_error(png_ptr, "Not enough image data");
++              if (png_ptr->push_length + 4 > png_ptr->buffer_size)
++              {
++                 png_push_save_buffer(png_ptr);
++                 return;
++              }
++              png_warning(png_ptr, "Skipping (ignoring) a chunk between "
++                                   "APNG chunks");
++              png_crc_finish(png_ptr, png_ptr->push_length);
++              png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
++              return;
++          }
++      }
++      else
++#endif
++#ifdef PNG_READ_APNG_SUPPORTED
++      if (png_ptr->chunk_name != png_IDAT && png_ptr->num_frames_read == 0)
++#else
+       if (png_ptr->chunk_name != png_IDAT)
++#endif
+       {
+          png_ptr->process_mode = PNG_READ_CHUNK_MODE;
+ 
+          if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
+             png_error(png_ptr, "Not enough compressed data");
+ 
++#ifdef PNG_READ_APNG_SUPPORTED
++         if (png_ptr->frame_end_fn != NULL)
++            (*(png_ptr->frame_end_fn))(png_ptr, png_ptr->num_frames_read);
++         png_ptr->num_frames_read++;
++#endif
++
+          return;
+       }
+ 
+       png_ptr->idat_size = png_ptr->push_length;
++
++#ifdef PNG_READ_APNG_SUPPORTED
++      if (png_ptr->num_frames_read > 0)
++      {
++         png_ensure_sequence_number(png_ptr, 4);
++         png_ptr->idat_size -= 4;
++      }
++#endif
+    }
+ 
+    if (png_ptr->idat_size && png_ptr->save_buffer_size)
+    {
+       png_size_t save_size = png_ptr->save_buffer_size;
+       png_uint_32 idat_size = png_ptr->idat_size;
+ 
+       /* We want the smaller of 'idat_size' and 'current_buffer_size', but they
+@@ -1827,16 +2008,27 @@ png_set_progressive_read_fn(png_structp 
+ 
+    png_ptr->info_fn = info_fn;
+    png_ptr->row_fn = row_fn;
+    png_ptr->end_fn = end_fn;
+ 
+    png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer);
+ }
+ 
++#ifdef PNG_READ_APNG_SUPPORTED
++void PNGAPI
++png_set_progressive_frame_fn(png_structp png_ptr,
++   png_progressive_frame_ptr frame_info_fn,
++   png_progressive_frame_ptr frame_end_fn)
++{
++   png_ptr->frame_info_fn = frame_info_fn;
++   png_ptr->frame_end_fn = frame_end_fn;
++}
++#endif
++
+ png_voidp PNGAPI
+ png_get_progressive_ptr(png_const_structp png_ptr)
+ {
+    if (png_ptr == NULL)
+       return (NULL);
+ 
+    return png_ptr->io_ptr;
+ }
+diff -up8 pngpriv.h pngpriv.h
+--- pngpriv.h	2012-02-18 15:31:14 -0500
++++ pngpriv.h	2012-02-19 16:02:28 -0500
+@@ -421,16 +421,20 @@ typedef PNG_CONST png_uint_16p FAR * png
+ #define PNG_HAVE_cHRM               0x40
+ #define PNG_HAVE_sRGB               0x80
+ #define PNG_HAVE_CHUNK_HEADER      0x100
+ #define PNG_WROTE_tIME             0x200
+ #define PNG_WROTE_INFO_BEFORE_PLTE 0x400
+ #define PNG_BACKGROUND_IS_GRAY     0x800
+ #define PNG_HAVE_PNG_SIGNATURE    0x1000
+ #define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
++#ifdef PNG_APNG_SUPPORTED
++#define PNG_HAVE_acTL             0x4000
++#define PNG_HAVE_fcTL             0x8000
++#endif
+ 
+ /* Flags for the transformations the PNG library does on the image data */
+ #define PNG_BGR                 0x0001
+ #define PNG_INTERLACE           0x0002
+ #define PNG_PACK                0x0004
+ #define PNG_SHIFT               0x0008
+ #define PNG_SWAP_BYTES          0x0010
+ #define PNG_INVERT_MONO         0x0020
+@@ -616,16 +620,25 @@ PNG_EXTERN png_fixed_point png_fixed PNG
+ #define png_sPLT PNG_CHUNK(115,  80,  76,  84)
+ #define png_sRGB PNG_CHUNK(115,  82,  71,  66)
+ #define png_sTER PNG_CHUNK(115,  84,  69,  82)
+ #define png_tEXt PNG_CHUNK(116,  69,  88, 116)
+ #define png_tIME PNG_CHUNK(116,  73,  77,  69)
+ #define png_tRNS PNG_CHUNK(116,  82,  78,  83)
+ #define png_zTXt PNG_CHUNK(122,  84,  88, 116)
+ 
++#ifdef PNG_APNG_SUPPORTED
++#define png_acTL PNG_CHUNK( 97,  99,  84,  76)
++#define png_fcTL PNG_CHUNK(102,  99,  84,  76)
++#define png_fdAT PNG_CHUNK(102, 100,  65,  84)
++
++/* For png_struct.apng_flags: */
++#define PNG_FIRST_FRAME_HIDDEN       0x0001
++#endif
++
+ /* The following will work on (signed char*) strings, whereas the get_uint_32
+  * macro will fail on top-bit-set values because of the sign extension.
+  */
+ #define PNG_CHUNK_FROM_STRING(s)\
+    PNG_CHUNK(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3])
+ 
+ /* This uses (char), not (png_byte) to avoid warnings on systems where (char) is
+  * signed and the argument is a (char[])  This macro will fail miserably on
+@@ -1299,16 +1312,55 @@ PNG_EXTERN void png_push_read_iTXt PNGAR
+ 
+ #ifdef PNG_MNG_FEATURES_SUPPORTED
+ PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info,
+     png_bytep row));
+ PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info,
+     png_bytep row));
+ #endif
+ 
++#ifdef PNG_APNG_SUPPORTED
++PNG_EXTERN void png_ensure_fcTL_is_valid PNGARG((png_structp png_ptr,
++   png_uint_32 width, png_uint_32 height,
++   png_uint_32 x_offset, png_uint_32 y_offset,
++   png_uint_16 delay_num, png_uint_16 delay_den,
++   png_byte dispose_op, png_byte blend_op));
++
++#ifdef PNG_READ_APNG_SUPPORTED
++PNG_EXTERN void png_handle_acTL PNGARG((png_structp png_ptr, png_infop info_ptr,
++   png_uint_32 length));
++PNG_EXTERN void png_handle_fcTL PNGARG((png_structp png_ptr, png_infop info_ptr,
++   png_uint_32 length));
++PNG_EXTERN void png_handle_fdAT PNGARG((png_structp png_ptr, png_infop info_ptr,
++   png_uint_32 length));
++PNG_EXTERN void png_have_info PNGARG((png_structp png_ptr, png_infop info_ptr));
++PNG_EXTERN void png_ensure_sequence_number PNGARG((png_structp png_ptr,
++   png_uint_32 length));
++PNG_EXTERN void png_read_reset PNGARG((png_structp png_ptr));
++PNG_EXTERN void png_read_reinit PNGARG((png_structp png_ptr,
++   png_infop info_ptr));
++#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
++PNG_EXTERN void png_progressive_read_reset PNGARG((png_structp png_ptr));
++#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
++#endif /* PNG_READ_APNG_SUPPORTED */
++
++#ifdef PNG_WRITE_APNG_SUPPORTED
++PNG_EXTERN void png_write_acTL PNGARG((png_structp png_ptr,
++   png_uint_32 num_frames, png_uint_32 num_plays));
++PNG_EXTERN void png_write_fcTL PNGARG((png_structp png_ptr,
++   png_uint_32 width, png_uint_32 height,
++   png_uint_32 x_offset, png_uint_32 y_offset,
++   png_uint_16 delay_num, png_uint_16 delay_den,
++   png_byte dispose_op, png_byte blend_op));
++PNG_EXTERN void png_write_reset PNGARG((png_structp png_ptr));
++PNG_EXTERN void png_write_reinit PNGARG((png_structp png_ptr,
++   png_infop info_ptr, png_uint_32 width, png_uint_32 height));
++#endif /* PNG_WRITE_APNG_SUPPORTED */
++#endif /* PNG_APNG_SUPPORTED */
++
+ /* Added at libpng version 1.4.0 */
+ #ifdef PNG_CHECK_cHRM_SUPPORTED
+ PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structp png_ptr,
+     png_fixed_point int_white_x, png_fixed_point int_white_y,
+     png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
+     int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
+     png_fixed_point int_blue_y));
+ #endif
+diff -up8 pngread.c pngread.c
+--- pngread.c	2012-02-18 15:31:14 -0500
++++ pngread.c	2012-02-19 16:03:41 -0500
+@@ -239,16 +239,19 @@ png_read_info(png_structp png_ptr, png_i
+       {
+          if (!(png_ptr->mode & PNG_HAVE_IHDR))
+             png_error(png_ptr, "Missing IHDR before IDAT");
+ 
+          else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
+              !(png_ptr->mode & PNG_HAVE_PLTE))
+             png_error(png_ptr, "Missing PLTE before IDAT");
+ 
++#ifdef PNG_READ_APNG_SUPPORTED
++         png_have_info(png_ptr, info_ptr);
++#endif
+          png_ptr->idat_size = length;
+          png_ptr->mode |= PNG_HAVE_IDAT;
+          break;
+       }
+ 
+ #ifdef PNG_READ_bKGD_SUPPORTED
+       else if (chunk_name == png_bKGD)
+          png_handle_bKGD(png_ptr, info_ptr, length);
+@@ -329,22 +332,100 @@ png_read_info(png_structp png_ptr, png_i
+          png_handle_zTXt(png_ptr, info_ptr, length);
+ #endif
+ 
+ #ifdef PNG_READ_iTXt_SUPPORTED
+       else if (chunk_name == png_iTXt)
+          png_handle_iTXt(png_ptr, info_ptr, length);
+ #endif
+ 
++#ifdef PNG_READ_APNG_SUPPORTED
++      else if (chunk_name == png_acTL)
++         png_handle_acTL(png_ptr, info_ptr, length);
++
++      else if (chunk_name == png_fcTL)
++         png_handle_fcTL(png_ptr, info_ptr, length);
++
++      else if (chunk_name == png_fdAT)
++         png_handle_fdAT(png_ptr, info_ptr, length);
++#endif
++
+       else
+          png_handle_unknown(png_ptr, info_ptr, length);
+    }
+ }
+ #endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
+ 
++#ifdef PNG_READ_APNG_SUPPORTED
++void PNGAPI
++png_read_frame_head(png_structp png_ptr, png_infop info_ptr)
++{
++    png_byte have_chunk_after_DAT; /* after IDAT or after fdAT */
++
++    png_debug(0, "Reading frame head");
++
++    if (!(png_ptr->mode & PNG_HAVE_acTL))
++        png_error(png_ptr, "attempt to png_read_frame_head() but "
++                           "no acTL present");
++
++    /* do nothing for the main IDAT */
++    if (png_ptr->num_frames_read == 0)
++        return;
++
++    png_crc_finish(png_ptr, 0); /* CRC from last IDAT or fdAT chunk */
++
++    png_read_reset(png_ptr);
++    png_ptr->mode &= ~PNG_HAVE_fcTL;
++
++    have_chunk_after_DAT = 0;
++    for (;;)
++    {
++        png_uint_32 length = png_read_chunk_header(png_ptr);
++
++        if (png_ptr->chunk_name == png_IDAT)
++        {
++            /* discard trailing IDATs for the first frame */
++            if (have_chunk_after_DAT || png_ptr->num_frames_read > 1)
++                png_error(png_ptr, "png_read_frame_head(): out of place IDAT");
++            png_crc_finish(png_ptr, length);
++        }
++
++        else if (png_ptr->chunk_name == png_fcTL)
++        {
++            png_handle_fcTL(png_ptr, info_ptr, length);
++            have_chunk_after_DAT = 1;
++        }
++
++        else if (png_ptr->chunk_name == png_fdAT)
++        {
++            png_ensure_sequence_number(png_ptr, length);
++
++            /* discard trailing fdATs for frames other than the first */
++            if (!have_chunk_after_DAT && png_ptr->num_frames_read > 1)
++                png_crc_finish(png_ptr, length - 4);
++            else if(png_ptr->mode & PNG_HAVE_fcTL)
++            {
++                png_ptr->idat_size = length - 4;
++                png_ptr->mode |= PNG_HAVE_IDAT;
++
++                break;
++            }
++            else
++                png_error(png_ptr, "png_read_frame_head(): out of place fdAT");
++        }
++        else
++        {
++            png_warning(png_ptr, "Skipped (ignored) a chunk "
++                                 "between APNG chunks");
++            png_crc_finish(png_ptr, length);
++        }
++    }
++}
++#endif /* PNG_READ_APNG_SUPPORTED */
++
+ /* Optional call to update the users info_ptr structure */
+ void PNGAPI
+ png_read_update_info(png_structp png_ptr, png_infop info_ptr)
+ {
+    png_debug(1, "in png_read_update_info");
+ 
+    if (png_ptr == NULL)
+       return;
+@@ -536,24 +617,57 @@ png_read_row(png_structp png_ptr, png_by
+    png_ptr->zstream.avail_out =
+        (uInt)(PNG_ROWBYTES(png_ptr->pixel_depth,
+        png_ptr->iwidth) + 1);
+ 
+    do
+    {
+       if (!(png_ptr->zstream.avail_in))
+       {
++#ifdef PNG_READ_APNG_SUPPORTED
++         png_uint_32 bytes_to_skip = 0;
++
++         while (!png_ptr->idat_size || bytes_to_skip != 0)
++         {
++            png_crc_finish(png_ptr, bytes_to_skip);
++            bytes_to_skip = 0;
++
++            png_ptr->idat_size = png_read_chunk_header(png_ptr);
++            if (png_ptr->num_frames_read == 0)
++            {
++               if (png_ptr->chunk_name != png_IDAT)
++                  png_error(png_ptr, "Not enough image data");
++            }
++            else
++            {
++               if (png_ptr->chunk_name == png_IEND)
++                  png_error(png_ptr, "Not enough image data");
++               if (png_ptr->chunk_name != png_fdAT)
++               {
++                  png_warning(png_ptr, "Skipped (ignored) a chunk "
++                                       "between APNG chunks");
++                  bytes_to_skip = png_ptr->idat_size;
++                  continue;
++               }
++
++               png_ensure_sequence_number(png_ptr, png_ptr->idat_size);
++
++               png_ptr->idat_size -= 4;
++            }
++         }
++#else
+          while (!png_ptr->idat_size)
+          {
+             png_crc_finish(png_ptr, 0);
+ 
+             png_ptr->idat_size = png_read_chunk_header(png_ptr);
+             if (png_ptr->chunk_name != png_IDAT)
+                png_error(png_ptr, "Not enough image data");
+          }
++#endif
+          png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size;
+          png_ptr->zstream.next_in = png_ptr->zbuf;
+          if (png_ptr->zbuf_size > png_ptr->idat_size)
+             png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size;
+          png_crc_read(png_ptr, png_ptr->zbuf,
+              (png_size_t)png_ptr->zstream.avail_in);
+          png_ptr->idat_size -= png_ptr->zstream.avail_in;
+       }
+@@ -562,16 +676,19 @@ png_read_row(png_structp png_ptr, png_by
+ 
+       if (ret == Z_STREAM_END)
+       {
+          if (png_ptr->zstream.avail_out || png_ptr->zstream.avail_in ||
+             png_ptr->idat_size)
+             png_benign_error(png_ptr, "Extra compressed data");
+          png_ptr->mode |= PNG_AFTER_IDAT;
+          png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
++#ifdef PNG_READ_APNG_SUPPORTED
++         png_ptr->num_frames_read++;
++#endif
+          break;
+       }
+ 
+       if (ret != Z_OK)
+          png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg :
+              "Decompression error");
+ 
+    } while (png_ptr->zstream.avail_out);
+@@ -924,16 +1041,25 @@ png_read_end(png_structp png_ptr, png_in
+          png_handle_zTXt(png_ptr, info_ptr, length);
+ #endif
+ 
+ #ifdef PNG_READ_iTXt_SUPPORTED
+       else if (chunk_name == png_iTXt)
+          png_handle_iTXt(png_ptr, info_ptr, length);
+ #endif
+ 
++#ifdef PNG_READ_APNG_SUPPORTED
++      else if (chunk_name == png_acTL)
++         png_handle_acTL(png_ptr, info_ptr, length);
++      else if (chunk_name == png_fcTL)
++         png_handle_fcTL(png_ptr, info_ptr, length);
++      else if (chunk_name == png_fdAT)
++         png_handle_fdAT(png_ptr, info_ptr, length);
++#endif
++
+       else
+          png_handle_unknown(png_ptr, info_ptr, length);
+    } while (!(png_ptr->mode & PNG_HAVE_IEND));
+ }
+ #endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
+ 
+ /* Free all memory used by the read */
+ void PNGAPI
+diff -up8 pngrutil.c pngrutil.c
+--- pngrutil.c	2012-02-18 15:31:14 -0500
++++ pngrutil.c	2012-02-19 16:02:28 -0500
+@@ -544,16 +544,21 @@ png_handle_IHDR(png_structp png_ptr, png
+    width = png_get_uint_31(png_ptr, buf);
+    height = png_get_uint_31(png_ptr, buf + 4);
+    bit_depth = buf[8];
+    color_type = buf[9];
+    compression_type = buf[10];
+    filter_type = buf[11];
+    interlace_type = buf[12];
+ 
++#ifdef PNG_READ_APNG_SUPPORTED
++   png_ptr->first_frame_width = width;
++   png_ptr->first_frame_height = height;
++#endif
++
+    /* Set internal variables */
+    png_ptr->width = width;
+    png_ptr->height = height;
+    png_ptr->bit_depth = (png_byte)bit_depth;
+    png_ptr->interlaced = (png_byte)interlace_type;
+    png_ptr->color_type = (png_byte)color_type;
+ #ifdef PNG_MNG_FEATURES_SUPPORTED
+    png_ptr->filter_type = (png_byte)filter_type;
+@@ -2608,16 +2613,189 @@ png_handle_iTXt(png_structp png_ptr, png
+    png_free(png_ptr, png_ptr->chunkdata);
+    png_ptr->chunkdata = NULL;
+ 
+    if (ret)
+       png_error(png_ptr, "Insufficient memory to store iTXt chunk");
+ }
+ #endif
+ 
++#ifdef PNG_READ_APNG_SUPPORTED
++void /* PRIVATE */
++png_handle_acTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
++{
++    png_byte data[8];
++    png_uint_32 num_frames;
++    png_uint_32 num_plays;
++    png_uint_32 didSet;
++
++    png_debug(1, "in png_handle_acTL");
++
++    if (!(png_ptr->mode & PNG_HAVE_IHDR))
++    {
++        png_error(png_ptr, "Missing IHDR before acTL");
++    }
++    else if (png_ptr->mode & PNG_HAVE_IDAT)
++    {
++        png_warning(png_ptr, "Invalid acTL after IDAT skipped");
++        png_crc_finish(png_ptr, length);
++        return;
++    }
++    else if (png_ptr->mode & PNG_HAVE_acTL)
++    {
++        png_warning(png_ptr, "Duplicate acTL skipped");
++        png_crc_finish(png_ptr, length);
++        return;
++    }
++    else if (length != 8)
++    {
++        png_warning(png_ptr, "acTL with invalid length skipped");
++        png_crc_finish(png_ptr, length);
++        return;
++    }
++
++    png_crc_read(png_ptr, data, 8);
++    png_crc_finish(png_ptr, 0);
++
++    num_frames = png_get_uint_31(png_ptr, data);
++    num_plays = png_get_uint_31(png_ptr, data + 4);
++
++    /* the set function will do error checking on num_frames */
++    didSet = png_set_acTL(png_ptr, info_ptr, num_frames, num_plays);
++    if(didSet)
++        png_ptr->mode |= PNG_HAVE_acTL;
++}
++
++void /* PRIVATE */
++png_handle_fcTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
++{
++    png_byte data[22];
++    png_uint_32 width;
++    png_uint_32 height;
++    png_uint_32 x_offset;
++    png_uint_32 y_offset;
++    png_uint_16 delay_num;
++    png_uint_16 delay_den;
++    png_byte dispose_op;
++    png_byte blend_op;
++
++    png_debug(1, "in png_handle_fcTL");
++
++    png_ensure_sequence_number(png_ptr, length);
++
++    if (!(png_ptr->mode & PNG_HAVE_IHDR))
++    {
++        png_error(png_ptr, "Missing IHDR before fcTL");
++    }
++    else if (png_ptr->mode & PNG_HAVE_IDAT)
++    {
++        /* for any frames other then the first this message may be misleading,
++        * but correct. PNG_HAVE_IDAT is unset before the frame head is read
++        * i can't think of a better message */
++        png_warning(png_ptr, "Invalid fcTL after IDAT skipped");
++        png_crc_finish(png_ptr, length-4);
++        return;
++    }
++    else if (png_ptr->mode & PNG_HAVE_fcTL)
++    {
++        png_warning(png_ptr, "Duplicate fcTL within one frame skipped");
++        png_crc_finish(png_ptr, length-4);
++        return;
++    }
++    else if (length != 26)
++    {
++        png_warning(png_ptr, "fcTL with invalid length skipped");
++        png_crc_finish(png_ptr, length-4);
++        return;
++    }
++
++    png_crc_read(png_ptr, data, 22);
++    png_crc_finish(png_ptr, 0);
++
++    width = png_get_uint_31(png_ptr, data);
++    height = png_get_uint_31(png_ptr, data + 4);
++    x_offset = png_get_uint_31(png_ptr, data + 8);
++    y_offset = png_get_uint_31(png_ptr, data + 12);
++    delay_num = png_get_uint_16(data + 16);
++    delay_den = png_get_uint_16(data + 18);
++    dispose_op = data[20];
++    blend_op = data[21];
++
++    if (png_ptr->num_frames_read == 0 && (x_offset != 0 || y_offset != 0))
++    {
++        png_warning(png_ptr, "fcTL for the first frame must have zero offset");
++        return;
++    }
++
++    if (info_ptr != NULL)
++    {
++        if (png_ptr->num_frames_read == 0 &&
++            (width != info_ptr->width || height != info_ptr->height))
++        {
++            png_warning(png_ptr, "size in first frame's fcTL must match "
++                               "the size in IHDR");
++            return;
++        }
++
++        /* The set function will do more error checking */
++        png_set_next_frame_fcTL(png_ptr, info_ptr, width, height,
++                                x_offset, y_offset, delay_num, delay_den,
++                                dispose_op, blend_op);
++
++        png_read_reinit(png_ptr, info_ptr);
++
++        png_ptr->mode |= PNG_HAVE_fcTL;
++    }
++}
++
++void /* PRIVATE */
++png_have_info(png_structp png_ptr, png_infop info_ptr)
++{
++    if((info_ptr->valid & PNG_INFO_acTL) && !(info_ptr->valid & PNG_INFO_fcTL))
++    {
++        png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN;
++        info_ptr->num_frames++;
++    }
++}
++
++void /* PRIVATE */
++png_handle_fdAT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
++{
++    png_ensure_sequence_number(png_ptr, length);
++
++    /* This function is only called from png_read_end(), png_read_info(),
++    * and png_push_read_chunk() which means that:
++    * - the user doesn't want to read this frame
++    * - or this is an out-of-place fdAT
++    * in either case it is safe to ignore the chunk with a warning */
++    png_warning(png_ptr, "ignoring fdAT chunk");
++    png_crc_finish(png_ptr, length - 4);
++    PNG_UNUSED(info_ptr)
++}
++
++void /* PRIVATE */
++png_ensure_sequence_number(png_structp png_ptr, png_uint_32 length)
++{
++    png_byte data[4];
++    png_uint_32 sequence_number;
++
++    if (length < 4)
++        png_error(png_ptr, "invalid fcTL or fdAT chunk found");
++
++    png_crc_read(png_ptr, data, 4);
++    sequence_number = png_get_uint_31(png_ptr, data);
++
++    if (sequence_number != png_ptr->next_seq_num)
++        png_error(png_ptr, "fcTL or fdAT chunk with out-of-order sequence "
++                           "number found");
++
++    png_ptr->next_seq_num++;
++}
++#endif /* PNG_READ_APNG_SUPPORTED */
++
+ /* This function is called when we haven't found a handler for a
+  * chunk.  If there isn't a problem with the chunk itself (ie bad
+  * chunk name, CRC, or a critical chunk), the chunk is silently ignored
+  * -- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which
+  * case it will be saved away to be written out later.
+  */
+ void /* PRIVATE */
+ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
+@@ -4150,9 +4328,86 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED
+    png_debug1(3, "iwidth = %u,", png_ptr->iwidth);
+    png_debug1(3, "num_rows = %u,", png_ptr->num_rows);
+    png_debug1(3, "rowbytes = %lu,", (unsigned long)png_ptr->rowbytes);
+    png_debug1(3, "irowbytes = %lu",
+        (unsigned long)PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1);
+ 
+    png_ptr->flags |= PNG_FLAG_ROW_INIT;
+ }
++
++#ifdef PNG_READ_APNG_SUPPORTED
++/* This function is to be called after the main IDAT set has been read and
++ * before a new IDAT is read. It resets some parts of png_ptr
++ * to make them usable by the read functions again */
++void /* PRIVATE */
++png_read_reset(png_structp png_ptr)
++{
++    png_ptr->mode &= ~PNG_HAVE_IDAT;
++    png_ptr->mode &= ~PNG_AFTER_IDAT;
++    png_ptr->row_number = 0;
++    png_ptr->pass = 0;
++    png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
++}
++
++void /* PRIVATE */
++png_read_reinit(png_structp png_ptr, png_infop info_ptr)
++{
++    png_ptr->width = info_ptr->next_frame_width;
++    png_ptr->height = info_ptr->next_frame_height;
++    png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width);
++    png_ptr->info_rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,
++        png_ptr->width);
++    if (png_ptr->prev_row)
++        png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
++}
++
++#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
++/* same as png_read_reset() but for the progressive reader */
++void /* PRIVATE */
++png_progressive_read_reset(png_structp png_ptr)
++{
++#ifdef PNG_READ_INTERLACING_SUPPORTED
++   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
++
++   /* Start of interlace block */
++    const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
++
++    /* Offset to next interlace block */
++    const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
++
++    /* Start of interlace block in the y direction */
++    const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
++
++    /* Offset to next interlace block in the y direction */
++    const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
++
++    if (png_ptr->interlaced)
++    {
++        if (!(png_ptr->transformations & PNG_INTERLACE))
++            png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -
++                                png_pass_ystart[0]) / png_pass_yinc[0];
++        else
++            png_ptr->num_rows = png_ptr->height;
++
++        png_ptr->iwidth = (png_ptr->width +
++                           png_pass_inc[png_ptr->pass] - 1 -
++                           png_pass_start[png_ptr->pass]) /
++                           png_pass_inc[png_ptr->pass];
++    }
++    else
++#endif /* PNG_READ_INTERLACING_SUPPORTED */
++    {
++        png_ptr->num_rows = png_ptr->height;
++        png_ptr->iwidth = png_ptr->width;
++    }
++    png_ptr->flags &= ~PNG_FLAG_ZLIB_FINISHED;
++    if (inflateReset(&(png_ptr->zstream)) != Z_OK)
++        png_error(png_ptr, "inflateReset failed");
++    png_ptr->zstream.avail_in = 0;
++    png_ptr->zstream.next_in = 0;
++    png_ptr->zstream.next_out = png_ptr->row_buf;
++    png_ptr->zstream.avail_out = (uInt)PNG_ROWBYTES(png_ptr->pixel_depth,
++        png_ptr->iwidth) + 1;
++}
++#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
++#endif /* PNG_READ_APNG_SUPPORTED */
+ #endif /* PNG_READ_SUPPORTED */
+diff -up8 pngset.c pngset.c
+--- pngset.c	2012-02-18 15:31:14 -0500
++++ pngset.c	2012-02-19 16:02:28 -0500
+@@ -257,16 +257,21 @@ png_set_IHDR(png_structp png_ptr, png_in
+        (PNG_UINT_32_MAX >> 3)      /* 8-byte RRGGBBAA pixels */
+        - 48       /* bigrowbuf hack */
+        - 1        /* filter byte */
+        - 7*8      /* rounding of width to multiple of 8 pixels */
+        - 8)       /* extra max_pixel_depth pad */
+       info_ptr->rowbytes = 0;
+    else
+       info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);
++
++#ifdef PNG_APNG_SUPPORTED
++   /* for non-animated png. this may be overwritten from an acTL chunk later */
++   info_ptr->num_frames = 1;
++#endif
+ }
+ 
+ #ifdef PNG_oFFs_SUPPORTED
+ void PNGAPI
+ png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
+     png_int_32 offset_x, png_int_32 offset_y, int unit_type)
+ {
+    png_debug1(1, "in %s storage function", "oFFs");
+@@ -1008,16 +1013,157 @@ png_set_sPLT(png_structp png_ptr,
+ 
+    info_ptr->splt_palettes = np;
+    info_ptr->splt_palettes_num += nentries;
+    info_ptr->valid |= PNG_INFO_sPLT;
+    info_ptr->free_me |= PNG_FREE_SPLT;
+ }
+ #endif /* PNG_sPLT_SUPPORTED */
+ 
++#ifdef PNG_APNG_SUPPORTED
++png_uint_32 PNGAPI
++png_set_acTL(png_structp png_ptr, png_infop info_ptr,
++    png_uint_32 num_frames, png_uint_32 num_plays)
++{
++    png_debug1(1, "in %s storage function", "acTL");
++
++    if (png_ptr == NULL || info_ptr == NULL)
++    {
++        png_warning(png_ptr,
++                    "Call to png_set_acTL() with NULL png_ptr "
++                    "or info_ptr ignored");
++        return (0);
++    }
++    if (num_frames == 0)
++    {
++        png_warning(png_ptr,
++                    "Ignoring attempt to set acTL with num_frames zero");
++        return (0);
++    }
++    if (num_frames > PNG_UINT_31_MAX)
++    {
++        png_warning(png_ptr,
++                    "Ignoring attempt to set acTL with num_frames > 2^31-1");
++        return (0);
++    }
++    if (num_plays > PNG_UINT_31_MAX)
++    {
++        png_warning(png_ptr,
++                    "Ignoring attempt to set acTL with num_plays "
++                    "> 2^31-1");
++        return (0);
++    }
++
++    info_ptr->num_frames = num_frames;
++    info_ptr->num_plays = num_plays;
++
++    info_ptr->valid |= PNG_INFO_acTL;
++
++    return (1);
++}
++
++/* delay_num and delay_den can hold any 16-bit values including zero */
++png_uint_32 PNGAPI
++png_set_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
++    png_uint_32 width, png_uint_32 height,
++    png_uint_32 x_offset, png_uint_32 y_offset,
++    png_uint_16 delay_num, png_uint_16 delay_den,
++    png_byte dispose_op, png_byte blend_op)
++{
++    png_debug1(1, "in %s storage function", "fcTL");
++
++    if (png_ptr == NULL || info_ptr == NULL)
++    {
++        png_warning(png_ptr,
++                    "Call to png_set_fcTL() with NULL png_ptr or info_ptr "
++                    "ignored");
++        return (0);
++    }
++
++    png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset,
++                             delay_num, delay_den, dispose_op, blend_op);
++
++    if (blend_op == PNG_BLEND_OP_OVER)
++    {
++        if (!(png_ptr->color_type & PNG_COLOR_MASK_ALPHA) &&
++            !(png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)))
++        {
++          png_warning(png_ptr, "PNG_BLEND_OP_OVER is meaningless "
++                               "and wasteful for opaque images, ignored");
++          blend_op = PNG_BLEND_OP_SOURCE;
++        }
++    }
++
++    info_ptr->next_frame_width = width;
++    info_ptr->next_frame_height = height;
++    info_ptr->next_frame_x_offset = x_offset;
++    info_ptr->next_frame_y_offset = y_offset;
++    info_ptr->next_frame_delay_num = delay_num;
++    info_ptr->next_frame_delay_den = delay_den;
++    info_ptr->next_frame_dispose_op = dispose_op;
++    info_ptr->next_frame_blend_op = blend_op;
++
++    info_ptr->valid |= PNG_INFO_fcTL;
++
++    return (1);
++}
++
++void /* PRIVATE */
++png_ensure_fcTL_is_valid(png_structp png_ptr,
++    png_uint_32 width, png_uint_32 height,
++    png_uint_32 x_offset, png_uint_32 y_offset,
++    png_uint_16 delay_num, png_uint_16 delay_den,
++    png_byte dispose_op, png_byte blend_op)
++{
++    if (width + x_offset > png_ptr->first_frame_width ||
++        height + y_offset > png_ptr->first_frame_height)
++        png_error(png_ptr, "dimensions of a frame are greater than"
++                           "the ones in IHDR");
++    if (width > PNG_UINT_31_MAX)
++        png_error(png_ptr, "invalid width in fcTL (> 2^31-1)");
++    if (height > PNG_UINT_31_MAX)
++        png_error(png_ptr, "invalid height in fcTL (> 2^31-1)");
++    if (x_offset > PNG_UINT_31_MAX)
++        png_error(png_ptr, "invalid x_offset in fcTL (> 2^31-1)");
++    if (y_offset > PNG_UINT_31_MAX)
++        png_error(png_ptr, "invalid y_offset in fcTL (> 2^31-1)");
++
++    if (dispose_op != PNG_DISPOSE_OP_NONE &&
++        dispose_op != PNG_DISPOSE_OP_BACKGROUND &&
++        dispose_op != PNG_DISPOSE_OP_PREVIOUS)
++        png_error(png_ptr, "invalid dispose_op in fcTL");
++
++    if (blend_op != PNG_BLEND_OP_SOURCE &&
++        blend_op != PNG_BLEND_OP_OVER)
++        png_error(png_ptr, "invalid blend_op in fcTL");
++
++    PNG_UNUSED(delay_num)
++    PNG_UNUSED(delay_den)
++}
++
++png_uint_32 PNGAPI
++png_set_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr,
++                              png_byte is_hidden)
++{
++    png_debug(1, "in png_first_frame_is_hidden()");
++
++    if (png_ptr == NULL)
++        return 0;
++
++    if (is_hidden)
++        png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN;
++    else
++        png_ptr->apng_flags &= ~PNG_FIRST_FRAME_HIDDEN;
++
++    PNG_UNUSED(info_ptr)
++
++    return 1;
++}
++#endif /* PNG_APNG_SUPPORTED */
++
+ #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
+ void PNGAPI
+ png_set_unknown_chunks(png_structp png_ptr,
+    png_infop info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)
+ {
+    png_unknown_chunkp np;
+    int i;
+ 
+diff -up8 pngstruct.h pngstruct.h
+--- pngstruct.h	2012-02-18 15:31:14 -0500
++++ pngstruct.h	2012-02-19 16:02:28 -0500
+@@ -288,16 +288,37 @@ struct png_struct_def
+    png_uint_32 mng_features_permitted;
+ #endif
+ 
+ /* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */
+ #ifdef PNG_MNG_FEATURES_SUPPORTED
+    png_byte filter_type;
+ #endif
+ 
++#ifdef PNG_APNG_SUPPORTED
++   png_uint_32 apng_flags;
++   png_uint_32 next_seq_num;         /* next fcTL/fdAT chunk sequence number */
++   png_uint_32 first_frame_width;
++   png_uint_32 first_frame_height;
++
++#ifdef PNG_READ_APNG_SUPPORTED
++   png_uint_32 num_frames_read;      /* incremented after all image data of */
++                                     /* a frame is read */
++#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
++   png_progressive_frame_ptr frame_info_fn; /* frame info read callback */
++   png_progressive_frame_ptr frame_end_fn;  /* frame data read callback */
++#endif
++#endif
++
++#ifdef PNG_WRITE_APNG_SUPPORTED
++   png_uint_32 num_frames_to_write;
++   png_uint_32 num_frames_written;
++#endif
++#endif /* PNG_APNG_SUPPORTED */
++
+ /* New members added in libpng-1.2.0 */
+ 
+ /* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
+ #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
+diff -up8 pngwrite.c pngwrite.c
+--- pngwrite.c	2012-02-18 15:31:14 -0500
++++ pngwrite.c	2012-02-19 16:02:28 -0500
+@@ -53,16 +53,20 @@ png_write_info_before_PLTE(png_structp p
+ #ifdef PNG_WRITE_INTERLACING_SUPPORTED
+        info_ptr->interlace_type);
+ #else
+        0);
+ #endif
+    /* The rest of these check to see if the valid field has the appropriate
+     * flag set, and if it does, writes the chunk.
+     */
++#ifdef PNG_WRITE_APNG_SUPPORTED
++   if (info_ptr->valid & PNG_INFO_acTL)
++      png_write_acTL(png_ptr, info_ptr->num_frames, info_ptr->num_plays);
++#endif
+ #ifdef PNG_WRITE_gAMA_SUPPORTED
+    if (info_ptr->valid & PNG_INFO_gAMA)
+       png_write_gAMA_fixed(png_ptr, info_ptr->gamma);
+ #endif
+ #ifdef PNG_WRITE_sRGB_SUPPORTED
+    if (info_ptr->valid & PNG_INFO_sRGB)
+       png_write_sRGB(png_ptr, (int)info_ptr->srgb_intent);
+ #endif
+@@ -300,16 +304,21 @@ png_write_end(png_structp png_ptr, png_i
+    png_debug(1, "in png_write_end");
+ 
+    if (png_ptr == NULL)
+       return;
+ 
+    if (!(png_ptr->mode & PNG_HAVE_IDAT))
+       png_error(png_ptr, "No IDATs written into file");
+ 
++#ifdef PNG_WRITE_APNG_SUPPORTED
++   if (png_ptr->num_frames_written != png_ptr->num_frames_to_write)
++      png_error(png_ptr, "Not enough frames written");
++#endif
++
+    /* See if user wants us to write information chunks */
+    if (info_ptr != NULL)
+    {
+ #ifdef PNG_WRITE_TEXT_SUPPORTED
+       int i; /* local index variable */
+ #endif
+ #ifdef PNG_WRITE_tIME_SUPPORTED
+       /* Check to see if user has supplied a time chunk */
+@@ -1647,9 +1656,47 @@ png_write_png(png_structp png_ptr, png_i
+ 
+    /* It is REQUIRED to call this to finish writing the rest of the file */
+    png_write_end(png_ptr, info_ptr);
+ 
+    PNG_UNUSED(transforms)   /* Quiet compiler warnings */
+    PNG_UNUSED(params)
+ }
+ #endif
++
++#ifdef PNG_WRITE_APNG_SUPPORTED
++void PNGAPI
++png_write_frame_head(png_structp png_ptr, png_infop info_ptr,
++    png_bytepp row_pointers, png_uint_32 width, png_uint_32 height,
++    png_uint_32 x_offset, png_uint_32 y_offset,
++    png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
++    png_byte blend_op)
++{
++    png_debug(1, "in png_write_frame_head");
++
++    /* there is a chance this has been set after png_write_info was called,
++    * so it would be set but not written. is there a way to be sure? */
++    if (!(info_ptr->valid & PNG_INFO_acTL))
++        png_error(png_ptr, "png_write_frame_head(): acTL not set");
++
++    png_write_reset(png_ptr);
++
++    png_write_reinit(png_ptr, info_ptr, width, height);
++
++    if ( !(png_ptr->num_frames_written == 0 &&
++           (png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) ) )
++        png_write_fcTL(png_ptr, width, height, x_offset, y_offset,
++                       delay_num, delay_den, dispose_op, blend_op);
++
++    PNG_UNUSED(row_pointers)
++}
++
++void PNGAPI
++png_write_frame_tail(png_structp png_ptr, png_infop info_ptr)
++{
++    png_debug(1, "in png_write_frame_tail");
++
++    png_ptr->num_frames_written++;
++
++    PNG_UNUSED(info_ptr)
++}
++#endif /* PNG_WRITE_APNG_SUPPORTED */
+ #endif /* PNG_WRITE_SUPPORTED */
+diff -up8 pngwutil.c pngwutil.c
+--- pngwutil.c	2012-02-18 15:31:14 -0500
++++ pngwutil.c	2012-02-19 16:02:28 -0500
+@@ -815,16 +815,21 @@ png_write_IHDR(png_structp png_ptr, png_
+    buf[9] = (png_byte)color_type;
+    buf[10] = (png_byte)compression_type;
+    buf[11] = (png_byte)filter_type;
+    buf[12] = (png_byte)interlace_type;
+ 
+    /* Write the chunk */
+    png_write_complete_chunk(png_ptr, png_IHDR, buf, (png_size_t)13);
+ 
++#ifdef PNG_WRITE_APNG_SUPPORTED
++   png_ptr->first_frame_width = width;
++   png_ptr->first_frame_height = height;
++#endif
++
+    /* Initialize zlib with PNG info */
+    png_ptr->zstream.zalloc = png_zalloc;
+    png_ptr->zstream.zfree = png_zfree;
+    png_ptr->zstream.opaque = (voidpf)png_ptr;
+ 
+    if (!(png_ptr->do_filter))
+    {
+       if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE ||
+@@ -1029,17 +1034,38 @@ png_write_IDAT(png_structp png_ptr, png_
+       }
+ 
+       else
+          png_error(png_ptr,
+              "Invalid zlib compression method or flags in IDAT");
+    }
+ #endif /* PNG_WRITE_OPTIMIZE_CMF_SUPPORTED */
+ 
++#ifdef PNG_WRITE_APNG_SUPPORTED
++   if (png_ptr->num_frames_written == 0)
++#endif
+    png_write_complete_chunk(png_ptr, png_IDAT, data, length);
++#ifdef PNG_WRITE_APNG_SUPPORTED
++   else
++   {
++      png_byte buf[4];
++
++      png_write_chunk_header(png_ptr, png_fdAT, 4 + length);
++
++      png_save_uint_32(buf, png_ptr->next_seq_num);
++      png_write_chunk_data(png_ptr, buf, 4);
++
++      png_write_chunk_data(png_ptr, data, length);
++
++      png_write_chunk_end(png_ptr);
++
++      png_ptr->next_seq_num++;
++   }
++#endif /* PNG_WRITE_APNG_SUPPORTED */
++
+    png_ptr->mode |= PNG_HAVE_IDAT;
+ 
+    /* Prior to 1.5.4 this code was replicated in every caller (except at the
+     * end, where it isn't technically necessary).  Since this function has
+     * flushed the data we can safely reset the zlib output buffer here.
+     */
+    png_ptr->zstream.next_out = png_ptr->zbuf;
+    png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
+@@ -1993,16 +2019,74 @@ png_write_tIME(png_structp png_ptr, png_
+    buf[4] = mod_time->hour;
+    buf[5] = mod_time->minute;
+    buf[6] = mod_time->second;
+ 
+    png_write_complete_chunk(png_ptr, png_tIME, buf, (png_size_t)7);
+ }
+ #endif
+ 
++#ifdef PNG_WRITE_APNG_SUPPORTED
++void /* PRIVATE */
++png_write_acTL(png_structp png_ptr,
++    png_uint_32 num_frames, png_uint_32 num_plays)
++{
++    png_byte buf[8];
++
++    png_debug(1, "in png_write_acTL");
++
++    png_ptr->num_frames_to_write = num_frames;
++
++    if (png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN)
++        num_frames--;
++
++    png_save_uint_32(buf, num_frames);
++    png_save_uint_32(buf + 4, num_plays);
++
++    png_write_complete_chunk(png_ptr, png_acTL, buf, (png_size_t)8);
++}
++
++void /* PRIVATE */
++png_write_fcTL(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
++    png_uint_32 x_offset, png_uint_32 y_offset,
++    png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
++    png_byte blend_op)
++{
++    png_byte buf[26];
++
++    png_debug(1, "in png_write_fcTL");
++
++    if (png_ptr->num_frames_written == 0 && (x_offset != 0 || y_offset != 0))
++        png_error(png_ptr, "x and/or y offset for the first frame aren't 0");
++    if (png_ptr->num_frames_written == 0 &&
++        (width != png_ptr->first_frame_width ||
++         height != png_ptr->first_frame_height))
++        png_error(png_ptr, "width and/or height in the first frame's fcTL "
++                           "don't match the ones in IHDR");
++
++    /* more error checking */
++    png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset,
++                             delay_num, delay_den, dispose_op, blend_op);
++
++    png_save_uint_32(buf, png_ptr->next_seq_num);
++    png_save_uint_32(buf + 4, width);
++    png_save_uint_32(buf + 8, height);
++    png_save_uint_32(buf + 12, x_offset);
++    png_save_uint_32(buf + 16, y_offset);
++    png_save_uint_16(buf + 20, delay_num);
++    png_save_uint_16(buf + 22, delay_den);
++    buf[24] = dispose_op;
++    buf[25] = blend_op;
++
++    png_write_complete_chunk(png_ptr, png_fcTL, buf, (png_size_t)26);
++
++    png_ptr->next_seq_num++;
++}
++#endif /* PNG_WRITE_APNG_SUPPORTED */
++
+ /* Initializes the row writing capability of libpng */
+ void /* PRIVATE */
+ png_write_start_row(png_structp png_ptr)
+ {
+ #ifdef PNG_WRITE_INTERLACING_SUPPORTED
+    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
+ 
+    /* Start of interlace block */
+@@ -3172,9 +3256,44 @@ png_write_filtered_row(png_structp png_p
+ 
+    if (png_ptr->flush_dist > 0 &&
+        png_ptr->flush_rows >= png_ptr->flush_dist)
+    {
+       png_write_flush(png_ptr);
+    }
+ #endif
+ }
++
++#ifdef PNG_WRITE_APNG_SUPPORTED
++void /* PRIVATE */
++png_write_reset(png_structp png_ptr)
++{
++    png_ptr->row_number = 0;
++    png_ptr->pass = 0;
++    png_ptr->mode &= ~PNG_HAVE_IDAT;
++}
++
++void /* PRIVATE */
++png_write_reinit(png_structp png_ptr, png_infop info_ptr,
++                 png_uint_32 width, png_uint_32 height)
++{
++    if (png_ptr->num_frames_written == 0 &&
++        (width != png_ptr->first_frame_width ||
++         height != png_ptr->first_frame_height))
++        png_error(png_ptr, "width and/or height in the first frame's fcTL "
++                           "don't match the ones in IHDR");
++    if (width > png_ptr->first_frame_width ||
++        height > png_ptr->first_frame_height)
++        png_error(png_ptr, "width and/or height for a frame greater than"
++                           "the ones in IHDR");
++
++    png_set_IHDR(png_ptr, info_ptr, width, height,
++                 info_ptr->bit_depth, info_ptr->color_type,
++                 info_ptr->interlace_type, info_ptr->compression_type,
++                 info_ptr->filter_type);
++
++    png_ptr->width = width;
++    png_ptr->height = height;
++    png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);
++    png_ptr->usr_width = png_ptr->width;
++}
++#endif /* PNG_WRITE_APNG_SUPPORTED */
+ #endif /* PNG_WRITE_SUPPORTED */
--- a/media/libpng/libpng.txt
+++ b/media/libpng/libpng.txt
@@ -1,24 +1,24 @@
-libpng.txt - A description on how to use and modify libpng
-
- libpng version 1.4.8 - July 7, 2011
+libpng-manual.txt - A description on how to use and modify libpng
+
+ libpng version 1.5.9 - February 18, 2012
  Updated and distributed by Glenn Randers-Pehrson
  <glennrp at users.sourceforge.net>
- Copyright (c) 1998-2010 Glenn Randers-Pehrson
+ Copyright (c) 1998-2011 Glenn Randers-Pehrson
 
  This document is released under the libpng license.
  For conditions of distribution and use, see the disclaimer
  and license in png.h
 
  Based on:
 
- libpng versions 0.97, January 1998, through 1.4.8 - July 7, 2011
+ libpng versions 0.97, January 1998, through 1.5.9 - February 18, 2012
  Updated and distributed by Glenn Randers-Pehrson
- Copyright (c) 1998-2010 Glenn Randers-Pehrson
+ Copyright (c) 1998-2011 Glenn Randers-Pehrson
 
  libpng 1.0 beta 6  version 0.96 May 28, 1997
  Updated and distributed by Andreas Dilger
  Copyright (c) 1996, 1997 Andreas Dilger
 
  libpng 1.0 beta 2 - version 0.88  January 26, 1996
  For conditions of distribution and use, see copyright
  notice in png.h. Copyright (c) 1995, 1996 Guy Eric
@@ -94,44 +94,213 @@ Libpng is thread safe, provided the thre
 instances of the structures.  Each thread should have its own
 png_struct and png_info instances, and thus its own image.
 Libpng does not protect itself against two threads using the
 same instance of a structure.
 
 II. Structures
 
 There are two main structures that are important to libpng, png_struct
-and png_info.  The first, png_struct, is an internal structure that
-will not, for the most part, be used by a user except as the first
-variable passed to every libpng function call.
+and png_info.  Both are internal structures that are no longer exposed
+in the libpng interface (as of libpng 1.5.0).
 
 The png_info structure is designed to provide information about the
 PNG file.  At one time, the fields of png_info were intended to be
 directly accessible to the user.  However, this tended to cause problems
 with applications using dynamically loaded libraries, and as a result
 a set of interface functions for png_info (the png_get_*() and png_set_*()
-functions) was developed.  The fields of png_info are still available for
-older applications, but it is suggested that applications use the new
-interfaces if at all possible.
-
-Applications that do make direct access to the members of png_struct (except
-for png_ptr->jmpbuf) must be recompiled whenever the library is updated,
-and applications that make direct access to the members of png_info must
-be recompiled if they were compiled or loaded with libpng version 1.0.6,
-in which the members were in a different order.  In version 1.0.7, the
-members of the png_info structure reverted to the old order, as they were
-in versions 0.97c through 1.0.5.  Starting with version 2.0.0, both
-structures are going to be hidden, and the contents of the structures will
-only be accessible through the png_get/png_set functions.
+functions) was developed, and direct access to the png_info fields was
+deprecated..
+
+The png_struct structure is the object used by the library to decode a
+single image.  As of 1.5.0 this structure is also not exposed.
+
+Almost all libpng APIs require a pointer to a png_struct as the first argument.
+Many (in particular the png_set and png_get APIs) also require a pointer
+to png_info as the second argument.  Some application visible macros
+defined in png.h designed for basic data access (reading and writing
+integers in the PNG format) don't take a png_info pointer, but it's almost
+always safe to assume that a (png_struct*) has to be passed to call an API
+function.
+
+You can have more than one png_info structure associated with an image,
+as illustrated in pngtest.c, one for information valid prior to the
+IDAT chunks and another (called "end_info" below) for things after them.
 
 The png.h header file is an invaluable reference for programming with libpng.
 And while I'm on the topic, make sure you include the libpng header file:
 
 #include <png.h>
 
+and also (as of libpng-1.5.0) the zlib header file, if you need it:
+
+#include <zlib.h>
+
+Types
+
+The png.h header file defines a number of integral types used by the
+APIs.  Most of these are fairly obvious; for example types corresponding
+to integers of particular sizes and types for passing color values.
+
+One exception is how non-integral numbers are handled.  For application
+convenience most APIs that take such numbers have C (double) arguments,
+however internally PNG, and libpng, use 32 bit signed integers and encode
+the value by multiplying by 100,000.  As of libpng 1.5.0 a convenience
+macro PNG_FP_1 is defined in png.h along with a type (png_fixed_point)
+which is simply (png_int_32).
+
+All APIs that take (double) arguments also have a matching API that
+takes the corresponding fixed point integer arguments.  The fixed point
+API has the same name as the floating point one with "_fixed" appended.
+The actual range of values permitted in the APIs is frequently less than
+the full range of (png_fixed_point) (-21474 to +21474).  When APIs require
+a non-negative argument the type is recorded as png_uint_32 above.  Consult
+the header file and the text below for more information.
+
+Special care must be take with sCAL chunk handling because the chunk itself
+uses non-integral values encoded as strings containing decimal floating point
+numbers.  See the comments in the header file.
+
+Configuration
+
+The main header file function declarations are frequently protected by C
+preprocessing directives of the form:
+
+    #ifdef PNG_feature_SUPPORTED
+    declare-function
+    #endif
+    ...
+    #ifdef PNG_feature_SUPPORTED
+    use-function
+    #endif
+
+The library can be built without support for these APIs, although a
+standard build will have all implemented APIs.  Application programs
+should check the feature macros before using an API for maximum
+portability.  From libpng 1.5.0 the feature macros set during the build
+of libpng are recorded in the header file "pnglibconf.h" and this file
+is always included by png.h.
+
+If you don't need to change the library configuration from the default, skip to
+the next section ("Reading").
+
+Notice that some of the makefiles in the 'scripts' directory and (in 1.5.0) all
+of the build project files in the 'projects' directory simply copy
+scripts/pnglibconf.h.prebuilt to pnglibconf.h.  This means that these build
+systems do not permit easy auto-configuration of the library - they only
+support the default configuration.
+
+The easiest way to make minor changes to the libpng configuration when
+auto-configuration is supported is to add definitions to the command line
+using (typically) CPPFLAGS.  For example:
+
+CPPFLAGS=-DPNG_NO_FLOATING_ARITHMETIC
+
+will change the internal libpng math implementation for gamma correction and
+other arithmetic calculations to fixed point, avoiding the need for fast
+floating point support.  The result can be seen in the generated pnglibconf.h -
+make sure it contains the changed feature macro setting.
+
+If you need to make more extensive configuration changes - more than one or two
+feature macro settings - you can either add -DPNG_USER_CONFIG to the build
+command line and put a list of feature macro settings in pngusr.h or you can set
+DFA_XTRA (a makefile variable) to a file containing the same information in the
+form of 'option' settings.
+
+A. Changing pnglibconf.h
+
+A variety of methods exist to build libpng.  Not all of these support
+reconfiguration of pnglibconf.h.  To reconfigure pnglibconf.h it must either be
+rebuilt from scripts/pnglibconf.dfa using awk or it must be edited by hand.
+
+Hand editing is achieved by copying scripts/pnglibconf.h.prebuilt to
+pnglibconf.h and changing the lines defining the supported features, paying
+very close attention to the 'option' information in scripts/pnglibconf.dfa
+that describes those features and their requirements.  This is easy to get
+wrong.
+
+B. Configuration using DFA_XTRA
+
+Rebuilding from pnglibconf.dfa is easy if a functioning 'awk', or a later
+variant such as 'nawk' or 'gawk', is available.  The configure build will
+automatically find an appropriate awk and build pnglibconf.h.
+The scripts/pnglibconf.mak file contains a set of make rules for doing the
+same thing if configure is not used, and many of the makefiles in the scripts
+directory use this approach.
+
+When rebuilding simply write a new file containing changed options and set
+DFA_XTRA to the name of this file.  This causes the build to append the new file
+to the end of scripts/pnglibconf.dfa.  The pngusr.dfa file should contain lines
+of the following forms:
+
+everything = off
+
+This turns all optional features off.  Include it at the start of pngusr.dfa to
+make it easier to build a minimal configuration.  You will need to turn at least
+some features on afterward to enable either reading or writing code, or both.
+
+option feature on
+option feature off
+
+Enable or disable a single feature.  This will automatically enable other
+features required by a feature that is turned on or disable other features that
+require a feature which is turned off.  Conflicting settings will cause an error
+message to be emitted by awk.
+
+setting feature default value
+
+Changes the default value of setting 'feature' to 'value'.  There are a small
+number of settings listed at the top of pnglibconf.h, they are documented in the
+source code.  Most of these values have performance implications for the library
+but most of them have no visible effect on the API.  Some can also be overridden
+from the API.
+
+This method of building a customized pnglibconf.h is illustrated in
+contrib/pngminim/*.  See the "$(PNGCONF):" target in the makefile and
+pngusr.dfa in these directories.
+
+C. Configuration using PNG_USR_CONFIG
+
+If -DPNG_USR_CONFIG is added to the CFLAGS when pnglibconf.h is built the file
+pngusr.h will automatically be included before the options in
+scripts/pnglibconf.dfa are processed.  Your pngusr.h file should contain only
+macro definitions turning features on or off or setting settings.
+
+Apart from the global setting "everything = off" all the options listed above
+can be set using macros in pngusr.h:
+
+#define PNG_feature_SUPPORTED
+
+is equivalent to:
+
+option feature on
+
+#define PNG_NO_feature
+
+is equivalent to:
+
+option feature off
+
+#define PNG_feature value
+
+is equivalent to:
+
+setting feature default value
+
+Notice that in both cases, pngusr.dfa and pngusr.h, the contents of the
+pngusr file you supply override the contents of scripts/pnglibconf.dfa
+
+If confusing or incomprehensible behavior results it is possible to
+examine the intermediate file pnglibconf.dfn to find the full set of
+dependency information for each setting and option.  Simply locate the
+feature in the file and read the C comments that precede it.
+
+This method is also illustrated in the contrib/pngminim/* makefiles and
+pngusr.h.
+
 III. Reading
 
 We'll now walk you through the possible functions to call when reading
 in a PNG file sequentially, briefly explaining the syntax and purpose
 of each one.  See example.c and png.h for more detail.  While
 progressive reading is covered in the next section, you will still
 need some of the functions discussed in this section to read a PNG
 file.
@@ -157,94 +326,93 @@ then only check the bytes (if any) that 
 (*): If you are not using the standard I/O functions, you will need
 to replace them with custom functions.  See the discussion under
 Customizing libpng.
 
 
     FILE *fp = fopen(file_name, "rb");
     if (!fp)
     {
-        return (ERROR);
+       return (ERROR);
     }
+
     fread(header, 1, number, fp);
     is_png = !png_sig_cmp(header, 0, number);
+
     if (!is_png)
     {
-        return (NOT_PNG);
+       return (NOT_PNG);
     }
 
 
 Next, png_struct and png_info need to be allocated and initialized.  In
 order to ensure that the size of these structures is correct even with a
 dynamically linked libpng, there are functions to initialize and
 allocate the structures.  We also pass the library version, optional
 pointers to error handling functions, and a pointer to a data struct for
 use by the error functions, if necessary (the pointer and functions can
 be NULL if the default error handlers are to be used).  See the section
 on Changes to Libpng below regarding the old initialization functions.
 The structure allocation functions quietly return NULL if they fail to
 create the structure, so your application should check for that.
 
     png_structp png_ptr = png_create_read_struct
-       (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
+        (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
         user_error_fn, user_warning_fn);
+
     if (!png_ptr)
-        return (ERROR);
+       return (ERROR);
 
     png_infop info_ptr = png_create_info_struct(png_ptr);
+
     if (!info_ptr)
     {
-        png_destroy_read_struct(&png_ptr,
+       png_destroy_read_struct(&png_ptr,
            (png_infopp)NULL, (png_infopp)NULL);
-        return (ERROR);
-    }
-
-    png_infop end_info = png_create_info_struct(png_ptr);
-    if (!end_info)
-    {
-        png_destroy_read_struct(&png_ptr, &info_ptr,
-          (png_infopp)NULL);
-        return (ERROR);
+       return (ERROR);
     }
 
 If you want to use your own memory allocation routines,
-define PNG_USER_MEM_SUPPORTED and use
+use a libpng that was built with PNG_USER_MEM_SUPPORTED defined, and use
 png_create_read_struct_2() instead of png_create_read_struct():
 
     png_structp png_ptr = png_create_read_struct_2
-       (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
+        (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
         user_error_fn, user_warning_fn, (png_voidp)
         user_mem_ptr, user_malloc_fn, user_free_fn);
 
 The error handling routines passed to png_create_read_struct()
 and the memory alloc/free routines passed to png_create_struct_2()
 are only necessary if you are not using the libpng supplied error
 handling and memory alloc/free functions.
 
 When libpng encounters an error, it expects to longjmp back
 to your routine.  Therefore, you will need to call setjmp and pass
 your png_jmpbuf(png_ptr).  If you read the file from different
-routines, you will need to update the jmpbuf field every time you enter
+routines, you will need to update the longjmp buffer every time you enter
 a new routine that will call a png_*() function.
 
 See your documentation of setjmp/longjmp for your compiler for more
 information on setjmp/longjmp.  See the discussion on libpng error
 handling in the Customizing Libpng section below for more information
 on the libpng error handling.  If an error occurs, and libpng longjmp's
 back to your setjmp, you will want to call png_destroy_read_struct() to
 free any memory.
 
     if (setjmp(png_jmpbuf(png_ptr)))
     {
-        png_destroy_read_struct(&png_ptr, &info_ptr,
+       png_destroy_read_struct(&png_ptr, &info_ptr,
            &end_info);
-        fclose(fp);
-        return (ERROR);
+       fclose(fp);
+       return (ERROR);
     }
 
+Pass (png_infopp)NULL instead of &end_info if you didn't create
+an end_info structure.
+
 If you would rather avoid the complexity of setjmp/longjmp issues,
 you can compile libpng with PNG_NO_SETJMP, in which case
 errors will result in a call to PNG_ABORT() which defaults to abort().
 
 You can #define PNG_ABORT() to a function that does something
 more useful than abort(), as long as your function does not
 return.
 
@@ -268,16 +436,41 @@ You can change the zlib compression buff
 reading compressed data with
 
     png_set_compression_buffer_size(png_ptr, buffer_size);
 
 where the default size is 8192 bytes.  Note that the buffer size
 is changed immediately and the buffer is reallocated immediately,
 instead of setting a flag to be acted upon later.
 
+If you want CRC errors to be handled in a different manner than
+the default, use
+
+    png_set_crc_action(png_ptr, crit_action, ancil_action);
+
+The values for png_set_crc_action() say how libpng is to handle CRC errors in
+ancillary and critical chunks, and whether to use the data contained
+therein.  Note that it is impossible to "discard" data in a critical
+chunk.
+
+Choices for (int) crit_action are
+   PNG_CRC_DEFAULT      0  error/quit
+   PNG_CRC_ERROR_QUIT   1  error/quit
+   PNG_CRC_WARN_USE     3  warn/use data
+   PNG_CRC_QUIET_USE    4  quiet/use data
+   PNG_CRC_NO_CHANGE    5  use the current value
+
+Choices for (int) ancil_action are
+   PNG_CRC_DEFAULT      0  error/quit
+   PNG_CRC_ERROR_QUIT   1  error/quit
+   PNG_CRC_WARN_DISCARD 2  warn/discard data
+   PNG_CRC_WARN_USE     3  warn/use data
+   PNG_CRC_QUIET_USE    4  quiet/use data
+   PNG_CRC_NO_CHANGE    5  use the current value
+
 Setting up callback code
 
 You can set up a callback function to handle any unknown chunks in the
 input stream. You must supply the function
 
     read_chunk_callback(png_structp png_ptr,
          png_unknown_chunkp chunk);
     {
@@ -331,50 +524,68 @@ You must supply a function
     }
 
 (You can give it another name that you like instead of "read_row_callback")
 
 To inform libpng about your function, use
 
     png_set_read_status_fn(png_ptr, read_row_callback);
 
+When this function is called the row has already been completely processed and
+the 'row' and 'pass' refer to the next row to be handled.  For the
+non-interlaced case the row that was just handled is simply one less than the
+passed in row number, and pass will always be 0.  For the interlaced case the
+same applies unless the row value is 0, in which case the row just handled was
+the last one from one of the preceding passes.  Because interlacing may skip a
+pass you cannot be sure that the preceding pass is just 'pass-1', if you really
+need to know what the last pass is record (row,pass) from the callback and use
+the last recorded value each time.
+
+As with the user transform you can find the output row using the
+PNG_ROW_FROM_PASS_ROW macro.
+
 Unknown-chunk handling
 
 Now you get to set the way the library processes unknown chunks in the
 input PNG stream. Both known and unknown chunks will be read.  Normal
 behavior is that known chunks will be parsed into information in
 various info_ptr members while unknown chunks will be discarded. This
 behavior can be wasteful if your application will never use some known
 chunk types. To change this, you can call:
 
     png_set_keep_unknown_chunks(png_ptr, keep,
         chunk_list, num_chunks);
     keep       - 0: default unknown chunk handling
                  1: ignore; do not keep
                  2: keep only if safe-to-copy
                  3: keep even if unsafe-to-copy
+
                You can use these definitions:
                  PNG_HANDLE_CHUNK_AS_DEFAULT   0
                  PNG_HANDLE_CHUNK_NEVER        1
                  PNG_HANDLE_CHUNK_IF_SAFE      2
                  PNG_HANDLE_CHUNK_ALWAYS       3
+
     chunk_list - list of chunks affected (a byte string,
                  five bytes per chunk, NULL or '\0' if
                  num_chunks is 0)
+
     num_chunks - number of chunks affected; if 0, all
                  unknown chunks are affected.  If nonzero,
                  only the chunks in the list are affected
 
 Unknown chunks declared in this way will be saved as raw data onto a
 list of png_unknown_chunk structures.  If a chunk that is normally
 known to libpng is named in the list, it will be handled as unknown,
 according to the "keep" directive.  If a chunk is named in successive
 instances of png_set_keep_unknown_chunks(), the final instance will
 take precedence.  The IHDR and IEND chunks should not be named in
 chunk_list; if they are, libpng will process them normally anyway.
+If you know that your application will never make use of some particular
+chunks, use PNG_HANDLE_CHUNK_NEVER (or 1) as demonstrated below.
 
 Here is an example of the usage of png_set_keep_unknown_chunks(),
 where the private "vpAg" chunk will later be processed by a user chunk
 callback function:
 
     png_byte vpAg[5]={118, 112,  65, 103, (png_byte) '\0'};
 
     #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
@@ -389,40 +600,46 @@ callback function:
       };
     #endif
 
     ...
 
     #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
       /* ignore all unknown chunks: */
       png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0);
+
       /* except for vpAg: */
       png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1);
+
       /* also ignore unused known chunks: */
       png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks,
          (int)sizeof(unused_chunks)/5);
     #endif
 
 User 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
+you wish to change 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().
+
+When writing a PNG datastream, put this statement before calling
+png_write_info() or png_write_png().
+
 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);
 
 The PNG specification sets no limit on the number of ancillary chunks
 allowed in a PNG datastream.  You can impose a limit on the total number
 of sPLT, tEXt, iTXt, zTXt, and unknown chunks that will be stored, with
@@ -443,27 +660,265 @@ other than IDAT can occupy, with
 
 and you can retrieve the limit with
 
    chunk_malloc_max = png_get_chunk_malloc_max(png_ptr);
 
 Any chunks that would cause either of these limits to be exceeded will
 be ignored.
 
+Information about your system
+
+If you intend to display the PNG or to incorporate it in other image data you
+need to tell libpng information about your display or drawing surface so that
+libpng can convert the values in the image to match the display.
+
+From libpng-1.5.4 this information can be set before reading the PNG file
+header.  In earlier versions png_set_gamma() existed but behaved incorrectly if
+called before the PNG file header had been read and png_set_alpha_mode() did not
+exist.
+
+If you need to support versions prior to libpng-1.5.4 test the version number
+as illustrated below using "PNG_LIBPNG_VER >= 10504" and follow the procedures
+described in the appropriate manual page.
+
+You give libpng the encoding expected by your system expressed as a 'gamma'
+value.  You can also specify a default encoding for the PNG file in
+case the required information is missing from the file.  By default libpng
+assumes that the PNG data matches your system, to keep this default call:
+
+   png_set_gamma(png_ptr, screen_gamma, 1/screen_gamma/*file gamma*/);
+
+or you can use the fixed point equivalent:
+
+   png_set_gamma_fixed(png_ptr, PNG_FP_1*screen_gamma, PNG_FP_1/screen_gamma);
+
+If you don't know the gamma for your system it is probably 2.2 - a good
+approximation to the IEC standard for display systems (sRGB).  If images are
+too contrasty or washed out you got the value wrong - check your system
+documentation!
+
+Many systems permit the system gamma to be changed via a lookup table in the
+display driver, a few systems, including older Macs, change the response by
+default.  As of 1.5.4 three special values are available to handle common
+situations:
+
+   PNG_DEFAULT_sRGB: Indicates that the system conforms to the IEC 61966-2-1
+                     standard.  This matches almost all systems.
+   PNG_GAMMA_MAC_18: Indicates that the system is an older (pre Mac OS 10.6)
+                     Apple Macintosh system with the default settings.
+   PNG_GAMMA_LINEAR: Just the fixed point value for 1.0 - indicates that the
+                     system expects data with no gamma encoding.
+
+You would use the linear (unencoded) value if you need to process the pixel
+values further because this avoids the need to decode and reencode each
+component value whenever arithmetic is performed.  A lot of graphics software
+uses linear values for this reason, often with higher precision component values
+to preserve overall accuracy.
+
+The second thing you may need to tell libpng about is how your system handles
+alpha channel information.  Some, but not all, PNG files contain an alpha
+channel.  To display these files correctly you need to compose the data onto a
+suitable background, as described in the PNG specification.
+
+Libpng only supports composing onto a single color (using png_set_background;
+see below).  Otherwise you must do the composition yourself and, in this case,
+you may need to call png_set_alpha_mode:
+
+#if PNG_LIBPNG_VER >= 10504
+   png_set_alpha_mode(png_ptr, mode, screen_gamma);
+#else
+   png_set_gamma(png_ptr, screen_gamma, 1.0/screen_gamma);
+#endif
+
+The screen_gamma value is the same as the argument to png_set_gamma; however,
+how it affects the output depends on the mode.  png_set_alpha_mode() sets the
+file gamma default to 1/screen_gamma, so normally you don't need to call
+png_set_gamma.  If you need different defaults call png_set_gamma() before
+png_set_alpha_mode() - if you call it after it will override the settings made
+by png_set_alpha_mode().
+
+The mode is as follows:
+
+    PNG_ALPHA_PNG: The data is encoded according to the PNG specification.  Red,
+green and blue, or gray, components are gamma encoded color
+values and are not premultiplied by the alpha value.  The
+alpha value is a linear measure of the contribution of the
+pixel to the corresponding final output pixel.
+
+You should normally use this format if you intend to perform
+color correction on the color values; most, maybe all, color
+correction software has no handling for the alpha channel and,
+anyway, the math to handle pre-multiplied component values is
+unnecessarily complex.
+
+Before you do any arithmetic on the component values you need
+to remove the gamma encoding and multiply out the alpha
+channel.  See the PNG specification for more detail.  It is
+important to note that when an image with an alpha channel is
+scaled, linear encoded, pre-multiplied component values must
+be used!
+
+The remaining modes assume you don't need to do any further color correction or
+that if you do, your color correction software knows all about alpha (it
+probably doesn't!)
+
+    PNG_ALPHA_STANDARD:  The data libpng produces
+is encoded in the standard way
+assumed by most correctly written graphics software.
+The gamma encoding will be removed by libpng and the
+linear component values will be pre-multiplied by the
+alpha channel.
+
+With this format the final image must be re-encoded to
+match the display gamma before the image is displayed.
+If your system doesn't do that, yet still seems to
+perform arithmetic on the pixels without decoding them,
+it is broken - check out the modes below.
+
+With PNG_ALPHA_STANDARD libpng always produces linear
+component values, whatever screen_gamma you supply.  The
+screen_gamma value is, however, used as a default for
+the file gamma if the PNG file has no gamma information.
+
+If you call png_set_gamma() after png_set_alpha_mode() you
+will override the linear encoding.  Instead the
+pre-multiplied pixel values will be gamma encoded but
+the alpha channel will still be linear.  This may
+actually match the requirements of some broken software,
+but it is unlikely.
+
+While linear 8-bit data is often used it has
+insufficient precision for any image with a reasonable
+dynamic range.  To avoid problems, and if your software
+supports it, use png_set_expand_16() to force all
+components to 16 bits.
+
+    PNG_ALPHA_OPTIMIZED: This mode is the same
+as PNG_ALPHA_STANDARD except that
+completely opaque pixels are gamma encoded according to
+the screen_gamma value.  Pixels with alpha less than 1.0
+will still have linear components.
+
+Use this format if you have control over your
+compositing software and do don't do other arithmetic
+(such as scaling) on the data you get from libpng.  Your
+compositing software can simply copy opaque pixels to
+the output but still has linear values for the
+non-opaque pixels.
+
+In normal compositing, where the alpha channel encodes
+partial pixel coverage (as opposed to broad area
+translucency), the inaccuracies of the 8-bit
+representation of non-opaque pixels are irrelevant.
+
+You can also try this format if your software is broken;
+it might look better.
+
+    PNG_ALPHA_BROKEN: This is PNG_ALPHA_STANDARD;
+however, all component values,
+including the alpha channel are gamma encoded.  This is
+an appropriate format to try if your software, or more
+likely hardware, is totally broken, i.e., if it performs
+linear arithmetic directly on gamma encoded values.
+
+In most cases of broken software or hardware the bug in the final display
+manifests as a subtle halo around composited parts of the image.  You may not
+even perceive this as a halo; the composited part of the image may simply appear
+separate from the background, as though it had been cut out of paper and pasted
+on afterward.
+
+If you don't have to deal with bugs in software or hardware, or if you can fix
+them, there are three recommended ways of using png_set_alpha_mode():
+
+   png_set_alpha_mode(png_ptr, PNG_ALPHA_PNG,
+       screen_gamma);
+
+You can do color correction on the result (libpng does not currently
+support color correction internally).  When you handle the alpha channel
+you need to undo the gamma encoding and multiply out the alpha.
+
+   png_set_alpha_mode(png_ptr, PNG_ALPHA_STANDARD,
+       screen_gamma);
+   png_set_expand_16(png_ptr);
+
+If you are using the high level interface, don't call png_set_expand_16();
+instead pass PNG_TRANSFORM_EXPAND_16 to the interface.
+
+With this mode you can't do color correction, but you can do arithmetic,
+including composition and scaling, on the data without further processing.
+
+   png_set_alpha_mode(png_ptr, PNG_ALPHA_OPTIMIZED,
+       screen_gamma);
+
+You can avoid the expansion to 16-bit components with this mode, but you
+lose the ability to scale the image or perform other linear arithmetic.
+All you can do is compose the result onto a matching output.  Since this
+mode is libpng-specific you also need to write your own composition
+software.
+
+If you don't need, or can't handle, the alpha channel you can call
+png_set_background() to remove it by compositing against a fixed color.  Don't
+call png_set_strip_alpha() to do this - it will leave spurious pixel values in
+transparent parts of this image.
+
+   png_set_background(png_ptr, &background_color,
+       PNG_BACKGROUND_GAMMA_SCREEN, 0, 1);
+
+The background_color is an RGB or grayscale value according to the data format
+libpng will produce for you.  Because you don't yet know the format of the PNG
+file, if you call png_set_background at this point you must arrange for the
+format produced by libpng to always have 8-bit or 16-bit components and then
+store the color as an 8-bit or 16-bit color as appropriate.  The color contains
+separate gray and RGB component values, so you can let libpng produce gray or
+RGB output according to the input format, but low bit depth grayscale images
+must always be converted to at least 8-bit format.  (Even though low bit depth
+grayscale images can't have an alpha channel they can have a transparent
+color!)
+
+You set the transforms you need later, either as flags to the high level
+interface or libpng API calls for the low level interface.  For reference the
+settings and API calls required are:
+
+8-bit values:
+   PNG_TRANSFORM_SCALE_16 | PNG_EXPAND
+   png_set_expand(png_ptr); png_set_scale_16(png_ptr);
+
+   If you must get exactly the same inaccurate results
+   produced by default in versions prior to libpng-1.5.4,
+   use PNG_TRANSFORM_STRIP_16 and png_set_strip_16(png_ptr)
+   instead.
+
+16-bit values:
+   PNG_TRANSFORM_EXPAND_16
+   png_set_expand_16(png_ptr);
+
+In either case palette image data will be expanded to RGB.  If you just want
+color data you can add PNG_TRANSFORM_GRAY_TO_RGB or png_set_gray_to_rgb(png_ptr)
+to the list.
+
+Calling png_set_background before the PNG file header is read will not work
+prior to libpng-1.5.4.  Because the failure may result in unexpected warnings or
+errors it is therefore much safer to call png_set_background after the head has
+been read.  Unfortunately this means that prior to libpng-1.5.4 it cannot be
+used with the high level interface.
+
 The high-level read interface
 
 At this point there are two ways to proceed; through the high-level
 read interface, or through a sequence of low-level read operations.
 You can use the high-level interface if (a) you are willing to read
 the entire image into memory, and (b) the input transformations
 you want to do are limited to the following set:
 
     PNG_TRANSFORM_IDENTITY      No transformation
-    PNG_TRANSFORM_STRIP_16      Strip 16-bit samples to
-                                8 bits
+    PNG_TRANSFORM_SCALE_16      Strip 16-bit samples to
+                                8-bit accurately
+    PNG_TRANSFORM_STRIP_16      Chop 16-bit samples to
+                                8-bit less accurately
     PNG_TRANSFORM_STRIP_ALPHA   Discard the alpha channel
     PNG_TRANSFORM_PACKING       Expand 1, 2 and 4-bit
                                 samples to bytes
     PNG_TRANSFORM_PACKSWAP      Change order of packed
                                 pixels to LSB first
     PNG_TRANSFORM_EXPAND        Perform set_expand()
     PNG_TRANSFORM_INVERT_MONO   Invert monochrome images
     PNG_TRANSFORM_SHIFT         Normalize pixels to the
@@ -472,16 +927,17 @@ you want to do are limited to the follow
                                 to BGRA
     PNG_TRANSFORM_SWAP_ALPHA    Flip RGBA to ARGB or GA
                                 to AG
     PNG_TRANSFORM_INVERT_ALPHA  Change alpha from opacity
                                 to transparency
     PNG_TRANSFORM_SWAP_ENDIAN   Byte-swap 16-bit samples
     PNG_TRANSFORM_GRAY_TO_RGB   Expand grayscale samples
                                 to RGB (or GA to RGBA)
+    PNG_TRANSFORM_EXPAND_16     Expand samples to 16 bits
 
 (This excludes setting a background color, doing gamma transformation,
 quantizing, and setting filler.)  If this is the case, simply do this:
 
     png_read_png(png_ptr, info_ptr, png_transforms, NULL)
 
 where png_transforms is an integer containing the bitwise OR of some
 set of transformation flags.  This call is equivalent to png_read_info(),
@@ -503,67 +959,91 @@ where row_pointers is an array of pointe
 
    png_bytep row_pointers[height];
 
 If you know your image size and pixel size ahead of time, you can allocate
 row_pointers prior to calling png_read_png() with
 
    if (height > PNG_UINT_32_MAX/png_sizeof(png_byte))
       png_error (png_ptr,
-         "Image is too tall to process in memory");
+          "Image is too tall to process in memory");
+
    if (width > PNG_UINT_32_MAX/pixel_size)
       png_error (png_ptr,
-         "Image is too wide to process in memory");
+          "Image is too wide to process in memory");
+
    row_pointers = png_malloc(png_ptr,
-      height*png_sizeof(png_bytep));
+       height*png_sizeof(png_bytep));
+
    for (int i=0; i<height, i++)
       row_pointers[i]=NULL;  /* security precaution */
+
    for (int i=0; i<height, i++)
       row_pointers[i]=png_malloc(png_ptr,
-         width*pixel_size);
+          width*pixel_size);
+
    png_set_rows(png_ptr, info_ptr, &row_pointers);
 
 Alternatively you could allocate your image in one big block and define
 row_pointers[i] to point into the proper places in your block.
 
 If you use png_set_rows(), the application is responsible for freeing
 row_pointers (and row_pointers[i], if they were separately allocated).
 
 If you don't allocate row_pointers ahead of time, png_read_png() will
-do it, and it'll be free'ed when you call png_destroy_*().
+do it, and it'll be free'ed by libpng when you call png_destroy_*().
 
 The low-level read interface
 
 If you are going the low-level route, you are now ready to read all
 the file information up to the actual image data.  You do this with a
 call to png_read_info().
 
     png_read_info(png_ptr, info_ptr);
 
 This will process all chunks up to but not including the image data.
 
+This also copies some of the data from the PNG file into the decode structure
+for use in later transformations.  Important information copied in is:
+
+1) The PNG file gamma from the gAMA chunk.  This overwrites the default value
+provided by an earlier call to png_set_gamma or png_set_alpha_mode.
+
+2) Prior to libpng-1.5.4 the background color from a bKGd chunk.  This
+damages the information provided by an earlier call to png_set_background
+resulting in unexpected behavior.  Libpng-1.5.4 no longer does this.
+
+3) The number of significant bits in each component value.  Libpng uses this to
+optimize gamma handling by reducing the internal lookup table sizes.
+
+4) The transparent color information from a tRNS chunk.  This can be modified by
+a later call to png_set_tRNS.
+
 Querying the info structure
 
 Functions are used to get the information from the info_ptr once it
 has been read.  Note that these fields may not be completely filled
 in until png_read_end() has read the chunk data following the image.
 
     png_get_IHDR(png_ptr, info_ptr, &width, &height,
        &bit_depth, &color_type, &interlace_type,
        &compression_type, &filter_method);
 
     width          - holds the width of the image
                      in pixels (up to 2^31).
+
     height         - holds the height of the image
                      in pixels (up to 2^31).
+
     bit_depth      - holds the bit depth of one of the
                      image channels.  (valid values are
                      1, 2, 4, 8, 16 and depend also on
                      the color_type.  See also
                      significant bits (sBIT) below).
+
     color_type     - describes which color/alpha channels
                          are present.
                      PNG_COLOR_TYPE_GRAY
                         (bit depths 1, 2, 4, 8, 16)
                      PNG_COLOR_TYPE_GRAY_ALPHA
                         (bit depths 8, 16)
                      PNG_COLOR_TYPE_PALETTE
                         (bit depths 1, 2, 4, 8)
@@ -596,38 +1076,48 @@ in until png_read_end() has read the chu
     the application's width and height variables.
     This is an unsafe situation if these are 16-bit
     variables.  In such situations, the
     png_get_image_width() and png_get_image_height()
     functions described below are safer.
 
     width            = png_get_image_width(png_ptr,
                          info_ptr);
+
     height           = png_get_image_height(png_ptr,
                          info_ptr);
+
     bit_depth        = png_get_bit_depth(png_ptr,
                          info_ptr);
+
     color_type       = png_get_color_type(png_ptr,
                          info_ptr);
+
     interlace_type   = png_get_interlace_type(png_ptr,
                          info_ptr);
+
     compression_type = png_get_compression_type(png_ptr,
                          info_ptr);
+
     filter_method    = png_get_filter_type(png_ptr,
                          info_ptr);
 
     channels = png_get_channels(png_ptr, info_ptr);
+
     channels       - number of channels of info for the
                      color type (valid values are 1 (GRAY,
                      PALETTE), 2 (GRAY_ALPHA), 3 (RGB),
                      4 (RGB_ALPHA or RGB + filler byte))
+
     rowbytes = png_get_rowbytes(png_ptr, info_ptr);
+
     rowbytes       - number of bytes needed to hold a row
 
     signature = png_get_signature(png_ptr, info_ptr);
+
     signature      - holds the signature read from the
                      file (if any).  The data is kept in
                      the same offset it would be if the
                      whole signature were read (i.e. if an
                      application had already read in 4
                      bytes of signature before starting
                      libpng, the remaining 4 bytes would
                      be in signature[4] through signature[7]
@@ -637,195 +1127,300 @@ These are also important, but their vali
 has been read.  The png_get_valid(png_ptr, info_ptr, PNG_INFO_<chunk>) and
 png_get_<chunk>(png_ptr, info_ptr, ...) functions return non-zero if the
 data has been read, or zero if it is missing.  The parameters to the
 png_get_<chunk> are set directly if they are simple data types, or a
 pointer into the info_ptr is returned for any complex types.
 
     png_get_PLTE(png_ptr, info_ptr, &palette,
                      &num_palette);
+
     palette        - the palette for the file
                      (array of png_color)
+
     num_palette    - number of entries in the palette
 
-    png_get_gAMA(png_ptr, info_ptr, &gamma);
-    gamma          - the gamma the file is written
-                     at (PNG_INFO_gAMA)
+    png_get_gAMA(png_ptr, info_ptr, &file_gamma);
+    png_get_gAMA_fixed(png_ptr, info_ptr, &int_file_gamma);
+
+    file_gamma     - the gamma at which the file is
+                     written (PNG_INFO_gAMA)
+
+    int_file_gamma - 100,000 times the gamma at which the
+                     file is written
+
+    png_get_cHRM(png_ptr, info_ptr,  &white_x, &white_y, &red_x, &red_y,
+                     &green_x, &green_y, &blue_x, &blue_y)
+    png_get_cHRM_XYZ(png_ptr, info_ptr, &red_X, &red_Y, &red_Z, &green_X,
+                     &green_Y, &green_Z, &blue_X, &blue_Y, &blue_Z)
+    png_get_cHRM_fixed(png_ptr, info_ptr, &int_white_x, &int_white_y,
+                     &int_red_x, &int_red_y, &int_green_x, &int_green_y,
+                     &int_blue_x, &int_blue_y)
+    png_get_cHRM_XYZ_fixed(png_ptr, info_ptr, &int_red_X, &int_red_Y,
+                     &int_red_Z, &int_green_X, &int_green_Y, &int_green_Z,
+                     &int_blue_X, &int_blue_Y, &int_blue_Z)
+
+    {white,red,green,blue}_{x,y}
+                     A color space encoding specified using the chromaticities
+                     of the end points and the white point. (PNG_INFO_cHRM)
+
+    {red,green,blue}_{X,Y,Z}
+                     A color space encoding specified using the encoding end
+                     points - the CIE tristimulus specification of the intended
+                     color of the red, green and blue channels in the PNG RGB
+                     data.  The white point is simply the sum of the three end
+                     points. (PNG_INFO_cHRM)
 
     png_get_sRGB(png_ptr, info_ptr, &srgb_intent);
-    srgb_intent    - the rendering intent (PNG_INFO_sRGB)
+
+    file_srgb_intent - the rendering intent (PNG_INFO_sRGB)
                      The presence of the sRGB chunk
                      means that the pixel data is in the
                      sRGB color space.  This chunk also
                      implies specific values of gAMA and
                      cHRM.
 
     png_get_iCCP(png_ptr, info_ptr, &name,
        &compression_type, &profile, &proflen);
+
     name             - The profile name.
+
     compression_type - The compression type; always
                        PNG_COMPRESSION_TYPE_BASE for PNG 1.0.
                        You may give NULL to this argument to
                        ignore it.
+
     profile          - International Color Consortium color
                        profile data. May contain NULs.
+
     proflen          - length of profile data in bytes.
 
     png_get_sBIT(png_ptr, info_ptr, &sig_bit);
+
     sig_bit        - the number of significant bits for
                      (PNG_INFO_sBIT) each of the gray,
                      red, green, and blue channels,
                      whichever are appropriate for the
                      given color type (png_color_16)
 
     png_get_tRNS(png_ptr, info_ptr, &trans_alpha,
                      &num_trans, &trans_color);
+
     trans_alpha    - array of alpha (transparency)
                      entries for palette (PNG_INFO_tRNS)
+
     num_trans      - number of transparent entries
                      (PNG_INFO_tRNS)
+
     trans_color    - graylevel or color sample values of
                      the single transparent color for
                      non-paletted images (PNG_INFO_tRNS)
 
     png_get_hIST(png_ptr, info_ptr, &hist);
                      (PNG_INFO_hIST)
+
     hist           - histogram of palette (array of
                      png_uint_16)
 
     png_get_tIME(png_ptr, info_ptr, &mod_time);
+
     mod_time       - time image was last modified
                     (PNG_VALID_tIME)
 
     png_get_bKGD(png_ptr, info_ptr, &background);
-    background     - background color (PNG_VALID_bKGD)
+
+    background     - background color (of type
+                     png_color_16p) (PNG_VALID_bKGD)
                      valid 16-bit red, green and blue
                      values, regardless of color_type
 
     num_comments   = png_get_text(png_ptr, info_ptr,
                      &text_ptr, &num_text);
+
     num_comments   - number of comments
+
     text_ptr       - array of png_text holding image
                      comments
+
     text_ptr[i].compression - type of compression used
                  on "text" PNG_TEXT_COMPRESSION_NONE
                            PNG_TEXT_COMPRESSION_zTXt
                            PNG_ITXT_COMPRESSION_NONE
                            PNG_ITXT_COMPRESSION_zTXt
+
     text_ptr[i].key   - keyword for comment.  Must contain
                          1-79 characters.
+
     text_ptr[i].text  - text comments for current
                          keyword.  Can be empty.
+
     text_ptr[i].text_length - length of text string,
                  after decompression, 0 for iTXt
+
     text_ptr[i].itxt_length - length of itxt string,
                  after decompression, 0 for tEXt/zTXt
+
     text_ptr[i].lang  - language of comment (empty
                          string for unknown).
+
     text_ptr[i].lang_key  - keyword in UTF-8
                          (empty string for unknown).
+
     Note that the itxt_length, lang, and lang_key
-    members of the text_ptr structure only exist
-    when the library is built with iTXt chunk support.
+    members of the text_ptr structure only exist when the
+    library is built with iTXt chunk support.  Prior to
+    libpng-1.4.0 the library was built by default without
+    iTXt support. Also note that when iTXt is supported,
+    they contain NULL pointers when the "compression"
+    field contains PNG_TEXT_COMPRESSION_NONE or
+    PNG_TEXT_COMPRESSION_zTXt.
 
     num_text       - number of comments (same as
                      num_comments; you can put NULL here
                      to avoid the duplication)
+
     Note while png_set_text() will accept text, language,
     and translated keywords that can be NULL pointers, the
     structure returned by png_get_text will always contain
     regular zero-terminated C strings.  They might be
     empty strings but they will never be NULL pointers.
 
     num_spalettes = png_get_sPLT(png_ptr, info_ptr,
        &palette_ptr);
+
+    num_spalettes  - number of sPLT chunks read.
+
     palette_ptr    - array of palette structures holding
                      contents of one or more sPLT chunks
                      read.
-    num_spalettes  - number of sPLT chunks read.
 
     png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y,
        &unit_type);
+
     offset_x       - positive offset from the left edge
-                     of the screen
+                     of the screen (can be negative)
+
     offset_y       - positive offset from the top edge
-                     of the screen
+                     of the screen (can be negative)
+
     unit_type      - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
 
     png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y,
        &unit_type);
+
     res_x          - pixels/unit physical resolution in
                      x direction
+
     res_y          - pixels/unit physical resolution in
                      x direction
+
     unit_type      - PNG_RESOLUTION_UNKNOWN,
                      PNG_RESOLUTION_METER
 
     png_get_sCAL(png_ptr, info_ptr, &unit, &width,
        &height)
+
     unit        - physical scale units (an integer)
+
     width       - width of a pixel in physical scale units
+
     height      - height of a pixel in physical scale units
                  (width and height are doubles)
 
     png_get_sCAL_s(png_ptr, info_ptr, &unit, &width,
        &height)
+
     unit        - physical scale units (an integer)
+
     width       - width of a pixel in physical scale units
+                  (expressed as a string)
+
     height      - height of a pixel in physical scale units
                  (width and height are strings like "2.54")
 
     num_unknown_chunks = png_get_unknown_chunks(png_ptr,
        info_ptr, &unknowns)
+
     unknowns          - array of png_unknown_chunk
                         structures holding unknown chunks
+
     unknowns[i].name  - name of unknown chunk
+
     unknowns[i].data  - data of unknown chunk
+
     unknowns[i].size  - size of unknown chunk's data
+
     unknowns[i].location - position of chunk in file
 
     The value of "i" corresponds to the order in which the
     chunks were read from the PNG file or inserted with the
     png_set_unknown_chunks() function.
 
+    The value of "location" is a bitwise "or" of
+
+         PNG_HAVE_IHDR  (0x01)
+         PNG_HAVE_PLTE  (0x02)
+         PNG_AFTER_IDAT (0x08)
+
 The data from the pHYs chunk can be retrieved in several convenient
 forms:
 
     res_x = png_get_x_pixels_per_meter(png_ptr,
        info_ptr)
+
     res_y = png_get_y_pixels_per_meter(png_ptr,
        info_ptr)
+
     res_x_and_y = png_get_pixels_per_meter(png_ptr,
        info_ptr)
+
     res_x = png_get_x_pixels_per_inch(png_ptr,
        info_ptr)
+
     res_y = png_get_y_pixels_per_inch(png_ptr,
        info_ptr)
+
     res_x_and_y = png_get_pixels_per_inch(png_ptr,
        info_ptr)
+
     aspect_ratio = png_get_pixel_aspect_ratio(png_ptr,
        info_ptr)
 
-   (Each of these returns 0 [signifying "unknown"] if
+    Each of these returns 0 [signifying "unknown"] if
        the data is not present or if res_x is 0;
-       res_x_and_y is 0 if res_x != res_y)
+       res_x_and_y is 0 if res_x != res_y
+
+    Note that because of the way the resolutions are
+       stored internally, the inch conversions won't
+       come out to exactly even number.  For example,
+       72 dpi is stored as 0.28346 pixels/meter, and
+       when this is retrieved it is 71.9988 dpi, so
+       be sure to round the returned value appropriately
+       if you want to display a reasonable-looking result.
 
 The data from the oFFs chunk can be retrieved in several convenient
 forms:
 
     x_offset = png_get_x_offset_microns(png_ptr, info_ptr);
+
     y_offset = png_get_y_offset_microns(png_ptr, info_ptr);
+
     x_offset = png_get_x_offset_inches(png_ptr, info_ptr);
+
     y_offset = png_get_y_offset_inches(png_ptr, info_ptr);
 
-   (Each of these returns 0 [signifying "unknown" if both
+    Each of these returns 0 [signifying "unknown" if both
        x and y are 0] if the data is not present or if the
-       chunk is present but the unit is the pixel)
-
-For more information, see the png_info definition in png.h and the
+       chunk is present but the unit is the pixel.  The
+       remark about inexact inch conversions applies here
+       as well, because a value in inches can't always be
+       converted to microns and back without some loss
+       of precision.
+
+For more information, see the
 PNG specification for chunk contents.  Be careful with trusting
 rowbytes, as some of the transformations could increase the space
 needed to hold a row (expand, filler, gray_to_rgb, etc.).
 See png_read_update_info(), below.
 
 A quick word about text_ptr and num_text.  PNG stores comments in
 keyword/text pairs, one pair per chunk, with no limit on the number
 of text chunks, and a 2^31 byte limit on their size.  While there are
@@ -850,349 +1445,369 @@ mentioned again below in the discussion 
 
 Input transformations
 
 After you've read the header information, you can set up the library
 to handle any special transformations of the image data.  The various
 ways to transform the data will be described in the order that they
 should occur.  This is important, as some of these change the color
 type and/or bit depth of the data, and some others only work on
-certain color types and bit depths.  Even though each transformation
-checks to see if it has data that it can do something with, you should
-make sure to only enable a transformation if it will be valid for the
-data.  For example, don't swap red and blue on grayscale data.
-
-The colors used for the background and transparency values should be
-supplied in the same format/depth as the current image data.  They
-are stored in the same format/depth as the image data in a bKGD or tRNS
-chunk, so this is what libpng expects for this data.  The colors are
-transformed to keep in sync with the image data when an application
-calls the png_read_update_info() routine (see below).
+certain color types and bit depths.
+
+Transformations you request are ignored if they don't have any meaning for a
+particular input data format.  However some transformations can have an effect
+as a result of a previous transformation.  If you specify a contradictory set of
+transformations, for example both adding and removing the alpha channel, you
+cannot predict the final result.
+
+The color used for the transparency values should be supplied in the same
+format/depth as the current image data.  It is stored in the same format/depth
+as the image data in a tRNS chunk, so this is what libpng expects for this data.
+
+The color used for the background value depends on the need_expand argument as
+described below.
 
 Data will be decoded into the supplied row buffers packed into bytes
 unless the library has been told to transform it into another format.
 For example, 4 bit/pixel paletted or grayscale data will be returned
 2 pixels/byte with the leftmost pixel in the high-order bits of the
 byte, unless png_set_packing() is called.  8-bit RGB data will be stored
 in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha()
 is called to insert filler bytes, either before or after each RGB triplet.
 16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant
-byte of the color value first, unless png_set_strip_16() is called to
+byte of the color value first, unless png_set_scale_16() is called to
 transform it to regular RGB RGB triplets, or png_set_filler() or
 png_set_add alpha() is called to insert filler bytes, either before or
 after each RRGGBB triplet.  Similarly, 8-bit or 16-bit grayscale data can
-be modified with
-png_set_filler(), png_set_add_alpha(), or png_set_strip_16().
+be modified with png_set_filler(), png_set_add_alpha(), png_set_strip_16(),
+or png_set_scale_16().
 
 The following code transforms grayscale images of less than 8 to 8 bits,
 changes paletted images to RGB, and adds a full alpha channel if there is
 transparency information in a tRNS chunk.  This is most useful on
 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)
         png_set_palette_to_rgb(png_ptr);
 
+    if (png_get_valid(png_ptr, info_ptr,
+        PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr);
+
     if (color_type == PNG_COLOR_TYPE_GRAY &&
         bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr);
 
-    if (png_get_valid(png_ptr, info_ptr,
-        PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr);
-
-These three functions are actually aliases for png_set_expand(), added
+The first two functions are actually aliases for png_set_expand(), added
 in libpng version 1.0.4, with the function names expanded to improve code
 readability.  In some future version they may actually do different
 things.
 
 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.4.8, not all possible expansions are supported.
+As of libpng version 1.5.2, png_set_expand_16() was added.  It behaves as
+png_set_expand(); however, the resultant channels have 16 bits rather than 8.
+Use this when the output color or gray channels are made linear to avoid fairly
+severe accuracy loss.
+
+   if (bit_depth < 16)
+      png_set_expand_16(png_ptr);
+
+PNG can have files with 16 bits per channel.  If you only can handle
+8 bits per channel, this will strip the pixels down to 8-bit.
+
+    if (bit_depth == 16)
+#if PNG_LIBPNG_VER >= 10504
+       png_set_scale_16(png_ptr);
+#else
+       png_set_strip_16(png_ptr);
+#endif
+
+(The more accurate "png_set_scale_16()" API became available in libpng version
+1.5.4).
+
+If you need to process the alpha channel on the image separately from the image
+data (for example if you convert it to a bitmap mask) it is possible to have
+libpng strip the channel leaving just RGB or gray data:
+
+    if (color_type & PNG_COLOR_MASK_ALPHA)
+       png_set_strip_alpha(png_ptr);
+
+If you strip the alpha channel you need to find some other way of dealing with
+the information.  If, instead, you want to convert the image to an opaque
+version with no alpha channel use png_set_background; see below.
+
+As of libpng version 1.5.2, almost all useful expansions are supported, the
+major ommissions are conversion of grayscale to indexed images (which can be
+done trivially in the application) and conversion of indexed to grayscale (which
+can be done by a trivial manipulation of the palette.)
 
 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
 the tRNS chunk is present, A means an alpha channel is present, and O
 means tRNS or alpha is present but all pixels in the image are opaque.
 
-  FROM  01  31   0  0T  0O   2  2T  2O   3  3T  3O  4A  4O  6A  6O 
+  FROM  01  31   0  0T  0O   2  2T  2O   3  3T  3O  4A  4O  6A  6O
    TO
-   01    -                   
-   31        -
-    0    1       -           
-   0T                -
-   0O                    -
-    2           GX           -
-   2T                            -
-   2O                                -
-    3        1                           -
-   3T                                        -
-   3O                                            -
-   4A                T                               -
-   4O                                                    -
-   6A               GX         TX           TX               -
-   6O                   GX                      TX               -
+   01    -  [G]  -   -   -   -   -   -   -   -   -   -   -   -   -
+   31   [Q]  Q  [Q] [Q] [Q]  Q   Q   Q   Q   Q   Q  [Q] [Q]  Q   Q
+    0    1   G   +   .   .   G   G   G   G   G   G   B   B  GB  GB
+   0T    lt  Gt  t   +   .   Gt  G   G   Gt  G   G   Bt  Bt GBt GBt
+   0O    lt  Gt  t   .   +   Gt  Gt  G   Gt  Gt  G   Bt  Bt GBt GBt
+    2    C   P   C   C   C   +   .   .   C   -   -  CB  CB   B   B
+   2T    Ct  -   Ct  C   C   t   +   t   -   -   -  CBt CBt  Bt  Bt
+   2O    Ct  -   Ct  C   C   t   t   +   -   -   -  CBt CBt  Bt  Bt
+    3   [Q]  p  [Q] [Q] [Q]  Q   Q   Q   +   .   .  [Q] [Q]  Q   Q
+   3T   [Qt] p  [Qt][Q] [Q]  Qt  Qt  Qt  t   +   t  [Qt][Qt] Qt  Qt
+   3O   [Qt] p  [Qt][Q] [Q]  Qt  Qt  Qt  t   t   +  [Qt][Qt] Qt  Qt
+   4A    lA  G   A   T   T   GA  GT  GT  GA  GT  GT  +   BA  G  GBA
+   4O    lA GBA  A   T   T   GA  GT  GT  GA  GT  GT  BA  +  GBA  G
+   6A    CA  PA  CA  C   C   A   T  tT   PA  P   P   C  CBA  +   BA
+   6O    CA PBA  CA  C   C   A  tT   T   PA  P   P  CBA  C   BA  +
 
 Within the matrix,
+     "+" identifies entries where 'from' and 'to' are the same.
      "-" means the transformation is not supported.
+     "." means nothing is necessary (a tRNS chunk can just be ignored).
+     "t" means the transformation is obtained by png_set_tRNS.
+     "A" means the transformation is obtained by png_set_add_alpha().
      "X" means the transformation is obtained by png_set_expand().
      "1" means the transformation is obtained by
-         png_set_expand_gray_1_2_4_to_8
-     "G" means the transformation is obtained by
-         png_set_gray_to_rgb().
+         png_set_expand_gray_1_2_4_to_8() (and by png_set_expand() if there
+         is no transparency in the original or the final format).
+     "C" means the transformation is obtained by png_set_gray_to_rgb().
+     "G" means the transformation is obtained by png_set_rgb_to_gray().
      "P" means the transformation is obtained by
          png_set_expand_palette_to_rgb().
-     "T" means the transformation is obtained by
-         png_set_tRNS_to_alpha().
-
-PNG can have files with 16 bits per channel.  If you only can handle
-8 bits per channel, this will strip the pixels down to 8 bit.
-
-    if (bit_depth == 16)
-        png_set_strip_16(png_ptr);
-
-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
-it with the background, so that's what you should probably do):
-
-    if (color_type & PNG_COLOR_MASK_ALPHA)
-        png_set_strip_alpha(png_ptr);
+     "p" means the transformation is obtained by png_set_packing().
+     "Q" means the transformation is obtained by png_set_quantize().
+     "T" means the transformation is obtained by png_set_tRNS_to_alpha().
+     "B" means the transformation is obtained by png_set_background(), or
+         png_strip_alpha().
+
+When an entry has multiple transforms listed all are required to cause the
+right overall transformation.  When two transforms are separated by a comma
+either will do the job.  When transforms are enclosed in [] the transform should
+do the job but this is currently unimplemented - a different format will result
+if the suggested transformations are used.
 
 In PNG files, the alpha channel in an image
 is the level of opacity.  If you need the alpha channel in an image to
 be the level of transparency instead of opacity, you can invert the
 alpha channel (or the tRNS chunk data) after it's read, so that 0 is
 fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit
 images) is fully transparent, with
 
     png_set_invert_alpha(png_ptr);
 
 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.  This code expands to 1 pixel per byte without changing the
 values of the pixels:
 
     if (bit_depth < 8)
-        png_set_packing(png_ptr);
+       png_set_packing(png_ptr);
 
 PNG files have possible bit depths of 1, 2, 4, 8, and 16.  All pixels
 stored in a PNG image have been "scaled" or "shifted" up to the next
 higher possible bit depth (e.g. from 5 bits/sample in the range [0,31]
 to 8 bits/sample in the range [0, 255]).  However, it is also possible
 to convert the PNG pixel data back to the original bit depth of the
 image.  This call reduces the pixels back down to the original bit depth:
 
     png_color_8p sig_bit;
 
     if (png_get_sBIT(png_ptr, info_ptr, &sig_bit))
-        png_set_shift(png_ptr, sig_bit);
+       png_set_shift(png_ptr, sig_bit);
 
 PNG files store 3-color pixels in red, green, blue order.  This code
 changes the storage of the pixels to blue, green, red:
 
     if (color_type == PNG_COLOR_TYPE_RGB ||
         color_type == PNG_COLOR_TYPE_RGB_ALPHA)
-        png_set_bgr(png_ptr);
+       png_set_bgr(png_ptr);
 
 PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them
 into 4 or 8 bytes for windowing systems that need them in this format:
 
     if (color_type == PNG_COLOR_TYPE_RGB)
-        png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE);
+       png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE);
 
 where "filler" is the 8 or 16-bit number to fill with, and the location is
 either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether
 you want the filler before the RGB or after.  This transformation
 does not affect images that already have full alpha channels.  To add an
 opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which
 will generate RGBA pixels.
 
 Note that png_set_filler() does not change the color type.  If you want
 to do that, you can add a true alpha channel with
 
     if (color_type == PNG_COLOR_TYPE_RGB ||
-           color_type == PNG_COLOR_TYPE_GRAY)
-    png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER);
+       color_type == PNG_COLOR_TYPE_GRAY)
+       png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER);
 
 where "filler" contains the alpha value to assign to each pixel.
 This function was added in libpng-1.2.7.
 
 If you are reading an image with an alpha channel, and you need the
 data as ARGB instead of the normal PNG format RGBA:
 
     if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
-        png_set_swap_alpha(png_ptr);
+       png_set_swap_alpha(png_ptr);
 
 For some uses, you may want a grayscale image to be represented as
 RGB.  This code will do that conversion:
 
     if (color_type == PNG_COLOR_TYPE_GRAY ||
         color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
-          png_set_gray_to_rgb(png_ptr);
+       png_set_gray_to_rgb(png_ptr);
 
 Conversely, you can convert an RGB or RGBA image to grayscale or grayscale
 with alpha.
 
     if (color_type == PNG_COLOR_TYPE_RGB ||
         color_type == PNG_COLOR_TYPE_RGB_ALPHA)
-          png_set_rgb_to_gray_fixed(png_ptr, error_action,
-             int red_weight, int green_weight);
+       png_set_rgb_to_gray(png_ptr, error_action, double red_weight,
+          double green_weight);
 
     error_action = 1: silently do the conversion
+
     error_action = 2: issue a warning if the original
                       image has any pixel where
                       red != green or red != blue
+
     error_action = 3: issue an error and abort the
                       conversion if the original
                       image has any pixel where
                       red != green or red != blue
 
-    red_weight:       weight of red component times 100000
-    green_weight:     weight of green component times 100000
+    red_weight:       weight of red component
+
+    green_weight:     weight of green component
                       If either weight is negative, default
-                      weights (21268, 71514) are used.
+                      weights are used.
+
+In the corresponding fixed point API the red_weight and green_weight values are
+simply scaled by 100,000:
+
+    png_set_rgb_to_gray(png_ptr, error_action, png_fixed_point red_weight,
+       png_fixed_point green_weight);
 
 If you have set error_action = 1 or 2, you can
 later check whether the image really was gray, after processing
 the image rows, with the png_get_rgb_to_gray_status(png_ptr) function.
 It will return a png_byte that is zero if the image was gray or
-1 if there were any non-gray pixels.  bKGD and sBIT data
+1 if there were any non-gray pixels.  Background and sBIT data
 will be silently converted to grayscale, using the green channel
-data, regardless of the error_action setting.
-
-With red_weight+green_weight<=100000,
-the normalized graylevel is computed:
-
-    int rw = red_weight * 65536;
-    int gw = green_weight * 65536;
-    int bw = 65536 - (rw + gw);
-    gray = (rw*red + gw*green + bw*blue)/65536;
-
-The default values approximate those recommended in the Charles
-Poynton's Color FAQ, <http://www.inforamp.net/~poynton/>
-Copyright (c) 1998-01-04 Charles Poynton <poynton at inforamp.net>
+data for sBIT, regardless of the error_action setting.
+
+The default values come from the PNG file cHRM chunk if present; otherwise, the
+defaults correspond to the ITU-R recommendation 709, and also the sRGB color
+space, as recommended in the Charles Poynton's Colour FAQ,
+<http://www.poynton.com/>, in section 9:
+
+   <http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC9>
+
+    Y = 0.2126 * R + 0.7152 * G + 0.0722 * B
+
+Previous versions of this document, 1998 through 2002, recommended a slightly
+different formula:
 
     Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
 
-Libpng approximates this with
-
-    Y = 0.21268 * R    + 0.7151 * G    + 0.07217 * B
-
-which can be expressed with integers as
-
-    Y = (6969 * R + 23434 * G + 2365 * B)/32768
+Libpng uses an integer approximation:
+
+    Y = (6968 * R + 23434 * G + 2366 * B)/32768
 
 The calculation is done in a linear colorspace, if the image gamma
-is known.
-
-If you have a grayscale and you are using png_set_expand_depth(),
-png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to
-a higher bit-depth, you must either supply the background color as a gray
-value at the original file bit-depth (need_expand = 1) or else supply the
-background color as an RGB triplet at the final, expanded bit depth
-(need_expand = 0).  Similarly, if you are reading a paletted image, you
-must either supply the background color as a palette index (need_expand = 1)
-or as an RGB triplet that may or may not be in the palette (need_expand = 0).
+can be determined.
+
+The png_set_background() function has been described already; it tells libpng to
+composite images with alpha or simple transparency against the supplied
+background color.  For compatibility with versions of libpng earlier than
+libpng-1.5.4 it is recommended that you call the function after reading the file
+header, even if you don't want to use the color in a bKGD chunk, if one exists.
+
+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 how the color is represented, both the format of the
+component values in the color (the number of bits) and the gamma encoding of the
+color.  The function takes two arguments, background_gamma_mode and need_expand
+to convey this information, however only two combinations are likely to be
+useful:
 
     png_color_16 my_background;
     png_color_16p image_background;
 
     if (png_get_bKGD(png_ptr, info_ptr, &image_background))
-        png_set_background(png_ptr, image_background,
-          PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
+       png_set_background(png_ptr, image_background,
+           PNG_BACKGROUND_GAMMA_FILE, 1/*needs to be expanded*/, 1);
     else
-        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
-to set the display gamma separately for each system is to check for a
-SCREEN_GAMMA or DISPLAY_GAMMA environment variable, which will hopefully be
-correctly set.
-
-Note that display_gamma is the overall gamma correction required to produce
-pleasing results, which depends on the lighting conditions in the surrounding
-environment.  In a dim or brightly lit room, no compensation other than
-the physical gamma exponent of the monitor is needed, while in a dark room
-a slightly smaller exponent is better.
-
-   double gamma, screen_gamma;
-
-   if (/* We have a user-defined screen
-       gamma value */)
-   {
-      screen_gamma = user_defined_screen_gamma;
-   }
-   /* One way that applications can share the same
-      screen gamma value */
-   else if ((gamma_str = getenv("SCREEN_GAMMA"))
-      != NULL)
-   {
-      screen_gamma = (double)atof(gamma_str);
-   }
-   /* If we don't have another value */
-   else
-   {
-      screen_gamma = 2.2; /* A good guess for a
-           PC monitor in a bright office or a dim room */
-      screen_gamma = 2.0; /* A good guess for a
-           PC monitor in a dark room */
-      screen_gamma = 1.7 or 1.0;  /* A good
-           guess for Mac systems */
-   }
-
-The png_set_gamma() function handles gamma transformations of the data.
-Pass both the file gamma and the current screen_gamma.  If the file does
-not have a gamma value, you can pass one anyway if you have an idea what
-it is (usually 0.45455 is a good guess for GIF images on PCs).  Note
-that file gammas are inverted from screen gammas.  See the discussions
-on gamma in the PNG specification for an excellent description of what
-gamma is, and why all applications should support it.  It is strongly
-recommended that PNG viewers support gamma correction.
-
-   if (png_get_gAMA(png_ptr, info_ptr, &gamma))
-      png_set_gamma(png_ptr, screen_gamma, gamma);
+       png_set_background(png_ptr, &my_background,
+           PNG_BACKGROUND_GAMMA_SCREEN, 0/*do not expand*/, 1);
+
+The second call was described above - my_background is in the format of the
+final, display, output produced by libpng.  Because you now know the format of
+the PNG it is possible to avoid the need to choose either 8-bit or 16-bit
+output and to retain palette images (the palette colors will be modified
+appropriately and the tRNS chunk removed.)  However, if you are doing this,
+take great care not to ask for transformations without checking first that
+they apply!
+
+In the first call the background color has the original bit depth and color type
+of the PNG file.  So, for palette images the color is supplied as a palette
+index and for low bit greyscale images the color is a reduced bit value in
+image_background->gray.
+
+If you didn't call png_set_gamma() before reading the file header, for example
+if you need your code to remain compatible with older versions of libpng prior
+to libpng-1.5.4, this is the place to call it.
+
+Do not call it if you called png_set_alpha_mode(); doing so will damage the
+settings put in place by png_set_alpha_mode().  (If png_set_alpha_mode() is
+supported then you can certainly do png_set_gamma() before reading the PNG
+header.)
+
+This API unconditionally sets the screen and file gamma values, so it will
+override the value in the PNG file unless it is called before the PNG file
+reading starts.  For this reason you must always call it with the PNG file
+value when you call it in this position:
+
+   if (png_get_gAMA(png_ptr, info_ptr, &file_gamma))
+      png_set_gamma(png_ptr, screen_gamma, file_gamma);
+
    else
       png_set_gamma(png_ptr, screen_gamma, 0.45455);
 
 If you need to reduce an RGB file to a paletted file, or if a paletted
 file has more entries then will fit on your screen, png_set_quantize()
-will do that.  Note that this is a simple match dither that merely
+will do that.  Note that this is a simple match quantization that merely
 finds the closest color available.  This should work fairly well with
-optimized palettes, and fairly badly with linear color cubes.  If you
-pass a palette that is larger then maximum_colors, the file will
+optimized palettes, but fairly badly with linear color cubes.  If you
+pass a palette that is larger than maximum_colors, the file will
 reduce the number of colors in the palette so it will fit into
-maximum_colors.  If there is a histogram, it will use it to make
+maximum_colors.  If there is a histogram, libpng will use it to make
 more intelligent choices when reducing the palette.  If there is no
 histogram, it may not do as good a job.
 
    if (color_type & PNG_COLOR_MASK_COLOR)
    {
       if (png_get_valid(png_ptr, info_ptr,
-         PNG_INFO_PLTE))
+          PNG_INFO_PLTE))
       {
          png_uint_16p histogram = NULL;
 
          png_get_hIST(png_ptr, info_ptr,
-            &histogram);
+             &histogram);
          png_set_quantize(png_ptr, palette, num_palette,
             max_screen_colors, histogram, 1);
       }
+
       else
       {
          png_color std_color_cube[MAX_SCREEN_COLORS] =
             { ... colors ... };
 
          png_set_quantize(png_ptr, std_color_cube,
             MAX_SCREEN_COLORS, MAX_SCREEN_COLORS,
             NULL,0);
@@ -1204,227 +1819,362 @@ The following code will reverse this (ma
 zero):
 
    if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY)
       png_set_invert_mono(png_ptr);
 
 This function can also be used to invert grayscale and gray-alpha images:
 
    if (color_type == PNG_COLOR_TYPE_GRAY ||
-        color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+       color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
       png_set_invert_mono(png_ptr);
 
-PNG files store 16 bit pixels in network byte order (big-endian,
+PNG files store 16-bit pixels in network byte order (big-endian,
 ie. most significant bits first).  This code changes the storage to the
 other way (little-endian, i.e. least significant bits first, the
 way PCs store them):
 
     if (bit_depth == 16)
-        png_set_swap(png_ptr);
+       png_set_swap(png_ptr);
 
 If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you
 need to change the order the pixels are packed into bytes, you can use:
 
     if (bit_depth < 8)
        png_set_packswap(png_ptr);
 
 Finally, you can write your own transformation function if none of
 the existing ones meets your needs.  This is done by setting a callback
 with
 
     png_set_read_user_transform_fn(png_ptr,
-       read_transform_fn);
+        read_transform_fn);
 
 You must supply the function
 
     void read_transform_fn(png_structp png_ptr, png_row_infop
         row_info, png_bytep data)
 
 See pngtest.c for a working example.  Your function will be called
-after all of the other transformations have been processed.
+after all of the other transformations have been processed.  Take care with
+interlaced images if you do the interlace yourself - the width of the row is the
+width in 'row_info', not the overall image width.
+
+If supported, libpng provides two information routines that you can use to find
+where you are in processing the image:
+
+   png_get_current_pass_number(png_structp png_ptr);
+   png_get_current_row_number(png_structp png_ptr);
+
+Don't try using these outside a transform callback - firstly they are only
+supported if user transforms are supported, secondly they may well return
+unexpected results unless the row is actually being processed at the moment they
+are called.
+
+With interlaced
+images the value returned is the row in the input sub-image image.  Use
+PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to
+find the output pixel (x,y) given an interlaced sub-image pixel (row,col,pass).
+
+The discussion of interlace handling above contains more information on how to
+use these values.
 
 You can also set up a pointer to a user structure for use by your
 callback function, and you can inform libpng that your transform
 function will change the number of channels or bit depth with the
 function
 
     png_set_user_transform_info(png_ptr, user_ptr,
-       user_depth, user_channels);
+        user_depth, user_channels);
 
 The user's application, not libpng, is responsible for allocating and
 freeing any memory required for the user structure.
 
 You can retrieve the pointer via the function
 png_get_user_transform_ptr().  For example:
 
     voidp read_user_transform_ptr =
-       png_get_user_transform_ptr(png_ptr);
+        png_get_user_transform_ptr(png_ptr);
 
 The last thing to handle is interlacing; this is covered in detail below,
 but you must call the function here if you want libpng to handle expansion
 of the interlaced image.
 
     number_of_passes = png_set_interlace_handling(png_ptr);
 
 After setting the transformations, libpng can update your png_info
 structure to reflect any transformations you've requested with this
-call.  This is most useful to update the info structure's rowbytes
+call.
+
+    png_read_update_info(png_ptr, info_ptr);
+
+This is most useful to update the info structure's rowbytes
 field so you can use it to allocate your image memory.  This function
 will also update your palette with the correct screen_gamma and
-background if these have been given with the calls above.
-
-    png_read_update_info(png_ptr, info_ptr);
+background if these have been given with the calls above.  You may
+only call png_read_update_info() once with a particular info_ptr.
 
 After you call png_read_update_info(), you can allocate any
 memory you need to hold the image.  The row data is simply
 raw byte data for all forms of images.  As the actual allocation
 varies among applications, no example will be given.  If you
 are allocating one large chunk, you will need to build an
 array of pointers to each row, as it will be needed for some
 of the functions below.
 
+Remember: Before you call png_read_update_info(), the png_get_*()
+functions return the values corresponding to the original PNG image.
+After you call png_read_update_info the values refer to the image
+that libpng will output.  Consequently you must call all the png_set_
+functions before you call png_read_update_info().  This is particularly
+important for png_set_interlace_handling() - if you are going to call
+png_read_update_info() you must call png_set_interlace_handling() before
+it unless you want to receive interlaced output.
+
 Reading image data
 
 After you've allocated memory, you can read the image data.
 The simplest way to do this is in one function call.  If you are
 allocating enough memory to hold the whole image, you can just
 call png_read_image() and libpng will read in all the image data
 and put it in the memory area supplied.  You will need to pass in
 an array of pointers to each row.
 
-This function automatically handles interlacing, so you don't need
-to call png_set_interlace_handling() or call this function multiple
-times, or any of that other stuff necessary with png_read_rows().
+This function automatically handles interlacing, so you don't
+need to call png_set_interlace_handling() (unless you call
+png_read_update_info()) or call this function multiple times, or any
+of that other stuff necessary with png_read_rows().
 
    png_read_image(png_ptr, row_pointers);
 
 where row_pointers is:
 
    png_bytep row_pointers[height];
 
 You can point to void or char or whatever you use for pixels.
 
 If you don't want to read in the whole image at once, you can
 use png_read_rows() instead.  If there is no interlacing (check
 interlace_type == PNG_INTERLACE_NONE), this is simple:
 
     png_read_rows(png_ptr, row_pointers, NULL,
-       number_of_rows);
+        number_of_rows);
 
 where row_pointers is the same as in the png_read_image() call.
 
 If you are doing this just one row at a time, you can do this with
 a single row_pointer instead of an array of row_pointers:
 
     png_bytep row_pointer = row;
     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)
-interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7)
-is a somewhat complicated 2D interlace scheme, known as Adam7, that
+interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7);
+a somewhat complicated 2D interlace scheme, known as Adam7, that
 breaks down an image into seven smaller images of varying size, based
-on an 8x8 grid.
+on an 8x8 grid.  This number is defined (from libpng 1.5) as
+PNG_INTERLACE_ADAM7_PASSES in png.h
 
 libpng can fill out those images or it can give them to you "as is".
-If you want them filled out, there are two ways to do that.  The one
+It is almost always better to have libpng handle the interlacing for you.
+If you want the images filled out, there are two ways to do that.  The one
 mentioned in the PNG specification is to expand each pixel to cover
 those pixels that have not been read yet (the "rectangle" method).
 This results in a blocky image for the first pass, which gradually
 smooths out as more pixels are read.  The other method is the "sparkle"
 method, where pixels are drawn only in their final locations, with the
 rest of the image remaining whatever colors they were initialized to
 before the start of the read.  The first method usually looks better,
 but tends to be slower, as there are more pixels to put in the rows.
 
-If you don't want libpng to handle the interlacing details, just call
-png_read_rows() seven times to read in all seven images.  Each of the
-images is a valid image by itself, or they can all be combined on an
-8x8 grid to form a single image (although if you intend to combine them
-you would be far better off using the libpng interlace handling).
-
-The first pass will return an image 1/8 as wide as the entire image
-(every 8th column starting in column 0) and 1/8 as high as the original
-(every 8th row starting in row 0), the second will be 1/8 as wide
-(starting in column 4) and 1/8 as high (also starting in row 0).  The
-third pass will be 1/4 as wide (every 4th pixel starting in column 0) and
-1/8 as high (every 8th row starting in row 4), and the fourth pass will
-be 1/4 as wide and 1/4 as high (every 4th column starting in column 2,
-and every 4th row starting in row 0).  The fifth pass will return an
-image 1/2 as wide, and 1/4 as high (starting at column 0 and row 2),
-while the sixth pass will be 1/2 as wide and 1/2 as high as the original
-(starting in column 1 and row 0).  The seventh and final pass will be as
-wide as the original, and 1/2 as high, containing all of the odd
-numbered scanlines.  Phew!
-
-If you want libpng to expand the images, call this before calling
-png_start_read_image() or png_read_update_info():
+If, as is likely, you want libpng to expand the images, call this before
+calling png_start_read_image() or png_read_update_info():
 
     if (interlace_type == PNG_INTERLACE_ADAM7)
-        number_of_passes
+       number_of_passes
            = png_set_interlace_handling(png_ptr);
 
-This will return the number of passes needed.  Currently, this
-is seven, but may change if another interlace type is added.
-This function can be called even if the file is not interlaced,
-where it will return one pass.
+This will return the number of passes needed.  Currently, this is seven,
+but may change if another interlace type is added.  This function can be
+called even if the file is not interlaced, where it will return one pass.
+You then need to read the whole image 'number_of_passes' times.  Each time
+will distribute the pixels from the current pass to the correct place in
+the output image, so you need to supply the same rows to png_read_rows in
+each pass.
 
 If you are not going to display the image after each pass, but are
 going to wait until the entire image is read in, use the sparkle
 effect.  This effect is faster and the end result of either method
 is exactly the same.  If you are planning on displaying the image
 after each pass, the "rectangle" effect is generally considered the
 better looking one.
 
 If you only want the "sparkle" effect, just call png_read_rows() as
 normal, with the third parameter NULL.  Make sure you make pass over
 the image number_of_passes times, and you don't change the data in the
 rows between calls.  You can change the locations of the data, just
 not the data.  Each pass only writes the pixels appropriate for that
 pass, and assumes the data from previous passes is still valid.
 
     png_read_rows(png_ptr, row_pointers, NULL,
-       number_of_rows);
+        number_of_rows);
 
 If you only want the first effect (the rectangles), do the same as
 before except pass the row buffer in the third parameter, and leave
 the second parameter NULL.
 
     png_read_rows(png_ptr, NULL, row_pointers,
-       number_of_rows);
+        number_of_rows);
+
+If you don't want libpng to handle the interlacing details, just call
+png_read_rows() PNG_INTERLACE_ADAM7_PASSES times to read in all the images.
+Each of the images is a valid image by itself, however you will almost
+certainly need to distribute the pixels from each sub-image to the
+correct place.  This is where everything gets very tricky.
+
+If you want to retrieve the separate images you must pass the correct
+number of rows to each successive call of png_read_rows().  The calculation
+gets pretty complicated for small images, where some sub-images may
+not even exist because either their width or height ends up zero.
+libpng provides two macros to help you in 1.5 and later versions:
+
+   png_uint_32 width = PNG_PASS_COLS(image_width, pass_number);
+   png_uint_32 height = PNG_PASS_ROWS(image_height, pass_number);
+
+Respectively these tell you the width and height of the sub-image
+corresponding to the numbered pass.  'pass' is in in the range 0 to 6 -
+this can be confusing because the specification refers to the same passes
+as 1 to 7!  Be careful, you must check both the width and height before
+calling png_read_rows() and not call it for that pass if either is zero.
+
+You can, of course, read each sub-image row by row.  If you want to
+produce optimal code to make a pixel-by-pixel transformation of an
+interlaced image this is the best approach; read each row of each pass,
+transform it, and write it out to a new interlaced image.
+
+If you want to de-interlace the image yourself libpng provides further
+macros to help that tell you where to place the pixels in the output image.
+Because the interlacing scheme is rectangular - sub-image pixels are always
+arranged on a rectangular grid - all you need to know for each pass is the
+starting column and row in the output image of the first pixel plus the
+spacing between each pixel.  As of libpng 1.5 there are four macros to
+retrieve this information:
+
+   png_uint_32 x = PNG_PASS_START_COL(pass);
+   png_uint_32 y = PNG_PASS_START_ROW(pass);
+   png_uint_32 xStep = 1U << PNG_PASS_COL_SHIFT(pass);
+   png_uint_32 yStep = 1U << PNG_PASS_ROW_SHIFT(pass);
+
+These allow you to write the obvious loop:
+
+   png_uint_32 input_y = 0;
+   png_uint_32 output_y = PNG_PASS_START_ROW(pass);
+
+   while (output_y < output_image_height)
+   {
+      png_uint_32 input_x = 0;
+      png_uint_32 output_x = PNG_PASS_START_COL(pass);
+
+      while (output_x < output_image_width)
+      {
+         image[output_y][output_x] =
+             subimage[pass][input_y][input_x++];
+
+         output_x += xStep;
+      }
+
+      ++input_y;
+      output_y += yStep;
+   }
+
+Notice that the steps between successive output rows and columns are
+returned as shifts.  This is possible because the pixels in the subimages
+are always a power of 2 apart - 1, 2, 4 or 8 pixels - in the original
+image.  In practice you may need to directly calculate the output coordinate
+given an input coordinate.  libpng provides two further macros for this
+purpose:
+
+   png_uint_32 output_x = PNG_COL_FROM_PASS_COL(input_x, pass);
+   png_uint_32 output_y = PNG_ROW_FROM_PASS_ROW(input_y, pass);
+
+Finally a pair of macros are provided to tell you if a particular image
+row or column appears in a given pass:
+
+   int col_in_pass = PNG_COL_IN_INTERLACE_PASS(output_x, pass);
+   int row_in_pass = PNG_ROW_IN_INTERLACE_PASS(output_y, pass);
+
+Bear in mind that you will probably also need to check the width and height
+of the pass in addition to the above to be sure the pass even exists!
+
+With any luck you are convinced by now that you don't want to do your own
+interlace handling.  In reality normally the only good reason for doing this
+is if you are processing PNG files on a pixel-by-pixel basis and don't want
+to load the whole file into memory when it is interlaced.
+
+libpng includes a test program, pngvalid, that illustrates reading and
+writing of interlaced images.  If you can't get interlacing to work in your
+code and don't want to leave it to libpng (the recommended approach), see
+how pngvalid.c does it.
 
 Finishing a sequential read
 
 After you are finished reading the image through the
 low-level interface, you can finish reading the file.  If you are
 interested in comments or time, which may be stored either before or
 after the image data, you should pass the separate png_info struct if
 you want to keep the comments from before and after the image
-separate.  If you are not interested, you can pass NULL.
+separate.
+
+    png_infop end_info = png_create_info_struct(png_ptr);
+
+    if (!end_info)
+    {
+       png_destroy_read_struct(&png_ptr, &info_ptr,
+           (png_infopp)NULL);
+       return (ERROR);
+    }
 
    png_read_end(png_ptr, end_info);
 
+If you are not interested, you should still call png_read_end()
+but you can pass NULL, avoiding the need to create an end_info structure.
+
+   png_read_end(png_ptr, (png_infop)NULL);
+
+If you don't call png_read_end(), then your file pointer will be
+left pointing to the first chunk after the last IDAT, which is probably
+not what you want if you expect to read something beyond the end of
+the PNG datastream.
+
 When you are done, you can free all memory allocated by libpng like this:
 
    png_destroy_read_struct(&png_ptr, &info_ptr,
        &end_info);
 
+or, if you didn't create an end_info structure,
+
+   png_destroy_read_struct(&png_ptr, &info_ptr,
+       (png_infopp)NULL);
+
 It is also possible to individually free the info_ptr members that
 point to libpng-allocated storage with the following function:
 
     png_free_data(png_ptr, info_ptr, mask, seq)
+
     mask - identifies data to be freed, a mask
            containing the bitwise OR of one or
            more of
              PNG_FREE_PLTE, PNG_FREE_TRNS,
              PNG_FREE_HIST, PNG_FREE_ICCP,
              PNG_FREE_PCAL, PNG_FREE_ROWS,
              PNG_FREE_SCAL, PNG_FREE_SPLT,
              PNG_FREE_TEXT, PNG_FREE_UNKN,
            or simply PNG_FREE_ALL
+
     seq  - sequence number of item to be freed
            (-1 for all items)
 
 This function may be safely called when the relevant storage has
 already been freed, or has not yet been allocated, or was allocated
 by the user and not by libpng,  and will in those cases do nothing.
 The "seq" parameter is ignored if only one item of the selected data
 type, such as PLTE, is allowed.  If "seq" is not -1, and multiple items
@@ -1432,23 +2182,25 @@ are allowed for the data type identified
 sPLT, only the n'th item in the structure is freed, where n is "seq".
 
 The default behavior is only to free data that was allocated internally
 by libpng.  This can be changed, so that libpng will not free the data,
 or so that it will free data that was allocated by the user with png_malloc()
 or png_zalloc() and passed in via a png_set_*() function, with
 
     png_data_freer(png_ptr, info_ptr, freer, mask)
-    mask   - which data elements are affected
-             same choices as in png_free_data()
+
     freer  - one of
                PNG_DESTROY_WILL_FREE_DATA
                PNG_SET_WILL_FREE_DATA
                PNG_USER_WILL_FREE_DATA
 
+    mask   - which data elements are affected
+             same choices as in png_free_data()
+
 This function only affects data that has already been allocated.
 You can call this function after reading the PNG data but before calling
 any png_set_*() functions, to control whether the user or the png_set_*()
 function is responsible for freeing any existing data that might be present,
 and again after the png_set_*() functions to control whether the user
 or png_destroy_*() is supposed to free the data.  When the user assumes
 responsibility for libpng-allocated data, the application must use
 png_free() to free it, and when the user transfers responsibility to libpng
@@ -1467,16 +2219,17 @@ the key member, and png_free_data() will
 if you transfer responsibility for free'ing text_ptr from libpng to your
 application, your application must not separately free those members.
 
 The png_free_data() function will turn off the "valid" flag for anything
 it frees.  If you need to turn the flag off for a chunk that was freed by
 your application instead of by libpng, you can use
 
     png_set_invalid(png_ptr, info_ptr, mask);
+
     mask - identifies the chunks to be made invalid,
            containing the bitwise OR of one or
            more of
              PNG_INFO_gAMA, PNG_INFO_sBIT,
              PNG_INFO_cHRM, PNG_INFO_PLTE,
              PNG_INFO_tRNS, PNG_INFO_bKGD,
              PNG_INFO_hIST, PNG_INFO_pHYs,
              PNG_INFO_oFFs, PNG_INFO_tIME,
@@ -1506,31 +2259,34 @@ png_infop info_ptr;
      initialize the progressive reader in your
      application. */
  int
  initialize_png_reader()
  {
     png_ptr = png_create_read_struct
         (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
          user_error_fn, user_warning_fn);
+
     if (!png_ptr)
         return (ERROR);
+
     info_ptr = png_create_info_struct(png_ptr);
+
     if (!info_ptr)
     {
-        png_destroy_read_struct(&png_ptr, (png_infopp)NULL,
-           (png_infopp)NULL);
-        return (ERROR);
+       png_destroy_read_struct(&png_ptr,
+          (png_infopp)NULL, (png_infopp)NULL);
+       return (ERROR);
     }
 
     if (setjmp(png_jmpbuf(png_ptr)))
     {
-        png_destroy_read_struct(&png_ptr, &info_ptr,
-           (png_infopp)NULL);
-        return (ERROR);
+       png_destroy_read_struct(&png_ptr, &info_ptr,
+          (png_infopp)NULL);
+       return (ERROR);
     }
 
     /* This one's new.  You can provide functions
        to be called when the header info is valid,
        when each row is completed, and when the image
        is finished.  If you aren't using all functions,
        you can specify NULL parameters.  Even when all
        three functions are NULL, you need to call
@@ -1552,35 +2308,41 @@ png_infop info_ptr;
 
  /* A code fragment that you call as you receive blocks
    of data */
  int
  process_data(png_bytep buffer, png_uint_32 length)
  {
     if (setjmp(png_jmpbuf(png_ptr)))
     {
-        png_destroy_read_struct(&png_ptr, &info_ptr,
+       png_destroy_read_struct(&png_ptr, &info_ptr,
            (png_infopp)NULL);
-        return (ERROR);
+       return (ERROR);
     }
 
     /* This one's new also.  Simply give it a chunk
        of data from the file stream (in order, of
        course).  On machines with segmented memory
        models machines, don't give it any more than
        64K.  The library seems to run fine with sizes
        of 4K. Although you can give it much less if
        necessary (I assume you can give it chunks of
        1 byte, I haven't tried less then 256 bytes
        yet).  When this function returns, you may
        want to display any rows that were generated
        in the row callback if you don't already do
        so there.
      */
     png_process_data(png_ptr, info_ptr, buffer, length);
+
+    /* At this point you can call png_process_data_skip if
+       you want to handle data the library will skip yourself;
+       it simply returns the number of bytes to skip (and stops
+       libpng skipping that number of bytes on the next
+       png_process_data call).
     return 0;
  }
 
  /* This function is called (as set by
     png_set_progressive_read_fn() above) when enough data
     has been supplied so all of the header has been
     read.
  */
@@ -1591,16 +2353,29 @@ png_infop info_ptr;
        the transformations mentioned in the Reading
        PNG files section.  For now, you _must_ call
        either png_start_read_image() or
        png_read_update_info() after all the
        transformations are set (even if you don't set
        any).  You may start getting rows before
        png_process_data() returns, so this is your
        last chance to prepare for that.
+
+       This is where you turn on interlace handling,
+       assuming you don't want to do it yourself.
+
+       If you need to you can stop the processing of
+       your original input data at this point by calling
+       png_process_data_pause.  This returns the number
+       of unprocessed bytes from the last png_process_data
+       call - it is up to you to ensure that the next call
+       sees these bytes again.  If you don't want to bother
+       with this you can get libpng to cache the unread
+       bytes by setting the 'save' parameter (see png.h) but
+       then libpng will have to copy the data internally.
      */
  }
 
  /* This function is called when each row of image
     data is complete */
  void
  row_callback(png_structp png_ptr, png_bytep new_row,
     png_uint_32 row_num, int pass)
@@ -1611,37 +2386,48 @@ png_infop info_ptr;
        of these rows will not be changed from the
        previous pass.  When the row is not changed,
        the new_row variable will be NULL.  The rows
        and passes are called in order, so you don't
        really need the row_num and pass, but I'm
        supplying them because it may make your life
        easier.
 
-       For the non-NULL rows of interlaced images,
+       If you did not turn on interlace handling then
+       the callback is called for each row of each
+       sub-image when the image is interlaced.  In this
+       case 'row_num' is the row in the sub-image, not
+       the row in the output image as it is in all other
+       cases.
+
+       For the non-NULL rows of interlaced images when
+       you have switched on libpng interlace handling,
        you must call png_progressive_combine_row()
        passing in the row and the old row.  You can
        call this function for NULL rows (it will just
        return) and for non-interlaced images (it just
        does the memcpy for you) if it will make the
        code easier.  Thus, you can just do this for
-       all cases:
+       all cases if you switch on interlace handling;
      */
 
         png_progressive_combine_row(png_ptr, old_row,
           new_row);
 
     /* where old_row is what was displayed for
        previously for the row.  Note that the first
        pass (pass == 0, really) will completely cover
        the old row, so the rows do not have to be
        initialized.  After the first pass (and only
        for interlaced images), you will have to pass
        the current row, and the function will combine
        the old row and the new row.
+
+       You can also call png_process_data_pause in this
+       callback - see above.
     */
  }
 
  void
  end_callback(png_structp png_ptr, png_infop info)
  {
     /* This function is called after the whole image
        has been read, including any chunks after the
@@ -1666,40 +2452,40 @@ back up in the reading section to unders
 Setup
 
 You will want to do the I/O initialization before you get into libpng,
 so if it doesn't work, you don't have anything to undo. If you are not
 using the standard I/O functions, you will need to replace them with
 custom writing functions.  See the discussion under Customizing libpng.
 
     FILE *fp = fopen(file_name, "wb");
+
     if (!fp)
-    {
        return (ERROR);
-    }
 
 Next, png_struct and png_info need to be allocated and initialized.
 As these can be both relatively large, you may not want to store these
 on the stack, unless you have stack space to spare.  Of course, you
 will want to check if they return NULL.  If you are also reading,
 you won't want to name your read structure and your write structure
 both "png_ptr"; you can call them anything you like, such as
 "read_ptr" and "write_ptr".  Look at pngtest.c, for example.
 
     png_structp png_ptr = png_create_write_struct
        (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
         user_error_fn, user_warning_fn);
+
     if (!png_ptr)
        return (ERROR);
 
     png_infop info_ptr = png_create_info_struct(png_ptr);
     if (!info_ptr)
     {
        png_destroy_write_struct(&png_ptr,
-         (png_infopp)NULL);
+           (png_infopp)NULL);
        return (ERROR);
     }
 
 If you want to use your own memory allocation routines,
 define PNG_USER_MEM_SUPPORTED and use
 png_create_write_struct_2() instead of png_create_write_struct():
 
     png_structp png_ptr = png_create_write_struct_2
@@ -1715,17 +2501,17 @@ write the file from different routines, 
 the png_jmpbuf(png_ptr) every time you enter a new routine that will
 call a png_*() function.  See your documentation of setjmp/longjmp
 for your compiler for more information on setjmp/longjmp.  See
 the discussion on libpng error handling in the Customizing Libpng
 section below for more information on the libpng error handling.
 
     if (setjmp(png_jmpbuf(png_ptr)))
     {
-       png_destroy_write_struct(&png_ptr, &info_ptr);
+    png_destroy_write_struct(&png_ptr, &info_ptr);
        fclose(fp);
        return (ERROR);
     }
     ...
     return;
 
 If you would rather avoid the complexity of setjmp/longjmp issues,
 you can compile libpng with PNG_NO_SETJMP, in which case
@@ -1766,16 +2552,30 @@ You must supply a function
     }
 
 (You can give it another name that you like instead of "write_row_callback")
 
 To inform libpng about your function, use
 
     png_set_write_status_fn(png_ptr, write_row_callback);
 
+When this function is called the row has already been completely processed and
+it has also been written out.  The 'row' and 'pass' refer to the next row to be
+handled.  For the
+non-interlaced case the row that was just handled is simply one less than the
+passed in row number, and pass will always be 0.  For the interlaced case the
+same applies unless the row value is 0, in which case the row just handled was
+the last one from one of the preceding passes.  Because interlacing may skip a
+pass you cannot be sure that the preceding pass is just 'pass-1', if you really
+need to know what the last pass is record (row,pass) from the callback and use
+the last recorded value each time.
+
+As with the user transform you can find the output row using the
+PNG_ROW_FROM_PASS_ROW macro.
+
 You now have the option of modifying how the compression library will
 run.  The following functions are mainly for testing, but may be useful
 in some cases, like if you need to write PNG files extremely fast and
 are willing to give up some compression, or if you want to get the
 maximum possible compression at the expense of slower writing.  If you
 have no special needs in this area, let the library do what it wants by
 not calling this function at all, as it has been tuned to deliver a good
 speed/compression ratio. The second parameter to png_set_filter() is
@@ -1785,54 +2585,64 @@ a PNG datastream that is to be embedded 
 parameter is a flag that indicates which filter type(s) are to be tested
 for each scanline.  See the PNG specification for details on the specific
 filter types.
 
 
     /* turn on or off filtering, and/or choose
        specific filters.  You can use either a single
        PNG_FILTER_VALUE_NAME or the bitwise OR of one
-       or more PNG_FILTER_NAME masks. */
+       or more PNG_FILTER_NAME masks.
+     */
     png_set_filter(png_ptr, 0,
        PNG_FILTER_NONE  | PNG_FILTER_VALUE_NONE |
        PNG_FILTER_SUB   | PNG_FILTER_VALUE_SUB  |
        PNG_FILTER_UP    | PNG_FILTER_VALUE_UP   |
        PNG_FILTER_AVG   | PNG_FILTER_VALUE_AVG  |
        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.
+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.
 
 If you are writing a PNG datastream that is to be embedded in a MNG
 datastream, the second parameter can be either 0 or 64.
 
 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 (zlib.h and algorithm.txt, distributed
 with zlib) for details on the compression levels.
 
-    /* set the zlib compression level */
+    #include zlib.h
+
+    /* Set the zlib compression level */
     png_set_compression_level(png_ptr,
         Z_BEST_COMPRESSION);
 
-    /* set other zlib parameters */
+    /* Set other zlib parameters for compressing IDAT */
     png_set_compression_mem_level(png_ptr, 8);
     png_set_compression_strategy(png_ptr,
         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)
+    /* Set zlib parameters for text compression
+     * If you don't call these, the parameters
+     * fall back on those defined for IDAT chunks
+     */
+    png_set_text_compression_mem_level(png_ptr, 8);
+    png_set_text_compression_strategy(png_ptr,
+        Z_DEFAULT_STRATEGY);
+    png_set_text_compression_window_bits(png_ptr, 15);
+    png_set_text_compression_method(png_ptr, 8);
 
 Setting the contents of info for output
 
 You now need to fill in the png_info structure with all the data you
 wish to write before the actual image.  Note that the only thing you
 are allowed to write after the image is the text chunks and the time
 chunk (as of PNG Specification 1.2, anyway).  See png_write_end() and
 the latest PNG specification for more information on that.  If you
@@ -1842,26 +2652,30 @@ fill them until png_write_end().  For al
 their data types, see png.h.  For explanations of what the fields
 contain, see the PNG specification.
 
 Some of the more important parts of the png_info are:
 
     png_set_IHDR(png_ptr, info_ptr, width, height,
        bit_depth, color_type, interlace_type,
        compression_type, filter_method)
+
     width          - holds the width of the image
                      in pixels (up to 2^31).
+
     height         - holds the height of the image
                      in pixels (up to 2^31).
+
     bit_depth      - holds the bit depth of one of the
                      image channels.
                      (valid values are 1, 2, 4, 8, 16
                      and depend also on the
                      color_type.  See also significant
                      bits (sBIT) below).
+
     color_type     - describes which color/alpha
                      channels are present.
                      PNG_COLOR_TYPE_GRAY
                         (bit depths 1, 2, 4, 8, 16)
                      PNG_COLOR_TYPE_GRAY_ALPHA
                         (bit depths 8, 16)
                      PNG_COLOR_TYPE_PALETTE
                         (bit depths 1, 2, 4, 8)
@@ -1871,18 +2685,20 @@ Some of the more important parts of the 
                         (bit_depths 8, 16)
 
                      PNG_COLOR_MASK_PALETTE
                      PNG_COLOR_MASK_COLOR
                      PNG_COLOR_MASK_ALPHA
 
     interlace_type - PNG_INTERLACE_NONE or
                      PNG_INTERLACE_ADAM7
+
     compression_type - (must be
                      PNG_COMPRESSION_TYPE_DEFAULT)
+
     filter_method  - (must be PNG_FILTER_TYPE_DEFAULT
                      or, if you are writing a PNG to
                      be embedded in a MNG datastream,
                      can also be
                      PNG_INTRAPIXEL_DIFFERENCING)
 
 If you call png_set_IHDR(), the call must appear before any of the
 other png_set_*() functions, because they might require access to some of
@@ -1890,25 +2706,54 @@ the IHDR settings.  The remaining png_se
 in any order.
 
 If you wish, you can reset the compression_type, interlace_type, or
 filter_method later by calling png_set_IHDR() again; if you do this, the
 width, height, bit_depth, and color_type must be the same in each call.
 
     png_set_PLTE(png_ptr, info_ptr, palette,
        num_palette);
+
     palette        - the palette for the file
                      (array of png_color)
     num_palette    - number of entries in the palette
 
-    png_set_gAMA(png_ptr, info_ptr, gamma);
-    gamma          - the gamma the image was created
-                     at (PNG_INFO_gAMA)
+    png_set_gAMA(png_ptr, info_ptr, file_gamma);
+    png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma);
+
+    file_gamma     - the gamma at which the image was
+                     created (PNG_INFO_gAMA)
+
+    int_file_gamma - 100,000 times the gamma at which
+                     the image was created
+
+    png_set_cHRM(png_ptr, info_ptr,  white_x, white_y, red_x, red_y,
+                     green_x, green_y, blue_x, blue_y)
+    png_set_cHRM_XYZ(png_ptr, info_ptr, red_X, red_Y, red_Z, green_X,
+                     green_Y, green_Z, blue_X, blue_Y, blue_Z)
+    png_set_cHRM_fixed(png_ptr, info_ptr, int_white_x, int_white_y,
+                     int_red_x, int_red_y, int_green_x, int_green_y,
+                     int_blue_x, int_blue_y)
+    png_set_cHRM_XYZ_fixed(png_ptr, info_ptr, int_red_X, int_red_Y,
+                     int_red_Z, int_green_X, int_green_Y, int_green_Z,
+                     int_blue_X, int_blue_Y, int_blue_Z)
+
+    {white,red,green,blue}_{x,y}
+                     A color space encoding specified using the chromaticities
+                     of the end points and the white point.
+
+    {red,green,blue}_{X,Y,Z}
+                     A color space encoding specified using the encoding end
+                     points - the CIE tristimulus specification of the intended
+                     color of the red, green and blue channels in the PNG RGB
+                     data.  The white point is simply the sum of the three end
+                     points.
 
     png_set_sRGB(png_ptr, info_ptr, srgb_intent);
+
     srgb_intent    - the rendering intent
                      (PNG_INFO_sRGB) The presence of
                      the sRGB chunk means that the pixel
                      data is in the sRGB color space.
                      This chunk also implies specific
                      values of gAMA and cHRM.  Rendering
                      intent is the CSS-1 property that
                      has been defined by the International
@@ -1918,69 +2763,83 @@ width, height, bit_depth, and color_type
                      PNG_sRGB_INTENT_SATURATION,
                      PNG_sRGB_INTENT_PERCEPTUAL,
                      PNG_sRGB_INTENT_ABSOLUTE, or
                      PNG_sRGB_INTENT_RELATIVE.
 
 
     png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr,
        srgb_intent);
+
     srgb_intent    - the rendering intent
                      (PNG_INFO_sRGB) The presence of the
                      sRGB chunk means that the pixel
                      data is in the sRGB color space.
                      This function also causes gAMA and
                      cHRM chunks with the specific values
                      that are consistent with sRGB to be
                      written.
 
     png_set_iCCP(png_ptr, info_ptr, name, compression_type,
-                      profile, proflen);
+                       profile, proflen);
+
     name             - The profile name.
+
     compression_type - The compression type; always
                        PNG_COMPRESSION_TYPE_BASE for PNG 1.0.
                        You may give NULL to this argument to
                        ignore it.
+
     profile          - International Color Consortium color
                        profile data. May contain NULs.
+
     proflen          - length of profile data in bytes.
 
     png_set_sBIT(png_ptr, info_ptr, sig_bit);
+
     sig_bit        - the number of significant bits for
                      (PNG_INFO_sBIT) each of the gray, red,
                      green, and blue channels, whichever are
                      appropriate for the given color type
                      (png_color_16)
 
     png_set_tRNS(png_ptr, info_ptr, trans_alpha,
        num_trans, trans_color);
+
     trans_alpha    - array of alpha (transparency)
                      entries for palette (PNG_INFO_tRNS)
+
+    num_trans      - number of transparent entries
+                     (PNG_INFO_tRNS)
+
     trans_color    - graylevel or color sample values
                      (in order red, green, blue) of the
                      single transparent color for
                      non-paletted images (PNG_INFO_tRNS)
-    num_trans      - number of transparent entries
-                     (PNG_INFO_tRNS)
 
     png_set_hIST(png_ptr, info_ptr, hist);
-                    (PNG_INFO_hIST)
+
     hist           - histogram of palette (array of
-                     png_uint_16)
+                     png_uint_16) (PNG_INFO_hIST)
 
     png_set_tIME(png_ptr, info_ptr, mod_time);
+
     mod_time       - time image was last modified
                      (PNG_VALID_tIME)
 
     png_set_bKGD(png_ptr, info_ptr, background);
-    background     - background color (PNG_VALID_bKGD)
+
+    background     - background color (of type
+                     png_color_16p) (PNG_VALID_bKGD)
 
     png_set_text(png_ptr, info_ptr, text_ptr, num_text);
+
     text_ptr       - array of png_text holding image
                      comments
+
     text_ptr[i].compression - type of compression used
                  on "text" PNG_TEXT_COMPRESSION_NONE
                            PNG_TEXT_COMPRESSION_zTXt
                            PNG_ITXT_COMPRESSION_NONE
                            PNG_ITXT_COMPRESSION_zTXt
     text_ptr[i].key   - keyword for comment.  Must contain
                  1-79 characters.
     text_ptr[i].text  - text comments for current
@@ -1988,61 +2847,82 @@ width, height, bit_depth, and color_type
     text_ptr[i].text_length - length of text string,
                  after decompression, 0 for iTXt
     text_ptr[i].itxt_length - length of itxt string,
                  after decompression, 0 for tEXt/zTXt
     text_ptr[i].lang  - language of comment (NULL or
                          empty for unknown).
     text_ptr[i].translated_keyword  - keyword in UTF-8 (NULL
                          or empty for unknown).
+
     Note that the itxt_length, lang, and lang_key
-    members of the text_ptr structure only exist
-    when the library is built with iTXt chunk support.
+    members of the text_ptr structure only exist when the
+    library is built with iTXt chunk support.  Prior to
+    libpng-1.4.0 the library was built by default without
+    iTXt support. Also note that when iTXt is supported,
+    they contain NULL pointers when the "compression"
+    field contains PNG_TEXT_COMPRESSION_NONE or
+    PNG_TEXT_COMPRESSION_zTXt.
 
     num_text       - number of comments
 
     png_set_sPLT(png_ptr, info_ptr, &palette_ptr,
        num_spalettes);
+
     palette_ptr    - array of png_sPLT_struct structures
                      to be added to the list of palettes
                      in the info structure.
     num_spalettes  - number of palette structures to be
                      added.
 
     png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y,
         unit_type);
+
     offset_x  - positive offset from the left
                      edge of the screen
+
     offset_y  - positive offset from the top
                      edge of the screen
+
     unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
 
     png_set_pHYs(png_ptr, info_ptr, res_x, res_y,
         unit_type);
+
     res_x       - pixels/unit physical resolution
                   in x direction
+
     res_y       - pixels/unit physical resolution
                   in y direction
+
     unit_type   - PNG_RESOLUTION_UNKNOWN,
                   PNG_RESOLUTION_METER
 
     png_set_sCAL(png_ptr, info_ptr, unit, width, height)
+
     unit        - physical scale units (an integer)
+
     width       - width of a pixel in physical scale units
+
     height      - height of a pixel in physical scale units
                   (width and height are doubles)
 
     png_set_sCAL_s(png_ptr, info_ptr, unit, width, height)
+
     unit        - physical scale units (an integer)
+
     width       - width of a pixel in physical scale units
+                  expressed as a string
+
     height      - height of a pixel in physical scale units
                  (width and height are strings like "2.54")
 
     png_set_unknown_chunks(png_ptr, info_ptr, &unknowns,
        num_unknowns)
+
     unknowns          - array of png_unknown_chunk
                         structures holding unknown chunks
     unknowns[i].name  - name of unknown chunk
     unknowns[i].data  - data of unknown chunk
     unknowns[i].size  - size of unknown chunk's data
     unknowns[i].location - position to write chunk in file
                            0: do not write chunk
                            PNG_HAVE_IHDR: before PLTE
@@ -2067,35 +2947,44 @@ The compression types have the same vali
 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 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.
+Until text gets around a few hundred bytes, it is not worth compressing it.
 After the text has been written out to the file, the compression type
 is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR,
 so that it isn't written out again at the end (in case you are calling
-png_write_end() with the same struct.
+png_write_end() with the same struct).
 
 The keywords that are given in the PNG Specification are:
 
     Title            Short (one line) title or
                      caption for image
+
     Author           Name of image's creator
+
     Description      Description of image (possibly long)
+
     Copyright        Copyright notice
+
     Creation Time    Time of original image creation
                      (usually RFC 1123 format, see below)
+
     Software         Software used to create the image
+
     Disclaimer       Legal disclaimer
+
     Warning          Warning of nature of content
+
     Source           Device used to create the image
+
     Comment          Miscellaneous comment; conversion
                      from other image format
 
 The keyword-text pairs work like this.  Keywords should be short
 simple descriptions of what the comment is about.  Some typical
 keywords are found in the PNG specification, as is some recommendations
 on keywords.  You can repeat keywords in a file.  You can even write
 some text before the image and some after.  For example, you may want
@@ -2255,39 +3144,41 @@ correctly pack the pixels into a single 
 
 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 recover the original data if desired.
 
     /* Set the true bit depth of the image data */
     if (color_type & PNG_COLOR_MASK_COLOR)
     {
-        sig_bit.red = true_bit_depth;
-        sig_bit.green = true_bit_depth;
-        sig_bit.blue = true_bit_depth;
+       sig_bit.red = true_bit_depth;
+       sig_bit.green = true_bit_depth;
+       sig_bit.blue = true_bit_depth;
     }
+
     else
     {
-        sig_bit.gray = true_bit_depth;
+       sig_bit.gray = true_bit_depth;
     }
+
     if (color_type & PNG_COLOR_MASK_ALPHA)
     {
-        sig_bit.alpha = true_bit_depth;
+       sig_bit.alpha = true_bit_depth;
     }
 
     png_set_sBIT(png_ptr, info_ptr, &sig_bit);
 
 If the data is stored in the row buffer in a bit depth other than
 one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG),
 this will scale the values to appear to be the correct bit depth as
 is required by PNG.
 
     png_set_shift(png_ptr, &sig_bit);