[devel] Enhance pngvalid, correct an error in gray_to_rgb, correct doc error.
This commit is contained in:
parent
d52cd11ed2
commit
f21a0d0eee
1
CHANGES
1
CHANGES
@ -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.)
|
skipping of unread data (e.g., if the reader marks a chunk to be skipped.)
|
||||||
|
|
||||||
Version 1.5.1beta09 [January 23, 2011]
|
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
|
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||||
(subscription required; visit
|
(subscription required; visit
|
||||||
|
@ -120,7 +120,8 @@ pngvalid.o pngtest.o: pnglibconf.h
|
|||||||
|
|
||||||
SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0'\
|
SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0'\
|
||||||
-DPNGLIB_VERSION='@PNGLIB_VERSION@'\
|
-DPNGLIB_VERSION='@PNGLIB_VERSION@'\
|
||||||
-DSYMBOL_PREFIX='$(SYMBOL_PREFIX)'
|
-DSYMBOL_PREFIX='$(SYMBOL_PREFIX)'\
|
||||||
|
-DPNG_NO_USE_READ_MACROS
|
||||||
|
|
||||||
.dfn.out:
|
.dfn.out:
|
||||||
rm -f $@ dfn.c dfn?.out
|
rm -f $@ dfn.c dfn?.out
|
||||||
|
@ -357,7 +357,8 @@ config.sub configure depcomp install-sh ltmain.sh missing
|
|||||||
SUFFIXES = .chk .dfn .out
|
SUFFIXES = .chk .dfn .out
|
||||||
SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0'\
|
SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0'\
|
||||||
-DPNGLIB_VERSION='@PNGLIB_VERSION@'\
|
-DPNGLIB_VERSION='@PNGLIB_VERSION@'\
|
||||||
-DSYMBOL_PREFIX='$(SYMBOL_PREFIX)'
|
-DSYMBOL_PREFIX='$(SYMBOL_PREFIX)'\
|
||||||
|
-DPNG_NO_USE_READ_MACROS
|
||||||
|
|
||||||
all: config.h
|
all: config.h
|
||||||
$(MAKE) $(AM_MAKEFLAGS) all-am
|
$(MAKE) $(AM_MAKEFLAGS) all-am
|
||||||
|
@ -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
|
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
|
Y = (6968 * R + 23434 * G + 2366 * B)/32768
|
||||||
|
|
||||||
which can be expressed with integers as
|
|
||||||
|
|
||||||
Y = (6969 * R + 23434 * G + 2365 * B)/32768
|
|
||||||
|
|
||||||
The calculation is done in a linear colorspace, if the image gamma
|
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(),
|
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
|
png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to
|
||||||
|
52
png.h
52
png.h
@ -1067,7 +1067,9 @@ PNG_EXPORT(30, void, png_set_bgr, (png_structp png_ptr));
|
|||||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||||
/* Expand the grayscale to 24-bit RGB if necessary. */
|
/* Expand the grayscale to 24-bit RGB if necessary. */
|
||||||
PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structp png_ptr));
|
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. */
|
/* Reduce RGB to grayscale. */
|
||||||
PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structp png_ptr,
|
PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structp png_ptr,
|
||||||
int error_action, double red, double green));
|
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)
|
(png_uint_32)32767) / (png_uint_32)65535L)
|
||||||
#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
|
#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
|
#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||||
PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));
|
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));
|
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. */
|
/* No png_save_int_16 -- may be added if there's a real need for it. */
|
||||||
#endif
|
#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
|
/* Maintainer: Put new public prototypes here ^, in libpng.3, and project
|
||||||
* defs
|
* defs
|
||||||
*/
|
*/
|
||||||
|
@ -692,8 +692,13 @@ png_set_gray_to_rgb(png_structp png_ptr)
|
|||||||
{
|
{
|
||||||
png_debug(1, "in png_set_gray_to_rgb");
|
png_debug(1, "in png_set_gray_to_rgb");
|
||||||
|
|
||||||
png_ptr->transformations |= PNG_GRAY_TO_RGB;
|
if (png_ptr != NULL)
|
||||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
{
|
||||||
|
/* 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
|
#endif
|
||||||
|
|
||||||
|
1643
pngvalid.c
1643
pngvalid.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user