[devel] Added const_png_structp and const_png_infop types, and used them in

prototypes for most png_get_*() functions.
diff --git a/ANNOUNCE b/ANNOUNCE
index f6449de..1a7cba5 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,5 +1,5 @@
 
-Libpng 1.5.1rc01 - January 21, 2011
+Libpng 1.5.1beta07 - January 22, 2011
 
 This is not intended to be a public release.  It will be replaced
 within a few weeks by a public version or by another test version.
@@ -9,20 +9,20 @@
 Source files with LF line endings (for Unix/Linux) and with a
 "configure" script
 
-   1.5.1rc01.tar.xz (LZMA-compressed, recommended)
-   1.5.1rc01.tar.gz
-   1.5.1rc01.tar.bz2
+   1.5.1beta07.tar.xz (LZMA-compressed, recommended)
+   1.5.1beta07.tar.gz
+   1.5.1beta07.tar.bz2
 
 Source files with CRLF line endings (for Windows), without the
 "configure" script
 
-   lp151r01.7z  (LZMA-compressed, recommended)
-   lp151r01.zip
+   lp151b07.7z  (LZMA-compressed, recommended)
+   lp151b07.zip
 
 Other information:
 
-   1.5.1rc01-README.txt
-   1.5.1rc01-LICENSE.txt
+   1.5.1beta07-README.txt
+   1.5.1beta07-LICENSE.txt
 
 Changes since the last public release (1.5.0):
 
@@ -32,7 +32,8 @@
     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,
+  Ensure that png_rgb_to_gray ignores palette mapped images, if libpng
+    internally happens to call it with one.
   Fixed the failure to handle palette mapped images correctly.
 
 Version 1.5.1beta02 [January 14, 2011]
@@ -64,8 +65,10 @@
   Revised png_fixed() in png.c to avoid compiler warning about reaching the
     end without returning anything.
 
-Version 1.5.1rc01 [January 21, 2011]
+Version 1.5.1rc01 [January 22, 2011]
   In the manual, describe the png_get_IHDR() arguments in the correct order.
+  Added const_png_structp and const_png_infop types, and used them in
+    prototypes for most png_get_*() functions.
 
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net:
 (subscription required; visit
diff --git a/CHANGES b/CHANGES
index d1f3915..f9c8d2a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3148,8 +3148,9 @@
     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,
-  Fixed the failure to handle palette mapped images correctly.
+  Ensure that png_rgb_to_gray ignores palette mapped images, if libpng
+    internally happens to call it with one.
+  Fixed a failure to handle palette mapped images correctly.
 
 Version 1.5.1beta02 [January 14, 2011]
   Fixed a bug in handling of interlaced images (bero at arklinux.org).
@@ -3180,8 +3181,10 @@
   Revised png_fixed() in png.c to avoid compiler warning about reaching the
     end without returning anything.
 
-Version 1.5.1rc01 [January 21, 2011]
+Version 1.5.1rc01 [January 22, 2011]
   In the manual, describe the png_get_IHDR() arguments in the correct order.
+  Added const_png_structp and const_png_infop types, and used them in
+    prototypes for most png_get_*() functions.
 
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 (subscription required; visit
diff --git a/png.c b/png.c
index fb0f588..a4a89da 100644
--- a/png.c
+++ b/png.c
@@ -14,7 +14,7 @@
 #include "pngpriv.h"
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_5_1rc01 Your_png_h_is_not_version_1_5_1rc01;
+typedef png_libpng_version_1_5_1beta07 Your_png_h_is_not_version_1_5_1beta07;
 
 /* Tells libpng that we have already handled the first "num_bytes" bytes
  * of the PNG file signature.  If the PNG data is embedded into another
@@ -547,7 +547,7 @@
 #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
 
 png_const_charp PNGAPI
-png_get_copyright(png_structp png_ptr)
+png_get_copyright(const_png_structp png_ptr)
 {
    PNG_UNUSED(png_ptr)  /* Silence compiler warning about unused png_ptr */
 #ifdef PNG_STRING_COPYRIGHT
@@ -555,13 +555,13 @@
 #else
 #  ifdef __STDC__
    return PNG_STRING_NEWLINE \
-     "libpng version 1.5.1rc01 - January 21, 2011" PNG_STRING_NEWLINE \
+     "libpng version 1.5.1beta07 - January 22, 2011" PNG_STRING_NEWLINE \
      "Copyright (c) 1998-2011 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
      "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
      "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
      PNG_STRING_NEWLINE;
 #  else
-      return "libpng version 1.5.1rc01 - January 21, 2011\
+      return "libpng version 1.5.1beta07 - January 22, 2011\
       Copyright (c) 1998-2011 Glenn Randers-Pehrson\
       Copyright (c) 1996-1997 Andreas Dilger\
       Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
@@ -578,14 +578,14 @@
  * it is guaranteed that png.c uses the correct version of png.h.
  */
 png_const_charp PNGAPI
-png_get_libpng_ver(png_structp png_ptr)
+png_get_libpng_ver(const_png_structp png_ptr)
 {
    /* Version of *.c files used when building libpng */
    return png_get_header_ver(png_ptr);
 }
 
 png_const_charp PNGAPI
-png_get_header_ver(png_structp png_ptr)
+png_get_header_ver(const_png_structp png_ptr)
 {
    /* Version of *.h files used when building libpng */
    PNG_UNUSED(png_ptr)  /* Silence compiler warning about unused png_ptr */
@@ -593,7 +593,7 @@
 }
 
 png_const_charp PNGAPI
-png_get_header_version(png_structp png_ptr)
+png_get_header_version(const_png_structp png_ptr)
 {
    /* Returns longer string containing both version and date */
    PNG_UNUSED(png_ptr)  /* Silence compiler warning about unused png_ptr */
diff --git a/png.h b/png.h
index f4bd6c7..4ad8c20 100644
--- a/png.h
+++ b/png.h
@@ -1,7 +1,7 @@
 
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.5.1rc01 - January 21, 2011
+ * libpng version 1.5.1beta07 - January 22, 2011
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -11,7 +11,7 @@
  * Authors and maintainers:
  *   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
  *   libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
- *   libpng versions 0.97, January 1998, through 1.5.1rc01 - January 21, 2011: Glenn
+ *   libpng versions 0.97, January 1998, through 1.5.1beta07 - January 22, 2011: Glenn
  *   See also "Contributing Authors", below.
  *
  * Note about libpng version numbers:
@@ -176,7 +176,7 @@
  *
  * This code is released under the libpng license.
  *
- * libpng versions 1.2.6, August 15, 2004, through 1.5.1rc01, January 21, 2011, are
+ * libpng versions 1.2.6, August 15, 2004, through 1.5.1beta07, January 22, 2011, 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:
@@ -288,13 +288,13 @@
  * Y2K compliance in libpng:
  * =========================
  *
- *    January 21, 2011
+ *    January 22, 2011
  *
  *    Since the PNG Development group is an ad-hoc body, we can't make
  *    an official declaration.
  *
  *    This is your unofficial assurance that libpng from version 0.71 and
- *    upward through 1.5.1rc01 are Y2K compliant.  It is my belief that
+ *    upward through 1.5.1beta07 are Y2K compliant.  It is my belief that
  *    earlier versions were also Y2K compliant.
  *
  *    Libpng only has three year fields.  One is a 2-byte unsigned integer
@@ -350,9 +350,9 @@
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.5.1rc01"
+#define PNG_LIBPNG_VER_STRING "1.5.1beta07"
 #define PNG_HEADER_VERSION_STRING \
-     " libpng version 1.5.1rc01 - January 21, 2011\n"
+     " libpng version 1.5.1beta07 - January 22, 2011\n"
 
 #define PNG_LIBPNG_VER_SONUM   15
 #define PNG_LIBPNG_VER_DLLNUM  15
@@ -365,7 +365,7 @@
  * PNG_LIBPNG_VER_STRING, omitting any leading zero:
  */
 
-#define PNG_LIBPNG_VER_BUILD  01
+#define PNG_LIBPNG_VER_BUILD  07
 
 /* Release Status */
 #define PNG_LIBPNG_BUILD_ALPHA    1
@@ -507,7 +507,7 @@
 /* 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_1rc01;
+typedef char* png_libpng_version_1_5_1beta07;
 
 /* 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
@@ -663,6 +663,7 @@
 
 typedef struct png_info_def png_info;
 typedef png_info FAR * png_infop;
+typedef PNG_CONST png_info FAR * const_png_infop;
 typedef png_info FAR * FAR * png_infopp;
 
 /* Maximum positive integer used in PNG is (2^31)-1 */
@@ -790,6 +791,7 @@
  * expected to return the read data in the buffer.
  */
 typedef struct png_struct_def png_struct;
+typedef PNG_CONST png_struct FAR * const_png_structp;
 typedef png_struct FAR * png_structp;
 
 typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp), );
@@ -945,7 +947,7 @@
     PNG_ALLOCATED);
 
 PNG_EXPORT(6, png_size_t, png_get_compression_buffer_size,
-    (png_structp png_ptr));
+    (const_png_structp png_ptr));
 
 PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structp png_ptr, 
     png_size_t size));
