Lines 73-79
read_png(FILE *file, int filetype, F_pic
Link Here
|
73 |
} |
73 |
} |
74 |
|
74 |
|
75 |
/* set long jump recovery here */ |
75 |
/* set long jump recovery here */ |
76 |
if (setjmp(png_ptr->jmpbuf)) { |
76 |
if (setjmp(png_jmpbuf(png_ptr))) { |
77 |
/* if we get here there was a problem reading the file */ |
77 |
/* if we get here there was a problem reading the file */ |
78 |
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); |
78 |
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); |
79 |
close_picfile(file,filetype); |
79 |
close_picfile(file,filetype); |
Lines 90-104
read_png(FILE *file, int filetype, F_pic
Link Here
|
90 |
png_get_IHDR(png_ptr, info_ptr, &w, &h, &bit_depth, &color_type, |
90 |
png_get_IHDR(png_ptr, info_ptr, &w, &h, &bit_depth, &color_type, |
91 |
&interlace_type, &compression_type, &filter_type); |
91 |
&interlace_type, &compression_type, &filter_type); |
92 |
|
92 |
|
93 |
if (info_ptr->valid & PNG_INFO_gAMA) |
93 |
png_fixed_point gamma = 0.45; |
94 |
png_set_gamma(png_ptr, 2.2, info_ptr->gamma); |
94 |
png_get_gAMA_fixed(png_ptr,info_ptr,&gamma); |
95 |
else |
95 |
png_set_gamma(png_ptr, 2.2, gamma); |
96 |
png_set_gamma(png_ptr, 2.2, 0.45); |
|
|
97 |
|
96 |
|
98 |
if (info_ptr->valid & PNG_INFO_bKGD) |
97 |
if (png_get_valid(png_ptr,info_ptr,PNG_INFO_bKGD)) { |
99 |
/* set the background to the one supplied */ |
98 |
/* set the background to the one supplied */ |
100 |
png_set_background(png_ptr, &info_ptr->background, |
99 |
png_color_16p background; |
|
|
100 |
png_get_bKGD(png_ptr,info_ptr,&background); |
101 |
png_set_background(png_ptr, background, |
101 |
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); |
102 |
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); |
|
|
103 |
} |
102 |
else { |
104 |
else { |
103 |
/* blend the canvas background using the alpha channel */ |
105 |
/* blend the canvas background using the alpha channel */ |
104 |
background.red = x_bg_color.red >> 8; |
106 |
background.red = x_bg_color.red >> 8; |
Lines 136-142
read_png(FILE *file, int filetype, F_pic
Link Here
|
136 |
|
138 |
|
137 |
if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)) { |
139 |
if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)) { |
138 |
png_get_hIST(png_ptr, info_ptr, &histogram); |
140 |
png_get_hIST(png_ptr, info_ptr, &histogram); |
|
|
141 |
#if PNG_LIBPNG_VER_MAJOR <= 1 && PNG_LIBPNG_VER_MINOR < 5 |
139 |
png_set_dither(png_ptr, palette, num_palette, 256, histogram, 0); |
142 |
png_set_dither(png_ptr, palette, num_palette, 256, histogram, 0); |
|
|
143 |
#else |
144 |
png_set_quantize(png_ptr, palette, num_palette, 256, histogram, 0); |
145 |
#endif |
140 |
} |
146 |
} |
141 |
} |
147 |
} |
142 |
if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { |
148 |
if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { |