| 1 | --- gtk-xmhtml/readPNG.c.orig 2002-08-06 14:25:46.000000000 -0700 |
| 2 | +++ gtk-xmhtml/readPNG.c 2014-06-19 08:34:04.000000000 -0700 |
| 3 | @@ -208,7 +208,7 @@ |
| 4 | |
| 5 | _XmHTMLWarning(__WFUNC__(NULL, "png_error"), |
| 6 | "libpng error on image %s: %s", ib->file, msg); |
| 7 | - longjmp(png_ptr->jmpbuf, 1); |
| 8 | + longjmp(png_jmpbuf(png_ptr), 1); |
| 9 | } |
| 10 | |
| 11 | /***** |
| 12 | @@ -256,11 +256,12 @@ |
| 13 | { |
| 14 | png_structp png_ptr; |
| 15 | png_infop info_ptr; |
| 16 | + png_colorp palette; |
| 17 | Byte *data; |
| 18 | int i, idx, npass; |
| 19 | int width, height, color_type; |
| 20 | int ncolors, max_colors; |
| 21 | - float gamma, fg_gamma; |
| 22 | + double gamma, fg_gamma; |
| 23 | Boolean has_alpha = False, has_cmap = False, do_gamma = True; |
| 24 | png_bytep *row_ptrs; |
| 25 | char msg[128]; |
| 26 | @@ -308,7 +309,7 @@ |
| 27 | return((XmHTMLRawImageData*)NULL); |
| 28 | } |
| 29 | /* now set error handler */ |
| 30 | - if(setjmp(png_ptr->jmpbuf)) |
| 31 | + if(setjmp(png_jmpbuf(png_ptr))) |
| 32 | { |
| 33 | /* |
| 34 | * PNG signalled an error. Destroy image data, free any allocated |
| 35 | @@ -342,17 +343,18 @@ |
| 36 | ResetRawImage(img_data); |
| 37 | |
| 38 | /* save width & height */ |
| 39 | - width = img_data->width = info_ptr->width; |
| 40 | - height = img_data->height = info_ptr->height; |
| 41 | + width = img_data->width = png_get_image_width(png_ptr, info_ptr); |
| 42 | + height = img_data->height = png_get_image_height(png_ptr, info_ptr); |
| 43 | |
| 44 | /* image depth */ |
| 45 | - ib->depth = info_ptr->bit_depth; |
| 46 | + ib->depth = png_get_bit_depth(png_ptr, info_ptr); |
| 47 | |
| 48 | /* no of colors */ |
| 49 | - ncolors = img_data->cmapsize = info_ptr->num_palette; |
| 50 | + png_get_PLTE(png_ptr, info_ptr, &palette, &ncolors); |
| 51 | + img_data->cmapsize = ncolors; |
| 52 | |
| 53 | /* type of image */ |
| 54 | - color_type = info_ptr->color_type; |
| 55 | + color_type = png_get_color_type(png_ptr, info_ptr); |
| 56 | |
| 57 | /* |
| 58 | * The fun stuff. This is based on readPNG by Greg Roelofs as found |
| 59 | @@ -383,7 +385,7 @@ |
| 60 | * Actual image creation is postponed until the image is |
| 61 | * needed. |
| 62 | */ |
| 63 | - if(info_ptr->valid & PNG_INFO_tRNS) |
| 64 | + if(png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) |
| 65 | { |
| 66 | _XmHTMLDebug(15, ("readPNG.c: tRNS chunk present\n")); |
| 67 | png_set_expand(png_ptr); |
| 68 | @@ -396,9 +398,9 @@ |
| 69 | AllocRawImageCmap(img_data, ncolors); |
| 70 | for(i = 0; i < ncolors; i++) |
| 71 | { |
| 72 | - img_data->cmap[i].red = info_ptr->palette[i].red; |
| 73 | - img_data->cmap[i].green = info_ptr->palette[i].green; |
| 74 | - img_data->cmap[i].blue = info_ptr->palette[i].blue; |
| 75 | + img_data->cmap[i].red = palette[i].red; |
| 76 | + img_data->cmap[i].green = palette[i].green; |
| 77 | + img_data->cmap[i].blue = palette[i].blue; |
| 78 | } |
| 79 | has_cmap = True; |
| 80 | data = (Byte*)malloc(width*height*sizeof(Byte)); |
| 81 | @@ -432,7 +434,7 @@ |
| 82 | * grayscale with transparency is expanded to RGB with alpha |
| 83 | * channel. |
| 84 | */ |
| 85 | - if(info_ptr->valid & PNG_INFO_tRNS) |
| 86 | + if(png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) |
| 87 | { |
| 88 | _XmHTMLDebug(15, ("readPNG.c: tRNS chunk present\n")); |
| 89 | png_set_gray_to_rgb(png_ptr); |
| 90 | @@ -511,7 +513,7 @@ |
| 91 | break; |
| 92 | default: |
| 93 | sprintf(msg, "bad PNG image: unknown color type (%d)", |
| 94 | - info_ptr->color_type); |
| 95 | + png_get_color_type(png_ptr, info_ptr)); |
| 96 | my_png_error(png_ptr, msg); |
| 97 | break; |
| 98 | } |
| 99 | @@ -521,16 +523,18 @@ |
| 100 | * Doing that for alpha channel images would change the colortype of the |
| 101 | * current image, leading to weird results. |
| 102 | */ |
| 103 | - if(!has_alpha && info_ptr->valid & PNG_INFO_bKGD) |
| 104 | + if(!has_alpha && png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD)) |
| 105 | { |
| 106 | - png_set_background(png_ptr, &(info_ptr->background), |
| 107 | + png_color_16p background; |
| 108 | + png_get_bKGD(png_ptr, info_ptr, &background); |
| 109 | + png_set_background(png_ptr, background, |
| 110 | PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); |
| 111 | - img_data->bg = info_ptr->background.index; |
| 112 | + img_data->bg = background->index; |
| 113 | } |
| 114 | |
| 115 | /* handle gamma correction */ |
| 116 | - if(info_ptr->valid & PNG_INFO_gAMA) |
| 117 | - fg_gamma = info_ptr->gamma; |
| 118 | + if(png_get_valid(png_ptr, info_ptr, PNG_INFO_gAMA)) |
| 119 | + png_get_gAMA(png_ptr, info_ptr, &fg_gamma); |
| 120 | else |
| 121 | fg_gamma = 0.45; |
| 122 | |
| 123 | @@ -541,20 +545,20 @@ |
| 124 | /* dithering gets handled by caller */ |
| 125 | |
| 126 | /* one byte per pixel */ |
| 127 | - if(info_ptr->bit_depth < 8) |
| 128 | + if(png_get_bit_depth(png_ptr, info_ptr) < 8) |
| 129 | png_set_packing(png_ptr); |
| 130 | |
| 131 | /* no tRNS chunk handling, we've expanded it to an alpha channel. */ |
| 132 | |
| 133 | /* handle interlacing */ |
| 134 | - if(info_ptr->interlace_type) |
| 135 | + if(png_get_interlace_type(png_ptr, info_ptr)) |
| 136 | npass = png_set_interlace_handling(png_ptr); |
| 137 | |
| 138 | /* and now update everything */ |
| 139 | png_read_update_info(png_ptr, info_ptr); |
| 140 | |
| 141 | /* has possibly changed if we have promoted GrayScale or tRNS chunks */ |
| 142 | - color_type = info_ptr->color_type; |
| 143 | + color_type = png_get_color_type(png_ptr, info_ptr); |
| 144 | |
| 145 | /* new color_type? */ |
| 146 | if(color_type == PNG_COLOR_TYPE_RGB_ALPHA) |
| 147 | @@ -574,10 +578,10 @@ |
| 148 | * will call doAlphaChannel to do the actual image creation. |
| 149 | */ |
| 150 | row_ptrs = (png_bytep*)malloc(height*sizeof(png_bytep)); |
| 151 | - png_data = (png_bytep)malloc(height*info_ptr->rowbytes); |
| 152 | + png_data = (png_bytep)malloc(height*png_get_rowbytes(png_ptr, info_ptr)); |
| 153 | |
| 154 | for(i = 0; i < height; i++) |
| 155 | - row_ptrs[i] = (png_bytep)png_data + i*info_ptr->rowbytes; |
| 156 | + row_ptrs[i] = (png_bytep)png_data + i*png_get_rowbytes(png_ptr, info_ptr); |
| 157 | |
| 158 | /* read it */ |
| 159 | png_read_image(png_ptr, row_ptrs); |
| 160 | @@ -606,7 +610,7 @@ |
| 161 | row_ptrs = (png_bytep*)malloc(height*sizeof(png_bytep)); |
| 162 | |
| 163 | for(i = 0; i < height; ++i) |
| 164 | - row_ptrs[i] = (png_bytep)data + i*info_ptr->rowbytes; |
| 165 | + row_ptrs[i] = (png_bytep)data + i*png_get_rowbytes(png_ptr, info_ptr); |
| 166 | |
| 167 | /* read it */ |
| 168 | png_read_image(png_ptr, row_ptrs); |