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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
$NetBSD: patch-src_im__png.c,v 1.1 2011/02/07 01:31:57 wiz Exp $
Fix build with png-1.5.
--- src/im_png.c.orig 2004-02-14 15:16:33.000000000 +0000
+++ src/im_png.c
@@ -55,7 +55,7 @@ my_error_exit(png_struct *pp, guchar *w)
*/
gboolean
-png_get_header(gchar *filename, png_info *info)
+png_get_header(gchar *filename, gint *width, gint *height, png_bytep color_type)
{
png_struct *pp;
png_info *linfo;
@@ -99,10 +99,9 @@ png_get_header(gchar *filename, png_info
png_init_io(pp, fp);
png_read_info(pp, linfo);
- info->width = linfo->width;
- info->height = linfo->height;
- info->valid = linfo->valid;
- info->color_type = linfo->color_type;
+ *width = png_get_image_width(pp, linfo);
+ *height = png_get_image_height(pp, linfo);
+ *color_type = png_get_color_type(pp, linfo);
g_free(linfo);
g_free(pp);
@@ -161,26 +160,30 @@ png_load(gchar *filename, PngLoadFunc fu
png_init_io(pp, fp);
png_read_info(pp, info);
- if (info->bit_depth < 8)
+ if (png_get_bit_depth(pp, info) < 8)
{
png_set_packing(pp);
png_set_expand(pp);
- if (info->valid & PNG_INFO_sBIT)
- png_set_shift(pp, &(info->sig_bit));
+ if (png_get_valid(pp, info, PNG_INFO_sBIT)) {
+ png_color_8p sig_bit;
+ png_get_sBIT(pp, info, &sig_bit);
+
+ png_set_shift(pp, sig_bit);
+ }
} else
- if (info->bit_depth == 16)
+ if (png_get_bit_depth(pp, info) == 16)
png_set_strip_16(pp);
/*
* Turn on interlace handling...
*/
- if (info->interlace_type)
+ if (png_get_interlace_type(pp, info))
num_passes = png_set_interlace_handling(pp);
else
num_passes = 1;
- switch (info->color_type)
+ switch (png_get_color_type(pp, info))
{
case PNG_COLOR_TYPE_RGB : /* RGB */
bpp = 3;
@@ -195,22 +198,30 @@ png_load(gchar *filename, PngLoadFunc fu
bpp = 2;
break;
case PNG_COLOR_TYPE_PALETTE : /* Indexed */
- bpp = info->num_trans ? 4:3;
+ {
+ png_bytep trans_alpha;
+ int num_trans;
+ png_color_16p trans_color;
+
+ png_get_tRNS(pp, info, &trans_alpha, &num_trans, &trans_color);
+
+ bpp = num_trans ? 4:3;
+ }
break;
};
- pixel = g_malloc(sizeof(guchar) * info->width * bpp);
+ pixel = g_malloc(sizeof(guchar) * png_get_image_width(pp, info) * bpp);
for (pass = 0; pass < num_passes; pass++)
{
- for (scanline = 0; scanline < info->height; scanline++)
+ for (scanline = 0; scanline < png_get_image_height(pp, info); scanline++)
{
- if (info->color_type == PNG_COLOR_TYPE_PALETTE)
+ if (png_get_color_type(pp, info) == PNG_COLOR_TYPE_PALETTE)
png_set_expand(pp);
png_read_row(pp, pixel, NULL);
- if ((*func) (pixel, info->width, 0, scanline, bpp, -1, 0)) goto png_read_cancelled;
+ if ((*func) (pixel, png_get_image_width(pp, info), 0, scanline, bpp, -1, 0)) goto png_read_cancelled;
};
};
|