]> git.pld-linux.org Git - packages/htmldoc.git/blob - htmldoc-libpng15.patch
- upstream fix for libpng15
[packages/htmldoc.git] / htmldoc-libpng15.patch
1 From upstream 1.8 branch svn r1668
2
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
5
6 The upstream version (below) works well.
7
8 Index: htmldoc/image.cxx
9 ===================================================================
10 --- htmldoc/image.cxx.orig
11 +++ htmldoc/image.cxx
12 @@ -3,23 +3,11 @@
13   *
14   *   Image handling routines for HTMLDOC, a HTML document processing program.
15   *
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.
19   *
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
25 - *   at:
26 - *
27 - *       Attn: ESP Licensing Information
28 - *       Easy Software Products
29 - *       44141 Airport View Drive, Suite 204
30 - *       Hollywood, Maryland 20636-3142 USA
31 - *
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".
37   *
38   * Contents:
39   *
40 @@ -1499,7 +1487,7 @@ image_load_png(image_t *img,      /* I - Imag
41  
42    rows = NULL;
43  
44 -  if (setjmp(pp->jmpbuf)) 
45 +  if (setjmp(png_jmpbuf(pp))) 
46    {
47      progress_error(HD_ERROR_BAD_FORMAT, "PNG file contains errors!");
48  
49 @@ -1526,7 +1514,7 @@ image_load_png(image_t *img,      /* I - Imag
50  
51    png_read_info(pp, info);
52  
53 -  if (info->color_type & PNG_COLOR_MASK_PALETTE)
54 +  if (png_get_color_type(pp, info) & PNG_COLOR_MASK_PALETTE)
55    {
56      png_set_expand(pp);
57  
58 @@ -1535,15 +1523,15 @@ image_load_png(image_t *img,    /* I - Imag
59      if (Encryption)
60        img->use ++;
61    }
62 -  else if (info->bit_depth < 8)
63 +  else if (png_get_bit_depth(pp, info) < 8)
64    {
65      png_set_packing(pp);
66      png_set_expand(pp);
67    }
68 -  else if (info->bit_depth == 16)
69 +  else if (png_get_bit_depth(pp, info) == 16)
70      png_set_strip_16(pp);
71  
72 -  if (info->color_type & PNG_COLOR_MASK_COLOR)
73 +  if (png_get_color_type(pp, info) & PNG_COLOR_MASK_COLOR)
74    {
75      depth      = 3;
76      img->depth = gray ? 1 : 3;
77 @@ -1554,10 +1542,10 @@ image_load_png(image_t *img,    /* I - Imag
78      img->depth = 1;
79    }
80  
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);
85  
86 -  if ((info->color_type & PNG_COLOR_MASK_ALPHA) || info->num_trans)
87 +  if (png_get_color_type(pp, info) & PNG_COLOR_MASK_ALPHA)
88    {
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
92  
93  #ifdef DEBUG
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)
99      puts("    COLOR");
100    else
101      puts("    GRAYSCALE");
102 -  if ((info->color_type & PNG_COLOR_MASK_ALPHA) || info->num_trans)
103 +  if (png_get_color_type(pp, info) & PNG_COLOR_MASK_ALPHA)
104      puts("    ALPHA");
105 -  if (info->color_type & PNG_COLOR_MASK_PALETTE)
106 +  if (png_get_color_type(pp, info) & PNG_COLOR_MASK_PALETTE)
107      puts("    PALETTE");
108  #endif // DEBUG
109  
110 @@ -1594,9 +1582,9 @@ image_load_png(image_t *img,      /* I - Imag
111    * Allocate pointers...
112    */
113  
114 -  rows = (png_bytep *)calloc(info->height, sizeof(png_bytep));
115 +  rows = (png_bytep *)calloc(png_get_image_height(pp, info), sizeof(png_bytep));
116  
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;
120  
121   /*
122 @@ -1610,7 +1598,7 @@ image_load_png(image_t *img,      /* I - Imag
123    * Generate the alpha mask as necessary...
124    */
125  
126 -  if ((info->color_type & PNG_COLOR_MASK_ALPHA) || info->num_trans)
127 +  if (png_get_color_type(pp, info) & PNG_COLOR_MASK_ALPHA)
128    {
129  #ifdef DEBUG
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...
133    */
134  
135 -  if (gray && info->color_type & PNG_COLOR_MASK_COLOR)
136 +  if (gray && png_get_color_type(pp, info) & PNG_COLOR_MASK_COLOR)
137    {
138     /*
139      * Greyscale output needed...
140 @@ -1720,7 +1708,7 @@ image_need_mask(image_t *img,     /* I - Ima
141    {
142      // Alpha mask
143      img->maskwidth = (img->width * scaling + 7) / 8;
144 -    size           = img->maskwidth * img->height * scaling;
145 +    size           = img->maskwidth * img->height * scaling + 1;
146    }
147  
148    img->mask = (uchar *)calloc(size, 1);
This page took 0.0521 seconds and 3 git commands to generate.