Lines 66-72
Fl_PNG_Image::Fl_PNG_Image(const char *png) // I - File to read
Link Here
|
66 |
png_structp pp; // PNG read pointer |
66 |
png_structp pp; // PNG read pointer |
67 |
png_infop info; // PNG info pointers |
67 |
png_infop info; // PNG info pointers |
68 |
png_bytep *rows; // PNG row pointers |
68 |
png_bytep *rows; // PNG row pointers |
69 |
|
69 |
png_byte color_type; // PNG color type |
|
|
70 |
png_byte bit_depth; // PNG bit depth |
70 |
|
71 |
|
71 |
// Open the PNG file... |
72 |
// Open the PNG file... |
72 |
if ((fp = fopen(png, "rb")) == NULL) return; |
73 |
if ((fp = fopen(png, "rb")) == NULL) return; |
Lines 75-81
Fl_PNG_Image::Fl_PNG_Image(const char *png) // I - File to read
Link Here
|
75 |
pp = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); |
76 |
pp = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); |
76 |
info = png_create_info_struct(pp); |
77 |
info = png_create_info_struct(pp); |
77 |
|
78 |
|
78 |
if (setjmp(pp->jmpbuf)) |
79 |
if (setjmp(png_jmpbuf(pp))) |
79 |
{ |
80 |
{ |
80 |
Fl::warning("PNG file \"%s\" contains errors!\n", png); |
81 |
Fl::warning("PNG file \"%s\" contains errors!\n", png); |
81 |
return; |
82 |
return; |
Lines 86-113
Fl_PNG_Image::Fl_PNG_Image(const char *png) // I - File to read
Link Here
|
86 |
|
87 |
|
87 |
// Get the image dimensions and convert to grayscale or RGB... |
88 |
// Get the image dimensions and convert to grayscale or RGB... |
88 |
png_read_info(pp, info); |
89 |
png_read_info(pp, info); |
|
|
90 |
color_type = png_get_color_type(pp, info); |
89 |
|
91 |
|
90 |
if (info->color_type == PNG_COLOR_TYPE_PALETTE) |
92 |
if (color_type == PNG_COLOR_TYPE_PALETTE) |
91 |
png_set_expand(pp); |
93 |
png_set_expand(pp); |
92 |
|
94 |
|
93 |
if (info->color_type & PNG_COLOR_MASK_COLOR) |
95 |
channels = png_get_channels(pp, info); |
94 |
channels = 3; |
|
|
95 |
else |
96 |
channels = 1; |
97 |
|
98 |
if ((info->color_type & PNG_COLOR_MASK_ALPHA) || info->num_trans) |
99 |
channels ++; |
100 |
|
96 |
|
101 |
w((int)(info->width)); |
97 |
w((int)(png_get_image_width(pp, info))); |
102 |
h((int)(info->height)); |
98 |
h((int)(png_get_image_height(pp, info))); |
103 |
d(channels); |
99 |
d(channels); |
104 |
|
100 |
|
105 |
if (info->bit_depth < 8) |
101 |
bit_depth = png_get_bit_depth(pp, info); |
|
|
102 |
if (bit_depth < 8) |
106 |
{ |
103 |
{ |
107 |
png_set_packing(pp); |
104 |
png_set_packing(pp); |
108 |
png_set_expand(pp); |
105 |
png_set_expand(pp); |
109 |
} |
106 |
} |
110 |
else if (info->bit_depth == 16) |
107 |
else if (bit_depth == 16) |
111 |
png_set_strip_16(pp); |
108 |
png_set_strip_16(pp); |
112 |
|
109 |
|
113 |
# if defined(HAVE_PNG_GET_VALID) && defined(HAVE_PNG_SET_TRNS_TO_ALPHA) |
110 |
# if defined(HAVE_PNG_GET_VALID) && defined(HAVE_PNG_SET_TRNS_TO_ALPHA) |