[devel] Added high-level PNG_TRANSFORM_GRAY_TO_RGB transform.
diff --git a/ANNOUNCE b/ANNOUNCE
index 354735a..8f3d6ef 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -495,8 +495,8 @@
   Refer to the libpng license instead of the libpng license in each file.
 
 version 1.4.0beta67 [June 29, 2009]
-  Relocated INVERT_ALPHA within png_read_png() and png_write_png()
-    to match its position in pngrtran.c.
+  Relocated INVERT_ALPHA within png_read_png() and png_write_png().
+  Added high-level API transform PNG_TRANSFORM_GRAY_TO_RGB.
 
 version 1.4.0betaN [future]
   Build shared libraries with -lz and sometimes -lm.
diff --git a/CHANGES b/CHANGES
index c82f3e4..056675f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2172,8 +2172,8 @@
   Refer to the libpng license instead of the libpng license in each file.
 
 version 1.4.0beta67 [June 29, 2009]
-  Relocated INVERT_ALPHA within png_read_png() and png_write_png()
-    to match its position in pngrtran.c.
+  Relocated INVERT_ALPHA within png_read_png() and png_write_png().
+  Added high-level API transform PNG_TRANSFORM_GRAY_TO_RGB.
 
 version 1.4.0betaN [future]
   Build shared libraries with -lz and sometimes -lm.
diff --git a/libpng-1.4.0beta67.txt b/libpng-1.4.0beta67.txt
index ce7d7f8..6b2be1f 100644
--- a/libpng-1.4.0beta67.txt
+++ b/libpng-1.4.0beta67.txt
@@ -447,6 +447,8 @@
     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)
 
 (This excludes setting a background color, doing gamma transformation,
 dithering, and setting filler.)  If this is the case, simply do this:
@@ -3028,13 +3030,18 @@
 
 We removed the trailing '.' from the warning and error messages.
 
+We added PNG_TRANSFORM_GRAY_TO_RGB to the available high-level
+input transforms.
+
 
 X. Detecting libpng
 
 The png_get_io_ptr() function has been present since libpng-0.88, has never
 changed, and is unaffected by conditional compilation macros.  It is the
 best choice for use in configure scripts for detecting the presence of any
-libpng version since 0.88.
+libpng version since 0.88.  In an autoconf "configure.in" you could use
+
+    AC_CHECK_LIB(png, png_get_io_ptr, ...
 
 XI. Source code repository
 
diff --git a/libpng.3 b/libpng.3
index 1a1e0fc..89575d2 100644
--- a/libpng.3
+++ b/libpng.3
@@ -1256,6 +1256,8 @@
     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)
 
 (This excludes setting a background color, doing gamma transformation,
 dithering, and setting filler.)  If this is the case, simply do this:
@@ -3837,13 +3839,18 @@
 
 We removed the trailing '.' from the warning and error messages.
 
+We added PNG_TRANSFORM_GRAY_TO_RGB to the available high-level
+input transforms.
+
 
 .SH X. Detecting libpng
 
 The png_get_io_ptr() function has been present since libpng-0.88, has never
 changed, and is unaffected by conditional compilation macros.  It is the
 best choice for use in configure scripts for detecting the presence of any
-libpng version since 0.88.
+libpng version since 0.88.  In an autoconf "configure.in" you could use
+
+    AC_CHECK_LIB(png, png_get_io_ptr, ...
 
 .SH XI. Source code repository
 
diff --git a/png.h b/png.h
index fb3fd32..2987402 100644
--- a/png.h
+++ b/png.h
@@ -1046,10 +1046,12 @@
 #define PNG_TRANSFORM_SWAP_ALPHA     0x0100    /* read and write */
 #define PNG_TRANSFORM_SWAP_ENDIAN    0x0200    /* read and write */
 #define PNG_TRANSFORM_INVERT_ALPHA   0x0400    /* read and write */
-#define PNG_TRANSFORM_STRIP_FILLER   0x0800    /* WRITE only */
+#define PNG_TRANSFORM_STRIP_FILLER   0x0800    /* write only */
 /* Added to libpng-1.2.34 */
 #define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER
-#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* WRITE only */
+#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */
+/* Added to libpng-1.4.0 */
+#define PNG_TRANSFORM_GRAY_TO_RGB   0x2000      /* read only */
 
 /* Flags for MNG supported features */
 #define PNG_FLAG_MNG_EMPTY_PLTE     0x01
diff --git a/pngread.c b/pngread.c
index 9ef8fd7..3120b44 100644
--- a/pngread.c
+++ b/pngread.c
@@ -1302,6 +1302,13 @@
        png_set_invert_alpha(png_ptr);
 #endif
 
+#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
+   /* Expand grayscale image to RGB
+    */
+   if (transforms & PNG_TRANSFORM_GRAY_TO_RGB)
+       png_set_gray_to_rgb(png_structp png_ptr);
+#endif
+
    /* We don't handle adding filler bytes */
 
    /* Optional call to gamma correct and add the background to the palette
diff --git a/pngwrite.c b/pngwrite.c
index 27744a7..526c505 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -1412,6 +1412,12 @@
       png_set_invert_alpha(png_ptr);
 #endif
 
+#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
+   /* Invert the alpha channel from opacity to transparency */
+   if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
+      png_set_invert_alpha(png_ptr);
+#endif
+
    /* ----------------------- end of transformations ------------------- */
 
    /* Write the bits */