@@ -1072,7 +1074,8 @@
 PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structp png_ptr, 
     int error_action, png_fixed_point red, png_fixed_point green));
 
-PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_structp png_ptr));
+PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (const_png_structp
+    png_ptr));
 #endif
 
 PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth, 
@@ -1409,7 +1412,7 @@
     png_error_ptr error_fn, png_error_ptr warning_fn));
 
 /* Return the user pointer associated with the error functions */
-PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_structp png_ptr));
+PNG_EXPORT(76, png_voidp, png_get_error_ptr, (const_png_structp png_ptr));
 
 /* Replace the default data output functions with a user supplied one(s).
  * If buffered output is not used, then output_flush_fn can be set to NULL.
@@ -1442,7 +1445,7 @@
 PNG_EXPORT(82, void, png_set_mem_fn, (png_structp png_ptr, png_voidp mem_ptr, 
     png_malloc_ptr malloc_fn, png_free_ptr free_fn));
 /* Return the user pointer associated with the memory functions */
-PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_structp png_ptr));
+PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (const_png_structp png_ptr));
 #endif
 
 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
@@ -1461,13 +1464,14 @@
     png_voidp user_transform_ptr, int user_transform_depth, 
     int user_transform_channels));
 /* Return the user pointer associated with the user transform functions */
-PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr, (png_structp png_ptr));
+PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr,
+    (const_png_structp png_ptr));
 #endif
 
 #ifdef PNG_USER_CHUNKS_SUPPORTED
 PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structp png_ptr, 
     png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));
-PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_structp png_ptr));
+PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (const_png_structp png_ptr));
 #endif
 
 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
@@ -1479,7 +1483,7 @@
     png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn));
 
 /* Returns the user pointer associated with the push read functions */
-PNG_EXPORT(91, png_voidp, png_get_progressive_ptr, (png_structp png_ptr));
+PNG_EXPORT(91, png_voidp, png_get_progressive_ptr, (const_png_structp png_ptr));
 
 /* Function to be called when data becomes available */
 PNG_EXPORT(92, void, png_process_data,
@@ -1605,92 +1609,92 @@
  */
 /* Returns "flag" if chunk data is valid in info_ptr. */
 PNG_EXPORT(110, png_uint_32, png_get_valid,
-    (png_structp png_ptr, png_infop info_ptr, 
+    (const_png_structp png_ptr, const_png_infop info_ptr, 
     png_uint_32 flag));
 
 /* Returns number of bytes needed to hold a transformed row. */
-PNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_structp png_ptr, 
-    png_infop info_ptr));
+PNG_EXPORT(111, png_size_t, png_get_rowbytes, (const_png_structp png_ptr, 
+    const_png_infop info_ptr));
 
 #ifdef PNG_INFO_IMAGE_SUPPORTED
 /* Returns row_pointers, which is an array of pointers to scanlines that was
  * returned from png_read_png().
  */
 PNG_EXPORT(112, png_bytepp, png_get_rows,
-    (png_structp png_ptr, png_infop info_ptr));
+    (const_png_structp png_ptr, const_png_infop info_ptr));
 /* Set row_pointers, which is an array of pointers to scanlines for use
  * by png_write_png().
  */
-PNG_EXPORT(113, void, png_set_rows, (png_structp png_ptr, png_infop info_ptr, 
-    png_bytepp row_pointers));
+PNG_EXPORT(113, void, png_set_rows, (png_structp png_ptr,
+    png_infop info_ptr, png_bytepp row_pointers));
 #endif
 
 /* Returns number of color channels in image. */
 PNG_EXPORT(114, png_byte, png_get_channels,
-    (png_structp png_ptr, png_infop info_ptr));
+    (const_png_structp png_ptr, const_png_infop info_ptr));
 
 #ifdef PNG_EASY_ACCESS_SUPPORTED
 /* Returns image width in pixels. */
-PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_structp png_ptr, 
-    png_infop info_ptr));
+PNG_EXPORT(115, png_uint_32, png_get_image_width, (const_png_structp png_ptr, 
+    const_png_infop info_ptr));
 
 /* Returns image height in pixels. */
-PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_structp png_ptr, 
-    png_infop info_ptr));
+PNG_EXPORT(116, png_uint_32, png_get_image_height, (const_png_structp png_ptr, 
+    const_png_infop info_ptr));
 
 /* Returns image bit_depth. */
 PNG_EXPORT(117, png_byte, png_get_bit_depth,
-    (png_structp png_ptr, png_infop info_ptr));
+    (const_png_structp png_ptr, const_png_infop info_ptr));
 
 /* Returns image color_type. */
-PNG_EXPORT(118, png_byte, png_get_color_type, (png_structp png_ptr, 
-    png_infop info_ptr));
+PNG_EXPORT(118, png_byte, png_get_color_type, (const_png_structp png_ptr, 
+    const_png_infop info_ptr));
 
 /* Returns image filter_type. */
-PNG_EXPORT(119, png_byte, png_get_filter_type, (png_structp png_ptr, 
-    png_infop info_ptr));
+PNG_EXPORT(119, png_byte, png_get_filter_type, (const_png_structp png_ptr, 
+    const_png_infop info_ptr));
 
 /* Returns image interlace_type. */
-PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_structp png_ptr, 
-    png_infop info_ptr));
+PNG_EXPORT(120, png_byte, png_get_interlace_type, (const_png_structp png_ptr, 
+    const_png_infop info_ptr));
 
 /* Returns image compression_type. */
-PNG_EXPORT(121, png_byte, png_get_compression_type, (png_structp png_ptr, 
-    png_infop info_ptr));
+PNG_EXPORT(121, png_byte, png_get_compression_type, (const_png_structp png_ptr, 
+    const_png_infop info_ptr));
 
 /* Returns image resolution in pixels per meter, from pHYs chunk data. */
-PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter, (png_structp png_ptr, 
-    png_infop info_ptr));
-PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter, (png_structp png_ptr, 
-    png_infop info_ptr));
-PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter, (png_structp png_ptr, 
-    png_infop info_ptr));
+PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter,
+    (const_png_structp png_ptr, const_png_infop info_ptr));
+PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter,
+    (const_png_structp png_ptr, const_png_infop info_ptr));
+PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter,
+    (const_png_structp png_ptr, const_png_infop info_ptr));
 
 /* Returns pixel aspect ratio, computed from pHYs chunk data.  */
-PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio, (png_structp png_ptr, 
-    png_infop info_ptr));
+PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio,
+    (const_png_structp png_ptr, const_png_infop info_ptr));
 PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed, 
-    (png_structp png_ptr, png_infop info_ptr));
+    (const_png_structp png_ptr, const_png_infop info_ptr));
 
 /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
-PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels, (png_structp png_ptr, 
-    png_infop info_ptr));
-PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels, (png_structp png_ptr, 
-    png_infop info_ptr));
-PNG_EXPORT(128, png_int_32, png_get_x_offset_microns, (png_structp png_ptr, 
-    png_infop info_ptr));
-PNG_EXPORT(129, png_int_32, png_get_y_offset_microns, (png_structp png_ptr, 
-    png_infop info_ptr));
+PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels,
+    (const_png_structp png_ptr, const_png_infop info_ptr));
+PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels,
+    (const_png_structp png_ptr, const_png_infop info_ptr));
+PNG_EXPORT(128, png_int_32, png_get_x_offset_microns,
+    (const_png_structp png_ptr, const_png_infop info_ptr));
+PNG_EXPORT(129, png_int_32, png_get_y_offset_microns,
+    (const_png_structp png_ptr, const_png_infop info_ptr));
 
 #endif /* PNG_EASY_ACCESS_SUPPORTED */
 
 /* Returns pointer to signature string read from PNG header */
-PNG_EXPORT(130, png_const_bytep, png_get_signature, (png_structp png_ptr, 
-    png_infop info_ptr));
+PNG_EXPORT(130, png_const_bytep, png_get_signature,
+    (const_png_structp png_ptr, png_infop info_ptr));
 
 #ifdef PNG_bKGD_SUPPORTED
 PNG_EXPORT(131, png_uint_32, png_get_bKGD,
-    (png_structp png_ptr, png_infop info_ptr, 
+    (const_png_structp png_ptr, png_infop info_ptr, 
     png_color_16p *background));
 #endif
 
@@ -1700,13 +1704,14 @@
 #endif
 
 #ifdef PNG_cHRM_SUPPORTED
-PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_structp png_ptr, 
-    png_infop info_ptr, double *white_x, double *white_y, double *red_x, 
+PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (const_png_structp png_ptr, 
+   const_png_infop info_ptr, double *white_x, double *white_y, double *red_x, 
     double *red_y, double *green_x, double *green_y, double *blue_x, 
     double *blue_y));
 #ifdef PNG_FIXED_POINT_SUPPORTED /* Otherwise not implemented */
-PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed, (png_structp png_ptr, 
-    png_infop info_ptr, png_fixed_point *int_white_x, 
+PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,
+    (const_png_structp png_ptr, 
+    const_png_infop info_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, 
@@ -1729,28 +1734,29 @@
 
 #ifdef PNG_gAMA_SUPPORTED
 PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA,
-    (png_structp png_ptr, png_infop info_ptr, 
+    (const_png_structp png_ptr, const_png_infop info_ptr, 
     double *file_gamma));
-PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed, (png_structp png_ptr, 
-    png_infop info_ptr, png_fixed_point *int_file_gamma));
+PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed,
+    (const_png_structp png_ptr, const_png_infop info_ptr,
+    png_fixed_point *int_file_gamma));
 #endif
 
 #ifdef PNG_gAMA_SUPPORTED
