Author: adamg Date: Sun Feb 12 12:58:44 2012 GMT Module: packages Tag: HEAD ---- Log message: - new (from OpenBSD which took it from NetBSD)
---- Files affected: packages/GraphicsMagick: GraphicsMagick-libpng15.patch (NONE -> 1.1) (NEW) ---- Diffs: ================================================================ Index: packages/GraphicsMagick/GraphicsMagick-libpng15.patch diff -u /dev/null packages/GraphicsMagick/GraphicsMagick-libpng15.patch:1.1 --- /dev/null Sun Feb 12 13:58:44 2012 +++ packages/GraphicsMagick/GraphicsMagick-libpng15.patch Sun Feb 12 13:58:39 2012 @@ -0,0 +1,1988 @@ +from: http://www.openbsd.org/cgi-bin/cvsweb/ports/graphics/GraphicsMagick/patches/patch-coders_png_c + +$OpenBSD: patch-coders_png_c,v 1.6 2011/07/08 20:36:09 naddy Exp $ + +png.c taken from 1.4.020110207 for compatibility with png 1.5. + +--- coders/png.c.orig Wed Mar 3 13:26:23 2010 ++++ coders/png.c Tue Jul 5 12:18:20 2011 +@@ -88,27 +88,8 @@ + #include "zlib.h" + + ++#if PNG_LIBPNG_VER > 10011 + /* +- * TO DO: rewrite using png_get_tRNS() instead of direct access to the +- * ping and ping_info structs. +- */ +-#if PNG_LIBPNG_VER < 10400 +-# define trans_color trans_values /* Changed at libpng-1.4.0beta35 */ +-# define trans_alpha trans /* Changed at libpng-1.4.0beta74 */ +-#else +- /* We could parse PNG_LIBPNG_VER_STRING here but it's too much bother.. +- * Just don't use libpng-1.4.0beta32-34 or beta67-73 +- */ +-# ifndef PNG_USER_CHUNK_CACHE_MAX /* Added at libpng-1.4.0beta32 */ +-# define trans_color trans_values /* Changed at libpng-1.4.0beta35 */ +-# endif +-# ifndef PNG_TRANSFORM_GRAY_TO_RGB /* Added at libpng-1.4.0beta67 */ +-# define trans_alpha trans /* Changed at libpng-1.4.0beta74 */ +-# endif +-#endif +- +-#if PNG_LIBPNG_VER > 95 +-/* + Optional declarations. Define or undefine them as you like. + */ + /* #define PNG_DEBUG -- turning this on breaks VisualC compiling */ +@@ -164,10 +145,6 @@ static SemaphoreInfo + PNG_MNG_FEATURES_SUPPORTED is disabled by default in libpng-1.0.9 and + will be enabled by default in libpng-1.2.0. + */ +-#if (PNG_LIBPNG_VER == 10009) /* work around libpng-1.0.9 bug */ +-# undef PNG_READ_EMPTY_PLTE_SUPPORTED +-# undef PNG_WRITE_EMPTY_PLTE_SUPPORTED +-#endif + #ifdef PNG_MNG_FEATURES_SUPPORTED + # ifndef PNG_READ_EMPTY_PLTE_SUPPORTED + # define PNG_READ_EMPTY_PLTE_SUPPORTED +@@ -244,6 +221,16 @@ static png_byte FARDATA mng_tIME[5]={116, 73, 77, 6 + static png_byte FARDATA mng_zTXt[5]={122, 84, 88, 116, '\0'}; + */ + ++typedef struct _UShortPixelPacket ++{ ++ unsigned short ++ red, ++ green, ++ blue, ++ opacity, ++ index; ++} UShortPixelPacket; ++ + typedef struct _MngBox + { + long +@@ -492,7 +479,6 @@ static const char* PngColorTypeToString(const unsigned + return result; + } + +-#if PNG_LIBPNG_VER > 95 + #if defined(PNG_SORT_PALETTE) + /* + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +@@ -785,7 +771,6 @@ static MagickPassFail CompressColormapTransFirst(Image + return(MagickPass); + } + #endif +-#endif /* PNG_LIBPNG_VER > 95 */ + #endif /* HasPNG */ + + /* +@@ -907,7 +892,7 @@ static MagickPassFail IsPNG(const unsigned char *magic + extern "C" { + #endif + +-#if (PNG_LIBPNG_VER > 95) ++#if (PNG_LIBPNG_VER > 10011) + static size_t WriteBlobMSBULong(Image *image,const unsigned long value) + { + unsigned char +@@ -956,13 +941,13 @@ static void LogPNGChunk(int logging, png_bytep type, u + " Writing %c%c%c%c chunk, length: %lu", + type[0],type[1],type[2],type[3],length); + } +-#endif /* PNG_LIBPNG_VER > 95 */ ++#endif /* PNG_LIBPNG_VER > 10011 */ + + #if defined(__cplusplus) || defined(c_plusplus) + } + #endif + +-#if PNG_LIBPNG_VER > 95 ++#if PNG_LIBPNG_VER > 10011 + /* + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % % +@@ -1351,7 +1336,11 @@ static void PNGErrorHandler(png_struct *ping,png_const + " libpng-%.1024s error: %.1024s", + PNG_LIBPNG_VER_STRING, message); + (void) ThrowException2(&image->exception,CoderError,message,image->filename); ++#if (PNG_LIBPNG_VER < 10500) + longjmp(ping->jmpbuf,1); ++#else ++ png_longjmp(ping,1); ++#endif + } + + static void PNGWarningHandler(png_struct *ping,png_const_charp message) +@@ -1372,19 +1361,8 @@ static void PNGWarningHandler(png_struct *ping,png_con + #ifdef PNG_USER_MEM_SUPPORTED + static png_voidp png_IM_malloc(png_structp png_ptr,png_uint_32 size) + { +-#if (PNG_LIBPNG_VER < 10011) +- png_voidp +- ret; +- + png_ptr=png_ptr; +- ret=MagickAllocateMemory(png_voidp,(size_t) size); +- if (ret == NULL) +- png_error("Insufficient memory."); +- return (ret); +-#else +- png_ptr=png_ptr; + return MagickAllocateMemory(png_voidp,(size_t) size); +-#endif + } + + /* +@@ -1560,11 +1538,24 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, + logging, + num_text, + num_passes, +- pass; ++ pass, ++ ping_bit_depth, ++ ping_colortype, ++ ping_interlace_method, ++ ping_compression_method, ++ ping_filter_method, ++ ping_num_trans; + +- PixelPacket ++ UShortPixelPacket + transparent_color; + ++ png_bytep ++ ping_trans_alpha; ++ ++ png_color_16p ++ ping_background, ++ ping_trans_color; ++ + png_info + *end_info, + *ping_info; +@@ -1572,6 +1563,11 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, + png_struct + *ping; + ++ png_uint_32 ++ ping_rowbytes, ++ ping_width, ++ ping_height; ++ + png_textp + text; + +@@ -1619,23 +1615,12 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, + LockSemaphoreInfo(png_semaphore); + #endif + +-#if (PNG_LIBPNG_VER < 10007) ++#if (PNG_LIBPNG_VER < 10012) + if (image_info->verbose) + printf("Your PNG library (libpng-%s) is rather old.\n", + PNG_LIBPNG_VER_STRING); + #endif + +-#if (PNG_LIBPNG_VER >= 10400) +-# ifndef PNG_TRANSFORM_GRAY_TO_RGB /* Added at libpng-1.4.0beta67 */ +- if (image_info->verbose) +- { +- printf("Your PNG library (libpng-%s) is an old beta version.\n", +- PNG_LIBPNG_VER_STRING); +- printf("Please update it.\n"); +- } +-# endif +-#endif +- + image=mng_info->image; + + /* +@@ -1665,7 +1650,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, + ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image); + } + png_pixels=(unsigned char *) NULL; +- if (setjmp(ping->jmpbuf)) ++ if (setjmp(png_jmpbuf(ping))) + { + /* + PNG image is corrupt. +@@ -1740,18 +1725,32 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, + + png_read_info(ping,ping_info); + ++ (void) png_get_IHDR(ping,ping_info, ++ &ping_width, ++ &ping_height, ++ &ping_bit_depth, ++ &ping_colortype, ++ &ping_interlace_method, ++ &ping_compression_method, ++ &ping_filter_method); ++ ++ (void) png_get_tRNS(ping, ping_info, &ping_trans_alpha, &ping_num_trans, ++ &ping_trans_color); ++ ++ (void) png_get_bKGD(ping, ping_info, &ping_background); ++ + #if (QuantumDepth == 8) + image->depth=8; + #else +- if (ping_info->bit_depth > 8) ++ if (ping_bit_depth > 8) + image->depth=16; + else + image->depth=8; + #endif + +- if (ping_info->bit_depth < 8) ++ if (ping_bit_depth < 8) + { +- if ((ping_info->color_type == PNG_COLOR_TYPE_PALETTE)) ++ if (ping_colortype == PNG_COLOR_TYPE_PALETTE) + { + png_set_packing(ping); + image->depth=8; +@@ -1761,21 +1760,22 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + " PNG width: %lu, height: %lu", +- (unsigned long)ping_info->width, +- (unsigned long)ping_info->height); ++ (unsigned long)ping_width, ++ (unsigned long)ping_height); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + " PNG color_type: %d, bit_depth: %d", +- ping_info->color_type, ping_info->bit_depth); ++ ping_colortype, ping_bit_depth); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + " PNG compression_method: %d", +- ping_info->compression_type); ++ ping_compression_method); + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + " PNG interlace_method: %d, filter_method: %d", +- ping_info->interlace_type,ping_info->filter_type); ++ ping_interlace_method, ++ ping_filter_method); + } + +-#if (PNG_LIBPNG_VER > 10008) && defined(PNG_READ_iCCP_SUPPORTED) +- if (ping_info->valid & PNG_INFO_iCCP) ++#if defined(PNG_READ_iCCP_SUPPORTED) ++ if (png_get_valid(ping, ping_info, PNG_INFO_iCCP)) + { + int + compression; +@@ -1803,15 +1803,19 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, + } + } + } +-#endif /* #if (PNG_LIBPNG_VER > 10008) && defined(PNG_READ_iCCP_SUPPORTED) */ ++#endif /* #if defined(PNG_READ_iCCP_SUPPORTED) */ + #if defined(PNG_READ_sRGB_SUPPORTED) + { + int + intent; + +- if (mng_info->have_global_srgb) +- image->rendering_intent=(RenderingIntent) +- (mng_info->global_srgb_intent+1); ++ if (!png_get_sRGB(ping,ping_info,&intent)) ++ { ++ if (mng_info->have_global_srgb) ++ { ++ png_set_sRGB(ping,ping_info,(mng_info->global_srgb_intent+1)); ++ } ++ } + if (png_get_sRGB(ping,ping_info,&intent)) + { + image->rendering_intent=(RenderingIntent) (intent+1); +@@ -1827,8 +1831,11 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, + double + file_gamma; + +- if (mng_info->have_global_gama) +- image->gamma=mng_info->global_gamma; ++ if (!png_get_gAMA(ping,ping_info,&file_gamma)) ++ { ++ if (mng_info->have_global_gama) ++ png_set_gAMA(ping,ping_info,mng_info->global_gamma); ++ } + if (png_get_gAMA(ping,ping_info,&file_gamma)) + { + image->gamma=(float) file_gamma; +@@ -1838,10 +1845,21 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, + file_gamma); + } + } +- if (mng_info->have_global_chrm) +- image->chromaticity=mng_info->global_chrm; +- if (ping_info->valid & PNG_INFO_cHRM) ++ if (!png_get_valid(ping, ping_info, PNG_INFO_cHRM)) + { ++ if (mng_info->have_global_chrm) ++ (void) png_set_cHRM(ping,ping_info, ++ mng_info->global_chrm.white_point.x, ++ mng_info->global_chrm.white_point.y, ++ mng_info->global_chrm.red_primary.x, ++ mng_info->global_chrm.red_primary.y, ++ mng_info->global_chrm.green_primary.x, ++ mng_info->global_chrm.green_primary.y, ++ mng_info->global_chrm.blue_primary.x, ++ mng_info->global_chrm.blue_primary.y); ++ } ++ if (png_get_valid(ping, ping_info, PNG_INFO_cHRM)) ++ { + (void) png_get_cHRM(ping,ping_info, + &image->chromaticity.white_point.x, + &image->chromaticity.white_point.y, +@@ -1867,12 +1885,9 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, + image->chromaticity.white_point.x=0.3127f; + image->chromaticity.white_point.y=0.3290f; + } +- if (mng_info->have_global_gama || image->rendering_intent) +- ping_info->valid|=PNG_INFO_gAMA; +- if (mng_info->have_global_chrm || image->rendering_intent) +- ping_info->valid|=PNG_INFO_cHRM; + #if defined(PNG_oFFs_SUPPORTED) +- if (mng_info->mng_type == 0 && (ping_info->valid & PNG_INFO_oFFs)) ++ if (mng_info->mng_type == 0 && (png_get_valid(ping, ping_info, ++ PNG_INFO_oFFs))) + { + image->page.x=png_get_x_offset_pixels(ping, ping_info); + image->page.y=png_get_y_offset_pixels(ping, ping_info); +@@ -1885,8 +1900,18 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, + } + #endif + #if defined(PNG_pHYs_SUPPORTED) +- if (ping_info->valid & PNG_INFO_pHYs) ++ if (!png_get_valid(ping, ping_info, PNG_INFO_pHYs)) + { ++ if (mng_info->have_global_phys) ++ { ++ png_set_pHYs(ping,ping_info, ++ mng_info->global_x_pixels_per_unit, ++ mng_info->global_y_pixels_per_unit, ++ mng_info->global_phys_unit_type); ++ } ++ } ++ if (png_get_valid(ping, ping_info, PNG_INFO_pHYs)) ++ { + int + unit_type; + +@@ -1915,25 +1940,8 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, + (unsigned long)y_resolution, + unit_type); + } +- else +- { +- if (mng_info->have_global_phys) +- { +- image->x_resolution=(float) mng_info->global_x_pixels_per_unit; +- image->y_resolution=(float) mng_info->global_y_pixels_per_unit; +- if (mng_info->global_phys_unit_type == PNG_RESOLUTION_METER) +- { +- image->units=PixelsPerCentimeterResolution; +- image->x_resolution=(double) +- mng_info->global_x_pixels_per_unit/100.0; +- image->y_resolution=(double) +- mng_info->global_y_pixels_per_unit/100.0; +- } +- ping_info->valid|=PNG_INFO_pHYs; +- } +- } + #endif +- if (ping_info->valid & PNG_INFO_PLTE) ++ if (png_get_valid(ping, ping_info, PNG_INFO_PLTE)) + { + int + number_colors; +@@ -1942,14 +1950,14 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, + palette; + + (void) png_get_PLTE(ping,ping_info,&palette,&number_colors); +- if (number_colors == 0 && ping_info->color_type == ++ if (number_colors == 0 && ping_colortype == + PNG_COLOR_TYPE_PALETTE) + { + if (mng_info->global_plte_length) + { + png_set_PLTE(ping,ping_info,mng_info->global_plte, + (int) mng_info->global_plte_length); +- if (!(ping_info->valid & PNG_INFO_tRNS)) ++ if (!(png_get_valid(ping, ping_info, PNG_INFO_tRNS))) + if (mng_info->global_trns_length) + { + if (mng_info->global_trns_length > +@@ -1966,7 +1974,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, + #ifndef PNG_READ_EMPTY_PLTE_SUPPORTED + mng_info->have_saved_bkgd_index || + #endif +- ping_info->valid & PNG_INFO_bKGD) ++ png_get_valid(ping, ping_info, PNG_INFO_bKGD)) + { + png_color_16 + background; +@@ -1974,9 +1982,9 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, + #ifndef PNG_READ_EMPTY_PLTE_SUPPORTED + if (mng_info->have_saved_bkgd_index) + background.index=mng_info->saved_bkgd_index; +- else + #endif +- background.index=ping_info->background.index; ++ if (png_get_valid(ping, ping_info, PNG_INFO_bKGD)) ++ background.index=ping_background->index; + background.red=(png_uint_16) + mng_info->global_plte[background.index].red; + background.green=(png_uint_16) +@@ -1995,34 +2003,76 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, + } + + #if defined(PNG_READ_bKGD_SUPPORTED) +- if (mng_info->have_global_bkgd && !(ping_info->valid & PNG_INFO_bKGD)) ++ if (mng_info->have_global_bkgd && ++ !(png_get_valid(ping,ping_info, PNG_INFO_bKGD))) + image->background_color=mng_info->mng_global_bkgd; +- if (ping_info->valid & PNG_INFO_bKGD) ++ if (png_get_valid(ping, ping_info, PNG_INFO_bKGD)) + { + /* + Set image background color. + */ ++ + if (logging) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + " Reading PNG bKGD chunk."); +- if (ping_info->bit_depth <= QuantumDepth) ++ ++ if (ping_bit_depth == QuantumDepth) + { +- image->background_color.red=ping_info->background.red; +- image->background_color.green=ping_info->background.green; +- image->background_color.blue=ping_info->background.blue; ++ image->background_color.red = ping_background->red; ++ image->background_color.green= ping_background->green; ++ image->background_color.blue = ping_background->blue; + } +- else ++ else /* Scale background components to 16-bit */ + { ++ unsigned int ++ bkgd_scale; ++ ++ if (logging != MagickFalse) ++ (void) LogMagickEvent(CoderEvent,GetMagickModule(), ++ " raw ping_background=(%d,%d,%d).",ping_background->red, ++ ping_background->green,ping_background->blue); ++ ++ bkgd_scale = 1; ++ if (ping_bit_depth == 1) ++ bkgd_scale = 255; ++ else if (ping_bit_depth == 2) ++ bkgd_scale = 85; ++ else if (ping_bit_depth == 4) ++ bkgd_scale = 17; ++ if (ping_bit_depth <= 8) ++ bkgd_scale *= 257; ++ ++ ping_background->red *= bkgd_scale; ++ ping_background->green *= bkgd_scale; ++ ping_background->blue *= bkgd_scale; ++ ++ if (logging != MagickFalse) ++ { ++ (void) LogMagickEvent(CoderEvent,GetMagickModule(), ++ " bkgd_scale=%d.",bkgd_scale); ++ (void) LogMagickEvent(CoderEvent,GetMagickModule(), ++ " ping_background=(%d,%d,%d).",ping_background->red, ++ ping_background->green,ping_background->blue); ++ } ++ + image->background_color.red= +- ScaleShortToQuantum(ping_info->background.red); ++ ScaleShortToQuantum(ping_background->red); + image->background_color.green= +- ScaleShortToQuantum(ping_info->background.green); ++ ScaleShortToQuantum(ping_background->green); + image->background_color.blue= +- ScaleShortToQuantum(ping_info->background.blue); ++ ScaleShortToQuantum(ping_background->blue); ++ image->background_color.opacity=OpaqueOpacity; ++ ++ if (logging != MagickFalse) ++ (void) LogMagickEvent(CoderEvent,GetMagickModule(), ++ " image->background_color=(%d,%d,%d).", ++ image->background_color.red, ++ image->background_color.green,image->background_color.blue); + } + } + #endif +- if (ping_info->valid & PNG_INFO_tRNS) ++ ++ if (png_get_valid(ping, ping_info, PNG_INFO_tRNS)) + { + int + bit_mask; +@@ -2031,49 +2081,70 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + " Reading PNG tRNS chunk."); + +- bit_mask = (1 << ping_info->bit_depth) - 1; ++ bit_mask = (1 << ping_bit_depth) - 1; + + /* + Image has a transparent background. + */ ++ + transparent_color.red= +- (Quantum)(ping_info->trans_color.red & bit_mask); ++ (unsigned short)(ping_trans_color->red & bit_mask); + transparent_color.green= +- (Quantum) (ping_info->trans_color.green & bit_mask); ++ (unsigned short) (ping_trans_color->green & bit_mask); + transparent_color.blue= +- (Quantum) (ping_info->trans_color.blue & bit_mask); ++ (unsigned short) (ping_trans_color->blue & bit_mask); + transparent_color.opacity= +- (Quantum) (ping_info->trans_color.gray & bit_mask); +- if (ping_info->color_type == PNG_COLOR_TYPE_GRAY) ++ (unsigned short) (ping_trans_color->gray & bit_mask); ++ ++ if (ping_colortype == PNG_COLOR_TYPE_GRAY) + { ++#if (Quantum_depth == 8) ++ if (ping_bit_depth < Quantum_depth) ++#endif ++ transparent_color.opacity=(unsigned short) ( ++ ping_trans_color->gray * ++ (65535L/((1UL << ping_bit_depth)-1))); ++ ++#if (Quantum_depth == 8) ++ else ++ transparent_color.opacity=(unsigned short) ( ++ (ping_trans_color->gray * 65535L)/ ++ ((1UL << ping_bit_depth)-1)); ++#endif ++ if (logging != MagickFalse) ++ { ++ (void) LogMagickEvent(CoderEvent,GetMagickModule(), ++ " Raw tRNS graylevel is %d.",ping_trans_color->gray); ++ (void) LogMagickEvent(CoderEvent,GetMagickModule(), ++ " scaled graylevel is %d.",transparent_color.opacity); ++ } + transparent_color.red=transparent_color.opacity; + transparent_color.green=transparent_color.opacity; + transparent_color.blue=transparent_color.opacity; + } + } + #if defined(PNG_READ_sBIT_SUPPORTED) +- if (mng_info->have_global_sbit) +- { +- int +- not_valid; +- not_valid=!ping_info->valid; +- if (not_valid & PNG_INFO_sBIT) ++ if (!png_get_valid(ping, ping_info, PNG_INFO_sBIT)) ++ if (mng_info->have_global_sbit) + png_set_sBIT(ping,ping_info,&mng_info->global_sbit); +- } <<Diff was trimmed, longer than 597 lines>> _______________________________________________ pld-cvs-commit mailing list [email protected] http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit
