From fded04fbf62be23b415b3edf7a2648e63aa5c63e Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Fri, 27 Aug 2010 14:21:21 -0500 Subject: [PATCH] [devel] Revised pngvalid.c 16-to-8-big conversion tests --- contrib/pngminim/decoder/pngusr.dfa | 4 +++- contrib/pngminim/encoder/pngusr.dfa | 7 +++++-- contrib/pngminim/preader/pngusr.dfa | 5 +++++ pngvalid.c | 14 +++++++++----- scripts/pnglibconf.dfa | 6 ++++++ 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/contrib/pngminim/decoder/pngusr.dfa b/contrib/pngminim/decoder/pngusr.dfa index e6c6e3d66..d8cae2627 100644 --- a/contrib/pngminim/decoder/pngusr.dfa +++ b/contrib/pngminim/decoder/pngusr.dfa @@ -7,6 +7,7 @@ # and license in png.h # First all the build options off: + everything = off # All that is required is some read code. This example switches @@ -31,7 +32,8 @@ option FLOATING_ARITHMETIC off # program here, pngm2pnm, requires the following. Take a look # at pnglibconf.h to find out the full set of what has to be # enabled to make the following work. + option SETJMP on option STDIO on option READ_EXPAND on -option READ_16BIT on +option READ_16_TO_8 on diff --git a/contrib/pngminim/encoder/pngusr.dfa b/contrib/pngminim/encoder/pngusr.dfa index f87317763..5a10474ab 100644 --- a/contrib/pngminim/encoder/pngusr.dfa +++ b/contrib/pngminim/encoder/pngusr.dfa @@ -7,26 +7,29 @@ # and license in png.h # First all the build options off: + everything = off -option NO_16BIT on - # Switch on the write code - this makes a minimalist encoder + option WRITE on # You must choose fixed or floating point arithmetic: # option FLOATING_POINT on + option FIXED_POINT on # You must chose the internal fixed point implementation or to # use the system floating point. The latter is considerably # smaller (by about 1kbyte on an x86 system): # option FLOATING_ARITHMETIC on + option FLOATING_ARITHMETIC off # Your program will probably need other options. The example # program here, pnm2pngm, requires the following. Take a look # at pnglibconf.h to find out the full set of what has to be # enabled to make the following work. + option SETJMP on option STDIO on diff --git a/contrib/pngminim/preader/pngusr.dfa b/contrib/pngminim/preader/pngusr.dfa index 0ebcc30d4..780ed0cd1 100644 --- a/contrib/pngminim/preader/pngusr.dfa +++ b/contrib/pngminim/preader/pngusr.dfa @@ -7,18 +7,22 @@ # and license in png.h # First all the build options off: + everything = off # Just switch on the progressive read code + option PROGRESSIVE_READ on # You may choose fixed or floating point APIs: # option FLOATING_POINT on + option FIXED_POINT on # You must chose the internal fixed point implementation or to # use the system floating point. The latter is considerably # smaller (by about 1kbyte on an x86 system): + option FLOATING_ARITHMETIC on # option FLOATING_ARITHMETIC off @@ -26,6 +30,7 @@ option FLOATING_ARITHMETIC on # program here, rpng2-x, requires the following. Take a look # at pnglibconf.h to find out the full set of what has to be # enabled to make the following work. + option SETJMP on option STDIO on option READ_bKGD on diff --git a/pngvalid.c b/pngvalid.c index 9a3d524c1..1a607c652 100644 --- a/pngvalid.c +++ b/pngvalid.c @@ -1,7 +1,7 @@ /* pngvalid.c - validate libpng by constructing then reading png files. * - * Last changed in libpng 1.5.0 [August 26, 2010] + * Last changed in libpng 1.5.0 [August 27, 2010] * Copyright (c) 2010 Glenn Randers-Pehrson * Written by John C. Bowler * @@ -2776,7 +2776,11 @@ gamma_info_imp(gamma_display *dp, png_structp pp, png_infop pi) * PNG_MAX_GAMMA_8 when doing the following. */ if (dp->strip16) - png_set_strip_16(pp); +# ifdef PNG_READ_16_TO_8 + png_set_strip_16(pp); +# else + png_error(pp, "strip16 (16 to 8 bit conversion) not supported"); +# endif png_read_update_info(pp, pi); @@ -3355,7 +3359,7 @@ static void perform_gamma_sbit_tests(png_modifier *pm, int speed) /* Note that this requires a 16 bit source image but produces 8 bit output, so * we only need the 16bit write support. */ -#ifdef PNG_WRITE_16BIT_SUPPORTED +#ifdef PNG_16_TO_8_SUPPORTED static void perform_gamma_strip16_tests(png_modifier *pm, int speed) { # ifndef PNG_MAX_GAMMA_8 @@ -3408,7 +3412,7 @@ static void perform_gamma_strip16_tests(png_modifier *pm, int speed) } } } -#endif +#endif /* 16 to 8 bit conversion */ static void perform_gamma_test(png_modifier *pm, int speed, int summary) @@ -3461,7 +3465,7 @@ perform_gamma_test(png_modifier *pm, int speed, int summary) #endif } -#ifdef PNG_WRITE_16BIT_SUPPORTED +#ifdef PNG_16_TO_8_SUPPORTED /* The 16 to 8 bit strip operations: */ pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = pm->error_gray_16 = pm->error_color_8 = pm->error_color_16 = 0; diff --git a/scripts/pnglibconf.dfa b/scripts/pnglibconf.dfa index e3a21bc00..cf1dc6202 100644 --- a/scripts/pnglibconf.dfa +++ b/scripts/pnglibconf.dfa @@ -291,6 +291,10 @@ setting USER_CHUNK_MALLOC_MAX default 0 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. + option READ_16BIT requires READ enables 16BIT option READ_QUANTIZE requires READ @@ -345,6 +349,8 @@ option READ_16_TO_8_ACCURATE_SCALE requires READ disabled option WRITE +# Disabling WRITE_16BIT prevents 16-bit PNG files from being +# generated. option WRITE_16BIT requires WRITE enables 16BIT option WRITE_TRANSFORMS requires WRITE