-PNG_FP_EXPORT(139, void, png_set_gAMA, (png_structp png_ptr, png_infop info_ptr, 
-    double file_gamma));
+PNG_FP_EXPORT(139, void, png_set_gAMA, (png_structp png_ptr,
+    png_infop info_ptr, double file_gamma));
 PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_structp png_ptr, 
     png_infop info_ptr, png_fixed_point int_file_gamma));
 #endif
 
 #ifdef PNG_hIST_SUPPORTED
 PNG_EXPORT(141, png_uint_32, png_get_hIST,
-    (png_structp png_ptr, png_infop info_ptr, 
+    (const_png_structp png_ptr, const_png_infop info_ptr, 
     png_uint_16p *hist));
 #endif
 
 #ifdef PNG_hIST_SUPPORTED
-PNG_EXPORT(142, void, png_set_hIST, (png_structp png_ptr, png_infop info_ptr, 
-    png_const_uint_16p hist));
+PNG_EXPORT(142, void, png_set_hIST, (png_structp png_ptr,
+    png_infop info_ptr, png_const_uint_16p hist));
 #endif
 
 PNG_EXPORT(143, png_uint_32, png_get_IHDR,
@@ -1765,7 +1771,7 @@
 
 #ifdef PNG_oFFs_SUPPORTED
 PNG_EXPORT(145, png_uint_32, png_get_oFFs,
-    (png_structp png_ptr, png_infop info_ptr, 
+    (const_png_structp png_ptr, const_png_infop info_ptr, 
     png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type));
 #endif
 
@@ -1777,21 +1783,22 @@
 
 #ifdef PNG_pCAL_SUPPORTED
 PNG_EXPORT(147, png_uint_32, png_get_pCAL,
-    (png_structp png_ptr, png_infop info_ptr, 
+    (const_png_structp png_ptr, const_png_infop info_ptr, 
     png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type,
     int *nparams, 
     png_charp *units, png_charpp *params));
 #endif
 
 #ifdef PNG_pCAL_SUPPORTED
-PNG_EXPORT(148, void, png_set_pCAL, (png_structp png_ptr, png_infop info_ptr, 
+PNG_EXPORT(148, void, png_set_pCAL, (png_structp png_ptr,
+    png_infop info_ptr, 
     png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, 
     int nparams, png_const_charp units, png_charpp params));
 #endif
 
 #ifdef PNG_pHYs_SUPPORTED
 PNG_EXPORT(149, png_uint_32, png_get_pHYs,
-    (png_structp png_ptr, png_infop info_ptr, 
+    (const_png_structp png_ptr, const_png_infop info_ptr, 
     png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
 #endif
 
@@ -1802,7 +1809,7 @@
 #endif
 
 PNG_EXPORT(151, png_uint_32, png_get_PLTE,
-    (png_structp png_ptr, png_infop info_ptr, 
+    (const_png_structp png_ptr, const_png_infop info_ptr, 
     png_colorp *palette, int *num_palette));
 
 PNG_EXPORT(152, void, png_set_PLTE,
@@ -1811,7 +1818,7 @@
 
 #ifdef PNG_sBIT_SUPPORTED
 PNG_EXPORT(153, png_uint_32, png_get_sBIT,
-    (png_structp png_ptr, png_infop info_ptr, 
+    (const_png_structp png_ptr, png_infop info_ptr, 
     png_color_8p *sig_bit));
 #endif
 
@@ -1821,8 +1828,8 @@
 #endif
 
 #ifdef PNG_sRGB_SUPPORTED
-PNG_EXPORT(155, png_uint_32, png_get_sRGB,
-    (png_structp png_ptr, png_infop info_ptr, int *intent));
+PNG_EXPORT(155, png_uint_32, png_get_sRGB, (const_png_structp png_ptr,
+    const_png_infop info_ptr, int *intent));
 #endif
 
 #ifdef PNG_sRGB_SUPPORTED
@@ -1834,7 +1841,7 @@
 
 #ifdef PNG_iCCP_SUPPORTED
 PNG_EXPORT(158, png_uint_32, png_get_iCCP,
-    (png_structp png_ptr, png_infop info_ptr, 
+    (const_png_structp png_ptr, const_png_infop info_ptr, 
     png_charpp name, int *compression_type, png_bytepp profile, 
     png_uint_32 *proflen));
 #endif
@@ -1848,7 +1855,7 @@
 
 #ifdef PNG_sPLT_SUPPORTED
 PNG_EXPORT(160, png_uint_32, png_get_sPLT,
-    (png_structp png_ptr, png_infop info_ptr, 
+    (const_png_structp png_ptr, const_png_infop info_ptr, 
     png_sPLT_tpp entries));
 #endif
 
@@ -1861,7 +1868,7 @@
 #ifdef PNG_TEXT_SUPPORTED
 /* png_get_text also returns the number of text chunks in *num_text */
 PNG_EXPORT(162, png_uint_32, png_get_text,
-    (png_structp png_ptr, png_infop info_ptr, 
+    (const_png_structp png_ptr, const_png_infop info_ptr, 
     png_textp *text_ptr, int *num_text));
 #endif
 
@@ -1880,7 +1887,7 @@
 
 #ifdef PNG_tIME_SUPPORTED
 PNG_EXPORT(164, png_uint_32, png_get_tIME,
-    (png_structp png_ptr, png_infop info_ptr, png_timep *mod_time));
+    (const_png_structp png_ptr, png_infop info_ptr, png_timep *mod_time));
 #endif
 
 #ifdef PNG_tIME_SUPPORTED
@@ -1890,7 +1897,7 @@
 
 #ifdef PNG_tRNS_SUPPORTED
 PNG_EXPORT(166, png_uint_32, png_get_tRNS,
-    (png_structp png_ptr, png_infop info_ptr, 
+    (const_png_structp png_ptr, png_infop info_ptr, 
     png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color));
 #endif
 
@@ -1903,7 +1910,7 @@
 
 #ifdef PNG_sCAL_SUPPORTED
 PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL,
-    (png_structp png_ptr, png_infop info_ptr, 
+    (const_png_structp png_ptr, const_png_infop info_ptr, 
     int *unit, double *width, double *height));
 #ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
 /* NOTE: this API is currently implemented using floating point arithmetic, 
@@ -1911,13 +1918,14 @@
  * In any case the range of values supported by png_fixed_point is small and it
  * is highly recommended that png_get_sCAL_s be used instead.
  */
-PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed, (png_structp png_ptr, 
-    png_infop info_ptr, int *unit, png_fixed_point *width, 
+PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed,
+    (png_structp png_ptr, const_png_infop info_ptr, int *unit,
+    png_fixed_point *width, 
     png_fixed_point *height));
 #endif
 PNG_EXPORT(169, png_uint_32, png_get_sCAL_s,
-    (png_structp png_ptr, 
-    png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight));
+    (const_png_structp png_ptr, const_png_infop info_ptr,
+    int *unit, png_charpp swidth, png_charpp sheight));
 
 PNG_FP_EXPORT(170, void, png_set_sCAL,
     (png_structp png_ptr, png_infop info_ptr, 
@@ -1948,11 +1956,12 @@
 #endif
 #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
 PNG_EXPORT(174, void, png_set_unknown_chunks, (png_structp png_ptr, 
-    png_infop info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns));
-PNG_EXPORT(175, void, png_set_unknown_chunk_location, (png_structp png_ptr, 
-    png_infop info_ptr, int chunk, int location));
-PNG_EXPORT(176, int, png_get_unknown_chunks, (png_structp png_ptr, 
-    png_infop info_ptr, png_unknown_chunkpp entries));
+    png_infop info_ptr, png_const_unknown_chunkp unknowns,
+    int num_unknowns));
+PNG_EXPORT(175, void, png_set_unknown_chunk_location,
+    (png_structp png_ptr, png_infop info_ptr, int chunk, int location));
+PNG_EXPORT(176, int, png_get_unknown_chunks, (const_png_structp png_ptr, 
+    const_png_infop info_ptr, png_unknown_chunkpp entries));
 #endif
 
 /* Png_free_data() will turn off the "valid" flag for anything it frees.
@@ -1970,10 +1979,14 @@
     int transforms, png_voidp params));
 #endif
 
-PNG_EXPORT(180, png_const_charp, png_get_copyright, (png_structp png_ptr));
-PNG_EXPORT(181, png_const_charp, png_get_header_ver, (png_structp png_ptr));
-PNG_EXPORT(182, png_const_charp, png_get_header_version, (png_structp png_ptr));
-PNG_EXPORT(183, png_const_charp, png_get_libpng_ver, (png_structp png_ptr));
+PNG_EXPORT(180, png_const_charp, png_get_copyright,
+    (const_png_structp png_ptr));
+PNG_EXPORT(181, png_const_charp, png_get_header_ver,
+    (const_png_structp png_ptr));
+PNG_EXPORT(182, png_const_charp, png_get_header_version,
+    (const_png_structp png_ptr));
+PNG_EXPORT(183, png_const_charp, png_get_libpng_ver,
+    (const_png_structp png_ptr));
 
 #ifdef PNG_MNG_FEATURES_SUPPORTED
 PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structp png_ptr, 
@@ -1999,46 +2012,49 @@
 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
 PNG_EXPORT(186, void, png_set_user_limits, (png_structp png_ptr, 
     png_uint_32 user_width_max, png_uint_32 user_height_max));
-PNG_EXPORT(187, png_uint_32, png_get_user_width_max, (png_structp png_ptr));
-PNG_EXPORT(188, png_uint_32, png_get_user_height_max, (png_structp png_ptr));
+PNG_EXPORT(187, png_uint_32, png_get_user_width_max,
+    (const_png_structp png_ptr));
+PNG_EXPORT(188, png_uint_32, png_get_user_height_max,
+    (const_png_structp png_ptr));
 /* Added in libpng-1.4.0 */
 PNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structp png_ptr, 
     png_uint_32 user_chunk_cache_max));
-PNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max, (png_structp png_ptr));
+PNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max,
+    (const_png_structp png_ptr));
 /* Added in libpng-1.4.1 */
 PNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structp png_ptr, 
     png_alloc_size_t user_chunk_cache_max));
 PNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max,
-    (png_structp png_ptr));
+    (const_png_structp png_ptr));
 #endif
 
 #if defined(PNG_INCH_CONVERSIONS_SUPPORTED)
-PNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch, (png_structp png_ptr, 
-    png_infop info_ptr));
+PNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch,
+    (const_png_structp png_ptr, const_png_infop info_ptr));
 
-PNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch, (png_structp png_ptr, 
-    png_infop info_ptr));
+PNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch,
+    (const_png_structp png_ptr, const_png_infop info_ptr));
 
-PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch, (png_structp png_ptr, 
-    png_infop info_ptr));
+PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch,
+    (const_png_structp png_ptr, const_png_infop info_ptr));
 
