blob: 94c8906a874a55dccc1b36b5432196d022e96281 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
--- a/codecs/png.cc
+++ b/codecs/png.cc
@@ -16,6 +16,7 @@
*/
#include <stdlib.h>
+#include <zlib.h>
#include <png.h>
#include <iostream>
@@ -104,7 +105,7 @@
image.w = width;
image.h = height;
image.bps = bit_depth;
- image.spp = info_ptr->channels;
+ image.spp = png_get_channels(png_ptr, info_ptr);
png_uint_32 res_x, res_y;
res_x = png_get_x_pixels_per_meter(png_ptr, info_ptr);
@@ -120,10 +121,13 @@
// png_set_packswap(png_ptr);
/* Expand paletted colors into true RGB triplets */
+
+ int num_trans;
+
if (color_type == PNG_COLOR_TYPE_PALETTE) {
png_set_palette_to_rgb(png_ptr);
image.bps = 8;
- if (info_ptr->num_trans)
+ if (num_trans)
image.spp = 4;
else
image.spp = 3;
|