1 from: http://www.openbsd.org/cgi-bin/cvsweb/ports/graphics/GraphicsMagick/patches/patch-coders_png_c
3 $OpenBSD: patch-coders_png_c,v 1.6 2011/07/08 20:36:09 naddy Exp $
5 png.c taken from 1.4.020110207 for compatibility with png 1.5.
7 --- coders/png.c.orig Wed Mar 3 13:26:23 2010
8 +++ coders/png.c Tue Jul 5 12:18:20 2011
13 +#if PNG_LIBPNG_VER > 10011
15 - * TO DO: rewrite using png_get_tRNS() instead of direct access to the
16 - * ping and ping_info structs.
18 -#if PNG_LIBPNG_VER < 10400
19 -# define trans_color trans_values /* Changed at libpng-1.4.0beta35 */
20 -# define trans_alpha trans /* Changed at libpng-1.4.0beta74 */
22 - /* We could parse PNG_LIBPNG_VER_STRING here but it's too much bother..
23 - * Just don't use libpng-1.4.0beta32-34 or beta67-73
25 -# ifndef PNG_USER_CHUNK_CACHE_MAX /* Added at libpng-1.4.0beta32 */
26 -# define trans_color trans_values /* Changed at libpng-1.4.0beta35 */
28 -# ifndef PNG_TRANSFORM_GRAY_TO_RGB /* Added at libpng-1.4.0beta67 */
29 -# define trans_alpha trans /* Changed at libpng-1.4.0beta74 */
33 -#if PNG_LIBPNG_VER > 95
35 Optional declarations. Define or undefine them as you like.
37 /* #define PNG_DEBUG -- turning this on breaks VisualC compiling */
38 @@ -164,10 +145,6 @@ static SemaphoreInfo
39 PNG_MNG_FEATURES_SUPPORTED is disabled by default in libpng-1.0.9 and
40 will be enabled by default in libpng-1.2.0.
42 -#if (PNG_LIBPNG_VER == 10009) /* work around libpng-1.0.9 bug */
43 -# undef PNG_READ_EMPTY_PLTE_SUPPORTED
44 -# undef PNG_WRITE_EMPTY_PLTE_SUPPORTED
46 #ifdef PNG_MNG_FEATURES_SUPPORTED
47 # ifndef PNG_READ_EMPTY_PLTE_SUPPORTED
48 # define PNG_READ_EMPTY_PLTE_SUPPORTED
49 @@ -244,6 +221,16 @@ static png_byte FARDATA mng_tIME[5]={116, 73, 77, 6
50 static png_byte FARDATA mng_zTXt[5]={122, 84, 88, 116, '\0'};
53 +typedef struct _UShortPixelPacket
63 typedef struct _MngBox
66 @@ -492,7 +479,6 @@ static const char* PngColorTypeToString(const unsigned
70 -#if PNG_LIBPNG_VER > 95
71 #if defined(PNG_SORT_PALETTE)
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 @@ -785,7 +771,6 @@ static MagickPassFail CompressColormapTransFirst(Image
78 -#endif /* PNG_LIBPNG_VER > 95 */
82 @@ -907,7 +892,7 @@ static MagickPassFail IsPNG(const unsigned char *magic
86 -#if (PNG_LIBPNG_VER > 95)
87 +#if (PNG_LIBPNG_VER > 10011)
88 static size_t WriteBlobMSBULong(Image *image,const unsigned long value)
91 @@ -956,13 +941,13 @@ static void LogPNGChunk(int logging, png_bytep type, u
92 " Writing %c%c%c%c chunk, length: %lu",
93 type[0],type[1],type[2],type[3],length);
95 -#endif /* PNG_LIBPNG_VER > 95 */
96 +#endif /* PNG_LIBPNG_VER > 10011 */
98 #if defined(__cplusplus) || defined(c_plusplus)
102 -#if PNG_LIBPNG_VER > 95
103 +#if PNG_LIBPNG_VER > 10011
105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107 @@ -1351,7 +1336,11 @@ static void PNGErrorHandler(png_struct *ping,png_const
108 " libpng-%.1024s error: %.1024s",
109 PNG_LIBPNG_VER_STRING, message);
110 (void) ThrowException2(&image->exception,CoderError,message,image->filename);
111 +#if (PNG_LIBPNG_VER < 10500)
112 longjmp(ping->jmpbuf,1);
114 + png_longjmp(ping,1);
118 static void PNGWarningHandler(png_struct *ping,png_const_charp message)
119 @@ -1372,19 +1361,8 @@ static void PNGWarningHandler(png_struct *ping,png_con
120 #ifdef PNG_USER_MEM_SUPPORTED
121 static png_voidp png_IM_malloc(png_structp png_ptr,png_uint_32 size)
123 -#if (PNG_LIBPNG_VER < 10011)
128 - ret=MagickAllocateMemory(png_voidp,(size_t) size);
130 - png_error("Insufficient memory.");
134 return MagickAllocateMemory(png_voidp,(size_t) size);
139 @@ -1560,11 +1538,24 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
147 + ping_interlace_method,
148 + ping_compression_method,
149 + ping_filter_method,
166 @@ -1572,6 +1563,11 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
178 @@ -1619,23 +1615,12 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
179 LockSemaphoreInfo(png_semaphore);
182 -#if (PNG_LIBPNG_VER < 10007)
183 +#if (PNG_LIBPNG_VER < 10012)
184 if (image_info->verbose)
185 printf("Your PNG library (libpng-%s) is rather old.\n",
186 PNG_LIBPNG_VER_STRING);
189 -#if (PNG_LIBPNG_VER >= 10400)
190 -# ifndef PNG_TRANSFORM_GRAY_TO_RGB /* Added at libpng-1.4.0beta67 */
191 - if (image_info->verbose)
193 - printf("Your PNG library (libpng-%s) is an old beta version.\n",
194 - PNG_LIBPNG_VER_STRING);
195 - printf("Please update it.\n");
200 image=mng_info->image;
203 @@ -1665,7 +1650,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
204 ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
206 png_pixels=(unsigned char *) NULL;
207 - if (setjmp(ping->jmpbuf))
208 + if (setjmp(png_jmpbuf(ping)))
211 PNG image is corrupt.
212 @@ -1740,18 +1725,32 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
214 png_read_info(ping,ping_info);
216 + (void) png_get_IHDR(ping,ping_info,
221 + &ping_interlace_method,
222 + &ping_compression_method,
223 + &ping_filter_method);
225 + (void) png_get_tRNS(ping, ping_info, &ping_trans_alpha, &ping_num_trans,
226 + &ping_trans_color);
228 + (void) png_get_bKGD(ping, ping_info, &ping_background);
230 #if (QuantumDepth == 8)
233 - if (ping_info->bit_depth > 8)
234 + if (ping_bit_depth > 8)
240 - if (ping_info->bit_depth < 8)
241 + if (ping_bit_depth < 8)
243 - if ((ping_info->color_type == PNG_COLOR_TYPE_PALETTE))
244 + if (ping_colortype == PNG_COLOR_TYPE_PALETTE)
246 png_set_packing(ping);
248 @@ -1761,21 +1760,22 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
250 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
251 " PNG width: %lu, height: %lu",
252 - (unsigned long)ping_info->width,
253 - (unsigned long)ping_info->height);
254 + (unsigned long)ping_width,
255 + (unsigned long)ping_height);
256 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
257 " PNG color_type: %d, bit_depth: %d",
258 - ping_info->color_type, ping_info->bit_depth);
259 + ping_colortype, ping_bit_depth);
260 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
261 " PNG compression_method: %d",
262 - ping_info->compression_type);
263 + ping_compression_method);
264 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
265 " PNG interlace_method: %d, filter_method: %d",
266 - ping_info->interlace_type,ping_info->filter_type);
267 + ping_interlace_method,
268 + ping_filter_method);
271 -#if (PNG_LIBPNG_VER > 10008) && defined(PNG_READ_iCCP_SUPPORTED)
272 - if (ping_info->valid & PNG_INFO_iCCP)
273 +#if defined(PNG_READ_iCCP_SUPPORTED)
274 + if (png_get_valid(ping, ping_info, PNG_INFO_iCCP))
278 @@ -1803,15 +1803,19 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
282 -#endif /* #if (PNG_LIBPNG_VER > 10008) && defined(PNG_READ_iCCP_SUPPORTED) */
283 +#endif /* #if defined(PNG_READ_iCCP_SUPPORTED) */
284 #if defined(PNG_READ_sRGB_SUPPORTED)
289 - if (mng_info->have_global_srgb)
290 - image->rendering_intent=(RenderingIntent)
291 - (mng_info->global_srgb_intent+1);
292 + if (!png_get_sRGB(ping,ping_info,&intent))
294 + if (mng_info->have_global_srgb)
296 + png_set_sRGB(ping,ping_info,(mng_info->global_srgb_intent+1));
299 if (png_get_sRGB(ping,ping_info,&intent))
301 image->rendering_intent=(RenderingIntent) (intent+1);
302 @@ -1827,8 +1831,11 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
306 - if (mng_info->have_global_gama)
307 - image->gamma=mng_info->global_gamma;
308 + if (!png_get_gAMA(ping,ping_info,&file_gamma))
310 + if (mng_info->have_global_gama)
311 + png_set_gAMA(ping,ping_info,mng_info->global_gamma);
313 if (png_get_gAMA(ping,ping_info,&file_gamma))
315 image->gamma=(float) file_gamma;
316 @@ -1838,10 +1845,21 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
320 - if (mng_info->have_global_chrm)
321 - image->chromaticity=mng_info->global_chrm;
322 - if (ping_info->valid & PNG_INFO_cHRM)
323 + if (!png_get_valid(ping, ping_info, PNG_INFO_cHRM))
325 + if (mng_info->have_global_chrm)
326 + (void) png_set_cHRM(ping,ping_info,
327 + mng_info->global_chrm.white_point.x,
328 + mng_info->global_chrm.white_point.y,
329 + mng_info->global_chrm.red_primary.x,
330 + mng_info->global_chrm.red_primary.y,
331 + mng_info->global_chrm.green_primary.x,
332 + mng_info->global_chrm.green_primary.y,
333 + mng_info->global_chrm.blue_primary.x,
334 + mng_info->global_chrm.blue_primary.y);
336 + if (png_get_valid(ping, ping_info, PNG_INFO_cHRM))
338 (void) png_get_cHRM(ping,ping_info,
339 &image->chromaticity.white_point.x,
340 &image->chromaticity.white_point.y,
341 @@ -1867,12 +1885,9 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
342 image->chromaticity.white_point.x=0.3127f;
343 image->chromaticity.white_point.y=0.3290f;
345 - if (mng_info->have_global_gama || image->rendering_intent)
346 - ping_info->valid|=PNG_INFO_gAMA;
347 - if (mng_info->have_global_chrm || image->rendering_intent)
348 - ping_info->valid|=PNG_INFO_cHRM;
349 #if defined(PNG_oFFs_SUPPORTED)
350 - if (mng_info->mng_type == 0 && (ping_info->valid & PNG_INFO_oFFs))
351 + if (mng_info->mng_type == 0 && (png_get_valid(ping, ping_info,
354 image->page.x=png_get_x_offset_pixels(ping, ping_info);
355 image->page.y=png_get_y_offset_pixels(ping, ping_info);
356 @@ -1885,8 +1900,18 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
359 #if defined(PNG_pHYs_SUPPORTED)
360 - if (ping_info->valid & PNG_INFO_pHYs)
361 + if (!png_get_valid(ping, ping_info, PNG_INFO_pHYs))
363 + if (mng_info->have_global_phys)
365 + png_set_pHYs(ping,ping_info,
366 + mng_info->global_x_pixels_per_unit,
367 + mng_info->global_y_pixels_per_unit,
368 + mng_info->global_phys_unit_type);
371 + if (png_get_valid(ping, ping_info, PNG_INFO_pHYs))
376 @@ -1915,25 +1940,8 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
377 (unsigned long)y_resolution,
382 - if (mng_info->have_global_phys)
384 - image->x_resolution=(float) mng_info->global_x_pixels_per_unit;
385 - image->y_resolution=(float) mng_info->global_y_pixels_per_unit;
386 - if (mng_info->global_phys_unit_type == PNG_RESOLUTION_METER)
388 - image->units=PixelsPerCentimeterResolution;
389 - image->x_resolution=(double)
390 - mng_info->global_x_pixels_per_unit/100.0;
391 - image->y_resolution=(double)
392 - mng_info->global_y_pixels_per_unit/100.0;
394 - ping_info->valid|=PNG_INFO_pHYs;
398 - if (ping_info->valid & PNG_INFO_PLTE)
399 + if (png_get_valid(ping, ping_info, PNG_INFO_PLTE))
403 @@ -1942,14 +1950,14 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
406 (void) png_get_PLTE(ping,ping_info,&palette,&number_colors);
407 - if (number_colors == 0 && ping_info->color_type ==
408 + if (number_colors == 0 && ping_colortype ==
409 PNG_COLOR_TYPE_PALETTE)
411 if (mng_info->global_plte_length)
413 png_set_PLTE(ping,ping_info,mng_info->global_plte,
414 (int) mng_info->global_plte_length);
415 - if (!(ping_info->valid & PNG_INFO_tRNS))
416 + if (!(png_get_valid(ping, ping_info, PNG_INFO_tRNS)))
417 if (mng_info->global_trns_length)
419 if (mng_info->global_trns_length >
420 @@ -1966,7 +1974,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
421 #ifndef PNG_READ_EMPTY_PLTE_SUPPORTED
422 mng_info->have_saved_bkgd_index ||
424 - ping_info->valid & PNG_INFO_bKGD)
425 + png_get_valid(ping, ping_info, PNG_INFO_bKGD))
429 @@ -1974,9 +1982,9 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
430 #ifndef PNG_READ_EMPTY_PLTE_SUPPORTED
431 if (mng_info->have_saved_bkgd_index)
432 background.index=mng_info->saved_bkgd_index;
435 - background.index=ping_info->background.index;
436 + if (png_get_valid(ping, ping_info, PNG_INFO_bKGD))
437 + background.index=ping_background->index;
438 background.red=(png_uint_16)
439 mng_info->global_plte[background.index].red;
440 background.green=(png_uint_16)
441 @@ -1995,34 +2003,76 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
444 #if defined(PNG_READ_bKGD_SUPPORTED)
445 - if (mng_info->have_global_bkgd && !(ping_info->valid & PNG_INFO_bKGD))
446 + if (mng_info->have_global_bkgd &&
447 + !(png_get_valid(ping,ping_info, PNG_INFO_bKGD)))
448 image->background_color=mng_info->mng_global_bkgd;
449 - if (ping_info->valid & PNG_INFO_bKGD)
450 + if (png_get_valid(ping, ping_info, PNG_INFO_bKGD))
453 Set image background color.
457 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
458 " Reading PNG bKGD chunk.");
459 - if (ping_info->bit_depth <= QuantumDepth)
461 + if (ping_bit_depth == QuantumDepth)
463 - image->background_color.red=ping_info->background.red;
464 - image->background_color.green=ping_info->background.green;
465 - image->background_color.blue=ping_info->background.blue;
466 + image->background_color.red = ping_background->red;
467 + image->background_color.green= ping_background->green;
468 + image->background_color.blue = ping_background->blue;
471 + else /* Scale background components to 16-bit */
476 + if (logging != MagickFalse)
477 + (void) LogMagickEvent(CoderEvent,GetMagickModule(),
478 + " raw ping_background=(%d,%d,%d).",ping_background->red,
479 + ping_background->green,ping_background->blue);
482 + if (ping_bit_depth == 1)
484 + else if (ping_bit_depth == 2)
486 + else if (ping_bit_depth == 4)
488 + if (ping_bit_depth <= 8)
491 + ping_background->red *= bkgd_scale;
492 + ping_background->green *= bkgd_scale;
493 + ping_background->blue *= bkgd_scale;
495 + if (logging != MagickFalse)
497 + (void) LogMagickEvent(CoderEvent,GetMagickModule(),
498 + " bkgd_scale=%d.",bkgd_scale);
499 + (void) LogMagickEvent(CoderEvent,GetMagickModule(),
500 + " ping_background=(%d,%d,%d).",ping_background->red,
501 + ping_background->green,ping_background->blue);
504 image->background_color.red=
505 - ScaleShortToQuantum(ping_info->background.red);
506 + ScaleShortToQuantum(ping_background->red);
507 image->background_color.green=
508 - ScaleShortToQuantum(ping_info->background.green);
509 + ScaleShortToQuantum(ping_background->green);
510 image->background_color.blue=
511 - ScaleShortToQuantum(ping_info->background.blue);
512 + ScaleShortToQuantum(ping_background->blue);
513 + image->background_color.opacity=OpaqueOpacity;
515 + if (logging != MagickFalse)
516 + (void) LogMagickEvent(CoderEvent,GetMagickModule(),
517 + " image->background_color=(%d,%d,%d).",
518 + image->background_color.red,
519 + image->background_color.green,image->background_color.blue);
523 - if (ping_info->valid & PNG_INFO_tRNS)
525 + if (png_get_valid(ping, ping_info, PNG_INFO_tRNS))
529 @@ -2031,49 +2081,70 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
530 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
531 " Reading PNG tRNS chunk.");
533 - bit_mask = (1 << ping_info->bit_depth) - 1;
534 + bit_mask = (1 << ping_bit_depth) - 1;
537 Image has a transparent background.
540 transparent_color.red=
541 - (Quantum)(ping_info->trans_color.red & bit_mask);
542 + (unsigned short)(ping_trans_color->red & bit_mask);
543 transparent_color.green=
544 - (Quantum) (ping_info->trans_color.green & bit_mask);
545 + (unsigned short) (ping_trans_color->green & bit_mask);
546 transparent_color.blue=
547 - (Quantum) (ping_info->trans_color.blue & bit_mask);
548 + (unsigned short) (ping_trans_color->blue & bit_mask);
549 transparent_color.opacity=
550 - (Quantum) (ping_info->trans_color.gray & bit_mask);
551 - if (ping_info->color_type == PNG_COLOR_TYPE_GRAY)
552 + (unsigned short) (ping_trans_color->gray & bit_mask);
554 + if (ping_colortype == PNG_COLOR_TYPE_GRAY)
556 +#if (Quantum_depth == 8)
557 + if (ping_bit_depth < Quantum_depth)
559 + transparent_color.opacity=(unsigned short) (
560 + ping_trans_color->gray *
561 + (65535L/((1UL << ping_bit_depth)-1)));
563 +#if (Quantum_depth == 8)
565 + transparent_color.opacity=(unsigned short) (
566 + (ping_trans_color->gray * 65535L)/
567 + ((1UL << ping_bit_depth)-1));
569 + if (logging != MagickFalse)
571 + (void) LogMagickEvent(CoderEvent,GetMagickModule(),
572 + " Raw tRNS graylevel is %d.",ping_trans_color->gray);
573 + (void) LogMagickEvent(CoderEvent,GetMagickModule(),
574 + " scaled graylevel is %d.",transparent_color.opacity);
576 transparent_color.red=transparent_color.opacity;
577 transparent_color.green=transparent_color.opacity;
578 transparent_color.blue=transparent_color.opacity;
581 #if defined(PNG_READ_sBIT_SUPPORTED)
582 - if (mng_info->have_global_sbit)
586 - not_valid=!ping_info->valid;
587 - if (not_valid & PNG_INFO_sBIT)
588 + if (!png_get_valid(ping, ping_info, PNG_INFO_sBIT))
589 + if (mng_info->have_global_sbit)
590 png_set_sBIT(ping,ping_info,&mng_info->global_sbit);
593 num_passes=png_set_interlace_handling(ping);
595 png_read_update_info(ping,ping_info);
597 + ping_rowbytes=png_get_rowbytes(ping,ping_info);
600 Initialize image structure.
602 mng_info->image_box.left=0;
603 - mng_info->image_box.right=(long) ping_info->width;
604 + mng_info->image_box.right=(long) ping_width;
605 mng_info->image_box.top=0;
606 - mng_info->image_box.bottom=(long) ping_info->height;
607 + mng_info->image_box.bottom=(long) ping_height;
608 if (mng_info->mng_type == 0)
610 - mng_info->mng_width=ping_info->width;
611 - mng_info->mng_height=ping_info->height;
612 + mng_info->mng_width=ping_width;
613 + mng_info->mng_height=ping_height;
614 mng_info->frame=mng_info->image_box;
615 mng_info->clip=mng_info->image_box;
617 @@ -2082,14 +2153,14 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
618 image->page.y=mng_info->y_off[mng_info->object_id];
620 image->compression=ZipCompression;
621 - image->columns=ping_info->width;
622 - image->rows=ping_info->height;
623 - if ((ping_info->color_type == PNG_COLOR_TYPE_PALETTE) ||
624 - (ping_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) ||
625 - (ping_info->color_type == PNG_COLOR_TYPE_GRAY))
626 + image->columns=ping_width;
627 + image->rows=ping_height;
628 + if ((ping_colortype == PNG_COLOR_TYPE_PALETTE) ||
629 + (ping_colortype == PNG_COLOR_TYPE_GRAY_ALPHA) ||
630 + (ping_colortype == PNG_COLOR_TYPE_GRAY))
632 image->storage_class=PseudoClass;
633 - image->colors=1 << ping_info->bit_depth;
634 + image->colors=1 << ping_bit_depth;
635 #if (QuantumDepth == 8)
636 if (image->colors > 256)
638 @@ -2097,7 +2168,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
639 if (image->colors > 65536L)
640 image->colors=65536L;
642 - if (ping_info->color_type == PNG_COLOR_TYPE_PALETTE)
643 + if (ping_colortype == PNG_COLOR_TYPE_PALETTE)
647 @@ -2121,7 +2192,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
649 if (!AllocateImageColormap(image,image->colors))
650 ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
651 - if (ping_info->color_type == PNG_COLOR_TYPE_PALETTE)
652 + if (ping_colortype == PNG_COLOR_TYPE_PALETTE)
656 @@ -2142,7 +2213,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
660 - scale=(MaxRGB/((1 << ping_info->bit_depth)-1));
661 + scale=(MaxRGB/((1 << ping_bit_depth)-1));
664 for (i=0; i < (long) image->colors; i++)
665 @@ -2182,10 +2253,9 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
666 " Reading PNG IDAT chunk(s)");
668 png_pixels=MagickAllocateMemory(unsigned char *,
669 - ping_info->rowbytes*image->rows);
670 + ping_rowbytes*image->rows);
672 - png_pixels=MagickAllocateMemory(unsigned char *,
673 - ping_info->rowbytes);
674 + png_pixels=MagickAllocateMemory(unsigned char *, ping_rowbytes);
675 if (png_pixels == (unsigned char *) NULL)
676 ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
678 @@ -2205,20 +2275,20 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
682 - depth=(long) ping_info->bit_depth;
683 + depth=(long) ping_bit_depth;
685 - image->matte=((ping_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) ||
686 - (ping_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) ||
687 - (ping_info->valid & PNG_INFO_tRNS));
688 + image->matte=((ping_colortype == PNG_COLOR_TYPE_RGB_ALPHA) ||
689 + (ping_colortype == PNG_COLOR_TYPE_GRAY_ALPHA) ||
690 + (png_get_valid(ping, ping_info, PNG_INFO_tRNS)));
692 for (y=0; y < (long) image->rows; y++)
695 - row_offset=ping_info->rowbytes*y;
696 + row_offset=ping_rowbytes*y;
699 png_read_row(ping,png_pixels+row_offset,NULL);
700 - if (!SetImagePixels(image,0,y,image->columns,1)) /* Was GetImagePixels() */
701 + if (!SetImagePixels(image,0,y,image->columns,1))
703 #if (QuantumDepth == 8)
705 @@ -2229,13 +2299,13 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
707 r=png_pixels+row_offset;
709 - if (ping_info->color_type == PNG_COLOR_TYPE_GRAY)
710 + if (ping_colortype == PNG_COLOR_TYPE_GRAY)
712 for (x=(long) image->columns; x > 0; x--)
716 - if ((ping_info->valid & PNG_INFO_tRNS) &&
717 + if ((png_get_valid(ping, ping_info, PNG_INFO_tRNS)) &&
718 (((*(p-2) << 8)|*(p-1))
719 == transparent_color.opacity))
721 @@ -2246,9 +2316,9 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
725 - else if (ping_info->color_type == PNG_COLOR_TYPE_RGB)
726 + else if (ping_colortype == PNG_COLOR_TYPE_RGB)
728 - if (ping_info->valid & PNG_INFO_tRNS)
729 + if (png_get_valid(ping, ping_info, PNG_INFO_tRNS))
730 for (x=(long) image->columns; x > 0; x--)
733 @@ -2282,25 +2352,25 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
737 - else if (ping_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
738 + else if (ping_colortype == PNG_COLOR_TYPE_RGB_ALPHA)
739 for (x=(long) (4*image->columns); x > 0; x--)
744 - else if (ping_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
745 + else if (ping_colortype == PNG_COLOR_TYPE_GRAY_ALPHA)
746 for (x=(long) (2*image->columns); x > 0; x--)
752 - if (depth == 8 && ping_info->color_type == PNG_COLOR_TYPE_GRAY)
753 + if (depth == 8 && ping_colortype == PNG_COLOR_TYPE_GRAY)
754 (void) ImportImagePixelArea(image,(QuantumType) GrayQuantum,
755 image->depth,png_pixels+
757 - if (ping_info->color_type == PNG_COLOR_TYPE_GRAY ||
758 - ping_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
759 + if (ping_colortype == PNG_COLOR_TYPE_GRAY ||
760 + ping_colortype == PNG_COLOR_TYPE_GRAY_ALPHA)
763 (void) ImportImagePixelArea(image,
764 @@ -2309,12 +2379,12 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
768 - else if (depth == 8 && ping_info->color_type == PNG_COLOR_TYPE_RGB)
769 + else if (depth == 8 && ping_colortype == PNG_COLOR_TYPE_RGB)
770 (void) ImportImagePixelArea(image,(QuantumType) RGBQuantum,
771 image->depth,png_pixels+
773 - else if (ping_info->color_type == PNG_COLOR_TYPE_RGB ||
774 - ping_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
775 + else if (ping_colortype == PNG_COLOR_TYPE_RGB ||
776 + ping_colortype == PNG_COLOR_TYPE_RGB_ALPHA)
779 (void) ImportImagePixelArea(image,(QuantumType) RGBAQuantum,
780 @@ -2322,28 +2392,28 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
784 - else if (ping_info->color_type == PNG_COLOR_TYPE_PALETTE)
785 + else if (ping_colortype == PNG_COLOR_TYPE_PALETTE)
786 (void) ImportImagePixelArea(image,(QuantumType) IndexQuantum,
787 - ping_info->bit_depth,png_pixels+
788 + ping_bit_depth,png_pixels+
790 /* FIXME, sample size ??? */
791 #else /* (QuantumDepth != 8) */
793 - if (ping_info->color_type == PNG_COLOR_TYPE_GRAY)
794 + if (ping_colortype == PNG_COLOR_TYPE_GRAY)
795 (void) ImportImagePixelArea(image,(QuantumType) GrayQuantum,
796 image->depth,png_pixels+
798 - else if (ping_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
799 + else if (ping_colortype == PNG_COLOR_TYPE_GRAY_ALPHA)
800 (void) ImportImagePixelArea(image,(QuantumType) GrayAlphaQuantum,
801 image->depth,png_pixels+
803 - else if (ping_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
804 + else if (ping_colortype == PNG_COLOR_TYPE_RGB_ALPHA)
805 (void) ImportImagePixelArea(image,(QuantumType) RGBAQuantum,
806 image->depth,png_pixels+
808 - else if (ping_info->color_type == PNG_COLOR_TYPE_PALETTE)
809 + else if (ping_colortype == PNG_COLOR_TYPE_PALETTE)
810 (void) ImportImagePixelArea(image,(QuantumType) IndexQuantum,
811 - ping_info->bit_depth,png_pixels+
812 + ping_bit_depth,png_pixels+
814 /* FIXME, sample size ??? */
816 @@ -2372,7 +2442,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
818 Convert grayscale image to PseudoClass pixel packets.
820 - image->matte=ping_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA;
821 + image->matte=ping_colortype == PNG_COLOR_TYPE_GRAY_ALPHA;
822 quantum_scanline=MagickAllocateMemory(Quantum *,
823 (image->matte ? 2 : 1) *
824 image->columns*sizeof(Quantum));
825 @@ -2385,7 +2455,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
829 - row_offset=ping_info->rowbytes*y;
830 + row_offset=ping_rowbytes*y;
833 png_read_row(ping,png_pixels+row_offset,NULL);
834 @@ -2395,7 +2465,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
835 indexes=AccessMutableIndexes(image);
836 p=png_pixels+row_offset;
838 - switch (ping_info->bit_depth)
839 + switch (ping_bit_depth)
843 @@ -2445,7 +2515,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
847 - if (ping_info->color_type == 4)
848 + if (ping_colortype == 4)
849 for (x=(long) image->columns; x > 0; x--)
852 @@ -2473,7 +2543,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
856 - if (ping_info->color_type == 4)
857 + if (ping_colortype == 4)
859 q->opacity=((*p++) << 8);
861 @@ -2488,7 +2558,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
865 - if (ping_info->color_type == 4)
866 + if (ping_colortype == 4)
868 q->opacity=((*p++) << 8);
870 @@ -2499,7 +2569,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
871 #else /* QuantumDepth == 8 */
873 p++; /* strip low byte */
874 - if (ping_info->color_type == 4)
875 + if (ping_colortype == 4)
877 q->opacity=(Quantum) (MaxRGB-(*p++));
879 @@ -2549,7 +2619,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
880 " exit ReadOnePNGImage().");
883 - if (ping_info->valid & PNG_INFO_tRNS)
884 + if (png_get_valid(ping, ping_info, PNG_INFO_tRNS))
888 @@ -2572,25 +2642,26 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
892 - if (ping_info->color_type == PNG_COLOR_TYPE_PALETTE)
893 + if (ping_colortype == PNG_COLOR_TYPE_PALETTE)
894 for (x=0; x < (long) image->columns; x++)
897 - if (index < ping_info->num_trans)
898 + if (index < ping_num_trans)
900 - ScaleCharToQuantum(255-ping_info->trans_alpha[index]);
901 + ScaleCharToQuantum(255-ping_trans_alpha[index]);
903 q->opacity=OpaqueOpacity;
906 - else if (ping_info->color_type == PNG_COLOR_TYPE_GRAY)
907 + else if (ping_colortype == PNG_COLOR_TYPE_GRAY)
908 for (x=0; x < (long) image->columns; x++)
911 q->red=image->colormap[index].red;
912 q->green=image->colormap[index].green;
913 q->blue=image->colormap[index].blue;
914 - if (q->red == transparent_color.opacity)
915 + if (ScaleQuantumToShort(q->red) ==
916 + transparent_color.opacity)
917 q->opacity=TransparentOpacity;
919 q->opacity=OpaqueOpacity;
920 @@ -2600,9 +2671,9 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
922 for (x=(long) image->columns; x > 0; x--)
924 - if (q->red == transparent_color.red &&
925 - q->green == transparent_color.green &&
926 - q->blue == transparent_color.blue)
927 + if (ScaleQuantumToShort(q->red) == transparent_color.red &&
928 + ScaleQuantumToShort(q->green) == transparent_color.green &&
929 + ScaleQuantumToShort(q->blue) == transparent_color.blue)
930 q->opacity=TransparentOpacity;
932 q->opacity=OpaqueOpacity;
933 @@ -2714,7 +2785,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
934 mng_info->ob[object_id]->interlace_method=interlace_method;
935 mng_info->ob[object_id]->compression_method=compression_method;
936 mng_info->ob[object_id]->filter_method=filter_method;
937 - if (ping_info->valid & PNG_INFO_PLTE)
938 + if (png_get_valid(ping, ping_info, PNG_INFO_PLTE))
942 @@ -5734,7 +5805,7 @@ static Image *ReadMNGImage(const ImageInfo *image_info
943 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"exit ReadMNGImage()");
946 -#else /* PNG_LIBPNG_VER > 95 */
947 +#else /* PNG_LIBPNG_VER > 10011 */
948 static Image *ReadPNGImage(const ImageInfo *image_info,
949 ExceptionInfo *exception)
951 @@ -5749,7 +5820,7 @@ static Image *ReadMNGImage(const ImageInfo *image_info
953 return (ReadPNGImage(image_info,exception));
955 -#endif /* PNG_LIBPNG_VER > 95 */
956 +#endif /* PNG_LIBPNG_VER > 10011 */
960 @@ -5960,7 +6031,7 @@ ModuleExport void UnregisterPNGImage(void)
964 -#if PNG_LIBPNG_VER > 95
965 +#if PNG_LIBPNG_VER > 10011
967 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
969 @@ -6043,28 +6114,13 @@ ModuleExport void UnregisterPNGImage(void)
973 -#if (PNG_LIBPNG_VER > 99 && PNG_LIBPNG_VER < 10007)
974 -/* This function became available in libpng version 1.0.6g. */
976 -png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size)
979 - png_free(png_ptr, png_ptr->zbuf); png_ptr->zbuf=NULL;
980 - png_ptr->zbuf_size=(png_size_t) size;
981 - png_ptr->zbuf=(png_bytep) png_malloc(png_ptr, size);
982 - if (!png_ptr->zbuf)
983 - png_error(png_ptr,"Unable to allocate zbuf");
988 png_write_raw_profile(const ImageInfo *image_info,png_struct *ping,
989 png_info *ping_info, const char *profile_type,
990 const char *profile_description,
991 const unsigned char *profile_data,
994 -#if (PNG_LIBPNG_VER > 10005)
998 @@ -6083,25 +6139,12 @@ png_write_raw_profile(const ImageInfo *image_info,png_
1001 hex[16]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
1004 -#if (PNG_LIBPNG_VER <= 10005)
1005 if (image_info->verbose)
1006 - (void) printf("Not ");
1007 - (void) image_info;
1010 - (void) profile_type;
1011 - (void) profile_description;
1012 - (void) profile_data;
1015 - if (image_info->verbose)
1017 (void) printf("writing raw profile: type=%.1024s, length=%lu\n",
1018 profile_type, (unsigned long)length);
1020 -#if (PNG_LIBPNG_VER > 10005)
1021 text=(png_textp) png_malloc(ping,(png_uint_32) sizeof(png_text));
1022 description_length=strlen((const char *) profile_description);
1023 allocated_length=(png_uint_32) (length*2 + (length >> 5) + 20
1024 @@ -6137,7 +6180,6 @@ png_write_raw_profile(const ImageInfo *image_info,png_
1025 png_free(ping,text[0].text);
1026 png_free(ping,text[0].key);
1027 png_free(ping,text);
1031 static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
1032 @@ -6152,17 +6194,34 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1038 + ping_bit_depth = 0,
1039 + ping_colortype = 0,
1040 + ping_interlace_method = 0,
1041 + ping_compression_method = 0,
1042 + ping_filter_method = 0,
1043 + ping_num_trans = 0;
1046 + ping_trans_alpha = NULL;
1068 @@ -6181,8 +6240,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1077 quantum_size, /* depth for ExportImage */
1078 @@ -6211,6 +6269,18 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1082 + /* Initialize some stuff */
1083 + ping_background.red = 0;
1084 + ping_background.green = 0;
1085 + ping_background.blue = 0;
1086 + ping_background.gray = 0;
1087 + ping_background.index = 0;
1089 + ping_trans_color.red=0;
1090 + ping_trans_color.green=0;
1091 + ping_trans_color.blue=0;
1092 + ping_trans_color.gray=0;
1094 image_colors=image->colors;
1095 image_depth=image->depth;
1096 image_matte=image->matte;
1097 @@ -6259,7 +6329,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1098 LockSemaphoreInfo(png_semaphore);
1101 - if (setjmp(ping->jmpbuf))
1102 + if (setjmp(png_jmpbuf(ping)))
1106 @@ -6288,16 +6358,16 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1110 - ping_info->width=image->columns;
1111 - ping_info->height=image->rows;
1112 + ping_width=image->columns;
1113 + ping_height=image->rows;
1116 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1118 - (unsigned long)ping_info->width);
1119 + (unsigned long)ping_width);
1120 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1122 - (unsigned long)ping_info->height);
1123 + (unsigned long)ping_height);
1124 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1125 " image->depth=%u",image_depth);
1127 @@ -6306,12 +6376,12 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1128 quantum_size=(image_depth > 8) ? 16:8;
1130 save_image_depth=image_depth;
1131 - ping_info->bit_depth=(png_byte) save_image_depth;
1132 + ping_bit_depth=(png_byte) save_image_depth;
1135 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1136 - " ping_info->bit_depth=%u",
1137 - ping_info->bit_depth);
1138 + " ping_bit_depth=%u",
1141 #if defined(PNG_pHYs_SUPPORTED)
1142 if ((image->x_resolution != 0) && (image->y_resolution != 0) &&
1143 @@ -6398,8 +6468,8 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1145 if (mng_info->write_png8)
1147 - ping_info->color_type=PNG_COLOR_TYPE_PALETTE;
1148 - ping_info->bit_depth=8;
1149 + ping_colortype=PNG_COLOR_TYPE_PALETTE;
1152 /* TO DO: make this a function cause it's used twice, except
1153 for reducing the sample depth from 8. */
1154 @@ -6424,13 +6494,13 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1155 " Colors quantized to %ld",
1159 - ping_info->valid|=PNG_INFO_tRNS;
1164 - ping_info->color_type=PNG_COLOR_TYPE_PALETTE;
1165 - ping_info->valid|=PNG_INFO_PLTE;
1167 + ping_colortype=PNG_COLOR_TYPE_PALETTE;
1169 #if defined(PNG_SORT_PALETTE)
1170 save_number_colors=image_colors;
1171 if (CompressColormapTransFirst(image) == MagickFail)
1172 @@ -6465,20 +6535,17 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1175 png_set_PLTE(ping,ping_info,palette,(int) number_colors);
1176 -#if (PNG_LIBPNG_VER > 10008)
1177 MagickFreeMemory(palette);
1180 Identify which colormap entry is transparent.
1182 - ping_info->trans_alpha=MagickAllocateMemory(unsigned char *,
1184 - if (ping_info->trans_alpha == (unsigned char *) NULL)
1185 + ping_trans_alpha=MagickAllocateMemory(unsigned char *, number_colors);
1186 + if (ping_trans_alpha == (unsigned char *) NULL)
1187 ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,
1189 assert(number_colors <= 256);
1190 for (i=0; i < (long) number_colors; i++)
1191 - ping_info->trans_alpha[i]=255;
1192 + ping_trans_alpha[i]=255;
1193 for (y=0; y < (long) image->rows; y++)
1195 register const PixelPacket
1196 @@ -6498,29 +6565,29 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1199 assert((unsigned long) index < number_colors);
1200 - ping_info->trans_alpha[index]=(png_byte) (255-
1201 + ping_trans_alpha[index]=(png_byte) (255-
1202 ScaleQuantumToChar(p->opacity));
1207 - ping_info->num_trans=0;
1209 for (i=0; i < (long) number_colors; i++)
1210 - if (ping_info->trans_alpha[i] != 255)
1211 - ping_info->num_trans=(unsigned short) (i+1);
1212 - if (ping_info->num_trans == 0)
1213 - ping_info->valid&=(~PNG_INFO_tRNS);
1214 - if (!(ping_info->valid & PNG_INFO_tRNS))
1215 - ping_info->num_trans=0;
1216 - if (ping_info->num_trans == 0)
1217 - MagickFreeMemory(ping_info->trans_alpha);
1218 + if (ping_trans_alpha[i] != 255)
1219 + ping_num_trans=(unsigned short) (i+1);
1220 + if (ping_num_trans == 0)
1221 + png_set_invalid(ping,ping_info,PNG_INFO_tRNS);
1222 + if (!(png_get_valid(ping,ping_info,PNG_INFO_tRNS)))
1224 + if (ping_num_trans == 0)
1225 + MagickFreeMemory(ping_trans_alpha);
1227 Identify which colormap entry is the background color.
1229 for (i=0; i < (long) Max(number_colors-1,1); i++)
1230 - if (RGBColorMatchExact(ping_info->background,image->colormap[i]))
1231 + if (RGBColorMatchExact(ping_background,image->colormap[i]))
1233 - ping_info->background.index=(png_uint_16) i;
1234 + ping_background.index=(png_uint_16) i;
1238 @@ -6530,79 +6597,79 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1239 else if (mng_info->write_png24)
1241 image_matte=MagickFalse;
1242 - ping_info->color_type=PNG_COLOR_TYPE_RGB;
1243 + ping_colortype=PNG_COLOR_TYPE_RGB;
1245 else if (mng_info->write_png32)
1247 image_matte=MagickTrue;
1248 - ping_info->color_type=PNG_COLOR_TYPE_RGB_ALPHA;
1249 + ping_colortype=PNG_COLOR_TYPE_RGB_ALPHA;
1253 - if (ping_info->bit_depth < 8)
1254 - ping_info->bit_depth=8;
1255 + if (ping_bit_depth < 8)
1258 - ping_info->color_type=PNG_COLOR_TYPE_RGB;
1259 + ping_colortype=PNG_COLOR_TYPE_RGB;
1260 if (characteristics.monochrome)
1262 if (characteristics.opaque)
1264 - ping_info->color_type=PNG_COLOR_TYPE_GRAY;
1265 - ping_info->bit_depth=1;
1266 + ping_colortype=PNG_COLOR_TYPE_GRAY;
1271 - ping_info->color_type=PNG_COLOR_TYPE_GRAY_ALPHA;
1272 + ping_colortype=PNG_COLOR_TYPE_GRAY_ALPHA;
1275 else if (characteristics.grayscale)
1277 if (characteristics.opaque)
1278 - ping_info->color_type=PNG_COLOR_TYPE_GRAY;
1279 + ping_colortype=PNG_COLOR_TYPE_GRAY;
1281 - ping_info->color_type=PNG_COLOR_TYPE_GRAY_ALPHA;
1282 + ping_colortype=PNG_COLOR_TYPE_GRAY_ALPHA;
1284 else if (characteristics.palette && image_colors <= 256)
1286 - ping_info->color_type=PNG_COLOR_TYPE_PALETTE;
1287 - ping_info->bit_depth=8;
1288 + ping_colortype=PNG_COLOR_TYPE_PALETTE;
1290 mng_info->IsPalette=MagickTrue;
1294 if (characteristics.opaque)
1295 - ping_info->color_type=PNG_COLOR_TYPE_RGB;
1296 + ping_colortype=PNG_COLOR_TYPE_RGB;
1298 - ping_info->color_type=PNG_COLOR_TYPE_RGB_ALPHA;
1299 + ping_colortype=PNG_COLOR_TYPE_RGB_ALPHA;
1301 if (image_info->type == BilevelType)
1303 if (characteristics.monochrome)
1306 - ping_info->bit_depth=1;
1310 if (image_info->type == GrayscaleType)
1311 - ping_info->color_type=PNG_COLOR_TYPE_GRAY;
1312 + ping_colortype=PNG_COLOR_TYPE_GRAY;
1313 if (image_info->type == GrayscaleMatteType)
1314 - ping_info->color_type=PNG_COLOR_TYPE_GRAY_ALPHA;
1315 + ping_colortype=PNG_COLOR_TYPE_GRAY_ALPHA;
1316 /* if (!mng_info->optimize && matte) */
1317 - /* ping_info->color_type=PNG_COLOR_TYPE_RGB_ALPHA; */
1318 + /* ping_colortype=PNG_COLOR_TYPE_RGB_ALPHA; */
1322 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1323 " Tentative PNG color type: %s (%d)",
1324 - PngColorTypeToString(ping_info->color_type),
1325 - ping_info->color_type);
1326 + PngColorTypeToString(ping_colortype),
1328 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1329 " image_info->type: %d",image_info->type);
1330 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1331 " image->depth: %u",image_depth);
1332 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1333 - " ping_info->bit_depth: %d",
1334 - ping_info->bit_depth);
1335 + " ping_bit_depth: %d",
1339 if (matte && (mng_info->optimize || mng_info->IsPalette))
1340 @@ -6614,10 +6681,10 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1343 No transparent pixels are present. Change 4 or 6 to 0 or 2,
1344 - and do not set the PNG_INFO_tRNS flag in ping_info->valid.
1345 + and do not set the PNG_INFO_tRNS flag.
1347 image_matte=MagickFalse;
1348 - ping_info->color_type&=0x03;
1349 + ping_colortype&=0x03;
1353 @@ -6625,13 +6692,13 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1357 - if (ping_info->bit_depth == 8)
1358 + if (ping_bit_depth == 8)
1360 - if (ping_info->bit_depth == 4)
1361 + if (ping_bit_depth == 4)
1363 - if (ping_info->bit_depth == 2)
1364 + if (ping_bit_depth == 2)
1366 - if (ping_info->bit_depth == 1)
1367 + if (ping_bit_depth == 1)
1371 @@ -6655,19 +6722,20 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1372 if ((p != (const PixelPacket *) NULL) &&
1373 (p->opacity != OpaqueOpacity))
1375 - ping_info->valid|=PNG_INFO_tRNS;
1376 - ping_info->trans_color.red=ScaleQuantumToShort(p->red)&mask;
1377 - ping_info->trans_color.green=ScaleQuantumToShort(p->green)
1378 + ping_trans_color.red=ScaleQuantumToShort(p->red)&mask;
1379 + ping_trans_color.green=ScaleQuantumToShort(p->green)
1381 - ping_info->trans_color.blue=ScaleQuantumToShort(p->blue)
1382 + ping_trans_color.blue=ScaleQuantumToShort(p->blue)
1384 - ping_info->trans_color.gray=
1385 + ping_trans_color.gray=
1386 (png_uint_16) ScaleQuantumToShort(PixelIntensity(p))&mask;
1387 - ping_info->trans_color.index=(unsigned char)
1388 + ping_trans_color.index=(unsigned char)
1389 (ScaleQuantumToChar(MaxRGB-p->opacity));
1390 + (void) png_set_tRNS(ping, ping_info, NULL, 0,
1391 + &ping_trans_color);
1394 - if (ping_info->valid & PNG_INFO_tRNS)
1395 + if (png_get_valid(ping, ping_info, PNG_INFO_tRNS))
1398 Determine if there is one and only one transparent color
1399 @@ -6684,7 +6752,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1401 if (p->opacity != OpaqueOpacity)
1403 - if (!RGBColorMatchExact(ping_info->trans_color,*p))
1404 + if (!RGBColorMatchExact(ping_trans_color,*p))
1406 break; /* Can't use RGB + tRNS for multiple
1407 transparent colors. */
1408 @@ -6697,7 +6765,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1412 - if (RGBColorMatchExact(ping_info->trans_color,*p))
1413 + if (RGBColorMatchExact(ping_trans_color,*p))
1414 break; /* Can't use RGB + tRNS when another pixel
1415 having the same RGB samples is
1417 @@ -6708,50 +6776,50 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1421 - ping_info->valid&=(~PNG_INFO_tRNS);
1422 + png_set_invalid(ping, ping_info, PNG_INFO_tRNS);
1424 - if (ping_info->valid & PNG_INFO_tRNS)
1425 + if (png_get_valid(ping, ping_info, PNG_INFO_tRNS))
1427 - ping_info->color_type &= 0x03; /* changes 4 or 6 to 0 or 2 */
1428 + ping_colortype &= 0x03; /* changes 4 or 6 to 0 or 2 */
1429 if (image_depth == 8)
1431 - ping_info->trans_color.red&=0xff;
1432 - ping_info->trans_color.green&=0xff;
1433 - ping_info->trans_color.blue&=0xff;
1434 - ping_info->trans_color.gray&=0xff;
1435 + ping_trans_color.red&=0xff;
1436 + ping_trans_color.green&=0xff;
1437 + ping_trans_color.blue&=0xff;
1438 + ping_trans_color.gray&=0xff;
1443 - if (ping_info->valid & PNG_INFO_tRNS)
1444 + if (png_get_valid(ping, ping_info, PNG_INFO_tRNS))
1445 image_matte=MagickFalse;
1446 if ((mng_info->optimize || mng_info->IsPalette) &&
1447 characteristics.grayscale && (!image_matte || image_depth >= 8))
1450 - ping_info->color_type=PNG_COLOR_TYPE_GRAY_ALPHA;
1451 + ping_colortype=PNG_COLOR_TYPE_GRAY_ALPHA;
1454 - ping_info->color_type=PNG_COLOR_TYPE_GRAY;
1455 + ping_colortype=PNG_COLOR_TYPE_GRAY;
1456 if (save_image_depth == 16 && image_depth == 8)
1457 - ping_info->trans_color.gray*=0x0101;
1458 + ping_trans_color.gray*=0x0101;
1460 if (image_depth > QuantumDepth)
1461 image_depth=QuantumDepth;
1462 if (image_colors == 0 || image_colors-1 > MaxRGB)
1463 image_colors=1 << image_depth;
1464 if (image_depth > 8)
1465 - ping_info->bit_depth=16;
1466 + ping_bit_depth=16;
1469 - if (ping_info->color_type == PNG_COLOR_TYPE_PALETTE)
1470 + if (ping_colortype == PNG_COLOR_TYPE_PALETTE)
1472 - ping_info->bit_depth=1;
1473 - while ((int) (1 << ping_info->bit_depth) <
1475 + while ((int) (1 << ping_bit_depth) <
1476 (long) image_colors)
1477 - ping_info->bit_depth <<= 1;
1478 + ping_bit_depth <<= 1;
1480 - else if (mng_info->optimize && ping_info->color_type ==
1481 + else if (mng_info->optimize && ping_colortype ==
1482 PNG_COLOR_TYPE_GRAY && image_colors < 17 &&
1483 mng_info->IsPalette)
1485 @@ -6779,11 +6847,11 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1486 depth_1_ok=MagickFalse;
1489 - ping_info->bit_depth=1;
1491 else if (depth_2_ok)
1492 - ping_info->bit_depth=2;
1494 else if (depth_4_ok)
1495 - ping_info->bit_depth=4;
1500 @@ -6796,13 +6864,10 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1503 number_colors=image_colors;
1505 - ping_info->valid|=PNG_INFO_tRNS;
1509 - ping_info->color_type=PNG_COLOR_TYPE_PALETTE;
1510 - ping_info->valid|=PNG_INFO_PLTE;
1511 + ping_colortype=PNG_COLOR_TYPE_PALETTE;
1512 if (mng_info->have_write_global_plte && !matte)
1514 png_set_PLTE(ping,ping_info,NULL,0);
1515 @@ -6847,14 +6912,12 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1516 " Setting up PLTE chunk with %d colors",
1517 (int) number_colors);
1518 png_set_PLTE(ping,ping_info,palette,(int) number_colors);
1519 -#if (PNG_LIBPNG_VER > 10008)
1520 MagickFreeMemory(palette);
1523 - ping_info->bit_depth=1;
1524 - while ((1UL << ping_info->bit_depth) < number_colors)
1525 - ping_info->bit_depth <<= 1;
1526 - ping_info->num_trans=0;
1528 + while ((1UL << ping_bit_depth) < number_colors)
1529 + ping_bit_depth <<= 1;
1534 @@ -6890,7 +6953,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1535 if (trans_alpha[index] != (png_byte) (255-
1536 ScaleQuantumToChar(p->opacity)))
1538 - ping_info->color_type=
1540 PNG_COLOR_TYPE_RGB_ALPHA;
1543 @@ -6900,11 +6963,11 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1547 - if (ping_info->color_type==PNG_COLOR_TYPE_RGB_ALPHA)
1548 + if (ping_colortype==PNG_COLOR_TYPE_RGB_ALPHA)
1550 - ping_info->num_trans=0;
1551 - ping_info->valid&=(~PNG_INFO_tRNS);
1552 - ping_info->valid&=(~PNG_INFO_PLTE);
1554 + png_set_invalid(ping, ping_info, PNG_INFO_tRNS);
1555 + png_set_invalid(ping, ping_info, PNG_INFO_PLTE);
1556 mng_info->IsPalette=MagickFalse;
1557 (void) SyncImage(image);
1559 @@ -6916,40 +6979,41 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1563 - if ((ping_info->valid & PNG_INFO_tRNS))
1564 + if (png_get_valid(ping, ping_info, PNG_INFO_tRNS))
1566 for (i=0; i < (long) number_colors; i++)
1568 if (trans_alpha[i] == 256)
1570 if (trans_alpha[i] != 255)
1571 - ping_info->num_trans=(unsigned short) (i+1);
1572 + ping_num_trans=(unsigned short) (i+1);
1575 - if (ping_info->num_trans == 0)
1576 - ping_info->valid&=(~PNG_INFO_tRNS);
1577 - if (!(ping_info->valid & PNG_INFO_tRNS))
1578 - ping_info->num_trans=0;
1579 - if (ping_info->num_trans != 0)
1580 + if (ping_num_trans == 0)
1581 + png_set_invalid(ping, ping_info, PNG_INFO_tRNS);
1582 + if (!png_get_valid(ping, ping_info, PNG_INFO_tRNS))
1585 + if (ping_num_trans != 0)
1587 - ping_info->trans_alpha=MagickAllocateMemory(
1588 - unsigned char *, number_colors);
1589 - if (ping_info->trans_alpha == (unsigned char *) NULL)
1590 - ThrowWriterException(ResourceLimitError,
1591 - MemoryAllocationFailed,image);
1592 - for (i=0; i < (long) number_colors; i++)
1593 - ping_info->trans_alpha[i]=(png_byte) trans_alpha[i];
1594 + for (i=0; i<256; i++)
1595 + ping_trans_alpha[i]=(png_byte) trans_alpha[i];
1598 + (void) png_set_tRNS(ping, ping_info,
1601 + &ping_trans_color);
1605 Identify which colormap entry is the background color.
1607 for (i=0; i < (long) Max(number_colors-1,1); i++)
1608 - if (RGBColorMatchExact(ping_info->background,
1609 + if (RGBColorMatchExact(ping_background,
1610 image->colormap[i]))
1612 - ping_info->background.index=(png_uint_16) i;
1613 + ping_background.index=(png_uint_16) i;
1617 @@ -6958,10 +7022,10 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1619 if ((save_image_depth == 16) && (image_depth == 8))
1621 - ping_info->trans_color.red*=0x0101;
1622 - ping_info->trans_color.green*=0x0101;
1623 - ping_info->trans_color.blue*=0x0101;
1624 - ping_info->trans_color.gray*=0x0101;
1625 + ping_trans_color.red*=0x0101;
1626 + ping_trans_color.green*=0x0101;
1627 + ping_trans_color.blue*=0x0101;
1628 + ping_trans_color.gray*=0x0101;
1632 @@ -6969,7 +7033,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1633 Adjust background and transparency samples in sub-8-bit
1636 - if (ping_info->bit_depth < 8 && ping_info->color_type ==
1637 + if (ping_bit_depth < 8 && ping_colortype ==
1638 PNG_COLOR_TYPE_GRAY)
1641 @@ -6978,7 +7042,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1645 - maxval=(1 << ping_info->bit_depth)-1;
1646 + maxval=(1 << ping_bit_depth)-1;
1649 background.gray=(png_uint_16)
1650 @@ -6989,28 +7053,26 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1651 " Setting up bKGD chunk");
1652 png_set_bKGD(ping,ping_info,&background);
1654 - ping_info->trans_color.gray=(png_uint_16)(maxval*
1655 - ping_info->trans_color.gray/
1657 + ping_trans_color.gray=(png_uint_16)(maxval*
1658 + ping_trans_color.gray/
1663 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1664 " PNG color type: %s (%d)",
1665 - PngColorTypeToString(ping_info->color_type),
1666 - ping_info->color_type);
1667 + PngColorTypeToString(ping_colortype),
1670 Initialize compression level and filtering.
1673 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1674 " Setting up deflate compression");
1675 -#if (PNG_LIBPNG_VER > 99)
1677 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1678 " Compression buffer size: 32768");
1679 png_set_compression_buffer_size(ping,32768L);
1682 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1683 " Compression mem level: 9");
1684 @@ -7044,7 +7106,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1686 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1687 " Filter_type: PNG_INTRAPIXEL_DIFFERENCING");
1688 - ping_info->filter_type=PNG_INTRAPIXEL_DIFFERENCING;
1689 + ping_filter_method=PNG_INTRAPIXEL_DIFFERENCING;
1693 @@ -7061,8 +7123,8 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1694 if ((image_info->quality % 10) != 5)
1695 base_filter=(int) image_info->quality % 10;
1697 - if ((ping_info->color_type == PNG_COLOR_TYPE_GRAY) ||
1698 - (ping_info->color_type == PNG_COLOR_TYPE_PALETTE) ||
1699 + if ((ping_colortype == PNG_COLOR_TYPE_GRAY) ||
1700 + (ping_colortype == PNG_COLOR_TYPE_PALETTE) ||
1701 (image_info->quality < 50))
1702 base_filter=PNG_NO_FILTERS;
1704 @@ -7099,7 +7161,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1706 if (LocaleCompare(profile_name,"ICM") == 0)
1708 -#if (PNG_LIBPNG_VER > 10008) && defined(PNG_WRITE_iCCP_SUPPORTED)
1709 +#if defined(PNG_WRITE_iCCP_SUPPORTED)
1712 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1713 @@ -7170,8 +7232,8 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1714 (void) png_set_sRGB(ping,ping_info,PerceptualIntent);
1715 png_set_gAMA(ping,ping_info,0.45455);
1717 - not_valid=(!ping_info->valid);
1718 - if ((!mng_info->write_mng) || not_valid & PNG_INFO_sRGB)
1719 + if ((!mng_info->write_mng) ||
1720 + !png_get_valid(ping, ping_info, PNG_INFO_sRGB))
1723 if (!mng_info->have_write_global_gama && (image->gamma != 0.0))
1724 @@ -7210,7 +7272,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1728 - ping_info->interlace_type=(image_info->interlace == LineInterlace);
1729 + ping_interlace_method=(image_info->interlace == LineInterlace);
1731 if (mng_info->write_mng)
1732 png_set_sig_bytes(ping,8);
1733 @@ -7219,6 +7281,15 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1734 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1735 " Writing PNG header chunks");
1737 + png_set_IHDR(ping,ping_info,
1742 + ping_interlace_method,
1743 + ping_compression_method,
1744 + ping_filter_method);
1746 png_write_info(ping,ping_info);
1748 #if (PNG_LIBPNG_VER == 10206)
1749 @@ -7313,7 +7384,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1751 if ((!mng_info->write_png8 && !mng_info->write_png24 &&
1752 !mng_info->write_png32) &&
1753 - (!image_matte || (ping_info->bit_depth >= QuantumDepth)) &&
1754 + (!image_matte || (ping_bit_depth >= QuantumDepth)) &&
1755 (mng_info->optimize || mng_info->IsPalette) &&
1756 IsGrayImage(image,&image->exception))
1758 @@ -7325,7 +7396,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1759 if (!AcquireImagePixels(image,0,y,image->columns,1,
1762 - if (ping_info->color_type == PNG_COLOR_TYPE_GRAY)
1763 + if (ping_colortype == PNG_COLOR_TYPE_GRAY)
1765 if (mng_info->IsPalette)
1766 (void) ExportImagePixelArea(image,
1767 @@ -7368,14 +7439,14 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1768 " pass %d, Image Is RGB,"
1769 " PNG colortype is %s (%d)",pass,
1770 PngColorTypeToString(
1771 - ping_info->color_type),
1772 - ping_info->color_type);
1775 for (y=0; y < (long) image->rows; y++)
1777 if (!AcquireImagePixels(image,0,y,image->columns,1,
1780 - if (ping_info->color_type == PNG_COLOR_TYPE_GRAY)
1781 + if (ping_colortype == PNG_COLOR_TYPE_GRAY)
1783 if (image->storage_class == DirectClass)
1784 (void) ExportImagePixelArea(image,(QuantumType)
1785 @@ -7388,7 +7459,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1789 - else if (ping_info->color_type ==
1790 + else if (ping_colortype ==
1791 PNG_COLOR_TYPE_GRAY_ALPHA)
1792 (void) ExportImagePixelArea(image,(QuantumType)
1794 @@ -7433,12 +7504,12 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1795 if (!AcquireImagePixels(image,0,y,image->columns,1,
1798 - if (ping_info->color_type == PNG_COLOR_TYPE_GRAY)
1799 + if (ping_colortype == PNG_COLOR_TYPE_GRAY)
1800 (void) ExportImagePixelArea(image,(QuantumType)
1804 - else if (ping_info->color_type ==
1805 + else if (ping_colortype ==
1806 PNG_COLOR_TYPE_GRAY_ALPHA)
1807 (void) ExportImagePixelArea(image,(QuantumType)
1809 @@ -7471,38 +7542,32 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1810 " Writing PNG image data");
1811 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1813 - (unsigned long)ping_info->width);
1814 + (unsigned long)ping_width);
1815 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1817 - (unsigned long)ping_info->height);
1818 + (unsigned long)ping_height);
1819 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1820 - " PNG sample depth: %d",ping_info->bit_depth);
1821 + " PNG sample depth: %d",ping_bit_depth);
1822 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1823 " PNG color type: %s (%d)",
1824 - PngColorTypeToString(ping_info->color_type),
1825 - ping_info->color_type);
1826 + PngColorTypeToString(ping_colortype),
1828 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1829 " PNG Interlace method: %d",
1830 - ping_info->interlace_type);
1831 + ping_interlace_method);
1834 Generate text chunks.
1836 -#if (PNG_LIBPNG_VER <= 10005)
1837 - ping_info->num_text=0;
1839 attribute=GetImageAttribute(image,(char *) NULL);
1840 for ( ; attribute != (const ImageAttribute *) NULL;
1841 attribute=attribute->next)
1843 -#if (PNG_LIBPNG_VER > 10005)
1848 if (*attribute->key == '[')
1850 -#if (PNG_LIBPNG_VER > 10005)
1851 text=(png_textp) png_malloc(ping,(png_uint_32) sizeof(png_text));
1852 text[0].key=attribute->key;
1853 text[0].text=attribute->value;
1854 @@ -7519,40 +7584,6 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1856 png_set_text(ping,ping_info,text,1);
1857 png_free(ping,text);
1859 - /* Work directly with ping_info struct;
1860 - * png_set_text before libpng version
1861 - * 1.0.5a is leaky */
1862 - if (ping_info->num_text == 0)
1864 - ping_info->text=MagickAllocateMemory(png_text *,
1865 - 256*sizeof(png_text));
1866 - if (ping_info->text == (png_text *) NULL)
1867 - (void) ThrowException(&image->exception,(ExceptionType)
1868 - ResourceLimitError,MemoryAllocationFailed,
1871 - i=ping_info->num_text++;
1873 - (void) ThrowException(&image->exception,(ExceptionType)
1874 - ResourceLimitError,
1875 - "Cannot write more than 256 PNG text chunks",
1877 - ping_info->text[i].key=attribute->key;
1878 - ping_info->text[i].text=attribute->value;
1879 - ping_info->text[i].text_length=strlen(attribute->value);
1880 - ping_info->text[i].compression=
1881 - image_info->compression == NoCompression ||
1882 - (image_info->compression == UndefinedCompression &&
1883 - ping_info->text[i].text_length < 128) ? -1 : 0;
1886 - (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1887 - " Setting up text chunk");
1888 - (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1889 - " keyword: %s",ping_info->text[i].key);
1894 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1895 @@ -7560,9 +7591,9 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1896 png_write_end(ping,ping_info);
1897 if (mng_info->need_fram && (int) image->dispose == BackgroundDispose)
1899 - if (mng_info->page.x || mng_info->page.y || (ping_info->width !=
1900 + if (mng_info->page.x || mng_info->page.y || (ping_width !=
1901 mng_info->page.width) ||
1902 - (ping_info->height != mng_info->page.height))
1903 + (ping_height != mng_info->page.height))
1907 @@ -7583,10 +7614,10 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1908 chunk[14]=0; /* clipping boundaries delta type */
1909 PNGLong(chunk+15,(png_uint_32) (mng_info->page.x)); /* left cb */
1910 PNGLong(chunk+19,(png_uint_32) (mng_info->page.x +
1911 - ping_info->width));
1913 PNGLong(chunk+23,(png_uint_32) (mng_info->page.y)); /* top cb */
1914 PNGLong(chunk+27,(png_uint_32) (mng_info->page.y +
1915 - ping_info->height));
1917 (void) WriteBlob(image,31,(char *) chunk);
1918 (void) WriteBlobMSBULong(image,crc32(0,chunk,31));
1919 mng_info->old_framing_mode=4;
1920 @@ -7605,7 +7636,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1922 /* Save depth actually written */
1924 - s[0]=(char) ping_info->bit_depth;
1925 + s[0]=(char) ping_bit_depth;
1928 (void) SetImageAttribute(image,"[png:bit-depth-written]",s);
1929 @@ -7613,18 +7644,6 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_in
1933 -#if (PNG_LIBPNG_VER < 10007)
1934 - if (ping_info->valid & PNG_INFO_PLTE)
1936 - MagickFreeMemory(ping_info->palette);
1937 - ping_info->valid&=(~PNG_INFO_PLTE);
1940 - if (ping_info->valid & PNG_INFO_tRNS)
1942 - MagickFreeMemory(ping_info->trans_alpha);
1943 - ping_info->valid&=(~PNG_INFO_tRNS);
1945 png_destroy_write_struct(&ping,&ping_info);
1947 MagickFreeMemory(png_pixels);
1948 @@ -8365,23 +8384,12 @@ static unsigned int WriteMNGImage(const ImageInfo *ima
1952 -#if (PNG_LIBPNG_VER < 10007)
1953 +#if (PNG_LIBPNG_VER < 10200)
1954 if (image_info->verbose)
1955 printf("Your PNG library (libpng-%s) is rather old.\n",
1956 PNG_LIBPNG_VER_STRING);
1959 -#if (PNG_LIBPNG_VER >= 10400)
1960 -# ifndef PNG_TRANSFORM_GRAY_TO_RGB /* Added at libpng-1.4.0beta67 */
1961 - if (image_info->verbose)
1963 - printf("Your PNG library (libpng-%s) is an old beta version.\n",
1964 - PNG_LIBPNG_VER_STRING);
1965 - printf("Please update it.\n");
1973 @@ -9196,7 +9204,7 @@ static unsigned int WriteMNGImage(const ImageInfo *ima
1974 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"exit WriteMNGImage()");
1977 -#else /* PNG_LIBPNG_VER > 95 */
1978 +#else /* PNG_LIBPNG_VER > 10011 */
1979 static unsigned int WritePNGImage(const ImageInfo *image_info,Image *image)
1982 @@ -9208,5 +9216,5 @@ static unsigned int WriteMNGImage(const ImageInfo *ima
1984 return (WritePNGImage(image_info,image));
1986 -#endif /* PNG_LIBPNG_VER > 95 */
1987 +#endif /* PNG_LIBPNG_VER > 10011 */