1 --- netpbm-10.35.65/converter/ppm/ppmtompeg/jpeg.c~ 2006-08-19 05:12:28.000000000 +0200
2 +++ netpbm-10.35.65/converter/ppm/ppmtompeg/jpeg.c 2009-07-15 08:52:06.372101451 +0200
5 buffer_height = 8; /* could be 2, 4,8 rows high */
7 - buffer_height = cinfo.max_v_samp_factor * cinfo.min_DCT_scaled_size;
8 + buffer_height = cinfo.max_v_samp_factor * cinfo.min_DCT_v_scaled_size;
11 for(cp=0,compptr = cinfo.comp_info;cp<cinfo.num_components;
12 --- netpbm-10.35.83/converter/other/pnmtopng.c.orig 2011-09-25 20:51:44.000000000 +0200
13 +++ netpbm-10.35.83/converter/other/pnmtopng.c 2012-01-29 08:48:17.363289175 +0100
16 #include <string.h> /* strcat() */
18 -#include <png.h> /* includes zlib.h and setjmp.h */
19 +#include <png.h> /* includes setjmp.h */
28 -#if PNG_LIBPNG_VER >= 10400
29 -#error Your PNG library (<png.h>) is incompatible with this Netpbm source code.
30 -#error You need either an older PNG library (older than 1.4)
31 -#error newer Netpbm source code (at least 10.47.04)
35 struct zlibCompression {
37 gray * const alpha_mask,
38 colorhash_table const cht,
39 coloralphahash_table const caht,
40 + png_struct * const png_ptr,
41 png_info * const info_ptr,
42 xelval const png_maxval,
43 unsigned int const depth) {
44 @@ -2109,21 +2106,22 @@
45 for (col = 0; col < cols; ++col) {
47 xel const p = xelrow[col];
48 + png_byte color_type = png_get_color_type(png_ptr, info_ptr);
49 PPM_DEPTH(p_png, p, maxval, png_maxval);
50 - if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
51 - info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
52 + if (color_type == PNG_COLOR_TYPE_GRAY ||
53 + color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
55 *pp++ = PNM_GET1(p_png) >> 8;
56 *pp++ = PNM_GET1(p_png) & 0xff;
57 - } else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
58 + } else if (color_type == PNG_COLOR_TYPE_PALETTE) {
59 unsigned int paletteIndex;
61 paletteIndex = lookupColorAlpha(caht, &p, &alpha_mask[col]);
63 paletteIndex = ppm_lookupcolor(cht, &p);
65 - } else if (info_ptr->color_type == PNG_COLOR_TYPE_RGB ||
66 - info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
67 + } else if (color_type == PNG_COLOR_TYPE_RGB ||
68 + color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
70 *pp++ = PPM_GETR(p_png) >> 8;
71 *pp++ = PPM_GETR(p_png) & 0xff;
74 pm_error("INTERNAL ERROR: undefined color_type");
76 - if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) {
77 + if (color_type & PNG_COLOR_MASK_ALPHA) {
78 int const png_alphaval = (int)
79 alpha_mask[col] * (float) png_maxval / maxval + 0.5;
83 makePngLine(line, xelrow, cols, maxval,
84 alpha, alpha ? alpha_mask[row] : NULL,
85 - cht, caht, info_ptr, png_maxval, depth);
86 + cht, caht, png_ptr, info_ptr, png_maxval, depth);
88 png_write_row(png_ptr, line);
90 @@ -2205,12 +2203,12 @@
93 doGamaChunk(struct cmdlineInfo const cmdline,
94 + png_struct * const png_ptr,
95 png_info * const info_ptr) {
97 if (cmdline.gammaSpec) {
99 - info_ptr->valid |= PNG_INFO_gAMA;
100 - info_ptr->gamma = cmdline.gamma;
101 + png_set_gAMA(png_ptr, info_ptr, cmdline.gamma);
105 @@ -2218,20 +2216,16 @@
108 doChrmChunk(struct cmdlineInfo const cmdline,
109 + png_struct * const png_ptr,
110 png_info * const info_ptr) {
112 if (cmdline.rgbSpec) {
114 - info_ptr->valid |= PNG_INFO_cHRM;
116 - info_ptr->x_white = cmdline.rgb.wx;
117 - info_ptr->y_white = cmdline.rgb.wy;
118 - info_ptr->x_red = cmdline.rgb.rx;
119 - info_ptr->y_red = cmdline.rgb.ry;
120 - info_ptr->x_green = cmdline.rgb.gx;
121 - info_ptr->y_green = cmdline.rgb.gy;
122 - info_ptr->x_blue = cmdline.rgb.bx;
123 - info_ptr->y_blue = cmdline.rgb.by;
124 + png_set_cHRM(png_ptr, info_ptr,
125 + cmdline.rgb.wx, cmdline.rgb.wy,
126 + cmdline.rgb.rx, cmdline.rgb.ry,
127 + cmdline.rgb.gx, cmdline.rgb.gy,
128 + cmdline.rgb.bx, cmdline.rgb.by);
132 @@ -2239,15 +2233,13 @@
135 doPhysChunk(struct cmdlineInfo const cmdline,
136 + png_struct * const png_ptr,
137 png_info * const info_ptr) {
139 if (cmdline.sizeSpec) {
141 - info_ptr->valid |= PNG_INFO_pHYs;
143 - info_ptr->x_pixels_per_unit = cmdline.size.x;
144 - info_ptr->y_pixels_per_unit = cmdline.size.y;
145 - info_ptr->phys_unit_type = cmdline.size.unit;
146 + png_set_pHYs(png_ptr, info_ptr,
147 + cmdline.size.x, cmdline.size.y, cmdline.size.unit);
151 @@ -2256,26 +2248,29 @@
154 doTimeChunk(struct cmdlineInfo const cmdline,
155 + png_struct * const png_ptr,
156 png_info * const info_ptr) {
158 if (cmdline.modtimeSpec) {
160 - info_ptr->valid |= PNG_INFO_tIME;
162 - png_convert_from_time_t(&info_ptr->mod_time, cmdline.modtime);
164 + png_convert_from_time_t(&ptime, cmdline.modtime);
165 + png_set_tIME(png_ptr, info_ptr, &ptime);
172 -doSbitChunk(png_info * const pngInfoP,
173 +doSbitChunk(png_struct * const png_ptr,
174 + png_info * const pngInfoP,
175 xelval const pngMaxval,
178 xelval const alphaMaxval) {
180 - if (pngInfoP->color_type != PNG_COLOR_TYPE_PALETTE &&
181 + png_byte color_type = png_get_color_type(png_ptr, pngInfoP);
182 + if (color_type != PNG_COLOR_TYPE_PALETTE &&
183 (pngMaxval > maxval || (alpha && pngMaxval > alphaMaxval))) {
185 /* We're writing in a bit depth that doesn't match the maxval
186 @@ -2294,27 +2289,27 @@
190 - pngInfoP->valid |= PNG_INFO_sBIT;
194 int const sbitval = pm_maxvaltobits(MIN(maxval, pngMaxval));
196 - if (pngInfoP->color_type & PNG_COLOR_MASK_COLOR) {
197 - pngInfoP->sig_bit.red = sbitval;
198 - pngInfoP->sig_bit.green = sbitval;
199 - pngInfoP->sig_bit.blue = sbitval;
200 + if (color_type & PNG_COLOR_MASK_COLOR) {
201 + sbit.red = sbitval;
202 + sbit.green = sbitval;
203 + sbit.blue = sbitval;
205 - pngInfoP->sig_bit.gray = sbitval;
206 + sbit.gray = sbitval;
209 pm_message("Writing sBIT chunk with bits = %d", sbitval);
211 - if (pngInfoP->color_type & PNG_COLOR_MASK_ALPHA) {
212 - pngInfoP->sig_bit.alpha =
213 + if (color_type & PNG_COLOR_MASK_ALPHA) {
215 pm_maxvaltobits(MIN(alphaMaxval, pngMaxval));
217 - pm_message(" alpha bits = %d", pngInfoP->sig_bit.alpha);
218 + pm_message(" alpha bits = %d", sbit.alpha);
220 + png_set_sBIT(png_ptr, pngInfoP, &sbit);
224 @@ -2595,43 +2590,41 @@
225 pm_error ("setjmp returns error condition (2)");
228 - png_init_io (png_ptr, stdout);
229 - info_ptr->width = cols;
230 - info_ptr->height = rows;
231 - info_ptr->bit_depth = depth;
236 - info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
237 + color_type = PNG_COLOR_TYPE_PALETTE;
238 else if (pnm_type == PPM_TYPE)
239 - info_ptr->color_type = PNG_COLOR_TYPE_RGB;
240 + color_type = PNG_COLOR_TYPE_RGB;
242 - info_ptr->color_type = PNG_COLOR_TYPE_GRAY;
243 + color_type = PNG_COLOR_TYPE_GRAY;
245 - if (alpha && info_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
246 - info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
247 + if (alpha && (color_type != PNG_COLOR_TYPE_PALETTE))
248 + color_type |= PNG_COLOR_MASK_ALPHA;
250 - info_ptr->interlace_type = cmdline.interlace;
251 + png_set_IHDR(png_ptr, info_ptr,
252 + cols, rows, depth, color_type, 0, 0, 0);
255 - doGamaChunk(cmdline, info_ptr);
256 + if(cmdline.interlace)
257 + png_set_interlace_handling(png_ptr);
259 - doChrmChunk(cmdline, info_ptr);
260 + doGamaChunk(cmdline, png_ptr, info_ptr);
262 - doPhysChunk(cmdline, info_ptr);
263 + doChrmChunk(cmdline, png_ptr, info_ptr);
265 - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
266 + doPhysChunk(cmdline, png_ptr, info_ptr);
268 + if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {
270 /* creating PNG palette (PLTE and tRNS chunks) */
272 createPngPalette(palette_pnm, palette_size, maxval,
273 trans_pnm, trans_size, alpha_maxval,
275 - info_ptr->valid |= PNG_INFO_PLTE;
276 - info_ptr->palette = palette;
277 - info_ptr->num_palette = palette_size;
278 + png_set_PLTE(png_ptr, info_ptr, palette, palette_size);
279 if (trans_size > 0) {
280 - info_ptr->valid |= PNG_INFO_tRNS;
281 - info_ptr->trans = trans;
282 - info_ptr->num_trans = trans_size; /* omit opaque values */
283 + png_set_tRNS(png_ptr, info_ptr, trans, trans_size, NULL);
285 /* creating hIST chunk */
287 @@ -2657,18 +2650,17 @@
289 ppm_freecolorhash(cht);
291 - info_ptr->valid |= PNG_INFO_hIST;
292 - info_ptr->hist = histogram;
293 + png_set_hIST(png_ptr, info_ptr, histogram);
295 pm_message("histogram created");
297 } else { /* color_type != PNG_COLOR_TYPE_PALETTE */
298 - if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
299 - info_ptr->color_type == PNG_COLOR_TYPE_RGB) {
300 + png_byte color_type = png_get_color_type(png_ptr, info_ptr);
301 + if (color_type == PNG_COLOR_TYPE_GRAY ||
302 + color_type == PNG_COLOR_TYPE_RGB) {
303 if (transparent > 0) {
304 - info_ptr->valid |= PNG_INFO_tRNS;
305 - info_ptr->trans_values =
306 - xelToPngColor_16(transcolor, maxval, png_maxval);
307 + png_color_16 c = xelToPngColor_16(transcolor, maxval, png_maxval);
308 + png_set_tRNS(png_ptr, info_ptr, NULL, 0, &c);
311 /* This is PNG_COLOR_MASK_ALPHA. Transparency will be handled
312 @@ -2676,60 +2668,58 @@
316 - if (info_ptr->valid && PNG_INFO_tRNS)
317 + png_color_16p trans_colorp = NULL;
318 + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
319 + png_get_tRNS(png_ptr, info_ptr, NULL, NULL, &trans_colorp);
321 + if(trans_colorp != NULL)
322 pm_message("Transparent color {gray, red, green, blue} = "
324 - info_ptr->trans_values.gray,
325 - info_ptr->trans_values.red,
326 - info_ptr->trans_values.green,
327 - info_ptr->trans_values.blue);
329 + trans_colorp->gray,
331 + trans_colorp->green,
332 + trans_colorp->blue);
334 pm_message("No transparent color");
339 if (cmdline.background) {
340 - info_ptr->valid |= PNG_INFO_bKGD;
341 - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
342 - info_ptr->background.index = background_index;
344 + if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {
345 + bkgd.index = background_index;
347 - info_ptr->background =
348 - xelToPngColor_16(backcolor, maxval, png_maxval);
349 + bkgd = xelToPngColor_16(backcolor, maxval, png_maxval);
351 pm_message("Writing bKGD chunk with background color "
352 " {gray, red, green, blue} = {%d, %d, %d, %d}",
353 - info_ptr->background.gray,
354 - info_ptr->background.red,
355 - info_ptr->background.green,
356 - info_ptr->background.blue );
362 + png_set_bKGD(png_ptr, info_ptr, &bkgd);
365 - doSbitChunk(info_ptr, png_maxval, maxval, alpha, alpha_maxval);
366 + doSbitChunk(png_ptr, info_ptr, png_maxval, maxval, alpha, alpha_maxval);
368 /* tEXT and zTXT chunks */
369 if (cmdline.text || cmdline.ztxt)
370 - pnmpng_read_text(info_ptr, tfp, !!cmdline.ztxt, cmdline.verbose);
371 + pnmpng_read_text(png_ptr, info_ptr, tfp, !!cmdline.ztxt, cmdline.verbose);
373 - doTimeChunk(cmdline, info_ptr);
374 + doTimeChunk(cmdline, png_ptr, info_ptr);
376 if (cmdline.filterSet != 0)
377 png_set_filter(png_ptr, 0, cmdline.filterSet);
379 setZlibCompression(png_ptr, cmdline.zlibCompression);
381 + png_init_io (png_ptr, stdout);
383 /* write the png-info struct */
384 png_write_info(png_ptr, info_ptr);
386 - if (cmdline.text || cmdline.ztxt)
387 - /* prevent from being written twice with png_write_end */
388 - info_ptr->num_text = 0;
390 - if (cmdline.modtime)
391 - /* prevent from being written twice with png_write_end */
392 - info_ptr->valid &= ~PNG_INFO_tIME;
394 /* let libpng take care of, e.g., bit-depth conversions */
395 png_set_packing (png_ptr);
397 --- netpbm-10.35.83/converter/other/pngtopnm.c.orig 2011-11-25 01:15:46.000000000 +0100
398 +++ netpbm-10.35.83/converter/other/pngtopnm.c 2012-01-29 13:39:20.230540563 +0100
403 -#if PNG_LIBPNG_VER >= 10400
404 -#error Your PNG library (<png.h>) is incompatible with this Netpbm source code.
405 -#error You need either an older PNG library (older than 1.4)
406 -#error newer Netpbm source code (at least 10.48)
409 typedef struct _jmpbuf_wrapper {
415 -#define get_png_val(p) _get_png_val (&(p), info_ptr->bit_depth)
416 +#define get_png_val(p) _get_png_val (&(p), bit_depth)
419 _get_png_val (png_byte ** const pp,
420 @@ -266,33 +261,37 @@
424 -static void save_text (png_info *info_ptr, FILE *tfp)
425 +static void save_text (png_struct *png_ptr, png_info *info_ptr, FILE *tfp)
427 -static void save_text (info_ptr, tfp)
428 +static void save_text (png_ptr, info_ptr, tfp)
429 +png_struct *png_ptr;
437 + png_get_text(png_ptr, info_ptr, &text, &num_text);
439 - for (i = 0 ; i < info_ptr->num_text ; i++) {
440 + for (i = 0 ; i < num_text ; i++) {
442 - while (info_ptr->text[i].key[j] != '\0' && info_ptr->text[i].key[j] != ' ')
443 + while (text[i].key[j] != '\0' && text[i].key[j] != ' ')
445 - if (info_ptr->text[i].key[j] != ' ') {
446 - fprintf (tfp, "%s", info_ptr->text[i].key);
447 - for (j = strlen (info_ptr->text[i].key) ; j < 15 ; j++)
448 + if (text[i].key[j] != ' ') {
449 + fprintf (tfp, "%s", text[i].key);
450 + for (j = strlen (text[i].key) ; j < 15 ; j++)
453 - fprintf (tfp, "\"%s\"", info_ptr->text[i].key);
454 - for (j = strlen (info_ptr->text[i].key) ; j < 13 ; j++)
455 + fprintf (tfp, "\"%s\"", text[i].key);
456 + for (j = strlen (text[i].key) ; j < 13 ; j++)
459 putc (' ', tfp); /* at least one space between key and text */
461 - for (j = 0 ; j < info_ptr->text[i].text_length ; j++) {
462 - putc (info_ptr->text[i].text[j], tfp);
463 - if (info_ptr->text[i].text[j] == '\n')
464 + for (j = 0 ; j < text[i].text_length ; j++) {
465 + putc (text[i].text[j], tfp);
466 + if (text[i].text[j] == '\n')
467 for (k = 0 ; k < 16 ; k++)
468 putc ((int)' ', tfp);
474 -static void show_time (png_info *info_ptr)
475 +static void show_time (png_struct *png_ptr, png_info *info_ptr)
477 -static void show_time (info_ptr)
478 +static void show_time (ptr_ptr, info_ptr)
479 +png_struct *png_ptr;
483 @@ -312,18 +312,20 @@
484 "July", "August", "September", "October", "November", "December"
487 - if (info_ptr->valid & PNG_INFO_tIME) {
488 - if (info_ptr->mod_time.month < 1 ||
489 - info_ptr->mod_time.month >= ARRAY_SIZE(month)) {
490 + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tIME)) {
491 + png_timep mod_timep;
492 + png_get_tIME(png_ptr, info_ptr, &mod_timep);
493 + if (mod_timep->month < 1 ||
494 + mod_timep->month >= ARRAY_SIZE(month)) {
495 pm_message("tIME chunk in PNG input is invalid; "
496 "modification time of image is unknown. "
497 "The month value, which should be in the range "
498 - "1-12, is %u", info_ptr->mod_time.month);
499 + "1-12, is %u", mod_timep->month);
501 pm_message ("modification time: %02d %s %d %02d:%02d:%02d",
502 - info_ptr->mod_time.day, month[info_ptr->mod_time.month],
503 - info_ptr->mod_time.year, info_ptr->mod_time.hour,
504 - info_ptr->mod_time.minute, info_ptr->mod_time.second);
505 + mod_timep->day, month[mod_timep->month],
506 + mod_timep->year, mod_timep->hour,
507 + mod_timep->minute, mod_timep->second);
511 @@ -360,12 +362,12 @@
515 -dump_png_info(png_info *info_ptr) {
516 +dump_png_info(png_struct *png_ptr, png_info *info_ptr) {
518 const char *type_string;
519 const char *filter_string;
521 - switch (info_ptr->color_type) {
522 + switch (png_get_color_type(png_ptr, info_ptr)) {
523 case PNG_COLOR_TYPE_GRAY:
524 type_string = "gray";
526 @@ -387,90 +389,106 @@
530 - switch (info_ptr->filter_type) {
531 + switch (png_get_filter_type(png_ptr, info_ptr)) {
532 case PNG_FILTER_TYPE_BASE:
533 asprintfN(&filter_string, "base filter");
536 asprintfN(&filter_string, "unknown filter type %d",
537 - info_ptr->filter_type);
538 + png_get_filter_type(png_ptr, info_ptr));
542 + png_uint_32 width, height;
543 + int bit_depth, color_type;
544 + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, NULL, NULL, NULL);
545 pm_message("reading a %ldw x %ldh image, %d bit%s",
546 - info_ptr->width, info_ptr->height,
547 - info_ptr->bit_depth, info_ptr->bit_depth > 1 ? "s" : "");
549 + bit_depth, bit_depth > 1 ? "s" : "");
551 pm_message("%s, %s, %s",
553 - info_ptr->interlace_type ?
554 + png_get_interlace_type(png_ptr, info_ptr) ?
555 "Adam7 interlaced" : "not interlaced",
558 + png_color_16p bkgp;
559 + if(png_get_bKGD(png_ptr, info_ptr, &bkgp) && (bkgp != NULL))
560 pm_message("background {index, gray, red, green, blue} = "
561 "{%d, %d, %d, %d, %d}",
562 - info_ptr->background.index,
563 - info_ptr->background.gray,
564 - info_ptr->background.red,
565 - info_ptr->background.green,
566 - info_ptr->background.blue);
574 strfree(filter_string);
576 - if (info_ptr->valid & PNG_INFO_tRNS)
577 + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
579 + png_get_tRNS(png_ptr, info_ptr, NULL, &num_trans, NULL);
580 pm_message("tRNS chunk (transparency): %u entries",
581 - info_ptr->num_trans);
585 pm_message("tRNS chunk (transparency): not present");
587 - if (info_ptr->valid & PNG_INFO_gAMA)
588 - pm_message("gAMA chunk (image gamma): gamma = %4.2f", info_ptr->gamma);
590 + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_gAMA)) {
592 + png_get_gAMA(png_ptr, info_ptr, &gamma);
593 + pm_message("gAMA chunk (image gamma): gamma = %4.2f", gamma);
595 pm_message("gAMA chunk (image gamma): not present");
597 - if (info_ptr->valid & PNG_INFO_sBIT)
598 + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT))
599 pm_message("sBIT chunk: present");
601 pm_message("sBIT chunk: not present");
603 - if (info_ptr->valid & PNG_INFO_cHRM)
604 + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_cHRM))
605 pm_message("cHRM chunk: present");
607 pm_message("cHRM chunk: not present");
609 - if (info_ptr->valid & PNG_INFO_PLTE)
610 - pm_message("PLTE chunk: %d entries", info_ptr->num_palette);
612 + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_PLTE)) {
613 + png_colorp palette;
615 + png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
616 + pm_message("PLTE chunk: %d entries", num_palette);
618 pm_message("PLTE chunk: not present");
620 - if (info_ptr->valid & PNG_INFO_bKGD)
621 + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD))
622 pm_message("bKGD chunk: present");
624 pm_message("bKGD chunk: not present");
626 - if (info_ptr->valid & PNG_INFO_hIST)
627 + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_hIST))
628 pm_message("hIST chunk: present");
630 pm_message("hIST chunk: not present");
632 - if (info_ptr->valid & PNG_INFO_pHYs)
633 + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_pHYs))
634 pm_message("pHYs chunk: present");
636 pm_message("pHYs chunk: not present");
638 - if (info_ptr->valid & PNG_INFO_oFFs)
639 + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_oFFs))
640 pm_message("oFFs chunk: present");
642 pm_message("oFFs chunk: not present");
644 - if (info_ptr->valid & PNG_INFO_tIME)
645 + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tIME))
646 pm_message("tIME chunk: present");
648 pm_message("tIME chunk: not present");
650 - if (info_ptr->valid & PNG_INFO_pCAL)
651 + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_pCAL))
652 pm_message("pCAL chunk: present");
654 pm_message("pCAL chunk: not present");
656 - if (info_ptr->valid & PNG_INFO_sRGB)
657 + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sRGB))
658 pm_message("sRGB chunk: present");
660 pm_message("sRGB chunk: not present");
664 isTransparentColor(pngcolor const color,
665 + png_struct * const png_ptr,
666 png_info * const info_ptr,
667 double const totalgamma) {
668 /*----------------------------------------------------------------------------
670 -----------------------------------------------------------------------------*/
673 - if (info_ptr->valid & PNG_INFO_tRNS) {
674 - const png_color_16 * const transColorP = &info_ptr->trans_values;
676 + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
677 + png_color_16p transColorP;
678 + png_get_tRNS(png_ptr, info_ptr, NULL, NULL, &transColorP);
680 /* There seems to be a problem here: you can't compare real
681 numbers for equality. Also, I'm not sure the gamma
686 - if (info_ptr->valid & PNG_INFO_gAMA)
687 - imageGamma = info_ptr->gamma;
689 + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_gAMA)) {
691 + png_get_gAMA(png_ptr, info_ptr, &gamma);
692 + imageGamma = gamma;
695 pm_message("PNG doesn't specify image gamma. Assuming 1.0");
698 /* in case of gamma-corrections, sBIT's as in the
699 PNG-file are not valid anymore
701 - info_ptr->valid &= ~PNG_INFO_sBIT;
702 + png_set_invalid(png_ptr, info_ptr, PNG_INFO_sBIT);
704 pm_message("image gamma is %4.2f, "
705 "converted for display gamma of %4.2f",
706 @@ -570,20 +591,23 @@
710 -paletteHasPartialTransparency(png_info * const info_ptr) {
711 +paletteHasPartialTransparency(png_struct * const png_ptr, png_info * const info_ptr) {
715 - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
716 - if (info_ptr->valid & PNG_INFO_tRNS) {
717 + if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {
718 + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
722 + png_bytep trans_alpha;
723 + png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans, NULL);
725 for (i = 0, foundGray = FALSE;
726 - i < info_ptr->num_trans && !foundGray;
727 + i < num_trans && !foundGray;
729 - if (info_ptr->trans[i] != 0 &&
730 - info_ptr->trans[i] != maxval) {
731 + if (trans_alpha[i] != 0 &&
732 + trans_alpha[i] != maxval) {
736 @@ -612,13 +636,14 @@
737 Return the result as *maxvalP.
738 -----------------------------------------------------------------------------*/
739 /* Initial assumption of maxval */
740 - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
741 + png_byte color_type = png_get_color_type(png_ptr, info_ptr);
742 + if (color_type == PNG_COLOR_TYPE_PALETTE) {
743 if (alpha == ALPHA_ONLY) {
744 - if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
745 - info_ptr->color_type == PNG_COLOR_TYPE_RGB)
746 + if (color_type == PNG_COLOR_TYPE_GRAY ||
747 + color_type == PNG_COLOR_TYPE_RGB)
748 /* The alpha mask will be all opaque, so maxval 1 is plenty */
750 - else if (paletteHasPartialTransparency(info_ptr))
751 + else if (paletteHasPartialTransparency(png_ptr, info_ptr))
752 /* Use same maxval as PNG transparency palette for simplicity*/
756 /* Use same maxval as PNG palette for simplicity */
759 - *maxvalP = (1l << info_ptr->bit_depth) - 1;
760 + *maxvalP = (1l << png_get_bit_depth(png_ptr, info_ptr)) - 1;
763 /* sBIT handling is very tricky. If we are extracting only the
764 @@ -641,20 +666,25 @@
768 - if (info_ptr->valid & PNG_INFO_sBIT) {
769 + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) {
770 + png_color_8p sig_bit;
771 + png_get_sBIT(png_ptr, info_ptr, &sig_bit);
774 - if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
775 - info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
776 + if (color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
777 + color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
779 - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
780 - (info_ptr->valid & PNG_INFO_tRNS)) {
781 + if (color_type == PNG_COLOR_TYPE_PALETTE &&
782 + png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
784 + png_bytep trans_alpha;
789 - for (i = 0; i < info_ptr->num_trans; ++i)
790 - if (info_ptr->trans[i] != 0 && info_ptr->trans[i] != 255) {
791 + png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans, NULL);
792 + for (i = 0; i < num_trans; ++i)
793 + if (trans_alpha[i] != 0 && trans_alpha[i] != 255) {
797 @@ -665,70 +695,73 @@
798 /* else fall though to normal case */
801 - if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE ||
802 - info_ptr->color_type == PNG_COLOR_TYPE_RGB ||
803 - info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) &&
804 - (info_ptr->sig_bit.red != info_ptr->sig_bit.green ||
805 - info_ptr->sig_bit.red != info_ptr->sig_bit.blue) &&
806 + if ((color_type == PNG_COLOR_TYPE_PALETTE ||
807 + color_type == PNG_COLOR_TYPE_RGB ||
808 + color_type == PNG_COLOR_TYPE_RGB_ALPHA) &&
809 + (sig_bit->red != sig_bit->green ||
810 + sig_bit->red != sig_bit->blue) &&
811 alpha == ALPHA_NONE) {
812 pm_message("This program cannot handle "
813 "different bit depths for color channels");
814 pm_message("writing file with %d bit resolution",
815 - info_ptr->bit_depth);
816 + png_get_bit_depth(png_ptr, info_ptr));
817 *errorlevelP = PNMTOPNG_WARNING_LEVEL;
819 - if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) &&
820 - (info_ptr->sig_bit.red < 255)) {
821 + if ((color_type == PNG_COLOR_TYPE_PALETTE) &&
822 + sig_bit->red < 255) {
824 - for (i = 0; i < info_ptr->num_palette; ++i) {
825 - info_ptr->palette[i].red >>=
826 - (8 - info_ptr->sig_bit.red);
827 - info_ptr->palette[i].green >>=
828 - (8 - info_ptr->sig_bit.green);
829 - info_ptr->palette[i].blue >>=
830 - (8 - info_ptr->sig_bit.blue);
831 + png_colorp palette;
833 + png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
834 + for (i = 0; i < num_palette; ++i) {
836 + (8 - sig_bit->red);
837 + palette[i].green >>=
838 + (8 - sig_bit->green);
839 + palette[i].blue >>=
840 + (8 - sig_bit->blue);
842 - *maxvalP = (1l << info_ptr->sig_bit.red) - 1;
843 + *maxvalP = (1l << sig_bit->red) - 1;
845 pm_message ("image has fewer significant bits, "
846 "writing file with %d bits per channel",
847 - info_ptr->sig_bit.red);
850 - if ((info_ptr->color_type == PNG_COLOR_TYPE_RGB ||
851 - info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) &&
852 - (info_ptr->sig_bit.red < info_ptr->bit_depth)) {
853 - png_set_shift (png_ptr, &(info_ptr->sig_bit));
854 - *maxvalP = (1l << info_ptr->sig_bit.red) - 1;
855 + if ((color_type == PNG_COLOR_TYPE_RGB ||
856 + color_type == PNG_COLOR_TYPE_RGB_ALPHA) &&
857 + (sig_bit->red < png_get_bit_depth(png_ptr, info_ptr))) {
858 + png_set_shift (png_ptr, sig_bit);
859 + *maxvalP = (1l << sig_bit->red) - 1;
861 pm_message("image has fewer significant bits, "
862 "writing file with %d "
864 - info_ptr->sig_bit.red);
867 - if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
868 - info_ptr->color_type ==
869 + if ((color_type == PNG_COLOR_TYPE_GRAY ||
871 PNG_COLOR_TYPE_GRAY_ALPHA) &&
872 - (info_ptr->sig_bit.gray < info_ptr->bit_depth)) {
873 - png_set_shift (png_ptr, &(info_ptr->sig_bit));
874 - *maxvalP = (1l << info_ptr->sig_bit.gray) - 1;
875 + (sig_bit->gray < png_get_bit_depth(png_ptr, info_ptr))) {
876 + png_set_shift (png_ptr, sig_bit);
877 + *maxvalP = (1l << sig_bit->gray) - 1;
879 pm_message("image has fewer significant bits, "
880 "writing file with %d bits",
881 - info_ptr->sig_bit.gray);
888 - if ((info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
889 - info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) &&
890 - (info_ptr->sig_bit.gray < info_ptr->bit_depth)) {
891 - png_set_shift (png_ptr, &(info_ptr->sig_bit));
892 + if ((color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
893 + color_type == PNG_COLOR_TYPE_GRAY_ALPHA) &&
894 + (sig_bit->gray < png_get_bit_depth(png_ptr, info_ptr))) {
895 + png_set_shift (png_ptr, sig_bit);
897 pm_message ("image has fewer significant bits, "
898 "writing file with %d bits",
899 - info_ptr->sig_bit.alpha);
900 - *maxvalP = (1l << info_ptr->sig_bit.alpha) - 1;
902 + *maxvalP = (1l << sig_bit->alpha) - 1;
906 @@ -739,22 +772,26 @@
910 -imageHasColor(png_info * const info_ptr) {
911 +imageHasColor(png_struct * const png_ptr, png_info * const info_ptr) {
914 + png_byte color_type = png_get_color_type(png_ptr, info_ptr);
916 - if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
917 - info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
918 + if (color_type == PNG_COLOR_TYPE_GRAY ||
919 + color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
922 - else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
923 + else if (color_type == PNG_COLOR_TYPE_PALETTE) {
927 + png_colorp palette;
930 + png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
931 for (i = 0, foundColor = FALSE;
932 - i < info_ptr->num_palette && !foundColor;
933 + i < num_palette && !foundColor;
935 - if (iscolor(info_ptr->palette[i]))
936 + if (iscolor(palette[i]))
940 @@ -767,14 +804,15 @@
944 -determineOutputType(png_info * const info_ptr,
945 +determineOutputType(png_struct * const png_ptr,
946 + png_info * const info_ptr,
947 enum alpha_handling const alphaHandling,
948 pngcolor const bgColor,
950 int * const pnmTypeP) {
952 if (alphaHandling != ALPHA_ONLY &&
953 - (imageHasColor(info_ptr) || !isGrayscale(bgColor)))
954 + (imageHasColor(png_ptr, info_ptr) || !isGrayscale(bgColor)))
955 *pnmTypeP = PPM_TYPE;
962 -getBackgroundColor(png_info * const info_ptr,
963 +getBackgroundColor(png_struct * const png_ptr,
964 + png_info * const info_ptr,
965 const char * const requestedColor,
966 float const totalgamma,
968 @@ -809,19 +848,24 @@
969 bgColorP->g = PPM_GETG(backcolor);
970 bgColorP->b = PPM_GETB(backcolor);
972 - } else if (info_ptr->valid & PNG_INFO_bKGD) {
973 + } else if (png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD)) {
974 + png_color_16p background;
975 + png_colorp palette;
977 + png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
978 + png_get_bKGD(png_ptr, info_ptr, &background);
979 /* didn't manage to get libpng to work (bugs?) concerning background
980 processing, therefore we do our own.
982 - switch (info_ptr->color_type) {
983 + switch (png_get_color_type(png_ptr, info_ptr)) {
984 case PNG_COLOR_TYPE_GRAY:
985 case PNG_COLOR_TYPE_GRAY_ALPHA:
986 bgColorP->r = bgColorP->g = bgColorP->b =
987 - gamma_correct(info_ptr->background.gray, totalgamma);
988 + gamma_correct(background->gray, totalgamma);
990 case PNG_COLOR_TYPE_PALETTE: {
991 png_color const rawBgcolor =
992 - info_ptr->palette[info_ptr->background.index];
993 + palette[background->index];
994 bgColorP->r = gamma_correct(rawBgcolor.red, totalgamma);
995 bgColorP->g = gamma_correct(rawBgcolor.green, totalgamma);
996 bgColorP->b = gamma_correct(rawBgcolor.blue, totalgamma);
999 case PNG_COLOR_TYPE_RGB:
1000 case PNG_COLOR_TYPE_RGB_ALPHA: {
1001 - png_color_16 const rawBgcolor = info_ptr->background;
1002 + png_color_16 const rawBgcolor = *background;
1004 bgColorP->r = gamma_correct(rawBgcolor.red, totalgamma);
1005 bgColorP->g = gamma_correct(rawBgcolor.green, totalgamma);
1006 @@ -842,12 +886,32 @@
1007 bgColorP->r = bgColorP->g = bgColorP->b = maxval;
1010 +static png_color_16p get_png_trans_colorp(png_struct *png_ptr, png_info *info_ptr)
1012 + png_color_16p trans_color;
1013 + png_get_tRNS(png_ptr, info_ptr, NULL, NULL, &trans_color);
1014 + return trans_color;
1017 +static int get_png_num_trans(png_struct *png_ptr, png_info *info_ptr)
1020 + png_get_tRNS(png_ptr, info_ptr, NULL, &num_trans, NULL);
1024 +static png_bytep get_png_trans_alpha(png_struct *png_ptr, png_info *info_ptr)
1026 + png_bytep trans_alpha;
1027 + png_get_tRNS(png_ptr, info_ptr, &trans_alpha, NULL, NULL);
1028 + return trans_alpha;
1032 writePnm(FILE * const ofP,
1033 xelval const maxval,
1035 + png_struct * const png_ptr,
1036 png_info * const info_ptr,
1037 png_byte ** const png_image,
1038 pngcolor const bgColor,
1039 @@ -865,6 +929,10 @@
1040 -----------------------------------------------------------------------------*/
1043 + png_uint_32 width, height;
1044 + int bit_depth, color_type;
1045 + png_colorp palette;
1049 pm_message ("writing a %s file (maxval=%u)",
1050 @@ -874,25 +942,28 @@
1054 - xelrow = pnm_allocrow(info_ptr->width);
1055 + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, NULL, NULL, NULL);
1056 + png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
1058 - pnm_writepnminit(stdout, info_ptr->width, info_ptr->height, maxval,
1059 + xelrow = pnm_allocrow(width);
1061 + pnm_writepnminit(stdout, width, height, maxval,
1064 - for (row = 0; row < info_ptr->height; ++row) {
1065 + for (row = 0; row < height; ++row) {
1066 png_byte * png_pixelP;
1069 png_pixelP = &png_image[row][0]; /* initial value */
1070 - for (col = 0; col < info_ptr->width; ++col) {
1071 - switch (info_ptr->color_type) {
1072 + for (col = 0; col < width; ++col) {
1073 + switch (color_type) {
1074 case PNG_COLOR_TYPE_GRAY: {
1076 fgColor.r = fgColor.g = fgColor.b = get_png_val(png_pixelP);
1077 setXel(&xelrow[col], fgColor, bgColor, alpha_handling,
1078 - ((info_ptr->valid & PNG_INFO_tRNS) &&
1079 + ((png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) &&
1081 - gamma_correct(info_ptr->trans_values.gray,
1082 + gamma_correct(get_png_trans_colorp(png_ptr, info_ptr)->gray,
1088 case PNG_COLOR_TYPE_PALETTE: {
1089 png_uint_16 const index = get_png_val(png_pixelP);
1090 - png_color const paletteColor = info_ptr->palette[index];
1091 + png_color const paletteColor = palette[index];
1096 fgColor.b = paletteColor.blue;
1098 setXel(&xelrow[col], fgColor, bgColor, alpha_handling,
1099 - (info_ptr->valid & PNG_INFO_tRNS) &&
1100 - index < info_ptr->num_trans ?
1101 - info_ptr->trans[index] : maxval);
1102 + (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) &&
1103 + index < get_png_num_trans(png_ptr, info_ptr) ?
1104 + get_png_trans_alpha(png_ptr, info_ptr)[index] : maxval);
1108 @@ -932,7 +1003,7 @@
1109 fgColor.g = get_png_val(png_pixelP);
1110 fgColor.b = get_png_val(png_pixelP);
1111 setXel(&xelrow[col], fgColor, bgColor, alpha_handling,
1112 - isTransparentColor(fgColor, info_ptr, totalgamma) ?
1113 + isTransparentColor(fgColor, png_ptr, info_ptr, totalgamma) ?
1117 @@ -950,10 +1021,10 @@
1121 - pm_error ("unknown PNG color type: %d", info_ptr->color_type);
1122 + pm_error ("unknown PNG color type: %d", color_type);
1125 - pnm_writepnmrow(ofP, xelrow, info_ptr->width, maxval, pnm_type, FALSE);
1126 + pnm_writepnmrow(ofP, xelrow, width, maxval, pnm_type, FALSE);
1128 pnm_freerow (xelrow);
1130 @@ -974,6 +1045,8 @@
1134 + png_uint_32 width, height;
1135 + int bit_depth, color_type;
1139 @@ -995,29 +1068,30 @@
1140 png_init_io (png_ptr, ifp);
1141 png_set_sig_bytes (png_ptr, SIG_CHECK_SIZE);
1142 png_read_info (png_ptr, info_ptr);
1143 + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, NULL, NULL, NULL);
1145 - MALLOCARRAY(png_image, info_ptr->height);
1146 + MALLOCARRAY(png_image, height);
1147 if (png_image == NULL) {
1148 png_destroy_read_struct (&png_ptr, &info_ptr, (png_infopp)NULL);
1150 pm_error ("couldn't allocate space for image");
1153 - if (info_ptr->bit_depth == 16)
1154 - linesize = 2 * info_ptr->width;
1155 + if (bit_depth == 16)
1156 + linesize = 2 * width;
1158 - linesize = info_ptr->width;
1161 - if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
1162 + if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
1165 - if (info_ptr->color_type == PNG_COLOR_TYPE_RGB)
1166 + if (color_type == PNG_COLOR_TYPE_RGB)
1169 - if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
1170 + if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
1173 - for (y = 0 ; y < info_ptr->height ; y++) {
1174 + for (y = 0 ; y < height ; y++) {
1175 png_image[y] = malloc (linesize);
1176 if (png_image[y] == NULL) {
1177 for (x = 0 ; x < y ; x++)
1178 @@ -1029,7 +1103,7 @@
1182 - if (info_ptr->bit_depth < 8)
1183 + if (bit_depth < 8)
1184 png_set_packing (png_ptr);
1186 setupGammaCorrection(png_ptr, info_ptr, cmdline.gamma, &totalgamma);
1187 @@ -1037,7 +1111,7 @@
1188 setupSignificantBits(png_ptr, info_ptr, cmdline.alpha,
1189 &maxval, errorlevelP);
1191 - getBackgroundColor(info_ptr, cmdline.background, totalgamma, maxval,
1192 + getBackgroundColor(png_ptr, info_ptr, cmdline.background, totalgamma, maxval,
1195 png_read_image (png_ptr, png_image);
1196 @@ -1048,16 +1122,18 @@
1197 completes. That's because it comes from chunks that are at the
1200 - dump_png_info(info_ptr);
1201 + dump_png_info(png_ptr, info_ptr);
1204 - show_time (info_ptr);
1205 + show_time (png_ptr, info_ptr);
1207 - save_text (info_ptr, tfp);
1208 + save_text (png_ptr, info_ptr, tfp);
1210 - if (info_ptr->valid & PNG_INFO_pHYs) {
1211 + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_pHYs)) {
1213 - r = (float)info_ptr->x_pixels_per_unit / info_ptr->y_pixels_per_unit;
1214 + png_uint_32 res_x, res_y;
1215 + png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, NULL);
1216 + r = (float)res_x / res_y;
1218 pm_message ("warning - non-square pixels; "
1219 "to fix do a 'pamscale -%cscale %g'",
1220 @@ -1067,13 +1143,13 @@
1224 - determineOutputType(info_ptr, cmdline.alpha, bgColor, maxval, &pnm_type);
1225 + determineOutputType(png_ptr, info_ptr, cmdline.alpha, bgColor, maxval, &pnm_type);
1227 - writePnm(stdout, maxval, pnm_type, info_ptr, png_image, bgColor,
1228 + writePnm(stdout, maxval, pnm_type, png_ptr, info_ptr, png_image, bgColor,
1229 cmdline.alpha, totalgamma);
1232 - for (y = 0 ; y < info_ptr->height ; y++)
1233 + for (y = 0 ; y < height ; y++)
1234 free (png_image[y]);
1236 png_destroy_read_struct (&png_ptr, &info_ptr, (png_infopp)NULL);
1237 --- netpbm-10.35.83/converter/other/pngtxt.c.orig 2006-08-19 05:12:28.000000000 +0200
1238 +++ netpbm-10.35.83/converter/other/pngtxt.c 2012-01-29 09:59:22.463431985 +0100
1243 -pnmpng_read_text (png_info * const info_ptr,
1244 +pnmpng_read_text (png_struct * const png_ptr,
1245 + png_info * const info_ptr,
1248 bool const verbose) {
1249 @@ -250,15 +251,16 @@
1250 unsigned int commentIdx;
1254 unsigned int allocatedComments;
1255 - /* Number of entries currently allocated for the info_ptr->text
1256 + /* Number of entries currently allocated for the text
1260 allocatedComments = 256; /* initial value */
1262 - MALLOCARRAY(info_ptr->text, allocatedComments);
1263 - if (info_ptr->text == NULL)
1264 + MALLOCARRAY(text, allocatedComments);
1266 pm_error("unable to allocate memory for comment array");
1270 if (lineLength == 0) {
1271 /* skip this empty line */
1273 - handleArrayAllocation(&info_ptr->text, &allocatedComments,
1274 + handleArrayAllocation(&text, &allocatedComments,
1276 if ((textline[0] != ' ') && (textline[0] != '\t')) {
1277 /* Line doesn't start with white space, which
1280 noCommentsYet = FALSE;
1282 - startComment(&info_ptr->text[commentIdx],
1283 + startComment(&text[commentIdx],
1284 textline, lineLength, ztxt);
1286 /* Line starts with whitespace, which means it is
1287 @@ -295,20 +297,20 @@
1288 pm_error("Invalid comment file format: "
1289 "first line is a continuation line! "
1290 "(It starts with whitespace)");
1291 - continueComment(&info_ptr->text[commentIdx],
1292 + continueComment(&text[commentIdx],
1293 textline, lineLength);
1299 - if (noCommentsYet)
1300 - info_ptr->num_text = 0;
1302 - info_ptr->num_text = commentIdx + 1;
1303 + if (!noCommentsYet)
1304 + png_set_text(png_ptr, info_ptr, text, commentIdx + 1);
1307 - pm_message("%d comments placed in text chunk", info_ptr->num_text);
1308 + pm_message("%d comments placed in text chunk", commentIdx + 1);
1314 --- netpbm-10.35.83/converter/other/pngtxt.h.orig 2006-08-19 05:12:28.000000000 +0200
1315 +++ netpbm-10.35.83/converter/other/pngtxt.h 2012-01-29 09:59:59.566766561 +0100
1320 -pnmpng_read_text (png_info * const info_ptr,
1321 +pnmpng_read_text (png_struct * const png_ptr,
1322 + png_info * const info_ptr,
1325 bool const verbose);
1326 --- netpbm-10.35.83/converter/other/pamrgbatopng.c.orig 2006-08-19 05:12:28.000000000 +0200
1327 +++ netpbm-10.35.83/converter/other/pamrgbatopng.c 2012-01-29 14:02:47.790587693 +0100
1328 @@ -101,10 +101,9 @@
1330 pm_error("Could not allocate PNG info structure");
1332 - infoP->width = pamP->width;
1333 - infoP->height = pamP->height;
1334 - infoP->bit_depth = 8;
1335 - infoP->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
1336 + png_set_IHDR(pngP, infoP,
1337 + pamP->width, pamP->height,
1338 + 8, PNG_COLOR_TYPE_RGB_ALPHA, 0, 0, 0);
1340 png_init_io(pngP, ofP);
1342 --- netpbm-10.35.90/converter/other/tifftopnm.c~ 2006-08-19 05:12:28.000000000 +0200
1343 +++ netpbm-10.35.90/converter/other/tifftopnm.c 2013-10-31 17:58:49.296479893 +0100
1344 @@ -902,14 +902,14 @@
1346 ok = TIFFRGBAImageBegin(&img, tif, stopOnErrorFalse, emsg) ;
1349 + pm_message("%s", emsg);
1350 *statusP = CONV_FAILED;
1353 ok = TIFFRGBAImageGet(&img, raster, cols, rows);
1354 TIFFRGBAImageEnd(&img) ;
1357 + pm_message("%s", emsg);
1358 *statusP = CONV_FAILED;
1360 *statusP = CONV_DONE;
1361 --- netpbm-10.35.90/converter/other/tifftopnm.c~ 2013-10-31 17:59:04.000000000 +0100
1362 +++ netpbm-10.35.90/converter/other/tifftopnm.c 2013-10-31 18:00:05.761780998 +0100
1365 ok = TIFFRGBAImageOK(tif, emsg);
1368 + pm_message("%s", emsg);
1369 *statusP = CONV_UNABLE;
1372 --- netpbm-10.35.90/converter/other/fiasco/pnmtofiasco.c~ 2006-08-19 05:12:28.000000000 +0200
1373 +++ netpbm-10.35.90/converter/other/fiasco/pnmtofiasco.c 2013-10-31 18:02:13.731936837 +0100
1378 - fprintf (stderr, fiasco_get_error_message ());
1379 + fprintf (stderr, "%s", fiasco_get_error_message ());
1380 fprintf (stderr, "\n");
1383 --- netpbm-10.35.90/converter/other/fiasco/params.c~ 2006-08-19 05:12:28.000000000 +0200
1384 +++ netpbm-10.35.90/converter/other/fiasco/params.c 2013-10-31 18:05:00.869560937 +0100
1386 fprintf (stderr, "Usage: %s [OPTION]...%s\n", progname,
1387 non_opt_string ? non_opt_string : " ");
1388 if (synopsis != NULL)
1389 - fprintf (stderr, synopsis);
1390 + fprintf (stderr, "%s", synopsis);
1391 fprintf (stderr, "\n\n");
1392 fprintf (stderr, "Mandatory or optional arguments to long options "
1393 "are mandatory or optional\nfor short options too. "