-PNG_FP_EXPORT(196, float, png_get_x_offset_inches, (png_structp png_ptr, 
-    png_infop info_ptr));
+PNG_FP_EXPORT(196, float, png_get_x_offset_inches,
+    (const_png_structp png_ptr, const_png_infop info_ptr));
 #ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */
 PNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed, 
-    (png_structp png_ptr, png_infop info_ptr));
+    (png_structp png_ptr, const_png_infop info_ptr));
 #endif
 
-PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_structp png_ptr, 
-    png_infop info_ptr));
+PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (const_png_structp png_ptr, 
+    const_png_infop info_ptr));
 #ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */
 PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed, 
-    (png_structp png_ptr, png_infop info_ptr));
+    (png_structp png_ptr, const_png_infop info_ptr));
 #endif
 
 #  ifdef PNG_pHYs_SUPPORTED
-PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_structp png_ptr, 
-    png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,
+PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (const_png_structp png_ptr, 
+    const_png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,
     int *unit_type));
 #  endif /* PNG_pHYs_SUPPORTED */
 #endif  /* PNG_INCH_CONVERSIONS_SUPPORTED */
diff --git a/pngconf.h b/pngconf.h
index d3dbeb9..bd10f4b 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,7 +1,7 @@
 
 /* pngconf.h - machine configurable file for libpng
  *
- * libpng version 1.5.1rc01 - (PENDING RELEASE)
+ * libpng version 1.5.1beta07 - (PENDING RELEASE)
  *
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngerror.c b/pngerror.c
index f209f46..5fa5769 100644
--- a/pngerror.c
+++ b/pngerror.c
@@ -1,7 +1,7 @@
 
 /* pngerror.c - stub functions for i/o and memory allocation
  *
- * Last changed in libpng 1.5.0 [January 6, 2011]
+ * Last changed in libpng 1.5.1 [(PENDING RELEASE)]
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -423,7 +423,7 @@
  * pointer before png_write_destroy and png_read_destroy are called.
  */
 png_voidp PNGAPI
