summaryrefslogtreecommitdiff
path: root/pcr/htmldoc/libpng15.patch
blob: 02f1d233020369dd64385f0e69b71022c53a837f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
Description: libpng 1.5 fixes
 This patch fixes incompatibilities with libpng 1.5.
Bug: http://www.htmldoc.org/str.php?L243+Qversion:1.8
Origin: http://www.htmldoc.org/str.php?F243+P0+S-2+C0+I0+E0+M10+Qversion%3A1.8
Forwarded: not-needed
Last-Update: 2011-12-04

Index: htmldoc-1.8.27/htmldoc/image.cxx
===================================================================
--- htmldoc-1.8.27.orig/htmldoc/image.cxx	2011-12-04 22:32:01.000000000 -0500
+++ htmldoc-1.8.27/htmldoc/image.cxx	2011-12-04 22:35:32.000000000 -0500
@@ -1472,6 +1472,9 @@
   png_bytep	*rows;		/* PNG row pointers */
   uchar		*inptr,		/* Input pixels */
 		*outptr;	/* Output pixels */
+  png_bytep trans_alpha;
+  int num_trans;
+  png_color_16p trans_color;
 
 
  /*
@@ -1499,7 +1502,7 @@
 
   rows = NULL;
 
-  if (setjmp(pp->jmpbuf)) 
+  if (setjmp(png_jmpbuf(pp))) 
   {
     progress_error(HD_ERROR_BAD_FORMAT, "PNG file contains errors!");
 
@@ -1526,7 +1529,7 @@
 
   png_read_info(pp, info);
 
-  if (info->color_type & PNG_COLOR_MASK_PALETTE)
+  if (png_get_color_type(pp, info) & PNG_COLOR_MASK_PALETTE)
   {
     png_set_expand(pp);
 
@@ -1535,15 +1538,15 @@
     if (Encryption)
       img->use ++;
   }
-  else if (info->bit_depth < 8)
+  else if (png_get_bit_depth(pp, info) < 8)
   {
     png_set_packing(pp);
     png_set_expand(pp);
   }
-  else if (info->bit_depth == 16)
+  else if (png_get_bit_depth(pp, info) == 16)
     png_set_strip_16(pp);
 
-  if (info->color_type & PNG_COLOR_MASK_COLOR)
+  if (png_get_color_type(pp, info) & PNG_COLOR_MASK_COLOR)
   {
     depth      = 3;
     img->depth = gray ? 1 : 3;
@@ -1554,10 +1557,11 @@
     img->depth = 1;
   }
 
-  img->width  = info->width;
-  img->height = info->height;
+  img->width  = png_get_image_width(pp, info);
+  img->height = png_get_image_height(pp, info);
 
-  if ((info->color_type & PNG_COLOR_MASK_ALPHA) || info->num_trans)
+  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 ((PSLevel == 0 && PDFVersion >= 14) || PSLevel == 3)
       image_need_mask(img, 8);
@@ -1571,14 +1575,14 @@
 
 #ifdef DEBUG
   printf("color_type=0x%04x, depth=%d, img->width=%d, img->height=%d, img->depth=%d\n",
-         info->color_type, depth, img->width, img->height, img->depth);
-  if (info->color_type & PNG_COLOR_MASK_COLOR)
+         png_get_color_type(pp, info), depth, img->width, img->height, img->depth);
+  if (png_get_color_type(pp, info) & PNG_COLOR_MASK_COLOR)
     puts("    COLOR");
   else
     puts("    GRAYSCALE");
-  if ((info->color_type & PNG_COLOR_MASK_ALPHA) || info->num_trans)
+  if ((png_get_color_type(pp, info) & PNG_COLOR_MASK_ALPHA) || num_trans)
     puts("    ALPHA");
-  if (info->color_type & PNG_COLOR_MASK_PALETTE)
+  if (png_get_color_type(pp, info) & PNG_COLOR_MASK_PALETTE)
     puts("    PALETTE");
 #endif // DEBUG
 
@@ -1594,9 +1598,9 @@
   * Allocate pointers...
   */
 
-  rows = (png_bytep *)calloc(info->height, sizeof(png_bytep));
+  rows = (png_bytep *)calloc(png_get_image_height(pp, info), sizeof(png_bytep));
 
-  for (i = 0; i < (int)info->height; i ++)
+  for (i = 0; i < (int)png_get_image_height(pp, info); i ++)
     rows[i] = img->pixels + i * img->width * depth;
 
  /*
@@ -1610,7 +1614,7 @@
   * Generate the alpha mask as necessary...
   */
 
-  if ((info->color_type & PNG_COLOR_MASK_ALPHA) || info->num_trans)
+  if ((png_get_color_type(pp, info) & PNG_COLOR_MASK_ALPHA) || num_trans)
   {
 #ifdef DEBUG
     for (inptr = img->pixels, i = 0; i < img->height; i ++)
@@ -1639,7 +1643,7 @@
   * Reformat the data as necessary for the reader...
   */
 
-  if (gray && info->color_type & PNG_COLOR_MASK_COLOR)
+  if (gray && png_get_color_type(pp, info) & PNG_COLOR_MASK_COLOR)
   {
    /*
     * Greyscale output needed...