1 --- XmHTML-1.1.7/lib/common/readPNG.c.orig 1998-11-16 23:56:19.000000000 +0100
2 +++ XmHTML-1.1.7/lib/common/readPNG.c 2012-02-12 17:27:36.741501024 +0100
5 _XmHTMLWarning(__WFUNC__(NULL, "png_error"), XMHTML_MSG_121, "png",
7 - longjmp(png_ptr->jmpbuf, 1);
8 + longjmp(png_jmpbuf(png_ptr), 1);
14 int width, height, color_type;
15 int ncolors, max_colors;
16 - float gamma, fg_gamma;
19 Boolean has_alpha = False, has_cmap = False, do_gamma = True;
23 static XmHTMLRawImageData *img_data;
26 return((XmHTMLRawImageData*)NULL);
28 /* now set error handler */
29 - if(setjmp(png_ptr->jmpbuf))
30 + if(setjmp(png_jmpbuf(png_ptr)))
33 * PNG signalled an error. Destroy image data, free any allocated
35 ResetRawImage(img_data);
37 /* save width & height */
38 - width = img_data->width = info_ptr->width;
39 - height = img_data->height = info_ptr->height;
40 + width = img_data->width = png_get_image_width(png_ptr, info_ptr);
41 + height = img_data->height = png_get_image_height(png_ptr, info_ptr);
44 - ib->depth = info_ptr->bit_depth;
45 + ib->depth = png_get_bit_depth(png_ptr, info_ptr);
48 - ncolors = img_data->cmapsize = info_ptr->num_palette;
49 + png_get_PLTE(png_ptr, info_ptr, &palette, &ncolors);
50 + img_data->cmapsize = ncolors;
53 - color_type = info_ptr->color_type;
54 + color_type = png_get_color_type(png_ptr, info_ptr);
57 * The fun stuff. This is based on readPNG by Greg Roelofs as found
59 * Actual image creation is postponed until the image is
62 - if(info_ptr->valid & PNG_INFO_tRNS)
63 + if(png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
65 _XmHTMLDebug(15, ("readPNG.c: tRNS chunk present\n"));
66 png_set_expand(png_ptr);
68 AllocRawImageCmap(img_data, ncolors);
69 for(i = 0; i < ncolors; i++)
71 - GETR(img_data->cmap[i]) = info_ptr->palette[i].red;
72 - GETG(img_data->cmap[i]) = info_ptr->palette[i].green;
73 - GETB(img_data->cmap[i]) = info_ptr->palette[i].blue;
74 + GETR(img_data->cmap[i]) = palette[i].red;
75 + GETG(img_data->cmap[i]) = palette[i].green;
76 + GETB(img_data->cmap[i]) = palette[i].blue;
79 data = (Byte*)malloc(width*height*sizeof(Byte));
81 * grayscale with transparency is expanded to RGB with alpha
84 - if(info_ptr->valid & PNG_INFO_tRNS)
85 + if(png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
87 _XmHTMLDebug(15, ("readPNG.c: tRNS chunk present\n"));
88 png_set_gray_to_rgb(png_ptr);
92 sprintf(msg, "bad PNG image: unknown color type (%d)",
93 - info_ptr->color_type);
94 + png_get_color_type(png_ptr, info_ptr));
95 my_png_error(png_ptr, msg);
99 * Doing that for alpha channel images would change the colortype of the
100 * current image, leading to weird results.
102 - if(!has_alpha && info_ptr->valid & PNG_INFO_bKGD)
103 + if(!has_alpha && png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD))
105 - png_set_background(png_ptr, &(info_ptr->background),
106 + png_color_16p background;
107 + png_get_bKGD(png_ptr, info_ptr, &background);
108 + png_set_background(png_ptr, background,
109 PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
110 - img_data->bg = info_ptr->background.index;
111 + img_data->bg = background->index;
114 /* handle gamma correction */
115 - if(info_ptr->valid & PNG_INFO_gAMA)
116 - fg_gamma = info_ptr->gamma;
117 + if(png_get_valid(png_ptr, info_ptr, PNG_INFO_gAMA))
118 + png_get_gAMA(png_ptr, info_ptr, &fg_gamma);
121 @@ -464,20 +469,20 @@
122 /* dithering gets handled by caller */
124 /* one byte per pixel */
125 - if(info_ptr->bit_depth < 8)
126 + if(png_get_bit_depth(png_ptr, info_ptr) < 8)
127 png_set_packing(png_ptr);
129 /* no tRNS chunk handling, we've expanded it to an alpha channel. */
131 /* handle interlacing */
132 - if(info_ptr->interlace_type)
133 + if(png_get_interlace_type(png_ptr, info_ptr))
134 npass = png_set_interlace_handling(png_ptr);
136 /* and now update everything */
137 png_read_update_info(png_ptr, info_ptr);
139 /* has possibly changed if we have promoted GrayScale or tRNS chunks */
140 - color_type = info_ptr->color_type;
141 + color_type = png_get_color_type(png_ptr, info_ptr);
143 /* new color_type? */
144 if(color_type == PNG_COLOR_TYPE_RGB_ALPHA)
145 @@ -497,10 +502,10 @@
146 * will call doAlphaChannel to do the actual image creation.
148 row_ptrs = (png_bytep*)malloc(height*sizeof(png_bytep));
149 - png_data = (png_bytep)malloc(height*info_ptr->rowbytes);
150 + png_data = (png_bytep)malloc(height*png_get_rowbytes(png_ptr, info_ptr));
152 for(i = 0; i < height; i++)
153 - row_ptrs[i] = (png_bytep)png_data + i*info_ptr->rowbytes;
154 + row_ptrs[i] = (png_bytep)png_data + i*png_get_rowbytes(png_ptr, info_ptr);
157 png_read_image(png_ptr, row_ptrs);
159 row_ptrs = (png_bytep*)malloc(height*sizeof(png_bytep));
161 for(i = 0; i < height; ++i)
162 - row_ptrs[i] = (png_bytep)data + i*info_ptr->rowbytes;
163 + row_ptrs[i] = (png_bytep)data + i*png_get_rowbytes(png_ptr, info_ptr);
166 png_read_image(png_ptr, row_ptrs);