-png_get_error_ptr(png_structp png_ptr)
+png_get_error_ptr(const_png_structp png_ptr)
 {
    if (png_ptr == NULL)
       return NULL;
diff --git a/pngget.c b/pngget.c
index 319ac6b..460f4dc 100644
--- a/pngget.c
+++ b/pngget.c
@@ -1,7 +1,7 @@
 
 /* pngget.c - retrieval of values from info struct
  *
- * Last changed in libpng 1.5.0 [January 6, 2011]
+ * Last changed in libpng 1.5.1 [(PENDING RELEASE)]
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -17,7 +17,8 @@
 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
 
 png_uint_32 PNGAPI
-png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
+png_get_valid(const_png_structp png_ptr, const_png_infop info_ptr,
+    png_uint_32 flag)
 {
    if (png_ptr != NULL && info_ptr != NULL)
       return(info_ptr->valid & flag);
@@ -26,7 +27,7 @@
 }
 
 png_size_t PNGAPI
-png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
+png_get_rowbytes(const_png_structp png_ptr, const_png_infop info_ptr)
 {
    if (png_ptr != NULL && info_ptr != NULL)
       return(info_ptr->rowbytes);
@@ -36,7 +37,7 @@
 
 #ifdef PNG_INFO_IMAGE_SUPPORTED
 png_bytepp PNGAPI
-png_get_rows(png_structp png_ptr, png_infop info_ptr)
+png_get_rows(const_png_structp png_ptr, const_png_infop info_ptr)
 {
    if (png_ptr != NULL && info_ptr != NULL)
       return(info_ptr->row_pointers);
@@ -48,7 +49,7 @@
 #ifdef PNG_EASY_ACCESS_SUPPORTED
 /* Easy access to info, added in libpng-0.99 */
 png_uint_32 PNGAPI
-png_get_image_width(png_structp png_ptr, png_infop info_ptr)
+png_get_image_width(const_png_structp png_ptr, const_png_infop info_ptr)
 {
    if (png_ptr != NULL && info_ptr != NULL)
       return info_ptr->width;
@@ -57,7 +58,7 @@
 }
 
 png_uint_32 PNGAPI
-png_get_image_height(png_structp png_ptr, png_infop info_ptr)
+png_get_image_height(const_png_structp png_ptr, const_png_infop info_ptr)
 {
    if (png_ptr != NULL && info_ptr != NULL)
       return info_ptr->height;
@@ -66,7 +67,7 @@
 }
 
 png_byte PNGAPI
-png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
+png_get_bit_depth(const_png_structp png_ptr, const_png_infop info_ptr)
 {
    if (png_ptr != NULL && info_ptr != NULL)
       return info_ptr->bit_depth;
@@ -75,7 +76,7 @@
 }
 
 png_byte PNGAPI
-png_get_color_type(png_structp png_ptr, png_infop info_ptr)
+png_get_color_type(const_png_structp png_ptr, const_png_infop info_ptr)
 {
    if (png_ptr != NULL && info_ptr != NULL)
       return info_ptr->color_type;
@@ -84,7 +85,7 @@
 }
 
 png_byte PNGAPI
-png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
+png_get_filter_type(const_png_structp png_ptr, const_png_infop info_ptr)
 {
    if (png_ptr != NULL && info_ptr != NULL)
       return info_ptr->filter_type;
@@ -93,7 +94,7 @@
 }
 
 png_byte PNGAPI
-png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
+png_get_interlace_type(const_png_structp png_ptr, const_png_infop info_ptr)
 {
    if (png_ptr != NULL && info_ptr != NULL)
       return info_ptr->interlace_type;
@@ -102,7 +103,7 @@
 }
 
 png_byte PNGAPI
-png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
+png_get_compression_type(const_png_structp png_ptr, const_png_infop info_ptr)
 {
    if (png_ptr != NULL && info_ptr != NULL)
       return info_ptr->compression_type;
@@ -111,7 +112,7 @@
 }
 
 png_uint_32 PNGAPI
-png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
+png_get_x_pixels_per_meter(const_png_structp png_ptr, const_png_infop info_ptr)
 {
 #ifdef PNG_pHYs_SUPPORTED
    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
@@ -128,7 +129,7 @@
 }
 
 png_uint_32 PNGAPI
-png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
+png_get_y_pixels_per_meter(const_png_structp png_ptr, const_png_infop info_ptr)
 {
 #ifdef PNG_pHYs_SUPPORTED
    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
@@ -145,7 +146,7 @@
 }
 
 png_uint_32 PNGAPI
-png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
+png_get_pixels_per_meter(const_png_structp png_ptr, const_png_infop info_ptr)
 {
 #ifdef PNG_pHYs_SUPPORTED
    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
@@ -163,7 +164,7 @@
 
 #ifdef PNG_FLOATING_POINT_SUPPORTED
 float PNGAPI
-png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
+png_get_pixel_aspect_ratio(const_png_structp png_ptr, const_png_infop info_ptr)
 {
 #ifdef PNG_READ_pHYs_SUPPORTED
    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
@@ -182,7 +183,8 @@
 
 #ifdef PNG_FIXED_POINT_SUPPORTED
 png_fixed_point PNGAPI
-png_get_pixel_aspect_ratio_fixed(png_structp png_ptr, png_infop info_ptr)
+png_get_pixel_aspect_ratio_fixed(const_png_structp png_ptr,
+    const_png_infop info_ptr)
 {
 #ifdef PNG_READ_pHYs_SUPPORTED
    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)
@@ -208,7 +210,7 @@
 #endif
 
 png_int_32 PNGAPI
-png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
+png_get_x_offset_microns(const_png_structp png_ptr, const_png_infop info_ptr)
 {
 #ifdef PNG_oFFs_SUPPORTED
    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
@@ -224,7 +226,7 @@
 }
 
 png_int_32 PNGAPI
-png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
+png_get_y_offset_microns(const_png_structp png_ptr, const_png_infop info_ptr)
 {
 #ifdef PNG_oFFs_SUPPORTED
    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
@@ -240,7 +242,7 @@
 }
 
 png_int_32 PNGAPI
-png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
+png_get_x_offset_pixels(const_png_structp png_ptr, const_png_infop info_ptr)
 {
 #ifdef PNG_oFFs_SUPPORTED
    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
@@ -256,7 +258,7 @@
 }
 
 png_int_32 PNGAPI
-png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
+png_get_y_offset_pixels(const_png_structp png_ptr, const_png_infop info_ptr)
 {
 #ifdef PNG_oFFs_SUPPORTED
    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
@@ -305,19 +307,19 @@
 }
 
 png_uint_32 PNGAPI
-png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
+png_get_pixels_per_inch(const_png_structp png_ptr, const_png_infop info_ptr)
 {
    return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr));
 }
 
 png_uint_32 PNGAPI
-png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
+png_get_x_pixels_per_inch(const_png_structp png_ptr, const_png_infop info_ptr)
 {
    return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr));
 }
 
 png_uint_32 PNGAPI
-png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
+png_get_y_pixels_per_inch(const_png_structp png_ptr, const_png_infop info_ptr)
 {
    return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr));
 }
@@ -335,7 +337,8 @@
 }
 
 png_fixed_point PNGAPI
