[devel] Enhance pngvalid, correct an error in gray_to_rgb, correct doc error.

This commit is contained in:
John Bowler 2011-01-23 23:55:19 -06:00 committed by Glenn Randers-Pehrson
parent d52cd11ed2
commit f21a0d0eee
7 changed files with 1668 additions and 53 deletions

View File

@ -3204,6 +3204,7 @@ Version 1.5.1beta08 [January 23, 2011]
skipping of unread data (e.g., if the reader marks a chunk to be skipped.)
Version 1.5.1beta09 [January 23, 2011]
Subject: [PATCH] Enhance pngvalid, correct an error in gray_to_rgb, correct doc error.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -120,7 +120,8 @@ pngvalid.o pngtest.o: pnglibconf.h
SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0'\
-DPNGLIB_VERSION='@PNGLIB_VERSION@'\
-DSYMBOL_PREFIX='$(SYMBOL_PREFIX)'
-DSYMBOL_PREFIX='$(SYMBOL_PREFIX)'\
-DPNG_NO_USE_READ_MACROS
.dfn.out:
rm -f $@ dfn.c dfn?.out

View File

@ -357,7 +357,8 @@ config.sub configure depcomp install-sh ltmain.sh missing
SUFFIXES = .chk .dfn .out
SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0'\
-DPNGLIB_VERSION='@PNGLIB_VERSION@'\
-DSYMBOL_PREFIX='$(SYMBOL_PREFIX)'
-DSYMBOL_PREFIX='$(SYMBOL_PREFIX)'\
-DPNG_NO_USE_READ_MACROS
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am

View File

@ -1341,16 +1341,12 @@ Copyright (c) 1998-01-04 Charles Poynton <poynton at inforamp.net>
Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
Libpng approximates this with
Libpng approximates this integers scaled by 32768:
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
Y = (6968 * R + 23434 * G + 2366 * B)/32768
The calculation is done in a linear colorspace, if the image gamma
is known.
can be determined.
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

52
png.h
View File

@ -1067,7 +1067,9 @@ PNG_EXPORT(30, void, png_set_bgr, (png_structp png_ptr));
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
/* Expand the grayscale to 24-bit RGB if necessary. */
PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structp png_ptr));
#endif
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
/* Reduce RGB to grayscale. */
PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structp png_ptr,
int error_action, double red, double green));
@ -2203,31 +2205,6 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
(png_uint_32)32767) / (png_uint_32)65535L)
#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
#ifdef PNG_USE_READ_MACROS
/* Inline macros to do direct reads of bytes from the input buffer.
* The png_get_int_32() routine assumes we are using two's complement
* format for negative values, which is almost certainly true.
*/
# define png_get_uint_32(buf) \
(((png_uint_32)(*(buf)) << 24) + \
((png_uint_32)(*((buf) + 1)) << 16) + \
((png_uint_32)(*((buf) + 2)) << 8) + \
((png_uint_32)(*((buf) + 3))))
/* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
* function) incorrectly returned a value of type png_uint_32.
*/
# define png_get_uint_16(buf) \
((png_uint_16) \
(((unsigned int)(*(buf)) << 8) + \
((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_READ_INT_FUNCTIONS_SUPPORTED
PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));
PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf));
@ -2255,6 +2232,31 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
/* No png_save_int_16 -- may be added if there's a real need for it. */
#endif
#ifdef PNG_USE_READ_MACROS
/* Inline macros to do direct reads of bytes from the input buffer.
* The png_get_int_32() routine assumes we are using two's complement
* format for negative values, which is almost certainly true.
*/
# define png_get_uint_32(buf) \
(((png_uint_32)(*(buf)) << 24) + \
((png_uint_32)(*((buf) + 1)) << 16) + \
((png_uint_32)(*((buf) + 2)) << 8) + \
((png_uint_32)(*((buf) + 3))))
/* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
* function) incorrectly returned a value of type png_uint_32.
*/
# define png_get_uint_16(buf) \
((png_uint_16) \
(((unsigned int)(*(buf)) << 8) + \
((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
/* Maintainer: Put new public prototypes here ^, in libpng.3, and project
* defs
*/

View File

@ -692,8 +692,13 @@ png_set_gray_to_rgb(png_structp png_ptr)
{
png_debug(1, "in png_set_gray_to_rgb");
png_ptr->transformations |= PNG_GRAY_TO_RGB;
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
if (png_ptr != NULL)
{
/* Because rgb must be 8 bits or more: */
png_set_expand_gray_1_2_4_to_8(png_ptr);
png_ptr->transformations |= PNG_GRAY_TO_RGB;
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
}
}
#endif

1643
pngvalid.c

File diff suppressed because it is too large Load Diff