--- ../htmldoc-orig-with-patches/htmldoc/image.cxx 2012-07-24 16:13:24.522576169 +0000
+++ htmldoc/image.cxx 2012-07-24 15:02:05.476727262 +0000
@@ -1475,7 +1475,7 @@
png_bytep trans_alpha;
int num_trans;
png_color_16p trans_color;
-
+ int color_type;
/*
* Setup the PNG data structures...
@@ -1528,8 +1528,11 @@
*/
png_read_info(pp, info);
-
- if (png_get_color_type(pp, info) & PNG_COLOR_MASK_PALETTE)
+
+ color_type = png_get_color_type(pp, info);
+ gray = color_type == PNG_COLOR_TYPE_GRAY;
+
+ if (color_type & PNG_COLOR_MASK_PALETTE)
{
png_set_expand(pp);
@@ -1543,10 +1546,10 @@
png_set_packing(pp);
png_set_expand(pp);
}
- else if (png_get_bit_depth(pp, info) == 16)
+ else if (png_get_bit_depth(pp, info) == 16) {
png_set_strip_16(pp);
-
- if (png_get_color_type(pp, info) & PNG_COLOR_MASK_COLOR)
+ }
+ if (color_type & PNG_COLOR_MASK_COLOR)
{
depth = 3;
img->depth = gray ? 1 : 3;
@@ -1561,7 +1564,7 @@
img->height = png_get_image_height(pp, info);
png_get_tRNS(pp, info, &trans_alpha, &num_trans, &trans_color);
- if ((png_get_color_type(pp, info) & PNG_COLOR_MASK_ALPHA) || num_trans)
+ if ((color_type & PNG_COLOR_MASK_ALPHA) || num_trans)
{
if ((PSLevel == 0 && PDFVersion >= 14) || PSLevel == 3)
image_need_mask(img, 8);
@@ -1575,14 +1578,14 @@
#ifdef DEBUG
printf("color_type=0x%04x, depth=%d, img->width=%d, img->height=%d, img->depth=%d\n",
- png_get_color_type(pp, info), depth, img->width, img->height, img->depth);
- if (png_get_color_type(pp, info) & PNG_COLOR_MASK_COLOR)
+ color_type, depth, img->width, img->height, img->depth);
+ if (color_type & PNG_COLOR_MASK_COLOR)
puts(" COLOR");
else
puts(" GRAYSCALE");
- if ((png_get_color_type(pp, info) & PNG_COLOR_MASK_ALPHA) || num_trans)
+ if (color_type & PNG_COLOR_MASK_ALPHA) || num_trans)
puts(" ALPHA");
- if (png_get_color_type(pp, info) & PNG_COLOR_MASK_PALETTE)
+ if (color_type & PNG_COLOR_MASK_PALETTE)
puts(" PALETTE");
#endif // DEBUG
@@ -1614,7 +1617,7 @@
* Generate the alpha mask as necessary...
*/
- if ((png_get_color_type(pp, info) & PNG_COLOR_MASK_ALPHA) || num_trans)
+ if ((color_type & PNG_COLOR_MASK_ALPHA) || num_trans)
{
#ifdef DEBUG
for (inptr = img->pixels, i = 0; i < img->height; i ++)
@@ -1643,12 +1646,11 @@
* Reformat the data as necessary for the reader...
*/
- if (gray && png_get_color_type(pp, info) & PNG_COLOR_MASK_COLOR)
+ if (gray && color_type & PNG_COLOR_MASK_COLOR)
{
/*
* Greyscale output needed...
*/
-
for (inptr = img->pixels, outptr = img->pixels, i = img->width * img->height;
i > 0;
inptr += depth, outptr ++, i --)