[devel] Added high-level PNG_TRANSFORM_GRAY_TO_RGB transform.

This commit is contained in:
Glenn Randers-Pehrson 2009-06-29 17:30:00 -05:00
parent 6878eb6899
commit 99708d560f
7 changed files with 37 additions and 8 deletions

View File

@ -495,8 +495,8 @@ version 1.4.0beta66 [June 27, 2009]
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.

View File

@ -2172,8 +2172,8 @@ version 1.4.0beta66 [June 27, 2009]
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.

View File

@ -447,6 +447,8 @@ you want to do are limited to the following set:
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 @@ The png_calloc() function was added.
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

View File

@ -1256,6 +1256,8 @@ you want to do are limited to the following set:
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 @@ The png_calloc() function was added.
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

6
png.h
View File

@ -1046,10 +1046,12 @@ typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp));
#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

View File

@ -1302,6 +1302,13 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
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

View File

@ -1406,6 +1406,12 @@ png_write_png(png_structp png_ptr, png_infop info_ptr,
png_set_packswap(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
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
/* Invert the alpha channel from opacity to transparency */
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)