From b2154ccb2bac8193837215d8b9cfaae296dd0c0f Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Thu, 26 Nov 2009 11:48:15 -0600 Subject: [PATCH] [devel] Moved the PNG_DIVIDE_* and PNG_*_PREMULTIPLY macros from png.h to pngpriv.h. --- ANNOUNCE | 1 + CHANGES | 1 + png.h | 21 +-------------------- pngpriv.h | 19 +++++++++++++++++++ 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index a8cd241a1..879a435f3 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -715,6 +715,7 @@ version 1.4.0beta105 [November 25, 2009] that the 255 is used as a double. version 1.4.0beta106 [November 26, 2009] + Moved the PNG_DIVIDE_* and PNG_*_PREMULTIPLY macros from png.h to pngpriv.h. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index 2c16bf20c..d65dab682 100644 --- a/CHANGES +++ b/CHANGES @@ -2402,6 +2402,7 @@ version 1.4.0beta105 [November 25, 2009] that the 255 is used as a double. version 1.4.0beta106 [November 26, 2009] + Moved the PNG_DIVIDE_* and PNG_*_PREMULTIPLY macros from png.h to pngpriv.h. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/png.h b/png.h index 523aef106..a44c363da 100644 --- a/png.h +++ b/png.h @@ -131,7 +131,7 @@ * 1.4.0beta15-36 14 10400 14.so.0.0[.0] * 1.4.0beta37-87 14 10400 14.so.14.0[.0] * 1.4.0rc01 14 10400 14.so.14.0[.0] - * 1.4.0beta88-106 14 10400 14.so.14.0[.0] + * 1.4.0beta88-105 14 10400 14.so.14.0[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be @@ -2474,15 +2474,6 @@ extern PNG_EXPORT(png_bytep,png_get_io_chunk_name) (png_uint_32)(alpha)) + (png_uint_32)32768L); \ (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } -#ifdef PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED -#define PNG_DIVIDE_BY_255(v) \ - ((png_byte)(((png_uint_16)(v) + \ - (((png_uint_16)(v) + 128) >> 8) + 128) >> 8)) -#define PNG_DIVIDE_BY_65535(v) \ - ((png_byte)(((png_uint_32)(v) + \ - (((png_uint_32)(v) + 32768L) >> 16) + 32768L) >> 16)) -#endif - #else /* Standard method using integer division */ # define png_composite(composite, fg, alpha, bg) \ @@ -2494,18 +2485,8 @@ extern PNG_EXPORT(png_bytep,png_get_io_chunk_name) (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \ (png_uint_32)32767) / (png_uint_32)65535L) - -#define PNG_DIVIDE_BY_255(v) (((png_uint_16)(v))/255) -#define PNG_DIVIDE_BY_65535(v) (((png_uint_32)(v))/65535L) #endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ -#ifdef PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED -#define PNG_8_BIT_PREMULTIPLY(color,alpha) \ - PNG_DIVIDE_BY_255((color)*(alpha)) -#define PNG_16_BIT_PREMULTIPLY(color,alpha)\ - PNG_DIVIDE_BY_65535((color)*(alpha)) -#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 diff --git a/pngpriv.h b/pngpriv.h index b1f41d52c..f120a65fe 100644 --- a/pngpriv.h +++ b/pngpriv.h @@ -831,6 +831,25 @@ PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr, int color_type, int interlace_type, int compression_type, int filter_type)); +#ifdef PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED +# ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED +# define PNG_DIVIDE_BY_255(v) \ + ((png_byte)(((png_uint_16)(v) + \ + (((png_uint_16)(v) + 128) >> 8) + 128) >> 8)) +# define PNG_DIVIDE_BY_65535(v) \ + ((png_byte)(((png_uint_32)(v) + \ + (((png_uint_32)(v) + 32768L) >> 16) + 32768L) >> 16)) +# else +# define PNG_DIVIDE_BY_255(v) (((png_uint_16)(v))/255) +# define PNG_DIVIDE_BY_65535(v) (((png_uint_32)(v))/65535L) +# endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ + +# define PNG_8_BIT_PREMULTIPLY(color,alpha) \ + PNG_DIVIDE_BY_255((color)*(alpha)) +# define PNG_16_BIT_PREMULTIPLY(color,alpha)\ + PNG_DIVIDE_BY_65535((color)*(alpha)) +#endif /* PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED */ + /* Free all memory used by the read (old method - NOT DLL EXPORTED) */ extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr));