Magellan Linux

Contents of /trunk/ghostscript-gpl/patches/ghostscript-gpl-9.02-libpng15.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1375 - (show annotations) (download)
Wed Jun 29 12:37:39 2011 UTC (12 years, 10 months ago) by niro
File size: 6699 byte(s)
added libpng-1.5 patch
1 $NetBSD: patch-ak,v 1.5 2011/01/15 14:08:10 wiz Exp $
2
3 Fix build with png-1.5. From John Bowler.
4
5 --- base/gdevpng.c.orig 2008-07-17 02:34:01.000000000 +0000
6 +++ base/gdevpng.c
7 @@ -36,12 +36,14 @@
8 #include "gdevpccm.h"
9 #include "gscdefs.h"
10
11 -#define PNG_INTERNAL
12 /*
13 * libpng versions 1.0.3 and later allow disabling access to the stdxxx
14 * files while retaining support for FILE * I/O.
15 + *
16 + * This is a misunderstanding - this is a build time option for libpng,
17 + * it has no effect on a user of libpng.
18 */
19 -#define PNG_NO_CONSOLE_IO
20 +/*#define PNG_NO_CONSOLE_IO*/
21 /*
22 * Earlier libpng versions require disabling FILE * I/O altogether.
23 * This produces a compiler warning about no prototype for png_init_io.
24 @@ -280,7 +282,7 @@ png_print_page(gx_device_printer * pdev,
25 goto done;
26 }
27 /* set error handling */
28 - if (setjmp(png_ptr->jmpbuf)) {
29 + if (setjmp(png_jmpbuf(png_ptr))) {
30 /* If we get here, we had a problem reading the file */
31 code = gs_note_error(gs_error_VMerror);
32 goto done;
33 @@ -290,19 +292,12 @@ png_print_page(gx_device_printer * pdev,
34 png_init_io(png_ptr, file);
35
36 /* set the file information here */
37 - info_ptr->width = pdev->width;
38 - info_ptr->height = pdev->height;
39 - /* resolution is in pixels per meter vs. dpi */
40 - info_ptr->x_pixels_per_unit =
41 - (png_uint_32) (pdev->HWResolution[0] * (100.0 / 2.54));
42 - info_ptr->y_pixels_per_unit =
43 - (png_uint_32) (pdev->HWResolution[1] * (100.0 / 2.54));
44 - info_ptr->phys_unit_type = PNG_RESOLUTION_METER;
45 - info_ptr->valid |= PNG_INFO_pHYs;
46 switch (depth) {
47 case 32:
48 - info_ptr->bit_depth = 8;
49 - info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
50 + png_set_IHDR(png_ptr, info_ptr, pdev->width, pdev->height,
51 + 8, PNG_COLOR_TYPE_RGB_ALPHA,
52 + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
53 + PNG_FILTER_TYPE_DEFAULT);
54 png_set_invert_alpha(png_ptr);
55 { gx_device_pngalpha *ppdev = (gx_device_pngalpha *)pdev;
56 png_color_16 background;
57 @@ -315,57 +310,69 @@ png_print_page(gx_device_printer * pdev,
58 }
59 break;
60 case 48:
61 - info_ptr->bit_depth = 16;
62 - info_ptr->color_type = PNG_COLOR_TYPE_RGB;
63 + png_set_IHDR(png_ptr, info_ptr, pdev->width, pdev->height,
64 + 16, PNG_COLOR_TYPE_RGB,
65 + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
66 + PNG_FILTER_TYPE_DEFAULT);
67 #if defined(ARCH_IS_BIG_ENDIAN) && (!ARCH_IS_BIG_ENDIAN)
68 png_set_swap(png_ptr);
69 #endif
70 break;
71 case 24:
72 - info_ptr->bit_depth = 8;
73 - info_ptr->color_type = PNG_COLOR_TYPE_RGB;
74 + png_set_IHDR(png_ptr, info_ptr, pdev->width, pdev->height,
75 + 8, PNG_COLOR_TYPE_RGB,
76 + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
77 + PNG_FILTER_TYPE_DEFAULT);
78 break;
79 case 8:
80 - info_ptr->bit_depth = 8;
81 - if (gx_device_has_color(pdev))
82 - info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
83 - else
84 - info_ptr->color_type = PNG_COLOR_TYPE_GRAY;
85 + png_set_IHDR(png_ptr, info_ptr, pdev->width, pdev->height,
86 + 8, gx_device_has_color(pdev) ?
87 + PNG_COLOR_TYPE_PALETTE : PNG_COLOR_TYPE_GRAY,
88 + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
89 + PNG_FILTER_TYPE_DEFAULT);
90 break;
91 case 4:
92 - info_ptr->bit_depth = 4;
93 - info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
94 + png_set_IHDR(png_ptr, info_ptr, pdev->width, pdev->height,
95 + 4, PNG_COLOR_TYPE_PALETTE,
96 + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
97 + PNG_FILTER_TYPE_DEFAULT);
98 break;
99 case 1:
100 - info_ptr->bit_depth = 1;
101 - info_ptr->color_type = PNG_COLOR_TYPE_GRAY;
102 + png_set_IHDR(png_ptr, info_ptr, pdev->width, pdev->height,
103 + 1, PNG_COLOR_TYPE_GRAY,
104 + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
105 + PNG_FILTER_TYPE_DEFAULT);
106 /* invert monocrome pixels */
107 png_set_invert_mono(png_ptr);
108 break;
109 + default:
110 + png_error(png_ptr, "invalid bit depth");
111 }
112
113 + /* resolution is in pixels per meter vs. dpi */
114 + png_set_pHYs(png_ptr, info_ptr,
115 + (png_uint_32) (pdev->HWResolution[0] * (100.0 / 2.54)),
116 + (png_uint_32) (pdev->HWResolution[1] * (100.0 / 2.54)),
117 + PNG_RESOLUTION_METER);
118 +
119 /* set the palette if there is one */
120 - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
121 + if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {
122 int i;
123 int num_colors = 1 << depth;
124 gx_color_value rgb[3];
125 + png_color palette[256];
126 +
127 + if (num_colors > 256)
128 + num_colors = 256;
129
130 - info_ptr->palette =
131 - (void *)gs_alloc_bytes(mem, 256 * sizeof(png_color),
132 - "png palette");
133 - if (info_ptr->palette == 0) {
134 - code = gs_note_error(gs_error_VMerror);
135 - goto done;
136 - }
137 - info_ptr->num_palette = num_colors;
138 - info_ptr->valid |= PNG_INFO_PLTE;
139 for (i = 0; i < num_colors; i++) {
140 (*dev_proc(pdev, map_color_rgb)) ((gx_device *) pdev,
141 (gx_color_index) i, rgb);
142 - info_ptr->palette[i].red = gx_color_value_to_byte(rgb[0]);
143 - info_ptr->palette[i].green = gx_color_value_to_byte(rgb[1]);
144 - info_ptr->palette[i].blue = gx_color_value_to_byte(rgb[2]);
145 + palette[i].red = gx_color_value_to_byte(rgb[0]);
146 + palette[i].green = gx_color_value_to_byte(rgb[1]);
147 + palette[i].blue = gx_color_value_to_byte(rgb[2]);
148 }
149 + png_set_PLTE(png_ptr, info_ptr, palette, num_colors);
150 }
151 /* add comment */
152 strncpy(software_key, "Software", sizeof(software_key));
153 @@ -375,15 +382,14 @@ png_print_page(gx_device_printer * pdev,
154 text_png.key = software_key;
155 text_png.text = software_text;
156 text_png.text_length = strlen(software_text);
157 - info_ptr->text = &text_png;
158 - info_ptr->num_text = 1;
159 + png_set_text(png_ptr, info_ptr, &text_png, 1);
160
161 /* write the file information */
162 png_write_info(png_ptr, info_ptr);
163
164 /* don't write the comments twice */
165 - info_ptr->num_text = 0;
166 - info_ptr->text = NULL;
167 + /*info_ptr->num_text = 0;*/
168 + /*info_ptr->text = NULL;*/
169
170 /* Write the contents of the image. */
171 for (y = 0; y < height; y++) {
172 @@ -395,7 +401,7 @@ png_print_page(gx_device_printer * pdev,
173 png_write_end(png_ptr, info_ptr);
174
175 /* if you alloced the palette, free it here */
176 - gs_free_object(mem, info_ptr->palette, "png palette");
177 + /*gs_free_object(mem, info_ptr->palette, "png palette");*/
178
179 done:
180 /* free the structures */
181 @@ -405,6 +411,7 @@ png_print_page(gx_device_printer * pdev,
182 return code;
183 }
184
185 +#if 0 /* not required in 1.5 */
186 /*
187 * Patch around a static reference to a never-used procedure.
188 * This could be avoided if we were willing to edit pngconf.h to
189 @@ -422,6 +429,7 @@ png_push_fill_buffer(png_structp png_ptr
190 {
191 }
192 #endif
193 +#endif
194
195 static int
196 pngalpha_open(gx_device * pdev)