1 From upstream 1.8 branch svn r1668
3 The previous libpng-1.5 conversion patch here caused corrupt PNG output
4 on 64 bit. e.g. http://answerpot.com/showthread.php?3662601-PNG+Rendering+Problems
6 The upstream version (below) works well.
8 Index: htmldoc/image.cxx
9 ===================================================================
10 --- htmldoc/image.cxx.orig
14 * Image handling routines for HTMLDOC, a HTML document processing program.
16 - * Copyright 1997-2005 by Easy Software Products.
17 + * Copyright 2011 by Michael R Sweet.
18 + * Copyright 1997-2010 by Easy Software Products. All rights reserved.
20 - * These coded instructions, statements, and computer programs are the
21 - * property of Easy Software Products and are protected by Federal
22 - * copyright law. Distribution and use rights are outlined in the file
23 - * "COPYING.txt" which should have been included with this file. If this
24 - * file is missing or damaged please contact Easy Software Products
27 - * Attn: ESP Licensing Information
28 - * Easy Software Products
29 - * 44141 Airport View Drive, Suite 204
30 - * Hollywood, Maryland 20636-3142 USA
32 - * Voice: (301) 373-9600
33 - * EMail: info@easysw.com
34 - * WWW: http://www.easysw.com
35 + * This program is free software. Distribution and use rights are outlined in
36 + * the file "COPYING.txt".
40 @@ -1499,7 +1487,7 @@ image_load_png(image_t *img, /* I - Imag
44 - if (setjmp(pp->jmpbuf))
45 + if (setjmp(png_jmpbuf(pp)))
47 progress_error(HD_ERROR_BAD_FORMAT, "PNG file contains errors!");
49 @@ -1526,7 +1514,7 @@ image_load_png(image_t *img, /* I - Imag
51 png_read_info(pp, info);
53 - if (info->color_type & PNG_COLOR_MASK_PALETTE)
54 + if (png_get_color_type(pp, info) & PNG_COLOR_MASK_PALETTE)
58 @@ -1535,15 +1523,15 @@ image_load_png(image_t *img, /* I - Imag
62 - else if (info->bit_depth < 8)
63 + else if (png_get_bit_depth(pp, info) < 8)
68 - else if (info->bit_depth == 16)
69 + else if (png_get_bit_depth(pp, info) == 16)
72 - if (info->color_type & PNG_COLOR_MASK_COLOR)
73 + if (png_get_color_type(pp, info) & PNG_COLOR_MASK_COLOR)
76 img->depth = gray ? 1 : 3;
77 @@ -1554,10 +1542,10 @@ image_load_png(image_t *img, /* I - Imag
81 - img->width = info->width;
82 - img->height = info->height;
83 + img->width = png_get_image_width(pp, info);
84 + img->height = png_get_image_height(pp, info);
86 - if ((info->color_type & PNG_COLOR_MASK_ALPHA) || info->num_trans)
87 + if (png_get_color_type(pp, info) & PNG_COLOR_MASK_ALPHA)
89 if ((PSLevel == 0 && PDFVersion >= 14) || PSLevel == 3)
90 image_need_mask(img, 8);
91 @@ -1571,14 +1559,14 @@ image_load_png(image_t *img, /* I - Imag
94 printf("color_type=0x%04x, depth=%d, img->width=%d, img->height=%d, img->depth=%d\n",
95 - info->color_type, depth, img->width, img->height, img->depth);
96 - if (info->color_type & PNG_COLOR_MASK_COLOR)
97 + png_get_color_type(pp, info), depth, img->width, img->height, img->depth);
98 + if (png_get_color_type(pp, info) & PNG_COLOR_MASK_COLOR)
102 - if ((info->color_type & PNG_COLOR_MASK_ALPHA) || info->num_trans)
103 + if (png_get_color_type(pp, info) & PNG_COLOR_MASK_ALPHA)
105 - if (info->color_type & PNG_COLOR_MASK_PALETTE)
106 + if (png_get_color_type(pp, info) & PNG_COLOR_MASK_PALETTE)
110 @@ -1594,9 +1582,9 @@ image_load_png(image_t *img, /* I - Imag
111 * Allocate pointers...
114 - rows = (png_bytep *)calloc(info->height, sizeof(png_bytep));
115 + rows = (png_bytep *)calloc(png_get_image_height(pp, info), sizeof(png_bytep));
117 - for (i = 0; i < (int)info->height; i ++)
118 + for (i = 0; i < (int)png_get_image_height(pp, info); i ++)
119 rows[i] = img->pixels + i * img->width * depth;
122 @@ -1610,7 +1598,7 @@ image_load_png(image_t *img, /* I - Imag
123 * Generate the alpha mask as necessary...
126 - if ((info->color_type & PNG_COLOR_MASK_ALPHA) || info->num_trans)
127 + if (png_get_color_type(pp, info) & PNG_COLOR_MASK_ALPHA)
130 for (inptr = img->pixels, i = 0; i < img->height; i ++)
131 @@ -1639,7 +1627,7 @@ image_load_png(image_t *img, /* I - Imag
132 * Reformat the data as necessary for the reader...
135 - if (gray && info->color_type & PNG_COLOR_MASK_COLOR)
136 + if (gray && png_get_color_type(pp, info) & PNG_COLOR_MASK_COLOR)
139 * Greyscale output needed...
140 @@ -1720,7 +1708,7 @@ image_need_mask(image_t *img, /* I - Ima
143 img->maskwidth = (img->width * scaling + 7) / 8;
144 - size = img->maskwidth * img->height * scaling;
145 + size = img->maskwidth * img->height * scaling + 1;
148 img->mask = (uchar *)calloc(size, 1);