mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[devel] Made it possible to undefine PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
to get the same (inaccurate) output as libpng-1.5.2 and earlier.
This commit is contained in:
13
pngrtran.c
13
pngrtran.c
@@ -1439,7 +1439,11 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
* The PNG_BACKGROUND_EXPAND code above does not expand to 16 bits at
|
||||
* present, so that case is ok (until do_expand_16 is moved.)
|
||||
*/
|
||||
#ifdef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
|
||||
# define CHOP(x) (x)=((png_uint_16)(((png_uint_32)(x)*255+32895) >> 16))
|
||||
#else
|
||||
# define CHOP(x) ((png_uint_16)((2*(png_uint_32)(x) + 257)/514))
|
||||
#endif
|
||||
CHOP(png_ptr->background.red);
|
||||
CHOP(png_ptr->background.green);
|
||||
CHOP(png_ptr->background.blue);
|
||||
@@ -2494,9 +2498,18 @@ png_do_chop(png_row_infop row_info, png_bytep row)
|
||||
*
|
||||
* (V * 255 + 32895) >> 16
|
||||
*/
|
||||
|
||||
#ifdef PNG_LEGACY_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
|
||||
*dp = *sp + ((((int)(*(sp + 1)) - *sp) > 128) ? 1 : 0);
|
||||
#else
|
||||
png_int_32 tmp = *sp++; /* must be signed! */
|
||||
# ifdef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
|
||||
tmp += (((int)*sp++ - tmp + 128) * 65535) >> 24;
|
||||
# else
|
||||
sp++;
|
||||
# endif
|
||||
*dp++ = (png_byte)tmp;
|
||||
#endif
|
||||
}
|
||||
|
||||
row_info->bit_depth = 8;
|
||||
|
||||
Reference in New Issue
Block a user