-png_get_x_offset_inches_fixed(png_structp png_ptr, png_infop info_ptr)
+png_get_x_offset_inches_fixed(png_structp png_ptr,
+    const_png_infop info_ptr)
 {
    return png_fixed_inches_from_microns(png_ptr,
        png_get_x_offset_microns(png_ptr, info_ptr));
@@ -344,7 +347,8 @@
 
 #ifdef PNG_FIXED_POINT_SUPPORTED
 png_fixed_point PNGAPI
-png_get_y_offset_inches_fixed(png_structp png_ptr, png_infop info_ptr)
+png_get_y_offset_inches_fixed(png_structp png_ptr,
+    const_png_infop info_ptr)
 {
    return png_fixed_inches_from_microns(png_ptr,
        png_get_y_offset_microns(png_ptr, info_ptr));
@@ -353,7 +357,7 @@
 
 #ifdef PNG_FLOATING_POINT_SUPPORTED
 float PNGAPI
-png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
+png_get_x_offset_inches(const_png_structp png_ptr, const_png_infop info_ptr)
 {
    /* To avoid the overflow do the conversion directly in floating
     * point.
@@ -364,7 +368,7 @@
 
 #ifdef PNG_FLOATING_POINT_SUPPORTED
 float PNGAPI
-png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
+png_get_y_offset_inches(const_png_structp png_ptr, const_png_infop info_ptr)
 {
    /* To avoid the overflow do the conversion directly in floating
     * point.
@@ -375,7 +379,7 @@
 
 #ifdef PNG_pHYs_SUPPORTED
 png_uint_32 PNGAPI
-png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
+png_get_pHYs_dpi(const_png_structp png_ptr, const_png_infop info_ptr,
     png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
 {
    png_uint_32 retval = 0;
@@ -419,7 +423,7 @@
 #endif  /* PNG_EASY_ACCESS_SUPPORTED */
 
 png_byte PNGAPI
-png_get_channels(png_structp png_ptr, png_infop info_ptr)
+png_get_channels(const_png_structp png_ptr, const_png_infop info_ptr)
 {
    if (png_ptr != NULL && info_ptr != NULL)
       return(info_ptr->channels);
@@ -428,7 +432,7 @@
 }
 
 png_const_bytep PNGAPI
-png_get_signature(png_structp png_ptr, png_infop info_ptr)
+png_get_signature(const_png_structp png_ptr, png_infop info_ptr)
 {
    if (png_ptr != NULL && info_ptr != NULL)
       return(info_ptr->signature);
@@ -438,7 +442,7 @@
 
 #ifdef PNG_bKGD_SUPPORTED
 png_uint_32 PNGAPI
-png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
+png_get_bKGD(const_png_structp png_ptr, png_infop info_ptr,
    png_color_16p *background)
 {
    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
@@ -457,7 +461,7 @@
 #ifdef PNG_cHRM_SUPPORTED
 #  ifdef PNG_FLOATING_POINT_SUPPORTED
 png_uint_32 PNGAPI
-png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
+png_get_cHRM(const_png_structp png_ptr, const_png_infop info_ptr,
     double *white_x, double *white_y, double *red_x, double *red_y,
     double *green_x, double *green_y, double *blue_x, double *blue_y)
 {
@@ -490,7 +494,7 @@
 
 #  ifdef PNG_FIXED_POINT_SUPPORTED
 png_uint_32 PNGAPI
-png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
+png_get_cHRM_fixed(const_png_structp png_ptr, const_png_infop info_ptr,
     png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
     png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
     png_fixed_point *blue_x, png_fixed_point *blue_y)
@@ -525,7 +529,7 @@
 
 #ifdef PNG_gAMA_SUPPORTED
 png_uint_32 PNGFAPI
-png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
+png_get_gAMA_fixed(const_png_structp png_ptr, const_png_infop info_ptr,
     png_fixed_point *file_gamma)
 {
    png_debug1(1, "in %s retrieval function", "gAMA");
@@ -541,7 +545,8 @@
 }
 #  ifdef PNG_FLOATING_POINT_SUPPORTED
 png_uint_32 PNGAPI
-png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
+png_get_gAMA(const_png_structp png_ptr, const_png_infop info_ptr,
+    double *file_gamma)
 {
    png_fixed_point igamma;
    png_uint_32 ok = png_get_gAMA_fixed(png_ptr, info_ptr, &igamma);
@@ -557,7 +562,8 @@
 
 #ifdef PNG_sRGB_SUPPORTED
 png_uint_32 PNGAPI
-png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
+png_get_sRGB(const_png_structp png_ptr, const_png_infop info_ptr,
+    int *file_srgb_intent)
 {
    png_debug1(1, "in %s retrieval function", "sRGB");
 
@@ -574,7 +580,7 @@
 
 #ifdef PNG_iCCP_SUPPORTED
 png_uint_32 PNGAPI
-png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
+png_get_iCCP(const_png_structp png_ptr, const_png_infop info_ptr,
     png_charpp name, int *compression_type,
     png_bytepp profile, png_uint_32 *proflen)
 {
@@ -599,7 +605,7 @@
 
 #ifdef PNG_sPLT_SUPPORTED
 png_uint_32 PNGAPI
-png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
+png_get_sPLT(const_png_structp png_ptr, const_png_infop info_ptr,
     png_sPLT_tpp spalettes)
 {
    if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
@@ -614,7 +620,8 @@
 
 #ifdef PNG_hIST_SUPPORTED
 png_uint_32 PNGAPI
-png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
+png_get_hIST(const_png_structp png_ptr, const_png_infop info_ptr,
+    png_uint_16p *hist)
 {
    png_debug1(1, "in %s retrieval function", "hIST");
 
@@ -670,7 +677,7 @@
 
 #ifdef PNG_oFFs_SUPPORTED
 png_uint_32 PNGAPI
-png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
+png_get_oFFs(const_png_structp png_ptr, const_png_infop info_ptr,
     png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
 {
    png_debug1(1, "in %s retrieval function", "oFFs");
@@ -690,7 +697,7 @@
 
 #ifdef PNG_pCAL_SUPPORTED
 png_uint_32 PNGAPI
-png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
+png_get_pCAL(const_png_structp png_ptr, const_png_infop info_ptr,
     png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
     png_charp *units, png_charpp *params)
 {
@@ -718,7 +725,7 @@
 #  ifdef PNG_FIXED_POINT_SUPPORTED
 #    ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
 png_uint_32 PNGAPI
-png_get_sCAL_fixed(png_structp png_ptr, png_infop info_ptr,
+png_get_sCAL_fixed(png_structp png_ptr, const_png_infop info_ptr,
     int *unit, png_fixed_point *width, png_fixed_point *height)
 {
    if (png_ptr != NULL && info_ptr != NULL &&
@@ -738,7 +745,7 @@
 #  endif /* FIXED_POINT */
 #  ifdef PNG_FLOATING_POINT_SUPPORTED
 png_uint_32 PNGAPI
-png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
+png_get_sCAL(const_png_structp png_ptr, const_png_infop info_ptr,
     int *unit, double *width, double *height)
 {
    if (png_ptr != NULL && info_ptr != NULL &&
@@ -754,7 +761,7 @@
 }
 #  endif /* FLOATING POINT */
 png_uint_32 PNGAPI
-png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
+png_get_sCAL_s(const_png_structp png_ptr, const_png_infop info_ptr,
     int *unit, png_charpp width, png_charpp height)
 {
    if (png_ptr != NULL && info_ptr != NULL &&
@@ -772,7 +779,7 @@
 
 #ifdef PNG_pHYs_SUPPORTED
 png_uint_32 PNGAPI
-png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
+png_get_pHYs(const_png_structp png_ptr, const_png_infop info_ptr,
     png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
 {
    png_uint_32 retval = 0;
@@ -806,8 +813,8 @@
 #endif /* pHYs */
 
 png_uint_32 PNGAPI
-png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
-    int *num_palette)
+png_get_PLTE(const_png_structp png_ptr, const_png_infop info_ptr,
+    png_colorp *palette, int *num_palette)
 {
    png_debug1(1, "in %s retrieval function", "PLTE");
 
@@ -825,7 +832,8 @@
 
 #ifdef PNG_sBIT_SUPPORTED
 png_uint_32 PNGAPI
-png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
+png_get_sBIT(const_png_structp png_ptr, png_infop info_ptr,
+    png_color_8p *sig_bit)
 {
    png_debug1(1, "in %s retrieval function", "sBIT");
 
@@ -842,8 +850,8 @@
 
 #ifdef PNG_TEXT_SUPPORTED
 png_uint_32 PNGAPI
-png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
-    int *num_text)
+png_get_text(const_png_structp png_ptr, const_png_infop info_ptr,
+    png_textp *text_ptr, int *num_text)
 {
    if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
    {
@@ -869,7 +877,7 @@
 
 #ifdef PNG_tIME_SUPPORTED
 png_uint_32 PNGAPI
-png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
+png_get_tIME(const_png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
 {
    png_debug1(1, "in %s retrieval function", "tIME");
 
@@ -886,7 +894,7 @@
 
 #ifdef PNG_tRNS_SUPPORTED
 png_uint_32 PNGAPI
-png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
+png_get_tRNS(const_png_structp png_ptr, png_infop info_ptr,
     png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
 {
    png_uint_32 retval = 0;
@@ -931,7 +939,7 @@
 
 #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
 int PNGAPI
-png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
+png_get_unknown_chunks(const_png_structp png_ptr, const_png_infop info_ptr,
     png_unknown_chunkpp unknowns)
 {
    if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
@@ -946,7 +954,7 @@
 
 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
 png_byte PNGAPI
-png_get_rgb_to_gray_status (png_structp png_ptr)
+png_get_rgb_to_gray_status (const_png_structp png_ptr)
 {
    return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
 }
@@ -954,14 +962,14 @@
 
 #ifdef PNG_USER_CHUNKS_SUPPORTED
 png_voidp PNGAPI
-png_get_user_chunk_ptr(png_structp png_ptr)
+png_get_user_chunk_ptr(const_png_structp png_ptr)
 {
    return (png_ptr ? png_ptr->user_chunk_ptr : NULL);
 }
 #endif
 
 png_size_t PNGAPI
-png_get_compression_buffer_size(png_structp png_ptr)
+png_get_compression_buffer_size(const_png_structp png_ptr)
 {
    return (png_ptr ? png_ptr->zbuf_size : 0L);
 }
@@ -971,27 +979,27 @@
 /* These functions were added to libpng 1.2.6 and were enabled
  * by default in libpng-1.4.0 */
 png_uint_32 PNGAPI
-png_get_user_width_max (png_structp png_ptr)
+png_get_user_width_max (const_png_structp png_ptr)
 {
    return (png_ptr ? png_ptr->user_width_max : 0);
 }
 
 png_uint_32 PNGAPI
-png_get_user_height_max (png_structp png_ptr)
+png_get_user_height_max (const_png_structp png_ptr)
 {
    return (png_ptr ? png_ptr->user_height_max : 0);
 }
 
 /* This function was added to libpng 1.4.0 */
 png_uint_32 PNGAPI
-png_get_chunk_cache_max (png_structp png_ptr)
+png_get_chunk_cache_max (const_png_structp png_ptr)
 {
    return (png_ptr ? png_ptr->user_chunk_cache_max : 0);
 }
 
 /* This function was added to libpng 1.4.1 */
 png_alloc_size_t PNGAPI
-png_get_chunk_malloc_max (png_structp png_ptr)
+png_get_chunk_malloc_max (const_png_structp png_ptr)
 {
    return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
 }
diff --git a/pngmem.c b/pngmem.c
index c7e8a9b..f9fd35f 100644
--- a/pngmem.c
+++ b/pngmem.c
@@ -1,7 +1,7 @@
 
 /* pngmem.c - stub functions for memory allocation
  *
- * Last changed in libpng 1.5.0 [January 6, 2011]
+ * Last changed in libpng 1.5.1 [(PENDING RELEASE)]
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -647,7 +647,7 @@
  * pointer before png_write_destroy and png_read_destroy are called.
  */
 png_voidp PNGAPI
-png_get_mem_ptr(png_structp png_ptr)
+png_get_mem_ptr(const_png_structp png_ptr)
 {
    if (png_ptr == NULL)
       return (NULL);
diff --git a/pngpread.c b/pngpread.c
index 0a9f229..1ff8b5d 100644
--- a/pngpread.c
+++ b/pngpread.c
@@ -1786,7 +1786,7 @@
 }
 
 png_voidp PNGAPI
-png_get_progressive_ptr(png_structp png_ptr)
+png_get_progressive_ptr(const_png_structp png_ptr)
 {
    if (png_ptr == NULL)
       return (NULL);
diff --git a/pngtest.c b/pngtest.c
index 4f7f65b..cc031c2 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -1784,4 +1784,4 @@
 }
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_5_1rc01 Your_png_h_is_not_version_1_5_1rc01;
+typedef png_libpng_version_1_5_1beta07 Your_png_h_is_not_version_1_5_1beta07;
diff --git a/pngtrans.c b/pngtrans.c
index 1f4da17..1662af7 100644
--- a/pngtrans.c
+++ b/pngtrans.c
@@ -1,7 +1,7 @@
 
 /* pngtrans.c - transforms the data in a row (used by both readers and writers)
  *
- * Last changed in libpng 1.5.0 [January 6, 2011]
+ * Last changed in libpng 1.5.1 [(PENDING RELEASE)]
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -697,7 +697,7 @@
  * are called.
  */
 png_voidp PNGAPI
-png_get_user_transform_ptr(png_structp png_ptr)
+png_get_user_transform_ptr(const_png_structp png_ptr)
 {
    if (png_ptr == NULL)
       return (NULL);