[devel] Made png_set_chop_16() API removeable

by disabling PNG_CHOP_16_TO_8_SUPPORTED
This commit is contained in:
Glenn Randers-Pehrson 2011-06-14 06:59:46 -05:00
parent 7dffa41643
commit 2232baa41b
7 changed files with 25 additions and 9 deletions

View File

@ -200,6 +200,8 @@ Version 1.5.4beta02 [June 14, 2011]
Removed the ACCURATE and LEGACY options (they are no longer useable)
Use the old scaling method for background if png_set_chop_16() was
called.
Made png_set_chop_16() API removeable by disabling PNG_CHOP_16_TO_8_SUPPORTED
Send comments/corrections/commendations to png-mng-implement at lists.sf.net:
(subscription required; visit

View File

@ -3463,6 +3463,7 @@ Version 1.5.4beta02 [June 14, 2011]
Removed the ACCURATE and LEGACY options (they are no longer useable)
Use the old scaling method for background if png_set_chop_16() was
called.
Made png_set_chop_16() API removeable by disabling PNG_CHOP_16_TO_8_SUPPORTED
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

2
png.h
View File

@ -1427,8 +1427,10 @@ PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structp png_ptr,
#define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
/* Scale a 16-bit depth file down to 8-bit, accurately. */
PNG_EXPORT(48, void, png_set_strip_16, (png_structp png_ptr));
# ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED
/* Strip the second byte of information from a 16-bit depth file. */
PNG_EXPORT(229, void, png_set_chop_16, (png_structp png_ptr));
# endif
#endif
#ifdef PNG_READ_QUANTIZE_SUPPORTED

View File

@ -823,8 +823,10 @@ PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info,
PNG_EXTERN void png_do_scale_16_to_8 PNGARG((png_row_infop row_info,
png_bytep row));
#ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED
PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info,
png_bytep row));
#endif
PNG_EXTERN void png_do_scale_16_to_8 PNGARG((png_row_infop row_info,
png_bytep row));
#endif

View File

@ -143,9 +143,12 @@ png_set_strip_16(png_structp png_ptr)
return;
png_ptr->transformations |= PNG_16_TO_8;
#ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED
png_ptr->transformations &= ~PNG_CHOP_16_TO_8;
#endif
}
#ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED
/* Chop 16-bit depth files to 8-bit depth */
void PNGAPI
png_set_chop_16(png_structp png_ptr)
@ -159,6 +162,7 @@ png_set_chop_16(png_structp png_ptr)
png_ptr->transformations &= ~PNG_16_TO_8;
}
#endif
#endif /* PNG_READ_16_TO_8_SUPPORTED */
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
void PNGAPI
@ -1454,7 +1458,7 @@ png_init_read_transformations(png_structp png_ptr)
* present, so that case is ok (until do_expand_16 is moved.)
*/
if (png_ptr->transformations & PNG_CHOP_16_TO_8)
if (png_ptr->transformations & PNG_16_TO_8)
{
# define CHOP(x) (x)=((png_uint_16)(((png_uint_32)(x)*255+32895) >> 16))
CHOP(png_ptr->background.red);
@ -1463,17 +1467,19 @@ png_init_read_transformations(png_structp png_ptr)
CHOP(png_ptr->background.gray);
# undef CHOP
}
#ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED
else /* Use pre-libpng-1.5.4 inaccurate "ACCURATE" scaling */
{
# define CHOP(x) ((png_uint_16)((2*(png_uint_32)(x) + 257)/514))
# define CHOP(x) (x)=((png_uint_16)((2*(png_uint_32)(x) + 257)/514))
CHOP(png_ptr->background.red);
CHOP(png_ptr->background.green);
CHOP(png_ptr->background.blue);
CHOP(png_ptr->background.gray);
# undef CHOP
}
#endif /* PNG_READ_CHOP_16_TO_8_SUPPORTED */
}
#endif
#endif /* PNG_READ_BACKGROUND_SUPPORTED && PNG_READ_EXPAND_16_SUPPORTED */
/* NOTE: below 'PNG_READ_ALPHA_MODE_SUPPORTED' is presumed to also enable the
* background support (see the comments in scripts/pnglibconf.dfa), this
@ -2149,8 +2155,10 @@ png_do_read_transformations(png_structp png_ptr)
#ifdef PNG_READ_16_TO_8_SUPPORTED
if (png_ptr->transformations & PNG_16_TO_8)
png_do_scale_16_to_8(&(png_ptr->row_info), png_ptr->row_buf + 1);
# ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED
else if (png_ptr->transformations & PNG_CHOP_16_TO_8)
png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1);
# endif
#endif
#ifdef PNG_READ_QUANTIZE_SUPPORTED

View File

@ -293,8 +293,8 @@ option READ enables READ_INTERLACING
# Disabling READ_16BIT does not disable reading 16-bit PNG files, but it
# forces them to be chopped down to 8-bit, and disables any 16-bit
# processing after that has happened. You need to be sure to enable READ_16_TO_8
# when you disable READ_16BIT for this to work properly.
# processing after that has happened. You need to be sure to enable
# READ_16_TO_8 when you disable READ_16BIT for this to work properly.
option READ_16BIT requires READ enables 16BIT
@ -346,8 +346,6 @@ option INCH_CONVERSIONS
option BUILD_GRAYSCALE_PALETTE
option READ_16_TO_8_ACCURATE_SCALE requires READ
# IN DEVELOPMENT
# These are currently experimental features; define them if you want
@ -552,7 +550,10 @@ option SAVE_INT_32 requires WRITE
# png_save_int_32 is required by the ancillary chunks oFFs and pCAL
# added at libpng-1.5.3
# added at libpng-1.5.4
option READ_CHOP_16_TO_8 requires READ_16_TO_8
option WRITE_OPTIMIZE_CMF requires WRITE
option READ_COMPRESSED_TEXT disabled
@ -570,7 +571,6 @@ option WRITE_iTXt enables WRITE_COMPRESSED_TEXT
option WRITE_zTXt enables WRITE_COMPRESSED_TEXT
option WRITE_COMPRESSED_TEXT enables WRITE_TEXT
# Turn this off to disable png_read_png() and png_write_png() and
# leave the row_pointers member out of the info structure.

View File

@ -76,6 +76,7 @@
#define PNG_READ_BGR_SUPPORTED
#define PNG_READ_bKGD_SUPPORTED
#define PNG_READ_cHRM_SUPPORTED
#define PNG_READ_CHOP_16_TO_8_SUPPORTED
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
#define PNG_READ_EXPAND_16_SUPPORTED
#define PNG_READ_EXPAND_SUPPORTED