From 74945f2f0466a124c1cf036ca8e6339841d3f646 Mon Sep 17 00:00:00 2001 From: John Bowler Date: Mon, 13 Jun 2011 20:50:42 -0500 Subject: [PATCH] [devel] Fix and clarify LEGACY 16-to-8 scaling. --- pngrtran.c | 10 +++++----- pngtest.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pngrtran.c b/pngrtran.c index 5fb6f4840..4ed4b4c7c 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -1,7 +1,7 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.5.3 [(PENDING RELEASE)] + * Last changed in libpng 1.5.4 [(PENDING RELEASE)] * Copyright (c) 1998-2011 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -2499,17 +2499,17 @@ 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_LEGACY_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED + tmp += (((int)*sp++ - tmp) > 128) ? 1 : 0; +#else # ifdef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED tmp += (((int)*sp++ - tmp + 128) * 65535) >> 24; # else sp++; # endif - *dp++ = (png_byte)tmp; #endif + *dp++ = (png_byte)tmp; } row_info->bit_depth = 8; diff --git a/pngtest.c b/pngtest.c index 2e74fc75e..515b535a2 100644 --- a/pngtest.c +++ b/pngtest.c @@ -1,7 +1,7 @@ /* pngtest.c - a simple test program to test libpng * - * Last changed in libpng 1.5.3 [(PENDING RELEASE)] + * Last changed in libpng 1.5.4 [(PENDING RELEASE)] * Copyright (c) 1998-2011 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -1794,4 +1794,4 @@ main(int argc, char *argv[]) } /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_5_4beta01 Your_png_h_is_not_version_1_5_4beta01; +typedef png_libpng_version_1_5_4beta02 Your_png_h_is_not_version_1_5_4beta02;