Add coding style guide.
[platform/core/uifw/coregl.git] / src / modules / tracepath / png.h
1 /* png.h - header file for PNG reference library
2  *
3  * libpng version 1.2.50 - July 10, 2012
4  * Copyright (c) 1998-2012 Glenn Randers-Pehrson
5  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
6  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
7  *
8  * This code is released under the libpng license (See LICENSE, below)
9  *
10  * Authors and maintainers:
11  *  libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
12  *  libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
13  *  libpng versions 0.97, January 1998, through 1.2.50 - July 10, 2012: Glenn
14  *  See also "Contributing Authors", below.
15  *
16  * Note about libpng version numbers:
17  *
18  *    Due to various miscommunications, unforeseen code incompatibilities
19  *    and occasional factors outside the authors' control, version numbering
20  *    on the library has not always been consistent and straightforward.
21  *    The following table summarizes matters since version 0.89c, which was
22  *    the first widely used release:
23  *
24  *    source                 png.h  png.h  shared-lib
25  *    version                string   int  version
26  *    -------                ------ -----  ----------
27  *    0.89c "1.0 beta 3"     0.89      89  1.0.89
28  *    0.90  "1.0 beta 4"     0.90      90  0.90  [should have been 2.0.90]
29  *    0.95  "1.0 beta 5"     0.95      95  0.95  [should have been 2.0.95]
30  *    0.96  "1.0 beta 6"     0.96      96  0.96  [should have been 2.0.96]
31  *    0.97b "1.00.97 beta 7" 1.00.97   97  1.0.1 [should have been 2.0.97]
32  *    0.97c                  0.97      97  2.0.97
33  *    0.98                   0.98      98  2.0.98
34  *    0.99                   0.99      98  2.0.99
35  *    0.99a-m                0.99      99  2.0.99
36  *    1.00                   1.00     100  2.1.0 [100 should be 10000]
37  *    1.0.0      (from here on, the   100  2.1.0 [100 should be 10000]
38  *    1.0.1       png.h string is   10001  2.1.0
39  *    1.0.1a-e    identical to the  10002  from here on, the shared library
40  *    1.0.2       source version)   10002  is 2.V where V is the source code
41  *    1.0.2a-b                      10003  version, except as noted.
42  *    1.0.3                         10003
43  *    1.0.3a-d                      10004
44  *    1.0.4                         10004
45  *    1.0.4a-f                      10005
46  *    1.0.5 (+ 2 patches)           10005
47  *    1.0.5a-d                      10006
48  *    1.0.5e-r                      10100 (not source compatible)
49  *    1.0.5s-v                      10006 (not binary compatible)
50  *    1.0.6 (+ 3 patches)           10006 (still binary incompatible)
51  *    1.0.6d-f                      10007 (still binary incompatible)
52  *    1.0.6g                        10007
53  *    1.0.6h                        10007  10.6h (testing xy.z so-numbering)
54  *    1.0.6i                        10007  10.6i
55  *    1.0.6j                        10007  2.1.0.6j (incompatible with 1.0.0)
56  *    1.0.7beta11-14        DLLNUM  10007  2.1.0.7beta11-14 (binary compatible)
57  *    1.0.7beta15-18           1    10007  2.1.0.7beta15-18 (binary compatible)
58  *    1.0.7rc1-2               1    10007  2.1.0.7rc1-2 (binary compatible)
59  *    1.0.7                    1    10007  (still compatible)
60  *    1.0.8beta1-4             1    10008  2.1.0.8beta1-4
61  *    1.0.8rc1                 1    10008  2.1.0.8rc1
62  *    1.0.8                    1    10008  2.1.0.8
63  *    1.0.9beta1-6             1    10009  2.1.0.9beta1-6
64  *    1.0.9rc1                 1    10009  2.1.0.9rc1
65  *    1.0.9beta7-10            1    10009  2.1.0.9beta7-10
66  *    1.0.9rc2                 1    10009  2.1.0.9rc2
67  *    1.0.9                    1    10009  2.1.0.9
68  *    1.0.10beta1              1    10010  2.1.0.10beta1
69  *    1.0.10rc1                1    10010  2.1.0.10rc1
70  *    1.0.10                   1    10010  2.1.0.10
71  *    1.0.11beta1-3            1    10011  2.1.0.11beta1-3
72  *    1.0.11rc1                1    10011  2.1.0.11rc1
73  *    1.0.11                   1    10011  2.1.0.11
74  *    1.0.12beta1-2            2    10012  2.1.0.12beta1-2
75  *    1.0.12rc1                2    10012  2.1.0.12rc1
76  *    1.0.12                   2    10012  2.1.0.12
77  *    1.1.0a-f                 -    10100  2.1.1.0a-f (branch abandoned)
78  *    1.2.0beta1-2             2    10200  2.1.2.0beta1-2
79  *    1.2.0beta3-5             3    10200  3.1.2.0beta3-5
80  *    1.2.0rc1                 3    10200  3.1.2.0rc1
81  *    1.2.0                    3    10200  3.1.2.0
82  *    1.2.1beta1-4             3    10201  3.1.2.1beta1-4
83  *    1.2.1rc1-2               3    10201  3.1.2.1rc1-2
84  *    1.2.1                    3    10201  3.1.2.1
85  *    1.2.2beta1-6            12    10202  12.so.0.1.2.2beta1-6
86  *    1.0.13beta1             10    10013  10.so.0.1.0.13beta1
87  *    1.0.13rc1               10    10013  10.so.0.1.0.13rc1
88  *    1.2.2rc1                12    10202  12.so.0.1.2.2rc1
89  *    1.0.13                  10    10013  10.so.0.1.0.13
90  *    1.2.2                   12    10202  12.so.0.1.2.2
91  *    1.2.3rc1-6              12    10203  12.so.0.1.2.3rc1-6
92  *    1.2.3                   12    10203  12.so.0.1.2.3
93  *    1.2.4beta1-3            13    10204  12.so.0.1.2.4beta1-3
94  *    1.0.14rc1               13    10014  10.so.0.1.0.14rc1
95  *    1.2.4rc1                13    10204  12.so.0.1.2.4rc1
96  *    1.0.14                  10    10014  10.so.0.1.0.14
97  *    1.2.4                   13    10204  12.so.0.1.2.4
98  *    1.2.5beta1-2            13    10205  12.so.0.1.2.5beta1-2
99  *    1.0.15rc1-3             10    10015  10.so.0.1.0.15rc1-3
100  *    1.2.5rc1-3              13    10205  12.so.0.1.2.5rc1-3
101  *    1.0.15                  10    10015  10.so.0.1.0.15
102  *    1.2.5                   13    10205  12.so.0.1.2.5
103  *    1.2.6beta1-4            13    10206  12.so.0.1.2.6beta1-4
104  *    1.0.16                  10    10016  10.so.0.1.0.16
105  *    1.2.6                   13    10206  12.so.0.1.2.6
106  *    1.2.7beta1-2            13    10207  12.so.0.1.2.7beta1-2
107  *    1.0.17rc1               10    10017  10.so.0.1.0.17rc1
108  *    1.2.7rc1                13    10207  12.so.0.1.2.7rc1
109  *    1.0.17                  10    10017  10.so.0.1.0.17
110  *    1.2.7                   13    10207  12.so.0.1.2.7
111  *    1.2.8beta1-5            13    10208  12.so.0.1.2.8beta1-5
112  *    1.0.18rc1-5             10    10018  10.so.0.1.0.18rc1-5
113  *    1.2.8rc1-5              13    10208  12.so.0.1.2.8rc1-5
114  *    1.0.18                  10    10018  10.so.0.1.0.18
115  *    1.2.8                   13    10208  12.so.0.1.2.8
116  *    1.2.9beta1-3            13    10209  12.so.0.1.2.9beta1-3
117  *    1.2.9beta4-11           13    10209  12.so.0.9[.0]
118  *    1.2.9rc1                13    10209  12.so.0.9[.0]
119  *    1.2.9                   13    10209  12.so.0.9[.0]
120  *    1.2.10beta1-8           13    10210  12.so.0.10[.0]
121  *    1.2.10rc1-3             13    10210  12.so.0.10[.0]
122  *    1.2.10                  13    10210  12.so.0.10[.0]
123  *    1.2.11beta1-4           13    10211  12.so.0.11[.0]
124  *    1.0.19rc1-5             10    10019  10.so.0.19[.0]
125  *    1.2.11rc1-5             13    10211  12.so.0.11[.0]
126  *    1.0.19                  10    10019  10.so.0.19[.0]
127  *    1.2.11                  13    10211  12.so.0.11[.0]
128  *    1.0.20                  10    10020  10.so.0.20[.0]
129  *    1.2.12                  13    10212  12.so.0.12[.0]
130  *    1.2.13beta1             13    10213  12.so.0.13[.0]
131  *    1.0.21                  10    10021  10.so.0.21[.0]
132  *    1.2.13                  13    10213  12.so.0.13[.0]
133  *    1.2.14beta1-2           13    10214  12.so.0.14[.0]
134  *    1.0.22rc1               10    10022  10.so.0.22[.0]
135  *    1.2.14rc1               13    10214  12.so.0.14[.0]
136  *    1.0.22                  10    10022  10.so.0.22[.0]
137  *    1.2.14                  13    10214  12.so.0.14[.0]
138  *    1.2.15beta1-6           13    10215  12.so.0.15[.0]
139  *    1.0.23rc1-5             10    10023  10.so.0.23[.0]
140  *    1.2.15rc1-5             13    10215  12.so.0.15[.0]
141  *    1.0.23                  10    10023  10.so.0.23[.0]
142  *    1.2.15                  13    10215  12.so.0.15[.0]
143  *    1.2.16beta1-2           13    10216  12.so.0.16[.0]
144  *    1.2.16rc1               13    10216  12.so.0.16[.0]
145  *    1.0.24                  10    10024  10.so.0.24[.0]
146  *    1.2.16                  13    10216  12.so.0.16[.0]
147  *    1.2.17beta1-2           13    10217  12.so.0.17[.0]
148  *    1.0.25rc1               10    10025  10.so.0.25[.0]
149  *    1.2.17rc1-3             13    10217  12.so.0.17[.0]
150  *    1.0.25                  10    10025  10.so.0.25[.0]
151  *    1.2.17                  13    10217  12.so.0.17[.0]
152  *    1.0.26                  10    10026  10.so.0.26[.0]
153  *    1.2.18                  13    10218  12.so.0.18[.0]
154  *    1.2.19beta1-31          13    10219  12.so.0.19[.0]
155  *    1.0.27rc1-6             10    10027  10.so.0.27[.0]
156  *    1.2.19rc1-6             13    10219  12.so.0.19[.0]
157  *    1.0.27                  10    10027  10.so.0.27[.0]
158  *    1.2.19                  13    10219  12.so.0.19[.0]
159  *    1.2.20beta01-04         13    10220  12.so.0.20[.0]
160  *    1.0.28rc1-6             10    10028  10.so.0.28[.0]
161  *    1.2.20rc1-6             13    10220  12.so.0.20[.0]
162  *    1.0.28                  10    10028  10.so.0.28[.0]
163  *    1.2.20                  13    10220  12.so.0.20[.0]
164  *    1.2.21beta1-2           13    10221  12.so.0.21[.0]
165  *    1.2.21rc1-3             13    10221  12.so.0.21[.0]
166  *    1.0.29                  10    10029  10.so.0.29[.0]
167  *    1.2.21                  13    10221  12.so.0.21[.0]
168  *    1.2.22beta1-4           13    10222  12.so.0.22[.0]
169  *    1.0.30rc1               10    10030  10.so.0.30[.0]
170  *    1.2.22rc1               13    10222  12.so.0.22[.0]
171  *    1.0.30                  10    10030  10.so.0.30[.0]
172  *    1.2.22                  13    10222  12.so.0.22[.0]
173  *    1.2.23beta01-05         13    10223  12.so.0.23[.0]
174  *    1.2.23rc01              13    10223  12.so.0.23[.0]
175  *    1.2.23                  13    10223  12.so.0.23[.0]
176  *    1.2.24beta01-02         13    10224  12.so.0.24[.0]
177  *    1.2.24rc01              13    10224  12.so.0.24[.0]
178  *    1.2.24                  13    10224  12.so.0.24[.0]
179  *    1.2.25beta01-06         13    10225  12.so.0.25[.0]
180  *    1.2.25rc01-02           13    10225  12.so.0.25[.0]
181  *    1.0.31                  10    10031  10.so.0.31[.0]
182  *    1.2.25                  13    10225  12.so.0.25[.0]
183  *    1.2.26beta01-06         13    10226  12.so.0.26[.0]
184  *    1.2.26rc01              13    10226  12.so.0.26[.0]
185  *    1.2.26                  13    10226  12.so.0.26[.0]
186  *    1.0.32                  10    10032  10.so.0.32[.0]
187  *    1.2.27beta01-06         13    10227  12.so.0.27[.0]
188  *    1.2.27rc01              13    10227  12.so.0.27[.0]
189  *    1.0.33                  10    10033  10.so.0.33[.0]
190  *    1.2.27                  13    10227  12.so.0.27[.0]
191  *    1.0.34                  10    10034  10.so.0.34[.0]
192  *    1.2.28                  13    10228  12.so.0.28[.0]
193  *    1.2.29beta01-03         13    10229  12.so.0.29[.0]
194  *    1.2.29rc01              13    10229  12.so.0.29[.0]
195  *    1.0.35                  10    10035  10.so.0.35[.0]
196  *    1.2.29                  13    10229  12.so.0.29[.0]
197  *    1.0.37                  10    10037  10.so.0.37[.0]
198  *    1.2.30beta01-04         13    10230  12.so.0.30[.0]
199  *    1.0.38rc01-08           10    10038  10.so.0.38[.0]
200  *    1.2.30rc01-08           13    10230  12.so.0.30[.0]
201  *    1.0.38                  10    10038  10.so.0.38[.0]
202  *    1.2.30                  13    10230  12.so.0.30[.0]
203  *    1.0.39rc01-03           10    10039  10.so.0.39[.0]
204  *    1.2.31rc01-03           13    10231  12.so.0.31[.0]
205  *    1.0.39                  10    10039  10.so.0.39[.0]
206  *    1.2.31                  13    10231  12.so.0.31[.0]
207  *    1.2.32beta01-02         13    10232  12.so.0.32[.0]
208  *    1.0.40rc01              10    10040  10.so.0.40[.0]
209  *    1.2.32rc01              13    10232  12.so.0.32[.0]
210  *    1.0.40                  10    10040  10.so.0.40[.0]
211  *    1.2.32                  13    10232  12.so.0.32[.0]
212  *    1.2.33beta01-02         13    10233  12.so.0.33[.0]
213  *    1.2.33rc01-02           13    10233  12.so.0.33[.0]
214  *    1.0.41rc01              10    10041  10.so.0.41[.0]
215  *    1.2.33                  13    10233  12.so.0.33[.0]
216  *    1.0.41                  10    10041  10.so.0.41[.0]
217  *    1.2.34beta01-07         13    10234  12.so.0.34[.0]
218  *    1.0.42rc01              10    10042  10.so.0.42[.0]
219  *    1.2.34rc01              13    10234  12.so.0.34[.0]
220  *    1.0.42                  10    10042  10.so.0.42[.0]
221  *    1.2.34                  13    10234  12.so.0.34[.0]
222  *    1.2.35beta01-03         13    10235  12.so.0.35[.0]
223  *    1.0.43rc01-02           10    10043  10.so.0.43[.0]
224  *    1.2.35rc01-02           13    10235  12.so.0.35[.0]
225  *    1.0.43                  10    10043  10.so.0.43[.0]
226  *    1.2.35                  13    10235  12.so.0.35[.0]
227  *    1.2.36beta01-05         13    10236  12.so.0.36[.0]
228  *    1.2.36rc01              13    10236  12.so.0.36[.0]
229  *    1.0.44                  10    10044  10.so.0.44[.0]
230  *    1.2.36                  13    10236  12.so.0.36[.0]
231  *    1.2.37beta01-03         13    10237  12.so.0.37[.0]
232  *    1.2.37rc01              13    10237  12.so.0.37[.0]
233  *    1.2.37                  13    10237  12.so.0.37[.0]
234  *    1.0.45                  10    10045  12.so.0.45[.0]
235  *    1.0.46                  10    10046  10.so.0.46[.0]
236  *    1.2.38beta01            13    10238  12.so.0.38[.0]
237  *    1.2.38rc01-03           13    10238  12.so.0.38[.0]
238  *    1.0.47                  10    10047  10.so.0.47[.0]
239  *    1.2.38                  13    10238  12.so.0.38[.0]
240  *    1.2.39beta01-05         13    10239  12.so.0.39[.0]
241  *    1.2.39rc01              13    10239  12.so.0.39[.0]
242  *    1.0.48                  10    10048  10.so.0.48[.0]
243  *    1.2.39                  13    10239  12.so.0.39[.0]
244  *    1.2.40beta01            13    10240  12.so.0.40[.0]
245  *    1.2.40rc01              13    10240  12.so.0.40[.0]
246  *    1.0.49                  10    10049  10.so.0.49[.0]
247  *    1.2.40                  13    10240  12.so.0.40[.0]
248  *    1.2.41beta01-18         13    10241  12.so.0.41[.0]
249  *    1.0.51rc01              10    10051  10.so.0.51[.0]
250  *    1.2.41rc01-03           13    10241  12.so.0.41[.0]
251  *    1.0.51                  10    10051  10.so.0.51[.0]
252  *    1.2.41                  13    10241  12.so.0.41[.0]
253  *    1.2.42beta01-02         13    10242  12.so.0.42[.0]
254  *    1.2.42rc01-05           13    10242  12.so.0.42[.0]
255  *    1.0.52                  10    10052  10.so.0.52[.0]
256  *    1.2.42                  13    10242  12.so.0.42[.0]
257  *    1.2.43beta01-05         13    10243  12.so.0.43[.0]
258  *    1.0.53rc01-02           10    10053  10.so.0.53[.0]
259  *    1.2.43rc01-02           13    10243  12.so.0.43[.0]
260  *    1.0.53                  10    10053  10.so.0.53[.0]
261  *    1.2.43                  13    10243  12.so.0.43[.0]
262  *    1.2.44beta01-03         13    10244  12.so.0.44[.0]
263  *    1.2.44rc01-03           13    10244  12.so.0.44[.0]
264  *    1.2.44                  13    10244  12.so.0.44[.0]
265  *    1.2.45beta01-03         13    10245  12.so.0.45[.0]
266  *    1.0.55rc01              10    10055  10.so.0.55[.0]
267  *    1.2.45rc01              13    10245  12.so.0.45[.0]
268  *    1.0.55                  10    10055  10.so.0.55[.0]
269  *    1.2.45                  13    10245  12.so.0.45[.0]
270  *    1.2.46rc01-02           13    10246  12.so.0.46[.0]
271  *    1.0.56                  10    10056  10.so.0.56[.0]
272  *    1.2.46                  13    10246  12.so.0.46[.0]
273  *    1.2.47beta01            13    10247  12.so.0.47[.0]
274  *    1.2.47rc01              13    10247  12.so.0.47[.0]
275  *    1.0.57rc01              10    10057  10.so.0.57[.0]
276  *    1.2.47                  13    10247  12.so.0.47[.0]
277  *    1.0.57                  10    10057  10.so.0.57[.0]
278  *    1.2.48beta01            13    10248  12.so.0.48[.0]
279  *    1.2.48rc01-02           13    10248  12.so.0.48[.0]
280  *    1.0.58                  10    10058  10.so.0.58[.0]
281  *    1.2.48                  13    10248  12.so.0.48[.0]
282  *    1.2.49rc01              13    10249  12.so.0.49[.0]
283  *    1.0.59                  10    10059  10.so.0.59[.0]
284  *    1.2.49                  13    10249  12.so.0.49[.0]
285  *    1.0.60                  10    10060  10.so.0.60[.0]
286  *    1.2.50                  13    10250  12.so.0.50[.0]
287  *
288  *    Henceforth the source version will match the shared-library major
289  *    and minor numbers; the shared-library major version number will be
290  *    used for changes in backward compatibility, as it is intended.  The
291  *    PNG_LIBPNG_VER macro, which is not used within libpng but is available
292  *    for applications, is an unsigned integer of the form xyyzz corresponding
293  *    to the source version x.y.z (leading zeros in y and z).  Beta versions
294  *    were given the previous public release number plus a letter, until
295  *    version 1.0.6j; from then on they were given the upcoming public
296  *    release number plus "betaNN" or "rcNN".
297  *
298  *    Binary incompatibility exists only when applications make direct access
299  *    to the info_ptr or png_ptr members through png.h, and the compiled
300  *    application is loaded with a different version of the library.
301  *
302  *    DLLNUM will change each time there are forward or backward changes
303  *    in binary compatibility (e.g., when a new feature is added).
304  *
305  * See libpng.txt or libpng.3 for more information.  The PNG specification
306  * is available as a W3C Recommendation and as an ISO Specification,
307  * <http://www.w3.org/TR/2003/REC-PNG-20031110/
308  */
309
310 /*
311  * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
312  *
313  * If you modify libpng you may insert additional notices immediately following
314  * this sentence.
315  *
316  * This code is released under the libpng license.
317  *
318  * libpng versions 1.2.6, August 15, 2004, through 1.2.50, July 10, 2012, are
319  * Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are
320  * distributed according to the same disclaimer and license as libpng-1.2.5
321  * with the following individual added to the list of Contributing Authors:
322  *
323  *    Cosmin Truta
324  *
325  * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are
326  * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
327  * distributed according to the same disclaimer and license as libpng-1.0.6
328  * with the following individuals added to the list of Contributing Authors:
329  *
330  *    Simon-Pierre Cadieux
331  *    Eric S. Raymond
332  *    Gilles Vollant
333  *
334  * and with the following additions to the disclaimer:
335  *
336  *    There is no warranty against interference with your enjoyment of the
337  *    library or against infringement.  There is no warranty that our
338  *    efforts or the library will fulfill any of your particular purposes
339  *    or needs.  This library is provided with all faults, and the entire
340  *    risk of satisfactory quality, performance, accuracy, and effort is with
341  *    the user.
342  *
343  * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
344  * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are
345  * distributed according to the same disclaimer and license as libpng-0.96,
346  * with the following individuals added to the list of Contributing Authors:
347  *
348  *    Tom Lane
349  *    Glenn Randers-Pehrson
350  *    Willem van Schaik
351  *
352  * libpng versions 0.89, June 1996, through 0.96, May 1997, are
353  * Copyright (c) 1996, 1997 Andreas Dilger
354  * Distributed according to the same disclaimer and license as libpng-0.88,
355  * with the following individuals added to the list of Contributing Authors:
356  *
357  *    John Bowler
358  *    Kevin Bracey
359  *    Sam Bushell
360  *    Magnus Holmgren
361  *    Greg Roelofs
362  *    Tom Tanner
363  *
364  * libpng versions 0.5, May 1995, through 0.88, January 1996, are
365  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
366  *
367  * For the purposes of this copyright and license, "Contributing Authors"
368  * is defined as the following set of individuals:
369  *
370  *    Andreas Dilger
371  *    Dave Martindale
372  *    Guy Eric Schalnat
373  *    Paul Schmidt
374  *    Tim Wegner
375  *
376  * The PNG Reference Library is supplied "AS IS".  The Contributing Authors
377  * and Group 42, Inc. disclaim all warranties, expressed or implied,
378  * including, without limitation, the warranties of merchantability and of
379  * fitness for any purpose.  The Contributing Authors and Group 42, Inc.
380  * assume no liability for direct, indirect, incidental, special, exemplary,
381  * or consequential damages, which may result from the use of the PNG
382  * Reference Library, even if advised of the possibility of such damage.
383  *
384  * Permission is hereby granted to use, copy, modify, and distribute this
385  * source code, or portions hereof, for any purpose, without fee, subject
386  * to the following restrictions:
387  *
388  * 1. The origin of this source code must not be misrepresented.
389  *
390  * 2. Altered versions must be plainly marked as such and
391  * must not be misrepresented as being the original source.
392  *
393  * 3. This Copyright notice may not be removed or altered from
394  *    any source or altered source distribution.
395  *
396  * The Contributing Authors and Group 42, Inc. specifically permit, without
397  * fee, and encourage the use of this source code as a component to
398  * supporting the PNG file format in commercial products.  If you use this
399  * source code in a product, acknowledgment is not required but would be
400  * appreciated.
401  */
402
403 /*
404  * A "png_get_copyright" function is available, for convenient use in "about"
405  * boxes and the like:
406  *
407  * printf("%s",png_get_copyright(NULL));
408  *
409  * Also, the PNG logo (in PNG format, of course) is supplied in the
410  * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
411  */
412
413 /*
414  * Libpng is OSI Certified Open Source Software.  OSI Certified is a
415  * certification mark of the Open Source Initiative.
416  */
417
418 /*
419  * The contributing authors would like to thank all those who helped
420  * with testing, bug fixes, and patience.  This wouldn't have been
421  * possible without all of you.
422  *
423  * Thanks to Frank J. T. Wojcik for helping with the documentation.
424  */
425
426 /*
427  * Y2K compliance in libpng:
428  * =========================
429  *
430  *    July 10, 2012
431  *
432  *    Since the PNG Development group is an ad-hoc body, we can't make
433  *    an official declaration.
434  *
435  *    This is your unofficial assurance that libpng from version 0.71 and
436  *    upward through 1.2.50 are Y2K compliant.  It is my belief that earlier
437  *    versions were also Y2K compliant.
438  *
439  *    Libpng only has three year fields.  One is a 2-byte unsigned integer
440  *    that will hold years up to 65535.  The other two hold the date in text
441  *    format, and will hold years up to 9999.
442  *
443  *    The integer is
444  *        "png_uint_16 year" in png_time_struct.
445  *
446  *    The strings are
447  *        "png_charp time_buffer" in png_struct and
448  *        "near_time_buffer", which is a local character string in png.c.
449  *
450  *    There are seven time-related functions:
451  *        png.c: png_convert_to_rfc_1123() in png.c
452  *          (formerly png_convert_to_rfc_1152() in error)
453  *        png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
454  *        png_convert_from_time_t() in pngwrite.c
455  *        png_get_tIME() in pngget.c
456  *        png_handle_tIME() in pngrutil.c, called in pngread.c
457  *        png_set_tIME() in pngset.c
458  *        png_write_tIME() in pngwutil.c, called in pngwrite.c
459  *
460  *    All handle dates properly in a Y2K environment.  The
461  *    png_convert_from_time_t() function calls gmtime() to convert from system
462  *    clock time, which returns (year - 1900), which we properly convert to
463  *    the full 4-digit year.  There is a possibility that applications using
464  *    libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
465  *    function, or that they are incorrectly passing only a 2-digit year
466  *    instead of "year - 1900" into the png_convert_from_struct_tm() function,
467  *    but this is not under our control.  The libpng documentation has always
468  *    stated that it works with 4-digit years, and the APIs have been
469  *    documented as such.
470  *
471  *    The tIME chunk itself is also Y2K compliant.  It uses a 2-byte unsigned
472  *    integer to hold the year, and can hold years as large as 65535.
473  *
474  *    zlib, upon which libpng depends, is also Y2K compliant.  It contains
475  *    no date-related code.
476  *
477  *       Glenn Randers-Pehrson
478  *       libpng maintainer
479  *       PNG Development Group
480  */
481
482 #ifndef PNG_H
483 #define PNG_H
484
485 /* This is not the place to learn how to use libpng.  The file libpng.txt
486  * describes how to use libpng, and the file example.c summarizes it
487  * with some code on which to build.  This file is useful for looking
488  * at the actual function definitions and structure components.
489  */
490
491 /* Version information for png.h - this should match the version in png.c */
492 #define PNG_LIBPNG_VER_STRING "1.2.50"
493 #define PNG_HEADER_VERSION_STRING \
494    " libpng version 1.2.50 - July 10, 2012\n"
495
496 #define PNG_LIBPNG_VER_SONUM   0
497 #define PNG_LIBPNG_VER_DLLNUM  13
498
499 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
500 #define PNG_LIBPNG_VER_MAJOR   1
501 #define PNG_LIBPNG_VER_MINOR   2
502 #define PNG_LIBPNG_VER_RELEASE 50
503 /* This should match the numeric part of the final component of
504  * PNG_LIBPNG_VER_STRING, omitting any leading zero:
505  */
506
507 #define PNG_LIBPNG_VER_BUILD  0
508
509 /* Release Status */
510 #define PNG_LIBPNG_BUILD_ALPHA    1
511 #define PNG_LIBPNG_BUILD_BETA     2
512 #define PNG_LIBPNG_BUILD_RC       3
513 #define PNG_LIBPNG_BUILD_STABLE   4
514 #define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7
515
516 /* Release-Specific Flags */
517 #define PNG_LIBPNG_BUILD_PATCH    8 /* Can be OR'ed with
518                                        PNG_LIBPNG_BUILD_STABLE only */
519 #define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with
520                                        PNG_LIBPNG_BUILD_SPECIAL */
521 #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
522                                        PNG_LIBPNG_BUILD_PRIVATE */
523
524 #define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
525
526 /* Careful here.  At one time, Guy wanted to use 082, but that would be octal.
527  * We must not include leading zeros.
528  * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
529  * version 1.0.0 was mis-numbered 100 instead of 10000).  From
530  * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release
531  */
532 #define PNG_LIBPNG_VER 10250 /* 1.2.50 */
533
534 #ifndef PNG_VERSION_INFO_ONLY
535 /* Include the compression library's header */
536 #include "zlib.h"
537 #endif
538
539 /* Include all user configurable info, including optional assembler routines */
540 #include "pngconf.h"
541
542 /*
543  * Added at libpng-1.2.8 */
544 /* Ref MSDN: Private as priority over Special
545  * VS_FF_PRIVATEBUILD File *was not* built using standard release
546  * procedures. If this value is given, the StringFileInfo block must
547  * contain a PrivateBuild string.
548  *
549  * VS_FF_SPECIALBUILD File *was* built by the original company using
550  * standard release procedures but is a variation of the standard
551  * file of the same version number. If this value is given, the
552  * StringFileInfo block must contain a SpecialBuild string.
553  */
554
555 #ifdef PNG_USER_PRIVATEBUILD
556 #  define PNG_LIBPNG_BUILD_TYPE \
557           (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE)
558 #else
559 #  ifdef PNG_LIBPNG_SPECIALBUILD
560 #    define PNG_LIBPNG_BUILD_TYPE \
561             (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL)
562 #  else
563 #    define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE)
564 #  endif
565 #endif
566
567 #ifndef PNG_VERSION_INFO_ONLY
568
569 /* Inhibit C++ name-mangling for libpng functions but not for system calls. */
570 #ifdef __cplusplus
571 extern "C" {
572 #endif /* __cplusplus */
573
574 /* This file is arranged in several sections.  The first section contains
575  * structure and type definitions.  The second section contains the external
576  * library functions, while the third has the internal library functions,
577  * which applications aren't expected to use directly.
578  */
579
580 #ifndef PNG_NO_TYPECAST_NULL
581 #define int_p_NULL                (int *)NULL
582 #define png_bytep_NULL            (png_bytep)NULL
583 #define png_bytepp_NULL           (png_bytepp)NULL
584 #define png_doublep_NULL          (png_doublep)NULL
585 #define png_error_ptr_NULL        (png_error_ptr)NULL
586 #define png_flush_ptr_NULL        (png_flush_ptr)NULL
587 #define png_free_ptr_NULL         (png_free_ptr)NULL
588 #define png_infopp_NULL           (png_infopp)NULL
589 #define png_malloc_ptr_NULL       (png_malloc_ptr)NULL
590 #define png_read_status_ptr_NULL  (png_read_status_ptr)NULL
591 #define png_rw_ptr_NULL           (png_rw_ptr)NULL
592 #define png_structp_NULL          (png_structp)NULL
593 #define png_uint_16p_NULL         (png_uint_16p)NULL
594 #define png_voidp_NULL            (png_voidp)NULL
595 #define png_write_status_ptr_NULL (png_write_status_ptr)NULL
596 #else
597 #define int_p_NULL                NULL
598 #define png_bytep_NULL            NULL
599 #define png_bytepp_NULL           NULL
600 #define png_doublep_NULL          NULL
601 #define png_error_ptr_NULL        NULL
602 #define png_flush_ptr_NULL        NULL
603 #define png_free_ptr_NULL         NULL
604 #define png_infopp_NULL           NULL
605 #define png_malloc_ptr_NULL       NULL
606 #define png_read_status_ptr_NULL  NULL
607 #define png_rw_ptr_NULL           NULL
608 #define png_structp_NULL          NULL
609 #define png_uint_16p_NULL         NULL
610 #define png_voidp_NULL            NULL
611 #define png_write_status_ptr_NULL NULL
612 #endif
613
614 /* Variables declared in png.c - only it needs to define PNG_NO_EXTERN */
615 #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
616 /* Version information for C files, stored in png.c.  This had better match
617  * the version above.
618  */
619 #ifdef PNG_USE_GLOBAL_ARRAYS
620 PNG_EXPORT_VAR (PNG_CONST char) png_libpng_ver[18];
621 /* Need room for 99.99.99beta99z */
622 #else
623 #define png_libpng_ver png_get_header_ver(NULL)
624 #endif
625
626 #ifdef PNG_USE_GLOBAL_ARRAYS
627 /* This was removed in version 1.0.5c */
628 /* Structures to facilitate easy interlacing.  See png.c for more details */
629 PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_start[7];
630 PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_inc[7];
631 PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_ystart[7];
632 PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_yinc[7];
633 PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_mask[7];
634 PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_dsp_mask[7];
635 /* This isn't currently used.  If you need it, see png.c for more details.
636 PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_height[7];
637 */
638 #endif
639
640 #endif /* PNG_NO_EXTERN */
641
642 /* Three color definitions.  The order of the red, green, and blue, (and the
643  * exact size) is not important, although the size of the fields need to
644  * be png_byte or png_uint_16 (as defined below).
645  */
646 typedef struct png_color_struct {
647         png_byte red;
648         png_byte green;
649         png_byte blue;
650 } png_color;
651 typedef png_color FAR *png_colorp;
652 typedef png_color FAR *FAR *png_colorpp;
653
654 typedef struct png_color_16_struct {
655         png_byte index;    /* used for palette files */
656         png_uint_16 red;   /* for use in red green blue files */
657         png_uint_16 green;
658         png_uint_16 blue;
659         png_uint_16 gray;  /* for use in grayscale files */
660 } png_color_16;
661 typedef png_color_16 FAR *png_color_16p;
662 typedef png_color_16 FAR *FAR *png_color_16pp;
663
664 typedef struct png_color_8_struct {
665         png_byte red;   /* for use in red green blue files */
666         png_byte green;
667         png_byte blue;
668         png_byte gray;  /* for use in grayscale files */
669         png_byte alpha; /* for alpha channel files */
670 } png_color_8;
671 typedef png_color_8 FAR *png_color_8p;
672 typedef png_color_8 FAR *FAR *png_color_8pp;
673
674 /*
675  * The following two structures are used for the in-core representation
676  * of sPLT chunks.
677  */
678 typedef struct png_sPLT_entry_struct {
679         png_uint_16 red;
680         png_uint_16 green;
681         png_uint_16 blue;
682         png_uint_16 alpha;
683         png_uint_16 frequency;
684 } png_sPLT_entry;
685 typedef png_sPLT_entry FAR *png_sPLT_entryp;
686 typedef png_sPLT_entry FAR *FAR *png_sPLT_entrypp;
687
688 /*  When the depth of the sPLT palette is 8 bits, the color and alpha samples
689  *  occupy the LSB of their respective members, and the MSB of each member
690  *  is zero-filled.  The frequency member always occupies the full 16 bits.
691  */
692
693 typedef struct png_sPLT_struct {
694         png_charp name;           /* palette name */
695         png_byte depth;           /* depth of palette samples */
696         png_sPLT_entryp entries;  /* palette entries */
697         png_int_32 nentries;      /* number of palette entries */
698 } png_sPLT_t;
699 typedef png_sPLT_t FAR *png_sPLT_tp;
700 typedef png_sPLT_t FAR *FAR *png_sPLT_tpp;
701
702 #ifdef PNG_TEXT_SUPPORTED
703 /* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,
704  * and whether that contents is compressed or not.  The "key" field
705  * points to a regular zero-terminated C string.  The "text", "lang", and
706  * "lang_key" fields can be regular C strings, empty strings, or NULL pointers.
707  * However, the * structure returned by png_get_text() will always contain
708  * regular zero-terminated C strings (possibly empty), never NULL pointers,
709  * so they can be safely used in printf() and other string-handling functions.
710  */
711 typedef struct png_text_struct {
712         int  compression;       /* compression value:
713                              -1: tEXt, none
714                               0: zTXt, deflate
715                               1: iTXt, none
716                               2: iTXt, deflate  */
717         png_charp key;          /* keyword, 1-79 character description of "text" */
718         png_charp text;         /* comment, may be an empty string (ie "")
719                               or a NULL pointer */
720         png_size_t text_length; /* length of the text string */
721 #ifdef PNG_iTXt_SUPPORTED
722         png_size_t itxt_length; /* length of the itxt string */
723         png_charp lang;         /* language code, 0-79 characters
724                               or a NULL pointer */
725         png_charp lang_key;     /* keyword translated UTF-8 string, 0 or more
726                               chars or a NULL pointer */
727 #endif
728 } png_text;
729 typedef png_text FAR *png_textp;
730 typedef png_text FAR *FAR *png_textpp;
731 #endif
732
733 /* Supported compression types for text in PNG files (tEXt, and zTXt).
734  * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed.
735  */
736 #define PNG_TEXT_COMPRESSION_NONE_WR -3
737 #define PNG_TEXT_COMPRESSION_zTXt_WR -2
738 #define PNG_TEXT_COMPRESSION_NONE    -1
739 #define PNG_TEXT_COMPRESSION_zTXt     0
740 #define PNG_ITXT_COMPRESSION_NONE     1
741 #define PNG_ITXT_COMPRESSION_zTXt     2
742 #define PNG_TEXT_COMPRESSION_LAST     3  /* Not a valid value */
743
744 /* png_time is a way to hold the time in an machine independent way.
745  * Two conversions are provided, both from time_t and struct tm.  There
746  * is no portable way to convert to either of these structures, as far
747  * as I know.  If you know of a portable way, send it to me.  As a side
748  * note - PNG has always been Year 2000 compliant!
749  */
750 typedef struct png_time_struct {
751         png_uint_16 year; /* full year, as in, 1995 */
752         png_byte month;   /* month of year, 1 - 12 */
753         png_byte day;     /* day of month, 1 - 31 */
754         png_byte hour;    /* hour of day, 0 - 23 */
755         png_byte minute;  /* minute of hour, 0 - 59 */
756         png_byte second;  /* second of minute, 0 - 60 (for leap seconds) */
757 } png_time;
758 typedef png_time FAR *png_timep;
759 typedef png_time FAR *FAR *png_timepp;
760
761 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
762  defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
763 /* png_unknown_chunk is a structure to hold queued chunks for which there is
764  * no specific support.  The idea is that we can use this to queue
765  * up private chunks for output even though the library doesn't actually
766  * know about their semantics.
767  */
768 #define PNG_CHUNK_NAME_LENGTH 5
769 typedef struct png_unknown_chunk_t {
770         png_byte name[PNG_CHUNK_NAME_LENGTH];
771         png_byte *data;
772         png_size_t size;
773
774         /* libpng-using applications should NOT directly modify this byte. */
775         png_byte location; /* mode of operation at read time */
776 }
777 png_unknown_chunk;
778 typedef png_unknown_chunk FAR *png_unknown_chunkp;
779 typedef png_unknown_chunk FAR *FAR *png_unknown_chunkpp;
780 #endif
781
782 /* png_info is a structure that holds the information in a PNG file so
783  * that the application can find out the characteristics of the image.
784  * If you are reading the file, this structure will tell you what is
785  * in the PNG file.  If you are writing the file, fill in the information
786  * you want to put into the PNG file, then call png_write_info().
787  * The names chosen should be very close to the PNG specification, so
788  * consult that document for information about the meaning of each field.
789  *
790  * With libpng < 0.95, it was only possible to directly set and read the
791  * the values in the png_info_struct, which meant that the contents and
792  * order of the values had to remain fixed.  With libpng 0.95 and later,
793  * however, there are now functions that abstract the contents of
794  * png_info_struct from the application, so this makes it easier to use
795  * libpng with dynamic libraries, and even makes it possible to use
796  * libraries that don't have all of the libpng ancillary chunk-handing
797  * functionality.
798  *
799  * In any case, the order of the parameters in png_info_struct should NOT
800  * be changed for as long as possible to keep compatibility with applications
801  * that use the old direct-access method with png_info_struct.
802  *
803  * The following members may have allocated storage attached that should be
804  * cleaned up before the structure is discarded: palette, trans, text,
805  * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
806  * splt_palettes, scal_unit, row_pointers, and unknowns.   By default, these
807  * are automatically freed when the info structure is deallocated, if they were
808  * allocated internally by libpng.  This behavior can be changed by means
809  * of the png_data_freer() function.
810  *
811  * More allocation details: all the chunk-reading functions that
812  * change these members go through the corresponding png_set_*
813  * functions.  A function to clear these members is available: see
814  * png_free_data().  The png_set_* functions do not depend on being
815  * able to point info structure members to any of the storage they are
816  * passed (they make their own copies), EXCEPT that the png_set_text
817  * functions use the same storage passed to them in the text_ptr or
818  * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
819  * functions do not make their own copies.
820  */
821 typedef struct png_info_struct {
822         /* The following are necessary for every PNG file */
823         png_uint_32 width
824         PNG_DEPSTRUCT;       /* width of image in pixels (from IHDR) */
825         png_uint_32 height
826         PNG_DEPSTRUCT;      /* height of image in pixels (from IHDR) */
827         png_uint_32 valid
828         PNG_DEPSTRUCT;       /* valid chunk data (see PNG_INFO_ below) */
829         png_uint_32 rowbytes
830         PNG_DEPSTRUCT;    /* bytes needed to hold an untransformed row */
831         png_colorp palette
832         PNG_DEPSTRUCT;      /* array of color values (valid & PNG_INFO_PLTE) */
833         png_uint_16 num_palette
834         PNG_DEPSTRUCT; /* number of color entries in "palette" (PLTE) */
835         png_uint_16 num_trans
836         PNG_DEPSTRUCT;   /* number of transparent palette color (tRNS) */
837         png_byte bit_depth
838         PNG_DEPSTRUCT;      /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
839         png_byte color_type
840         PNG_DEPSTRUCT;     /* see PNG_COLOR_TYPE_ below (from IHDR) */
841         /* The following three should have been named *_method not *_type */
842         png_byte compression_type
843         PNG_DEPSTRUCT; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
844         png_byte filter_type
845         PNG_DEPSTRUCT;    /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
846         png_byte interlace_type
847         PNG_DEPSTRUCT; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
848
849         /* The following is informational only on read, and not used on writes. */
850         png_byte channels
851         PNG_DEPSTRUCT;       /* number of data channels per pixel (1, 2, 3, 4) */
852         png_byte pixel_depth PNG_DEPSTRUCT;    /* number of bits per pixel */
853         png_byte spare_byte
854         PNG_DEPSTRUCT;     /* to align the data, and for future use */
855         png_byte signature[8]
856         PNG_DEPSTRUCT;   /* magic bytes read by libpng from start of file */
857
858         /* The rest of the data is optional.  If you are reading, check the
859          * valid field to see if the information in these are valid.  If you
860          * are writing, set the valid field to those chunks you want written,
861          * and initialize the appropriate fields below.
862          */
863
864 #if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
865         /* The gAMA chunk describes the gamma characteristics of the system
866          * on which the image was created, normally in the range [1.0, 2.5].
867          * Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
868          */
869         float gamma
870         PNG_DEPSTRUCT; /* gamma value of image, if (valid & PNG_INFO_gAMA) */
871 #endif
872
873 #ifdef PNG_sRGB_SUPPORTED
874         /* GR-P, 0.96a */
875         /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
876         png_byte srgb_intent PNG_DEPSTRUCT; /* sRGB rendering intent [0, 1, 2, or 3] */
877 #endif
878
879 #ifdef PNG_TEXT_SUPPORTED
880         /* The tEXt, and zTXt chunks contain human-readable textual data in
881          * uncompressed, compressed, and optionally compressed forms, respectively.
882          * The data in "text" is an array of pointers to uncompressed,
883          * null-terminated C strings. Each chunk has a keyword that describes the
884          * textual data contained in that chunk.  Keywords are not required to be
885          * unique, and the text string may be empty.  Any number of text chunks may
886          * be in an image.
887          */
888         int num_text PNG_DEPSTRUCT; /* number of comments read/to write */
889         int max_text PNG_DEPSTRUCT; /* current size of text array */
890         png_textp text PNG_DEPSTRUCT; /* array of comments read/to write */
891 #endif /* PNG_TEXT_SUPPORTED */
892
893 #ifdef PNG_tIME_SUPPORTED
894         /* The tIME chunk holds the last time the displayed image data was
895          * modified.  See the png_time struct for the contents of this struct.
896          */
897         png_time mod_time PNG_DEPSTRUCT;
898 #endif
899
900 #ifdef PNG_sBIT_SUPPORTED
901         /* The sBIT chunk specifies the number of significant high-order bits
902          * in the pixel data.  Values are in the range [1, bit_depth], and are
903          * only specified for the channels in the pixel data.  The contents of
904          * the low-order bits is not specified.  Data is valid if
905          * (valid & PNG_INFO_sBIT) is non-zero.
906          */
907         png_color_8 sig_bit PNG_DEPSTRUCT; /* significant bits in color channels */
908 #endif
909
910 #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \
911 defined(PNG_READ_BACKGROUND_SUPPORTED)
912         /* The tRNS chunk supplies transparency data for paletted images and
913          * other image types that don't need a full alpha channel.  There are
914          * "num_trans" transparency values for a paletted image, stored in the
915          * same order as the palette colors, starting from index 0.  Values
916          * for the data are in the range [0, 255], ranging from fully transparent
917          * to fully opaque, respectively.  For non-paletted images, there is a
918          * single color specified that should be treated as fully transparent.
919          * Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
920          */
921         png_bytep trans PNG_DEPSTRUCT; /* transparent values for paletted image */
922         png_color_16 trans_values
923         PNG_DEPSTRUCT; /* transparent color for non-palette image */
924 #endif
925
926 #if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
927         /* The bKGD chunk gives the suggested image background color if the
928          * display program does not have its own background color and the image
929          * is needs to composited onto a background before display.  The colors
930          * in "background" are normally in the same color space/depth as the
931          * pixel data.  Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
932          */
933         png_color_16 background PNG_DEPSTRUCT;
934 #endif
935
936 #ifdef PNG_oFFs_SUPPORTED
937         /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
938          * and downwards from the top-left corner of the display, page, or other
939          * application-specific co-ordinate space.  See the PNG_OFFSET_ defines
940          * below for the unit types.  Valid if (valid & PNG_INFO_oFFs) non-zero.
941          */
942         png_int_32 x_offset PNG_DEPSTRUCT; /* x offset on page */
943         png_int_32 y_offset PNG_DEPSTRUCT; /* y offset on page */
944         png_byte offset_unit_type PNG_DEPSTRUCT; /* offset units type */
945 #endif
946
947 #ifdef PNG_pHYs_SUPPORTED
948         /* The pHYs chunk gives the physical pixel density of the image for
949          * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
950          * defines below).  Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
951          */
952         png_uint_32 x_pixels_per_unit PNG_DEPSTRUCT; /* horizontal pixel density */
953         png_uint_32 y_pixels_per_unit PNG_DEPSTRUCT; /* vertical pixel density */
954         png_byte phys_unit_type
955         PNG_DEPSTRUCT; /* resolution type (see PNG_RESOLUTION_ below) */
956 #endif
957
958 #ifdef PNG_hIST_SUPPORTED
959         /* The hIST chunk contains the relative frequency or importance of the
960          * various palette entries, so that a viewer can intelligently select a
961          * reduced-color palette, if required.  Data is an array of "num_palette"
962          * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
963          * is non-zero.
964          */
965         png_uint_16p hist PNG_DEPSTRUCT;
966 #endif
967
968 #ifdef PNG_cHRM_SUPPORTED
969         /* The cHRM chunk describes the CIE color characteristics of the monitor
970          * on which the PNG was created.  This data allows the viewer to do gamut
971          * mapping of the input image to ensure that the viewer sees the same
972          * colors in the image as the creator.  Values are in the range
973          * [0.0, 0.8].  Data valid if (valid & PNG_INFO_cHRM) non-zero.
974          */
975 #ifdef PNG_FLOATING_POINT_SUPPORTED
976         float x_white PNG_DEPSTRUCT;
977         float y_white PNG_DEPSTRUCT;
978         float x_red PNG_DEPSTRUCT;
979         float y_red PNG_DEPSTRUCT;
980         float x_green PNG_DEPSTRUCT;
981         float y_green PNG_DEPSTRUCT;
982         float x_blue PNG_DEPSTRUCT;
983         float y_blue PNG_DEPSTRUCT;
984 #endif
985 #endif
986
987 #ifdef PNG_pCAL_SUPPORTED
988         /* The pCAL chunk describes a transformation between the stored pixel
989          * values and original physical data values used to create the image.
990          * The integer range [0, 2^bit_depth - 1] maps to the floating-point
991          * range given by [pcal_X0, pcal_X1], and are further transformed by a
992          * (possibly non-linear) transformation function given by "pcal_type"
993          * and "pcal_params" into "pcal_units".  Please see the PNG_EQUATION_
994          * defines below, and the PNG-Group's PNG extensions document for a
995          * complete description of the transformations and how they should be
996          * implemented, and for a description of the ASCII parameter strings.
997          * Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
998          */
999         png_charp pcal_purpose PNG_DEPSTRUCT;  /* pCAL chunk description string */
1000         png_int_32 pcal_X0 PNG_DEPSTRUCT;      /* minimum value */
1001         png_int_32 pcal_X1 PNG_DEPSTRUCT;      /* maximum value */
1002         png_charp pcal_units
1003         PNG_DEPSTRUCT;    /* Latin-1 string giving physical units */
1004         png_charpp pcal_params
1005         PNG_DEPSTRUCT;  /* ASCII strings containing parameter values */
1006         png_byte pcal_type
1007         PNG_DEPSTRUCT;      /* equation type (see PNG_EQUATION_ below) */
1008         png_byte pcal_nparams
1009         PNG_DEPSTRUCT;   /* number of parameters given in pcal_params */
1010 #endif
1011
1012         /* New members added in libpng-1.0.6 */
1013 #ifdef PNG_FREE_ME_SUPPORTED
1014         png_uint_32 free_me
1015         PNG_DEPSTRUCT;     /* flags items libpng is responsible for freeing */
1016 #endif
1017
1018 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
1019  defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
1020         /* Storage for unknown chunks that the library doesn't recognize. */
1021         png_unknown_chunkp unknown_chunks PNG_DEPSTRUCT;
1022         png_size_t unknown_chunks_num PNG_DEPSTRUCT;
1023 #endif
1024
1025 #ifdef PNG_iCCP_SUPPORTED
1026         /* iCCP chunk data. */
1027         png_charp iccp_name PNG_DEPSTRUCT;     /* profile name */
1028         png_charp iccp_profile
1029         PNG_DEPSTRUCT;  /* International Color Consortium profile data */
1030         /* Note to maintainer: should be png_bytep */
1031         png_uint_32 iccp_proflen PNG_DEPSTRUCT;  /* ICC profile data length */
1032         png_byte iccp_compression PNG_DEPSTRUCT; /* Always zero */
1033 #endif
1034
1035 #ifdef PNG_sPLT_SUPPORTED
1036         /* Data on sPLT chunks (there may be more than one). */
1037         png_sPLT_tp splt_palettes PNG_DEPSTRUCT;
1038         png_uint_32 splt_palettes_num PNG_DEPSTRUCT;
1039 #endif
1040
1041 #ifdef PNG_sCAL_SUPPORTED
1042         /* The sCAL chunk describes the actual physical dimensions of the
1043          * subject matter of the graphic.  The chunk contains a unit specification
1044          * a byte value, and two ASCII strings representing floating-point
1045          * values.  The values are width and height corresponsing to one pixel
1046          * in the image.  This external representation is converted to double
1047          * here.  Data values are valid if (valid & PNG_INFO_sCAL) is non-zero.
1048          */
1049         png_byte scal_unit PNG_DEPSTRUCT;         /* unit of physical scale */
1050 #ifdef PNG_FLOATING_POINT_SUPPORTED
1051         double scal_pixel_width PNG_DEPSTRUCT;    /* width of one pixel */
1052         double scal_pixel_height PNG_DEPSTRUCT;   /* height of one pixel */
1053 #endif
1054 #ifdef PNG_FIXED_POINT_SUPPORTED
1055         png_charp scal_s_width PNG_DEPSTRUCT;     /* string containing height */
1056         png_charp scal_s_height PNG_DEPSTRUCT;    /* string containing width */
1057 #endif
1058 #endif
1059
1060 #ifdef PNG_INFO_IMAGE_SUPPORTED
1061         /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */
1062         /* Data valid if (valid & PNG_INFO_IDAT) non-zero */
1063         png_bytepp row_pointers PNG_DEPSTRUCT;        /* the image bits */
1064 #endif
1065
1066 #if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED)
1067         png_fixed_point int_gamma
1068         PNG_DEPSTRUCT; /* gamma of image, if (valid & PNG_INFO_gAMA) */
1069 #endif
1070
1071 #if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED)
1072         png_fixed_point int_x_white PNG_DEPSTRUCT;
1073         png_fixed_point int_y_white PNG_DEPSTRUCT;
1074         png_fixed_point int_x_red PNG_DEPSTRUCT;
1075         png_fixed_point int_y_red PNG_DEPSTRUCT;
1076         png_fixed_point int_x_green PNG_DEPSTRUCT;
1077         png_fixed_point int_y_green PNG_DEPSTRUCT;
1078         png_fixed_point int_x_blue PNG_DEPSTRUCT;
1079         png_fixed_point int_y_blue PNG_DEPSTRUCT;
1080 #endif
1081
1082 } png_info;
1083
1084 typedef png_info FAR *png_infop;
1085 typedef png_info FAR *FAR *png_infopp;
1086
1087 /* Maximum positive integer used in PNG is (2^31)-1 */
1088 #define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)
1089 #define PNG_UINT_32_MAX ((png_uint_32)(-1))
1090 #define PNG_SIZE_MAX ((png_size_t)(-1))
1091 #if defined(PNG_1_0_X) || defined (PNG_1_2_X)
1092 /* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */
1093 #define PNG_MAX_UINT PNG_UINT_31_MAX
1094 #endif
1095
1096 /* These describe the color_type field in png_info. */
1097 /* color type masks */
1098 #define PNG_COLOR_MASK_PALETTE    1
1099 #define PNG_COLOR_MASK_COLOR      2
1100 #define PNG_COLOR_MASK_ALPHA      4
1101
1102 /* color types.  Note that not all combinations are legal */
1103 #define PNG_COLOR_TYPE_GRAY 0
1104 #define PNG_COLOR_TYPE_PALETTE  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
1105 #define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)
1106 #define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
1107 #define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
1108 /* aliases */
1109 #define PNG_COLOR_TYPE_RGBA  PNG_COLOR_TYPE_RGB_ALPHA
1110 #define PNG_COLOR_TYPE_GA  PNG_COLOR_TYPE_GRAY_ALPHA
1111
1112 /* This is for compression type. PNG 1.0-1.2 only define the single type. */
1113 #define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */
1114 #define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE
1115
1116 /* This is for filter type. PNG 1.0-1.2 only define the single type. */
1117 #define PNG_FILTER_TYPE_BASE      0 /* Single row per-byte filtering */
1118 #define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */
1119 #define PNG_FILTER_TYPE_DEFAULT   PNG_FILTER_TYPE_BASE
1120
1121 /* These are for the interlacing type.  These values should NOT be changed. */
1122 #define PNG_INTERLACE_NONE        0 /* Non-interlaced image */
1123 #define PNG_INTERLACE_ADAM7       1 /* Adam7 interlacing */
1124 #define PNG_INTERLACE_LAST        2 /* Not a valid value */
1125
1126 /* These are for the oFFs chunk.  These values should NOT be changed. */
1127 #define PNG_OFFSET_PIXEL          0 /* Offset in pixels */
1128 #define PNG_OFFSET_MICROMETER     1 /* Offset in micrometers (1/10^6 meter) */
1129 #define PNG_OFFSET_LAST           2 /* Not a valid value */
1130
1131 /* These are for the pCAL chunk.  These values should NOT be changed. */
1132 #define PNG_EQUATION_LINEAR       0 /* Linear transformation */
1133 #define PNG_EQUATION_BASE_E       1 /* Exponential base e transform */
1134 #define PNG_EQUATION_ARBITRARY    2 /* Arbitrary base exponential transform */
1135 #define PNG_EQUATION_HYPERBOLIC   3 /* Hyperbolic sine transformation */
1136 #define PNG_EQUATION_LAST         4 /* Not a valid value */
1137
1138 /* These are for the sCAL chunk.  These values should NOT be changed. */
1139 #define PNG_SCALE_UNKNOWN         0 /* unknown unit (image scale) */
1140 #define PNG_SCALE_METER           1 /* meters per pixel */
1141 #define PNG_SCALE_RADIAN          2 /* radians per pixel */
1142 #define PNG_SCALE_LAST            3 /* Not a valid value */
1143
1144 /* These are for the pHYs chunk.  These values should NOT be changed. */
1145 #define PNG_RESOLUTION_UNKNOWN    0 /* pixels/unknown unit (aspect ratio) */
1146 #define PNG_RESOLUTION_METER      1 /* pixels/meter */
1147 #define PNG_RESOLUTION_LAST       2 /* Not a valid value */
1148
1149 /* These are for the sRGB chunk.  These values should NOT be changed. */
1150 #define PNG_sRGB_INTENT_PERCEPTUAL 0
1151 #define PNG_sRGB_INTENT_RELATIVE   1
1152 #define PNG_sRGB_INTENT_SATURATION 2
1153 #define PNG_sRGB_INTENT_ABSOLUTE   3
1154 #define PNG_sRGB_INTENT_LAST       4 /* Not a valid value */
1155
1156 /* This is for text chunks */
1157 #define PNG_KEYWORD_MAX_LENGTH     79
1158
1159 /* Maximum number of entries in PLTE/sPLT/tRNS arrays */
1160 #define PNG_MAX_PALETTE_LENGTH    256
1161
1162 /* These determine if an ancillary chunk's data has been successfully read
1163  * from the PNG header, or if the application has filled in the corresponding
1164  * data in the info_struct to be written into the output file.  The values
1165  * of the PNG_INFO_<chunk> defines should NOT be changed.
1166  */
1167 #define PNG_INFO_gAMA 0x0001
1168 #define PNG_INFO_sBIT 0x0002
1169 #define PNG_INFO_cHRM 0x0004
1170 #define PNG_INFO_PLTE 0x0008
1171 #define PNG_INFO_tRNS 0x0010
1172 #define PNG_INFO_bKGD 0x0020
1173 #define PNG_INFO_hIST 0x0040
1174 #define PNG_INFO_pHYs 0x0080
1175 #define PNG_INFO_oFFs 0x0100
1176 #define PNG_INFO_tIME 0x0200
1177 #define PNG_INFO_pCAL 0x0400
1178 #define PNG_INFO_sRGB 0x0800   /* GR-P, 0.96a */
1179 #define PNG_INFO_iCCP 0x1000   /* ESR, 1.0.6 */
1180 #define PNG_INFO_sPLT 0x2000   /* ESR, 1.0.6 */
1181 #define PNG_INFO_sCAL 0x4000   /* ESR, 1.0.6 */
1182 #define PNG_INFO_IDAT 0x8000L  /* ESR, 1.0.6 */
1183
1184 /* This is used for the transformation routines, as some of them
1185  * change these values for the row.  It also should enable using
1186  * the routines for other purposes.
1187  */
1188 typedef struct png_row_info_struct {
1189         png_uint_32 width; /* width of row */
1190         png_uint_32 rowbytes; /* number of bytes in row */
1191         png_byte color_type; /* color type of row */
1192         png_byte bit_depth; /* bit depth of row */
1193         png_byte channels; /* number of channels (1, 2, 3, or 4) */
1194         png_byte pixel_depth; /* bits per pixel (depth * channels) */
1195 } png_row_info;
1196
1197 typedef png_row_info FAR *png_row_infop;
1198 typedef png_row_info FAR *FAR *png_row_infopp;
1199
1200 /* These are the function types for the I/O functions and for the functions
1201  * that allow the user to override the default I/O functions with his or her
1202  * own.  The png_error_ptr type should match that of user-supplied warning
1203  * and error functions, while the png_rw_ptr type should match that of the
1204  * user read/write data functions.
1205  */
1206 typedef struct png_struct_def png_struct;
1207 typedef png_struct FAR *png_structp;
1208
1209 typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp));
1210 typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t));
1211 typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp));
1212 typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32,
1213                 int));
1214 typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32,
1215                 int));
1216
1217 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
1218 typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp,
1219                 png_infop));
1220 typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop));
1221 typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
1222                 png_uint_32, int));
1223 #endif
1224
1225 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
1226     defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
1227     defined(PNG_LEGACY_SUPPORTED)
1228 typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp,
1229                 png_row_infop, png_bytep));
1230 #endif
1231
1232 #ifdef PNG_USER_CHUNKS_SUPPORTED
1233 typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp,
1234                 png_unknown_chunkp));
1235 #endif
1236 #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
1237 typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp));
1238 #endif
1239
1240 /* Transform masks for the high-level interface */
1241 #define PNG_TRANSFORM_IDENTITY       0x0000    /* read and write */
1242 #define PNG_TRANSFORM_STRIP_16       0x0001    /* read only */
1243 #define PNG_TRANSFORM_STRIP_ALPHA    0x0002    /* read only */
1244 #define PNG_TRANSFORM_PACKING        0x0004    /* read and write */
1245 #define PNG_TRANSFORM_PACKSWAP       0x0008    /* read and write */
1246 #define PNG_TRANSFORM_EXPAND         0x0010    /* read only */
1247 #define PNG_TRANSFORM_INVERT_MONO    0x0020    /* read and write */
1248 #define PNG_TRANSFORM_SHIFT          0x0040    /* read and write */
1249 #define PNG_TRANSFORM_BGR            0x0080    /* read and write */
1250 #define PNG_TRANSFORM_SWAP_ALPHA     0x0100    /* read and write */
1251 #define PNG_TRANSFORM_SWAP_ENDIAN    0x0200    /* read and write */
1252 #define PNG_TRANSFORM_INVERT_ALPHA   0x0400    /* read and write */
1253 #define PNG_TRANSFORM_STRIP_FILLER   0x0800    /* write only, deprecated */
1254 /* Added to libpng-1.2.34 */
1255 #define PNG_TRANSFORM_STRIP_FILLER_BEFORE 0x0800  /* write only */
1256 #define PNG_TRANSFORM_STRIP_FILLER_AFTER  0x1000  /* write only */
1257 /* Added to libpng-1.2.41 */
1258 #define PNG_TRANSFORM_GRAY_TO_RGB   0x2000      /* read only */
1259
1260 /* Flags for MNG supported features */
1261 #define PNG_FLAG_MNG_EMPTY_PLTE     0x01
1262 #define PNG_FLAG_MNG_FILTER_64      0x04
1263 #define PNG_ALL_MNG_FEATURES        0x05
1264
1265 typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t));
1266 typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp));
1267
1268 /* The structure that holds the information to read and write PNG files.
1269  * The only people who need to care about what is inside of this are the
1270  * people who will be modifying the library for their own special needs.
1271  * It should NOT be accessed directly by an application, except to store
1272  * the jmp_buf.
1273  */
1274
1275 struct png_struct_def {
1276 #ifdef PNG_SETJMP_SUPPORTED
1277         jmp_buf jmpbuf;            /* used in png_error */
1278 #endif
1279         png_error_ptr error_fn
1280         PNG_DEPSTRUCT;    /* function for printing errors and aborting */
1281         png_error_ptr warning_fn PNG_DEPSTRUCT;  /* function for printing warnings */
1282         png_voidp error_ptr
1283         PNG_DEPSTRUCT;       /* user supplied struct for error functions */
1284         png_rw_ptr write_data_fn PNG_DEPSTRUCT;  /* function for writing output data */
1285         png_rw_ptr read_data_fn PNG_DEPSTRUCT;   /* function for reading input data */
1286         png_voidp io_ptr
1287         PNG_DEPSTRUCT;          /* ptr to application struct for I/O functions */
1288
1289 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
1290         png_user_transform_ptr read_user_transform_fn
1291         PNG_DEPSTRUCT; /* user read transform */
1292 #endif
1293
1294 #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
1295         png_user_transform_ptr write_user_transform_fn
1296         PNG_DEPSTRUCT; /* user write transform */
1297 #endif
1298
1299         /* These were added in libpng-1.0.2 */
1300 #ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
1301 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
1302     defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
1303         png_voidp user_transform_ptr
1304         PNG_DEPSTRUCT; /* user supplied struct for user transform */
1305         png_byte user_transform_depth
1306         PNG_DEPSTRUCT;    /* bit depth of user transformed pixels */
1307         png_byte user_transform_channels
1308         PNG_DEPSTRUCT; /* channels in user transformed pixels */
1309 #endif
1310 #endif
1311
1312         png_uint_32 mode
1313         PNG_DEPSTRUCT;          /* tells us where we are in the PNG file */
1314         png_uint_32 flags
1315         PNG_DEPSTRUCT;         /* flags indicating various things to libpng */
1316         png_uint_32 transformations
1317         PNG_DEPSTRUCT; /* which transformations to perform */
1318
1319         z_stream zstream
1320         PNG_DEPSTRUCT;          /* pointer to decompression structure (below) */
1321         png_bytep zbuf PNG_DEPSTRUCT;            /* buffer for zlib */
1322         png_size_t zbuf_size PNG_DEPSTRUCT;      /* size of zbuf */
1323         int zlib_level PNG_DEPSTRUCT;            /* holds zlib compression level */
1324         int zlib_method PNG_DEPSTRUCT;           /* holds zlib compression method */
1325         int zlib_window_bits
1326         PNG_DEPSTRUCT;      /* holds zlib compression window bits */
1327         int zlib_mem_level
1328         PNG_DEPSTRUCT;        /* holds zlib compression memory level */
1329         int zlib_strategy PNG_DEPSTRUCT;         /* holds zlib compression strategy */
1330
1331         png_uint_32 width PNG_DEPSTRUCT;         /* width of image in pixels */
1332         png_uint_32 height PNG_DEPSTRUCT;        /* height of image in pixels */
1333         png_uint_32 num_rows PNG_DEPSTRUCT;      /* number of rows in current pass */
1334         png_uint_32 usr_width PNG_DEPSTRUCT;     /* width of row at start of write */
1335         png_uint_32 rowbytes PNG_DEPSTRUCT;      /* size of row in bytes */
1336 #if 0 /* Replaced with the following in libpng-1.2.43 */
1337         png_size_t irowbytes PNG_DEPSTRUCT;
1338 #endif
1339         /* Added in libpng-1.2.43 */
1340 #ifdef PNG_USER_LIMITS_SUPPORTED
1341         /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown
1342          * chunks that can be stored (0 means unlimited).
1343          */
1344         png_uint_32 user_chunk_cache_max PNG_DEPSTRUCT;
1345 #endif
1346         png_uint_32 iwidth
1347         PNG_DEPSTRUCT;        /* width of current interlaced row in pixels */
1348         png_uint_32 row_number PNG_DEPSTRUCT;    /* current row in interlace pass */
1349         png_bytep prev_row
1350         PNG_DEPSTRUCT;        /* buffer to save previous (unfiltered) row */
1351         png_bytep row_buf
1352         PNG_DEPSTRUCT;         /* buffer to save current (unfiltered) row */
1353 #ifndef PNG_NO_WRITE_FILTER
1354         png_bytep sub_row
1355         PNG_DEPSTRUCT;         /* buffer to save "sub" row when filtering */
1356         png_bytep up_row
1357         PNG_DEPSTRUCT;          /* buffer to save "up" row when filtering */
1358         png_bytep avg_row
1359         PNG_DEPSTRUCT;         /* buffer to save "avg" row when filtering */
1360         png_bytep paeth_row
1361         PNG_DEPSTRUCT;       /* buffer to save "Paeth" row when filtering */
1362 #endif
1363         png_row_info row_info PNG_DEPSTRUCT;     /* used for transformation routines */
1364
1365         png_uint_32 idat_size PNG_DEPSTRUCT;     /* current IDAT size for read */
1366         png_uint_32 crc PNG_DEPSTRUCT;           /* current chunk CRC value */
1367         png_colorp palette PNG_DEPSTRUCT;        /* palette from the input file */
1368         png_uint_16 num_palette
1369         PNG_DEPSTRUCT;   /* number of color entries in palette */
1370         png_uint_16 num_trans PNG_DEPSTRUCT;     /* number of transparency values */
1371         png_byte chunk_name[5]
1372         PNG_DEPSTRUCT;    /* null-terminated name of current chunk */
1373         png_byte compression PNG_DEPSTRUCT;      /* file compression type (always 0) */
1374         png_byte filter PNG_DEPSTRUCT;           /* file filter type (always 0) */
1375         png_byte interlaced
1376         PNG_DEPSTRUCT;       /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
1377         png_byte pass PNG_DEPSTRUCT;             /* current interlace pass (0 - 6) */
1378         png_byte do_filter
1379         PNG_DEPSTRUCT;        /* row filter flags (see PNG_FILTER_ below ) */
1380         png_byte color_type PNG_DEPSTRUCT;       /* color type of file */
1381         png_byte bit_depth PNG_DEPSTRUCT;        /* bit depth of file */
1382         png_byte usr_bit_depth PNG_DEPSTRUCT;    /* bit depth of users row */
1383         png_byte pixel_depth PNG_DEPSTRUCT;      /* number of bits per pixel */
1384         png_byte channels PNG_DEPSTRUCT;         /* number of channels in file */
1385         png_byte usr_channels PNG_DEPSTRUCT;     /* channels at start of write */
1386         png_byte sig_bytes
1387         PNG_DEPSTRUCT;        /* magic bytes read/written from start of file */
1388
1389 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
1390 #ifdef PNG_LEGACY_SUPPORTED
1391         png_byte filler PNG_DEPSTRUCT;           /* filler byte for pixel expansion */
1392 #else
1393         png_uint_16 filler
1394         PNG_DEPSTRUCT;           /* filler bytes for pixel expansion */
1395 #endif
1396 #endif
1397
1398 #ifdef PNG_bKGD_SUPPORTED
1399         png_byte background_gamma_type PNG_DEPSTRUCT;
1400 #  ifdef PNG_FLOATING_POINT_SUPPORTED
1401         float background_gamma PNG_DEPSTRUCT;
1402 #  endif
1403         png_color_16 background
1404         PNG_DEPSTRUCT;   /* background color in screen gamma space */
1405 #ifdef PNG_READ_GAMMA_SUPPORTED
1406         png_color_16 background_1
1407         PNG_DEPSTRUCT; /* background normalized to gamma 1.0 */
1408 #endif
1409 #endif /* PNG_bKGD_SUPPORTED */
1410
1411 #ifdef PNG_WRITE_FLUSH_SUPPORTED
1412         png_flush_ptr output_flush_fn PNG_DEPSTRUCT; /* Function for flushing output */
1413         png_uint_32 flush_dist
1414         PNG_DEPSTRUCT;    /* how many rows apart to flush, 0 - no flush */
1415         png_uint_32 flush_rows
1416         PNG_DEPSTRUCT;    /* number of rows written since last flush */
1417 #endif
1418
1419 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
1420         int gamma_shift
1421         PNG_DEPSTRUCT;      /* number of "insignificant" bits 16-bit gamma */
1422 #ifdef PNG_FLOATING_POINT_SUPPORTED
1423         float gamma PNG_DEPSTRUCT;          /* file gamma value */
1424         float screen_gamma PNG_DEPSTRUCT;   /* screen gamma value (display_exponent) */
1425 #endif
1426 #endif
1427
1428 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
1429         png_bytep gamma_table PNG_DEPSTRUCT;     /* gamma table for 8-bit depth files */
1430         png_bytep gamma_from_1 PNG_DEPSTRUCT;    /* converts from 1.0 to screen */
1431         png_bytep gamma_to_1 PNG_DEPSTRUCT;      /* converts from file to 1.0 */
1432         png_uint_16pp gamma_16_table
1433         PNG_DEPSTRUCT; /* gamma table for 16-bit depth files */
1434         png_uint_16pp gamma_16_from_1 PNG_DEPSTRUCT; /* converts from 1.0 to screen */
1435         png_uint_16pp gamma_16_to_1 PNG_DEPSTRUCT; /* converts from file to 1.0 */
1436 #endif
1437
1438 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)
1439         png_color_8 sig_bit
1440         PNG_DEPSTRUCT;       /* significant bits in each available channel */
1441 #endif
1442
1443 #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
1444         png_color_8 shift
1445         PNG_DEPSTRUCT;         /* shift for significant bit tranformation */
1446 #endif
1447
1448 #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
1449  || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
1450         png_bytep trans
1451         PNG_DEPSTRUCT;           /* transparency values for paletted files */
1452         png_color_16 trans_values
1453         PNG_DEPSTRUCT; /* transparency values for non-paletted files */
1454 #endif
1455
1456         png_read_status_ptr read_row_fn
1457         PNG_DEPSTRUCT;   /* called after each row is decoded */
1458         png_write_status_ptr write_row_fn
1459         PNG_DEPSTRUCT; /* called after each row is encoded */
1460 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
1461         png_progressive_info_ptr info_fn
1462         PNG_DEPSTRUCT; /* called after header data fully read */
1463         png_progressive_row_ptr row_fn
1464         PNG_DEPSTRUCT;   /* called after each prog. row is decoded */
1465         png_progressive_end_ptr end_fn
1466         PNG_DEPSTRUCT;   /* called after image is complete */
1467         png_bytep save_buffer_ptr
1468         PNG_DEPSTRUCT;        /* current location in save_buffer */
1469         png_bytep save_buffer
1470         PNG_DEPSTRUCT;            /* buffer for previously read data */
1471         png_bytep current_buffer_ptr
1472         PNG_DEPSTRUCT;     /* current location in current_buffer */
1473         png_bytep current_buffer
1474         PNG_DEPSTRUCT;         /* buffer for recently used data */
1475         png_uint_32 push_length
1476         PNG_DEPSTRUCT;          /* size of current input chunk */
1477         png_uint_32 skip_length
1478         PNG_DEPSTRUCT;          /* bytes to skip in input data */
1479         png_size_t save_buffer_size
1480         PNG_DEPSTRUCT;      /* amount of data now in save_buffer */
1481         png_size_t save_buffer_max PNG_DEPSTRUCT;       /* total size of save_buffer */
1482         png_size_t buffer_size
1483         PNG_DEPSTRUCT;           /* total amount of available input data */
1484         png_size_t current_buffer_size
1485         PNG_DEPSTRUCT;   /* amount of data now in current_buffer */
1486         int process_mode
1487         PNG_DEPSTRUCT;                 /* what push library is currently doing */
1488         int cur_palette
1489         PNG_DEPSTRUCT;                  /* current push library palette index */
1490
1491 #  ifdef PNG_TEXT_SUPPORTED
1492         png_size_t current_text_size
1493         PNG_DEPSTRUCT;   /* current size of text input data */
1494         png_size_t current_text_left
1495         PNG_DEPSTRUCT;   /* how much text left to read in input */
1496         png_charp current_text PNG_DEPSTRUCT;         /* current text chunk buffer */
1497         png_charp current_text_ptr
1498         PNG_DEPSTRUCT;     /* current location in current_text */
1499 #  endif /* PNG_TEXT_SUPPORTED */
1500 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
1501
1502 #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
1503         /* for the Borland special 64K segment handler */
1504         png_bytepp offset_table_ptr PNG_DEPSTRUCT;
1505         png_bytep offset_table PNG_DEPSTRUCT;
1506         png_uint_16 offset_table_number PNG_DEPSTRUCT;
1507         png_uint_16 offset_table_count PNG_DEPSTRUCT;
1508         png_uint_16 offset_table_count_free PNG_DEPSTRUCT;
1509 #endif
1510
1511 #ifdef PNG_READ_DITHER_SUPPORTED
1512         png_bytep palette_lookup PNG_DEPSTRUCT;         /* lookup table for dithering */
1513         png_bytep dither_index
1514         PNG_DEPSTRUCT;           /* index translation for palette files */
1515 #endif
1516
1517 #if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED)
1518         png_uint_16p hist PNG_DEPSTRUCT;                /* histogram */
1519 #endif
1520
1521 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
1522         png_byte heuristic_method
1523         PNG_DEPSTRUCT;        /* heuristic for row filter selection */
1524         png_byte num_prev_filters
1525         PNG_DEPSTRUCT;        /* number of weights for previous rows */
1526         png_bytep prev_filters
1527         PNG_DEPSTRUCT;           /* filter type(s) of previous row(s) */
1528         png_uint_16p filter_weights
1529         PNG_DEPSTRUCT;      /* weight(s) for previous line(s) */
1530         png_uint_16p inv_filter_weights
1531         PNG_DEPSTRUCT;  /* 1/weight(s) for previous line(s) */
1532         png_uint_16p filter_costs
1533         PNG_DEPSTRUCT;        /* relative filter calculation cost */
1534         png_uint_16p inv_filter_costs
1535         PNG_DEPSTRUCT;    /* 1/relative filter calculation cost */
1536 #endif
1537
1538 #ifdef PNG_TIME_RFC1123_SUPPORTED
1539         png_charp time_buffer
1540         PNG_DEPSTRUCT;            /* String to hold RFC 1123 time text */
1541 #endif
1542
1543         /* New members added in libpng-1.0.6 */
1544
1545 #ifdef PNG_FREE_ME_SUPPORTED
1546         png_uint_32 free_me
1547         PNG_DEPSTRUCT;   /* flags items libpng is responsible for freeing */
1548 #endif
1549
1550 #ifdef PNG_USER_CHUNKS_SUPPORTED
1551         png_voidp user_chunk_ptr PNG_DEPSTRUCT;
1552         png_user_chunk_ptr read_user_chunk_fn
1553         PNG_DEPSTRUCT; /* user read chunk handler */
1554 #endif
1555
1556 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
1557         int num_chunk_list PNG_DEPSTRUCT;
1558         png_bytep chunk_list PNG_DEPSTRUCT;
1559 #endif
1560
1561         /* New members added in libpng-1.0.3 */
1562 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
1563         png_byte rgb_to_gray_status PNG_DEPSTRUCT;
1564         /* These were changed from png_byte in libpng-1.0.6 */
1565         png_uint_16 rgb_to_gray_red_coeff PNG_DEPSTRUCT;
1566         png_uint_16 rgb_to_gray_green_coeff PNG_DEPSTRUCT;
1567         png_uint_16 rgb_to_gray_blue_coeff PNG_DEPSTRUCT;
1568 #endif
1569
1570         /* New member added in libpng-1.0.4 (renamed in 1.0.9) */
1571 #if defined(PNG_MNG_FEATURES_SUPPORTED) || \
1572     defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
1573     defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
1574         /* Changed from png_byte to png_uint_32 at version 1.2.0 */
1575 #ifdef PNG_1_0_X
1576         png_byte mng_features_permitted PNG_DEPSTRUCT;
1577 #else
1578         png_uint_32 mng_features_permitted PNG_DEPSTRUCT;
1579 #endif /* PNG_1_0_X */
1580 #endif
1581
1582         /* New member added in libpng-1.0.7 */
1583 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
1584         png_fixed_point int_gamma PNG_DEPSTRUCT;
1585 #endif
1586
1587         /* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */
1588 #ifdef PNG_MNG_FEATURES_SUPPORTED
1589         png_byte filter_type PNG_DEPSTRUCT;
1590 #endif
1591
1592 #ifdef PNG_1_0_X
1593         /* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */
1594         png_uint_32 row_buf_size PNG_DEPSTRUCT;
1595 #endif
1596
1597         /* New members added in libpng-1.2.0 */
1598 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
1599 #  ifndef PNG_1_0_X
1600 #    ifdef PNG_MMX_CODE_SUPPORTED
1601         png_byte     mmx_bitdepth_threshold PNG_DEPSTRUCT;
1602         png_uint_32  mmx_rowbytes_threshold PNG_DEPSTRUCT;
1603 #    endif
1604         png_uint_32  asm_flags PNG_DEPSTRUCT;
1605 #  endif
1606 #endif
1607
1608         /* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
1609 #ifdef PNG_USER_MEM_SUPPORTED
1610         png_voidp mem_ptr
1611         PNG_DEPSTRUCT;            /* user supplied struct for mem functions */
1612         png_malloc_ptr malloc_fn PNG_DEPSTRUCT;     /* function for allocating memory */
1613         png_free_ptr free_fn PNG_DEPSTRUCT;         /* function for freeing memory */
1614 #endif
1615
1616         /* New member added in libpng-1.0.13 and 1.2.0 */
1617         png_bytep big_row_buf
1618         PNG_DEPSTRUCT;        /* buffer to save current (unfiltered) row */
1619
1620 #ifdef PNG_READ_DITHER_SUPPORTED
1621         /* The following three members were added at version 1.0.14 and 1.2.4 */
1622         png_bytep dither_sort PNG_DEPSTRUCT;        /* working sort array */
1623         png_bytep index_to_palette
1624         PNG_DEPSTRUCT;   /* where the original index currently is */
1625         /* in the palette */
1626         png_bytep palette_to_index
1627         PNG_DEPSTRUCT;   /* which original index points to this */
1628         /* palette color */
1629 #endif
1630
1631         /* New members added in libpng-1.0.16 and 1.2.6 */
1632         png_byte compression_type PNG_DEPSTRUCT;
1633
1634 #ifdef PNG_USER_LIMITS_SUPPORTED
1635         png_uint_32 user_width_max PNG_DEPSTRUCT;
1636         png_uint_32 user_height_max PNG_DEPSTRUCT;
1637 #endif
1638
1639         /* New member added in libpng-1.0.25 and 1.2.17 */
1640 #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
1641         /* Storage for unknown chunk that the library doesn't recognize. */
1642         png_unknown_chunk unknown_chunk PNG_DEPSTRUCT;
1643 #endif
1644
1645         /* New members added in libpng-1.2.26 */
1646         png_uint_32 old_big_row_buf_size PNG_DEPSTRUCT;
1647         png_uint_32 old_prev_row_size PNG_DEPSTRUCT;
1648
1649         /* New member added in libpng-1.2.30 */
1650         png_charp chunkdata PNG_DEPSTRUCT;  /* buffer for reading chunk data */
1651
1652
1653 };
1654
1655
1656 /* This triggers a compiler error in png.c, if png.c and png.h
1657  * do not agree upon the version number.
1658  */
1659 typedef png_structp version_1_2_50;
1660
1661 typedef png_struct FAR *FAR *png_structpp;
1662
1663 /* Here are the function definitions most commonly used.  This is not
1664  * the place to find out how to use libpng.  See libpng.txt for the
1665  * full explanation, see example.c for the summary.  This just provides
1666  * a simple one line description of the use of each function.
1667  */
1668
1669 /* Returns the version number of the library */
1670 extern PNG_EXPORT(png_uint_32, png_access_version_number) PNGARG((void));
1671
1672 /* Tell lib we have already handled the first <num_bytes> magic bytes.
1673  * Handling more than 8 bytes from the beginning of the file is an error.
1674  */
1675 extern PNG_EXPORT(void, png_set_sig_bytes) PNGARG((png_structp png_ptr,
1676                 int num_bytes));
1677
1678 /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a
1679  * PNG file.  Returns zero if the supplied bytes match the 8-byte PNG
1680  * signature, and non-zero otherwise.  Having num_to_check == 0 or
1681  * start > 7 will always fail (ie return non-zero).
1682  */
1683 extern PNG_EXPORT(int, png_sig_cmp) PNGARG((png_bytep sig, png_size_t start,
1684                 png_size_t num_to_check));
1685
1686 /* Simple signature checking function.  This is the same as calling
1687  * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
1688  */
1689 extern PNG_EXPORT(int, png_check_sig) PNGARG((png_bytep sig,
1690                 int num)) PNG_DEPRECATED;
1691
1692 /* Allocate and initialize png_ptr struct for reading, and any other memory. */
1693 extern PNG_EXPORT(png_structp, png_create_read_struct)
1694 PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
1695         png_error_ptr error_fn, png_error_ptr warn_fn)) PNG_ALLOCATED;
1696
1697 /* Allocate and initialize png_ptr struct for writing, and any other memory */
1698 extern PNG_EXPORT(png_structp, png_create_write_struct)
1699 PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
1700         png_error_ptr error_fn, png_error_ptr warn_fn)) PNG_ALLOCATED;
1701
1702 #ifdef PNG_WRITE_SUPPORTED
1703 extern PNG_EXPORT(png_uint_32, png_get_compression_buffer_size)
1704 PNGARG((png_structp png_ptr));
1705 #endif
1706
1707 #ifdef PNG_WRITE_SUPPORTED
1708 extern PNG_EXPORT(void, png_set_compression_buffer_size)
1709 PNGARG((png_structp png_ptr, png_uint_32 size));
1710 #endif
1711
1712 /* Reset the compression stream */
1713 extern PNG_EXPORT(int, png_reset_zstream) PNGARG((png_structp png_ptr));
1714
1715 /* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */
1716 #ifdef PNG_USER_MEM_SUPPORTED
1717 extern PNG_EXPORT(png_structp, png_create_read_struct_2)
1718 PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
1719         png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
1720         png_malloc_ptr malloc_fn, png_free_ptr free_fn)) PNG_ALLOCATED;
1721 extern PNG_EXPORT(png_structp, png_create_write_struct_2)
1722 PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
1723         png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
1724         png_malloc_ptr malloc_fn, png_free_ptr free_fn)) PNG_ALLOCATED;
1725 #endif
1726
1727 /* Write a PNG chunk - size, type, (optional) data, CRC. */
1728 extern PNG_EXPORT(void, png_write_chunk) PNGARG((png_structp png_ptr,
1729                 png_bytep chunk_name, png_bytep data, png_size_t length));
1730
1731 /* Write the start of a PNG chunk - length and chunk name. */
1732 extern PNG_EXPORT(void, png_write_chunk_start) PNGARG((png_structp png_ptr,
1733                 png_bytep chunk_name, png_uint_32 length));
1734
1735 /* Write the data of a PNG chunk started with png_write_chunk_start(). */
1736 extern PNG_EXPORT(void, png_write_chunk_data) PNGARG((png_structp png_ptr,
1737                 png_bytep data, png_size_t length));
1738
1739 /* Finish a chunk started with png_write_chunk_start() (includes CRC). */
1740 extern PNG_EXPORT(void, png_write_chunk_end) PNGARG((png_structp png_ptr));
1741
1742 /* Allocate and initialize the info structure */
1743 extern PNG_EXPORT(png_infop, png_create_info_struct)
1744 PNGARG((png_structp png_ptr)) PNG_ALLOCATED;
1745
1746 #if defined(PNG_1_0_X) || defined (PNG_1_2_X)
1747 /* Initialize the info structure (old interface - DEPRECATED) */
1748 extern PNG_EXPORT(void, png_info_init) PNGARG((png_infop info_ptr))
1749 PNG_DEPRECATED;
1750 #undef png_info_init
1751 #define png_info_init(info_ptr) png_info_init_3(&info_ptr,\
1752     png_sizeof(png_info));
1753 #endif
1754
1755 extern PNG_EXPORT(void, png_info_init_3) PNGARG((png_infopp info_ptr,
1756                 png_size_t png_info_struct_size));
1757
1758 /* Writes all the PNG information before the image. */
1759 extern PNG_EXPORT(void, png_write_info_before_PLTE) PNGARG((png_structp png_ptr,
1760                 png_infop info_ptr));
1761 extern PNG_EXPORT(void, png_write_info) PNGARG((png_structp png_ptr,
1762                 png_infop info_ptr));
1763
1764 #ifdef PNG_SEQUENTIAL_READ_SUPPORTED
1765 /* Read the information before the actual image data. */
1766 extern PNG_EXPORT(void, png_read_info) PNGARG((png_structp png_ptr,
1767                 png_infop info_ptr));
1768 #endif
1769
1770 #ifdef PNG_TIME_RFC1123_SUPPORTED
1771 extern PNG_EXPORT(png_charp, png_convert_to_rfc1123)
1772 PNGARG((png_structp png_ptr, png_timep ptime));
1773 #endif
1774
1775 #ifdef PNG_CONVERT_tIME_SUPPORTED
1776 /* Convert from a struct tm to png_time */
1777 extern PNG_EXPORT(void, png_convert_from_struct_tm) PNGARG((png_timep ptime,
1778                 struct tm FAR *ttime));
1779
1780 /* Convert from time_t to png_time.  Uses gmtime() */
1781 extern PNG_EXPORT(void, png_convert_from_time_t) PNGARG((png_timep ptime,
1782                 time_t ttime));
1783 #endif /* PNG_CONVERT_tIME_SUPPORTED */
1784
1785 #ifdef PNG_READ_EXPAND_SUPPORTED
1786 /* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
1787 extern PNG_EXPORT(void, png_set_expand) PNGARG((png_structp png_ptr));
1788 #ifndef PNG_1_0_X
1789 extern PNG_EXPORT(void, png_set_expand_gray_1_2_4_to_8) PNGARG((png_structp
1790                 png_ptr));
1791 #endif
1792 extern PNG_EXPORT(void, png_set_palette_to_rgb) PNGARG((png_structp png_ptr));
1793 extern PNG_EXPORT(void, png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr));
1794 #if defined(PNG_1_0_X) || defined (PNG_1_2_X)
1795 /* Deprecated */
1796 extern PNG_EXPORT(void, png_set_gray_1_2_4_to_8) PNGARG((png_structp
1797                 png_ptr)) PNG_DEPRECATED;
1798 #endif
1799 #endif
1800
1801 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
1802 /* Use blue, green, red order for pixels. */
1803 extern PNG_EXPORT(void, png_set_bgr) PNGARG((png_structp png_ptr));
1804 #endif
1805
1806 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
1807 /* Expand the grayscale to 24-bit RGB if necessary. */
1808 extern PNG_EXPORT(void, png_set_gray_to_rgb) PNGARG((png_structp png_ptr));
1809 #endif
1810
1811 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
1812 /* Reduce RGB to grayscale. */
1813 #ifdef PNG_FLOATING_POINT_SUPPORTED
1814 extern PNG_EXPORT(void, png_set_rgb_to_gray) PNGARG((png_structp png_ptr,
1815                 int error_action, double red, double green ));
1816 #endif
1817 extern PNG_EXPORT(void, png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr,
1818                 int error_action, png_fixed_point red, png_fixed_point green ));
1819 extern PNG_EXPORT(png_byte, png_get_rgb_to_gray_status) PNGARG((png_structp
1820                 png_ptr));
1821 #endif
1822
1823 extern PNG_EXPORT(void, png_build_grayscale_palette) PNGARG((int bit_depth,
1824                 png_colorp palette));
1825
1826 #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
1827 extern PNG_EXPORT(void, png_set_strip_alpha) PNGARG((png_structp png_ptr));
1828 #endif
1829
1830 #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
1831     defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
1832 extern PNG_EXPORT(void, png_set_swap_alpha) PNGARG((png_structp png_ptr));
1833 #endif
1834
1835 #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
1836     defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
1837 extern PNG_EXPORT(void, png_set_invert_alpha) PNGARG((png_structp png_ptr));
1838 #endif
1839
1840 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
1841 /* Add a filler byte to 8-bit Gray or 24-bit RGB images. */
1842 extern PNG_EXPORT(void, png_set_filler) PNGARG((png_structp png_ptr,
1843                 png_uint_32 filler, int flags));
1844 /* The values of the PNG_FILLER_ defines should NOT be changed */
1845 #define PNG_FILLER_BEFORE 0
1846 #define PNG_FILLER_AFTER 1
1847 /* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */
1848 #ifndef PNG_1_0_X
1849 extern PNG_EXPORT(void, png_set_add_alpha) PNGARG((png_structp png_ptr,
1850                 png_uint_32 filler, int flags));
1851 #endif
1852 #endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */
1853
1854 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
1855 /* Swap bytes in 16-bit depth files. */
1856 extern PNG_EXPORT(void, png_set_swap) PNGARG((png_structp png_ptr));
1857 #endif
1858
1859 #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
1860 /* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */
1861 extern PNG_EXPORT(void, png_set_packing) PNGARG((png_structp png_ptr));
1862 #endif
1863
1864 #if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
1865 /* Swap packing order of pixels in bytes. */
1866 extern PNG_EXPORT(void, png_set_packswap) PNGARG((png_structp png_ptr));
1867 #endif
1868
1869 #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
1870 /* Converts files to legal bit depths. */
1871 extern PNG_EXPORT(void, png_set_shift) PNGARG((png_structp png_ptr,
1872                 png_color_8p true_bits));
1873 #endif
1874
1875 #if defined(PNG_READ_INTERLACING_SUPPORTED) || \
1876     defined(PNG_WRITE_INTERLACING_SUPPORTED)
1877 /* Have the code handle the interlacing.  Returns the number of passes. */
1878 extern PNG_EXPORT(int, png_set_interlace_handling) PNGARG((
1879                         png_structp png_ptr));
1880 #endif
1881
1882 #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
1883 /* Invert monochrome files */
1884 extern PNG_EXPORT(void, png_set_invert_mono) PNGARG((png_structp png_ptr));
1885 #endif
1886
1887 #ifdef PNG_READ_BACKGROUND_SUPPORTED
1888 /* Handle alpha and tRNS by replacing with a background color. */
1889 #ifdef PNG_FLOATING_POINT_SUPPORTED
1890 extern PNG_EXPORT(void, png_set_background) PNGARG((png_structp png_ptr,
1891                 png_color_16p background_color, int background_gamma_code,
1892                 int need_expand, double background_gamma));
1893 #endif
1894 #define PNG_BACKGROUND_GAMMA_UNKNOWN 0
1895 #define PNG_BACKGROUND_GAMMA_SCREEN  1
1896 #define PNG_BACKGROUND_GAMMA_FILE    2
1897 #define PNG_BACKGROUND_GAMMA_UNIQUE  3
1898 #endif
1899
1900 #ifdef PNG_READ_16_TO_8_SUPPORTED
1901 /* Strip the second byte of information from a 16-bit depth file. */
1902 extern PNG_EXPORT(void, png_set_strip_16) PNGARG((png_structp png_ptr));
1903 #endif
1904
1905 #ifdef PNG_READ_DITHER_SUPPORTED
1906 /* Turn on dithering, and reduce the palette to the number of colors available. */
1907 extern PNG_EXPORT(void, png_set_dither) PNGARG((png_structp png_ptr,
1908                 png_colorp palette, int num_palette, int maximum_colors,
1909                 png_uint_16p histogram, int full_dither));
1910 #endif
1911
1912 #ifdef PNG_READ_GAMMA_SUPPORTED
1913 /* Handle gamma correction. Screen_gamma=(display_exponent) */
1914 #ifdef PNG_FLOATING_POINT_SUPPORTED
1915 extern PNG_EXPORT(void, png_set_gamma) PNGARG((png_structp png_ptr,
1916                 double screen_gamma, double default_file_gamma));
1917 #endif
1918 #endif
1919
1920 #if defined(PNG_1_0_X) || defined (PNG_1_2_X)
1921 #if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
1922     defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
1923 /* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */
1924 /* Deprecated and will be removed.  Use png_permit_mng_features() instead. */
1925 extern PNG_EXPORT(void, png_permit_empty_plte) PNGARG((png_structp png_ptr,
1926                 int empty_plte_permitted)) PNG_DEPRECATED;
1927 #endif
1928 #endif
1929
1930 #ifdef PNG_WRITE_FLUSH_SUPPORTED
1931 /* Set how many lines between output flushes - 0 for no flushing */
1932 extern PNG_EXPORT(void, png_set_flush) PNGARG((png_structp png_ptr, int nrows));
1933 /* Flush the current PNG output buffer */
1934 extern PNG_EXPORT(void, png_write_flush) PNGARG((png_structp png_ptr));
1935 #endif
1936
1937 /* Optional update palette with requested transformations */
1938 extern PNG_EXPORT(void, png_start_read_image) PNGARG((png_structp png_ptr));
1939
1940 /* Optional call to update the users info structure */
1941 extern PNG_EXPORT(void, png_read_update_info) PNGARG((png_structp png_ptr,
1942                 png_infop info_ptr));
1943
1944 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
1945 /* Read one or more rows of image data. */
1946 extern PNG_EXPORT(void, png_read_rows) PNGARG((png_structp png_ptr,
1947                 png_bytepp row, png_bytepp display_row, png_uint_32 num_rows));
1948 #endif
1949
1950 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
1951 /* Read a row of data. */
1952 extern PNG_EXPORT(void, png_read_row) PNGARG((png_structp png_ptr,
1953                 png_bytep row,
1954                 png_bytep display_row));
1955 #endif
1956
1957 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
1958 /* Read the whole image into memory at once. */
1959 extern PNG_EXPORT(void, png_read_image) PNGARG((png_structp png_ptr,
1960                 png_bytepp image));
1961 #endif
1962
1963 /* Write a row of image data */
1964 extern PNG_EXPORT(void, png_write_row) PNGARG((png_structp png_ptr,
1965                 png_bytep row));
1966
1967 /* Write a few rows of image data */
1968 extern PNG_EXPORT(void, png_write_rows) PNGARG((png_structp png_ptr,
1969                 png_bytepp row, png_uint_32 num_rows));
1970
1971 /* Write the image data */
1972 extern PNG_EXPORT(void, png_write_image) PNGARG((png_structp png_ptr,
1973                 png_bytepp image));
1974
1975 /* Writes the end of the PNG file. */
1976 extern PNG_EXPORT(void, png_write_end) PNGARG((png_structp png_ptr,
1977                 png_infop info_ptr));
1978
1979 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
1980 /* Read the end of the PNG file. */
1981 extern PNG_EXPORT(void, png_read_end) PNGARG((png_structp png_ptr,
1982                 png_infop info_ptr));
1983 #endif
1984
1985 /* Free any memory associated with the png_info_struct */
1986 extern PNG_EXPORT(void, png_destroy_info_struct) PNGARG((png_structp png_ptr,
1987                 png_infopp info_ptr_ptr));
1988
1989 /* Free any memory associated with the png_struct and the png_info_structs */
1990 extern PNG_EXPORT(void, png_destroy_read_struct) PNGARG((png_structpp
1991                 png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));
1992
1993 /* Free all memory used by the read (old method - NOT DLL EXPORTED) */
1994 extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
1995                                      png_infop end_info_ptr)) PNG_DEPRECATED;
1996
1997 /* Free any memory associated with the png_struct and the png_info_structs */
1998 extern PNG_EXPORT(void, png_destroy_write_struct)
1999 PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr));
2000
2001 /* Free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
2002 extern void png_write_destroy PNGARG((png_structp png_ptr)) PNG_DEPRECATED;
2003
2004 /* Set the libpng method of handling chunk CRC errors */
2005 extern PNG_EXPORT(void, png_set_crc_action) PNGARG((png_structp png_ptr,
2006                 int crit_action, int ancil_action));
2007
2008 /* Values for png_set_crc_action() to say how to handle CRC errors in
2009  * ancillary and critical chunks, and whether to use the data contained
2010  * therein.  Note that it is impossible to "discard" data in a critical
2011  * chunk.  For versions prior to 0.90, the action was always error/quit,
2012  * whereas in version 0.90 and later, the action for CRC errors in ancillary
2013  * chunks is warn/discard.  These values should NOT be changed.
2014  *
2015  *      value                       action:critical     action:ancillary
2016  */
2017 #define PNG_CRC_DEFAULT       0  /* error/quit          warn/discard data */
2018 #define PNG_CRC_ERROR_QUIT    1  /* error/quit          error/quit        */
2019 #define PNG_CRC_WARN_DISCARD  2  /* (INVALID)           warn/discard data */
2020 #define PNG_CRC_WARN_USE      3  /* warn/use data       warn/use data     */
2021 #define PNG_CRC_QUIET_USE     4  /* quiet/use data      quiet/use data    */
2022 #define PNG_CRC_NO_CHANGE     5  /* use current value   use current value */
2023
2024 /* These functions give the user control over the scan-line filtering in
2025  * libpng and the compression methods used by zlib.  These functions are
2026  * mainly useful for testing, as the defaults should work with most users.
2027  * Those users who are tight on memory or want faster performance at the
2028  * expense of compression can modify them.  See the compression library
2029  * header file (zlib.h) for an explination of the compression functions.
2030  */
2031
2032 /* Set the filtering method(s) used by libpng.  Currently, the only valid
2033  * value for "method" is 0.
2034  */
2035 extern PNG_EXPORT(void, png_set_filter) PNGARG((png_structp png_ptr, int method,
2036                 int filters));
2037
2038 /* Flags for png_set_filter() to say which filters to use.  The flags
2039  * are chosen so that they don't conflict with real filter types
2040  * below, in case they are supplied instead of the #defined constants.
2041  * These values should NOT be changed.
2042  */
2043 #define PNG_NO_FILTERS     0x00
2044 #define PNG_FILTER_NONE    0x08
2045 #define PNG_FILTER_SUB     0x10
2046 #define PNG_FILTER_UP      0x20
2047 #define PNG_FILTER_AVG     0x40
2048 #define PNG_FILTER_PAETH   0x80
2049 #define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
2050                          PNG_FILTER_AVG | PNG_FILTER_PAETH)
2051
2052 /* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
2053  * These defines should NOT be changed.
2054  */
2055 #define PNG_FILTER_VALUE_NONE  0
2056 #define PNG_FILTER_VALUE_SUB   1
2057 #define PNG_FILTER_VALUE_UP    2
2058 #define PNG_FILTER_VALUE_AVG   3
2059 #define PNG_FILTER_VALUE_PAETH 4
2060 #define PNG_FILTER_VALUE_LAST  5
2061
2062 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */
2063 /* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_
2064  * defines, either the default (minimum-sum-of-absolute-differences), or
2065  * the experimental method (weighted-minimum-sum-of-absolute-differences).
2066  *
2067  * Weights are factors >= 1.0, indicating how important it is to keep the
2068  * filter type consistent between rows.  Larger numbers mean the current
2069  * filter is that many times as likely to be the same as the "num_weights"
2070  * previous filters.  This is cumulative for each previous row with a weight.
2071  * There needs to be "num_weights" values in "filter_weights", or it can be
2072  * NULL if the weights aren't being specified.  Weights have no influence on
2073  * the selection of the first row filter.  Well chosen weights can (in theory)
2074  * improve the compression for a given image.
2075  *
2076  * Costs are factors >= 1.0 indicating the relative decoding costs of a
2077  * filter type.  Higher costs indicate more decoding expense, and are
2078  * therefore less likely to be selected over a filter with lower computational
2079  * costs.  There needs to be a value in "filter_costs" for each valid filter
2080  * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't
2081  * setting the costs.  Costs try to improve the speed of decompression without
2082  * unduly increasing the compressed image size.
2083  *
2084  * A negative weight or cost indicates the default value is to be used, and
2085  * values in the range [0.0, 1.0) indicate the value is to remain unchanged.
2086  * The default values for both weights and costs are currently 1.0, but may
2087  * change if good general weighting/cost heuristics can be found.  If both
2088  * the weights and costs are set to 1.0, this degenerates the WEIGHTED method
2089  * to the UNWEIGHTED method, but with added encoding time/computation.
2090  */
2091 #ifdef PNG_FLOATING_POINT_SUPPORTED
2092 extern PNG_EXPORT(void, png_set_filter_heuristics) PNGARG((png_structp png_ptr,
2093                 int heuristic_method, int num_weights, png_doublep filter_weights,
2094                 png_doublep filter_costs));
2095 #endif
2096 #endif /*  PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
2097
2098 /* Heuristic used for row filter selection.  These defines should NOT be
2099  * changed.
2100  */
2101 #define PNG_FILTER_HEURISTIC_DEFAULT    0  /* Currently "UNWEIGHTED" */
2102 #define PNG_FILTER_HEURISTIC_UNWEIGHTED 1  /* Used by libpng < 0.95 */
2103 #define PNG_FILTER_HEURISTIC_WEIGHTED   2  /* Experimental feature */
2104 #define PNG_FILTER_HEURISTIC_LAST       3  /* Not a valid value */
2105
2106 /* Set the library compression level.  Currently, valid values range from
2107  * 0 - 9, corresponding directly to the zlib compression levels 0 - 9
2108  * (0 - no compression, 9 - "maximal" compression).  Note that tests have
2109  * shown that zlib compression levels 3-6 usually perform as well as level 9
2110  * for PNG images, and do considerably fewer caclulations.  In the future,
2111  * these values may not correspond directly to the zlib compression levels.
2112  */
2113 extern PNG_EXPORT(void, png_set_compression_level) PNGARG((png_structp png_ptr,
2114                 int level));
2115
2116 extern PNG_EXPORT(void, png_set_compression_mem_level)
2117 PNGARG((png_structp png_ptr, int mem_level));
2118
2119 extern PNG_EXPORT(void, png_set_compression_strategy)
2120 PNGARG((png_structp png_ptr, int strategy));
2121
2122 extern PNG_EXPORT(void, png_set_compression_window_bits)
2123 PNGARG((png_structp png_ptr, int window_bits));
2124
2125 extern PNG_EXPORT(void, png_set_compression_method) PNGARG((png_structp png_ptr,
2126                 int method));
2127
2128 /* These next functions are called for input/output, memory, and error
2129  * handling.  They are in the file pngrio.c, pngwio.c, and pngerror.c,
2130  * and call standard C I/O routines such as fread(), fwrite(), and
2131  * fprintf().  These functions can be made to use other I/O routines
2132  * at run time for those applications that need to handle I/O in a
2133  * different manner by calling png_set_???_fn().  See libpng.txt for
2134  * more information.
2135  */
2136
2137 #ifdef PNG_STDIO_SUPPORTED
2138 /* Initialize the input/output for the PNG file to the default functions. */
2139 extern PNG_EXPORT(void, png_init_io) PNGARG((png_structp png_ptr,
2140                 png_FILE_p fp));
2141 #endif
2142
2143 /* Replace the (error and abort), and warning functions with user
2144  * supplied functions.  If no messages are to be printed you must still
2145  * write and use replacement functions. The replacement error_fn should
2146  * still do a longjmp to the last setjmp location if you are using this
2147  * method of error handling.  If error_fn or warning_fn is NULL, the
2148  * default function will be used.
2149  */
2150
2151 extern PNG_EXPORT(void, png_set_error_fn) PNGARG((png_structp png_ptr,
2152                 png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));
2153
2154 /* Return the user pointer associated with the error functions */
2155 extern PNG_EXPORT(png_voidp, png_get_error_ptr) PNGARG((png_structp png_ptr));
2156
2157 /* Replace the default data output functions with a user supplied one(s).
2158  * If buffered output is not used, then output_flush_fn can be set to NULL.
2159  * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time
2160  * output_flush_fn will be ignored (and thus can be NULL).
2161  * It is probably a mistake to use NULL for output_flush_fn if
2162  * write_data_fn is not also NULL unless you have built libpng with
2163  * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's
2164  * default flush function, which uses the standard *FILE structure, will
2165  * be used.
2166  */
2167 extern PNG_EXPORT(void, png_set_write_fn) PNGARG((png_structp png_ptr,
2168                 png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));
2169
2170 /* Replace the default data input function with a user supplied one. */
2171 extern PNG_EXPORT(void, png_set_read_fn) PNGARG((png_structp png_ptr,
2172                 png_voidp io_ptr, png_rw_ptr read_data_fn));
2173
2174 /* Return the user pointer associated with the I/O functions */
2175 extern PNG_EXPORT(png_voidp, png_get_io_ptr) PNGARG((png_structp png_ptr));
2176
2177 extern PNG_EXPORT(void, png_set_read_status_fn) PNGARG((png_structp png_ptr,
2178                 png_read_status_ptr read_row_fn));
2179
2180 extern PNG_EXPORT(void, png_set_write_status_fn) PNGARG((png_structp png_ptr,
2181                 png_write_status_ptr write_row_fn));
2182
2183 #ifdef PNG_USER_MEM_SUPPORTED
2184 /* Replace the default memory allocation functions with user supplied one(s). */
2185 extern PNG_EXPORT(void, png_set_mem_fn) PNGARG((png_structp png_ptr,
2186                 png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn));
2187 /* Return the user pointer associated with the memory functions */
2188 extern PNG_EXPORT(png_voidp, png_get_mem_ptr) PNGARG((png_structp png_ptr));
2189 #endif
2190
2191 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
2192     defined(PNG_LEGACY_SUPPORTED)
2193 extern PNG_EXPORT(void, png_set_read_user_transform_fn) PNGARG((png_structp
2194                 png_ptr, png_user_transform_ptr read_user_transform_fn));
2195 #endif
2196
2197 #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
2198     defined(PNG_LEGACY_SUPPORTED)
2199 extern PNG_EXPORT(void, png_set_write_user_transform_fn) PNGARG((png_structp
2200                 png_ptr, png_user_transform_ptr write_user_transform_fn));
2201 #endif
2202
2203 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
2204     defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
2205     defined(PNG_LEGACY_SUPPORTED)
2206 extern PNG_EXPORT(void, png_set_user_transform_info) PNGARG((png_structp
2207                 png_ptr, png_voidp user_transform_ptr, int user_transform_depth,
2208                 int user_transform_channels));
2209 /* Return the user pointer associated with the user transform functions */
2210 extern PNG_EXPORT(png_voidp, png_get_user_transform_ptr)
2211 PNGARG((png_structp png_ptr));
2212 #endif
2213
2214 #ifdef PNG_USER_CHUNKS_SUPPORTED
2215 extern PNG_EXPORT(void, png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr,
2216                 png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));
2217 extern PNG_EXPORT(png_voidp, png_get_user_chunk_ptr) PNGARG((png_structp
2218                 png_ptr));
2219 #endif
2220
2221 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
2222 /* Sets the function callbacks for the push reader, and a pointer to a
2223  * user-defined structure available to the callback functions.
2224  */
2225 extern PNG_EXPORT(void, png_set_progressive_read_fn) PNGARG((
2226                         png_structp png_ptr,
2227                         png_voidp progressive_ptr,
2228                         png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
2229                         png_progressive_end_ptr end_fn));
2230
2231 /* Returns the user pointer associated with the push read functions */
2232 extern PNG_EXPORT(png_voidp, png_get_progressive_ptr)
2233 PNGARG((png_structp png_ptr));
2234
2235 /* Function to be called when data becomes available */
2236 extern PNG_EXPORT(void, png_process_data) PNGARG((png_structp png_ptr,
2237                 png_infop info_ptr, png_bytep buffer, png_size_t buffer_size));
2238
2239 /* Function that combines rows.  Not very much different than the
2240  * png_combine_row() call.  Is this even used?????
2241  */
2242 extern PNG_EXPORT(void, png_progressive_combine_row) PNGARG((
2243                         png_structp png_ptr,
2244                         png_bytep old_row, png_bytep new_row));
2245 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
2246
2247 extern PNG_EXPORT(png_voidp, png_malloc) PNGARG((png_structp png_ptr,
2248                 png_uint_32 size)) PNG_ALLOCATED;
2249
2250 #ifdef PNG_1_0_X
2251 #  define png_malloc_warn png_malloc
2252 #else
2253 /* Added at libpng version 1.2.4 */
2254 extern PNG_EXPORT(png_voidp, png_malloc_warn) PNGARG((png_structp png_ptr,
2255                 png_uint_32 size)) PNG_ALLOCATED;
2256 #endif
2257
2258 /* Frees a pointer allocated by png_malloc() */
2259 extern PNG_EXPORT(void, png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
2260
2261 #ifdef PNG_1_0_X
2262 /* Function to allocate memory for zlib. */
2263 extern PNG_EXPORT(voidpf, png_zalloc) PNGARG((voidpf png_ptr, uInt items,
2264                 uInt size));
2265
2266 /* Function to free memory for zlib */
2267 extern PNG_EXPORT(void, png_zfree) PNGARG((voidpf png_ptr, voidpf ptr));
2268 #endif
2269
2270 /* Free data that was allocated internally */
2271 extern PNG_EXPORT(void, png_free_data) PNGARG((png_structp png_ptr,
2272                 png_infop info_ptr, png_uint_32 free_me, int num));
2273 #ifdef PNG_FREE_ME_SUPPORTED
2274 /* Reassign responsibility for freeing existing data, whether allocated
2275  * by libpng or by the application
2276  */
2277 extern PNG_EXPORT(void, png_data_freer) PNGARG((png_structp png_ptr,
2278                 png_infop info_ptr, int freer, png_uint_32 mask));
2279 #endif
2280 /* Assignments for png_data_freer */
2281 #define PNG_DESTROY_WILL_FREE_DATA 1
2282 #define PNG_SET_WILL_FREE_DATA 1
2283 #define PNG_USER_WILL_FREE_DATA 2
2284 /* Flags for png_ptr->free_me and info_ptr->free_me */
2285 #define PNG_FREE_HIST 0x0008
2286 #define PNG_FREE_ICCP 0x0010
2287 #define PNG_FREE_SPLT 0x0020
2288 #define PNG_FREE_ROWS 0x0040
2289 #define PNG_FREE_PCAL 0x0080
2290 #define PNG_FREE_SCAL 0x0100
2291 #define PNG_FREE_UNKN 0x0200
2292 #define PNG_FREE_LIST 0x0400
2293 #define PNG_FREE_PLTE 0x1000
2294 #define PNG_FREE_TRNS 0x2000
2295 #define PNG_FREE_TEXT 0x4000
2296 #define PNG_FREE_ALL  0x7fff
2297 #define PNG_FREE_MUL  0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
2298
2299 #ifdef PNG_USER_MEM_SUPPORTED
2300 extern PNG_EXPORT(png_voidp, png_malloc_default) PNGARG((png_structp png_ptr,
2301                 png_uint_32 size)) PNG_ALLOCATED;
2302 extern PNG_EXPORT(void, png_free_default) PNGARG((png_structp png_ptr,
2303                 png_voidp ptr));
2304 #endif
2305
2306 extern PNG_EXPORT(png_voidp, png_memcpy_check) PNGARG((png_structp png_ptr,
2307                 png_voidp s1, png_voidp s2, png_uint_32 size)) PNG_DEPRECATED;
2308
2309 extern PNG_EXPORT(png_voidp, png_memset_check) PNGARG((png_structp png_ptr,
2310                 png_voidp s1, int value, png_uint_32 size)) PNG_DEPRECATED;
2311
2312 #if defined(USE_FAR_KEYWORD)  /* memory model conversion function */
2313 extern void *png_far_to_near PNGARG((png_structp png_ptr, png_voidp ptr,
2314                                      int check));
2315 #endif /* USE_FAR_KEYWORD */
2316
2317 #ifndef PNG_NO_ERROR_TEXT
2318 /* Fatal error in PNG image of libpng - can't continue */
2319 extern PNG_EXPORT(void, png_error) PNGARG((png_structp png_ptr,
2320                 png_const_charp error_message)) PNG_NORETURN;
2321
2322 /* The same, but the chunk name is prepended to the error string. */
2323 extern PNG_EXPORT(void, png_chunk_error) PNGARG((png_structp png_ptr,
2324                 png_const_charp error_message)) PNG_NORETURN;
2325 #else
2326 /* Fatal error in PNG image of libpng - can't continue */
2327 extern PNG_EXPORT(void, png_err) PNGARG((png_structp png_ptr)) PNG_NORETURN;
2328 #endif
2329
2330 #ifndef PNG_NO_WARNINGS
2331 /* Non-fatal error in libpng.  Can continue, but may have a problem. */
2332 extern PNG_EXPORT(void, png_warning) PNGARG((png_structp png_ptr,
2333                 png_const_charp warning_message));
2334
2335 #ifdef PNG_READ_SUPPORTED
2336 /* Non-fatal error in libpng, chunk name is prepended to message. */
2337 extern PNG_EXPORT(void, png_chunk_warning) PNGARG((png_structp png_ptr,
2338                 png_const_charp warning_message));
2339 #endif /* PNG_READ_SUPPORTED */
2340 #endif /* PNG_NO_WARNINGS */
2341
2342 /* The png_set_<chunk> functions are for storing values in the png_info_struct.
2343  * Similarly, the png_get_<chunk> calls are used to read values from the
2344  * png_info_struct, either storing the parameters in the passed variables, or
2345  * setting pointers into the png_info_struct where the data is stored.  The
2346  * png_get_<chunk> functions return a non-zero value if the data was available
2347  * in info_ptr, or return zero and do not change any of the parameters if the
2348  * data was not available.
2349  *
2350  * These functions should be used instead of directly accessing png_info
2351  * to avoid problems with future changes in the size and internal layout of
2352  * png_info_struct.
2353  */
2354 /* Returns "flag" if chunk data is valid in info_ptr. */
2355 extern PNG_EXPORT(png_uint_32, png_get_valid) PNGARG((png_structp png_ptr,
2356                 png_infop info_ptr, png_uint_32 flag));
2357
2358 /* Returns number of bytes needed to hold a transformed row. */
2359 extern PNG_EXPORT(png_uint_32, png_get_rowbytes) PNGARG((png_structp png_ptr,
2360                 png_infop info_ptr));
2361
2362 #ifdef PNG_INFO_IMAGE_SUPPORTED
2363 /* Returns row_pointers, which is an array of pointers to scanlines that was
2364  * returned from png_read_png().
2365  */
2366 extern PNG_EXPORT(png_bytepp, png_get_rows) PNGARG((png_structp png_ptr,
2367                 png_infop info_ptr));
2368 /* Set row_pointers, which is an array of pointers to scanlines for use
2369  * by png_write_png().
2370  */
2371 extern PNG_EXPORT(void, png_set_rows) PNGARG((png_structp png_ptr,
2372                 png_infop info_ptr, png_bytepp row_pointers));
2373 #endif
2374
2375 /* Returns number of color channels in image. */
2376 extern PNG_EXPORT(png_byte, png_get_channels) PNGARG((png_structp png_ptr,
2377                 png_infop info_ptr));
2378
2379 #ifdef PNG_EASY_ACCESS_SUPPORTED
2380 /* Returns image width in pixels. */
2381 extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp
2382                 png_ptr, png_infop info_ptr));
2383
2384 /* Returns image height in pixels. */
2385 extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp
2386                 png_ptr, png_infop info_ptr));
2387
2388 /* Returns image bit_depth. */
2389 extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp
2390                 png_ptr, png_infop info_ptr));
2391
2392 /* Returns image color_type. */
2393 extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp
2394                 png_ptr, png_infop info_ptr));
2395
2396 /* Returns image filter_type. */
2397 extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp
2398                 png_ptr, png_infop info_ptr));
2399
2400 /* Returns image interlace_type. */
2401 extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp
2402                 png_ptr, png_infop info_ptr));
2403
2404 /* Returns image compression_type. */
2405 extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp
2406                 png_ptr, png_infop info_ptr));
2407
2408 /* Returns image resolution in pixels per meter, from pHYs chunk data. */
2409 extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp
2410                 png_ptr, png_infop info_ptr));
2411 extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp
2412                 png_ptr, png_infop info_ptr));
2413 extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp
2414                 png_ptr, png_infop info_ptr));
2415
2416 /* Returns pixel aspect ratio, computed from pHYs chunk data.  */
2417 #ifdef PNG_FLOATING_POINT_SUPPORTED
2418 extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp
2419                 png_ptr, png_infop info_ptr));
2420 #endif
2421
2422 /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
2423 extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp
2424                 png_ptr, png_infop info_ptr));
2425 extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp
2426                 png_ptr, png_infop info_ptr));
2427 extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp
2428                 png_ptr, png_infop info_ptr));
2429 extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp
2430                 png_ptr, png_infop info_ptr));
2431
2432 #endif /* PNG_EASY_ACCESS_SUPPORTED */
2433
2434 /* Returns pointer to signature string read from PNG header */
2435 extern PNG_EXPORT(png_bytep, png_get_signature) PNGARG((png_structp png_ptr,
2436                 png_infop info_ptr));
2437
2438 #ifdef PNG_bKGD_SUPPORTED
2439 extern PNG_EXPORT(png_uint_32, png_get_bKGD) PNGARG((png_structp png_ptr,
2440                 png_infop info_ptr, png_color_16p *background));
2441 #endif
2442
2443 #ifdef PNG_bKGD_SUPPORTED
2444 extern PNG_EXPORT(void, png_set_bKGD) PNGARG((png_structp png_ptr,
2445                 png_infop info_ptr, png_color_16p background));
2446 #endif
2447
2448 #ifdef PNG_cHRM_SUPPORTED
2449 #ifdef PNG_FLOATING_POINT_SUPPORTED
2450 extern PNG_EXPORT(png_uint_32, png_get_cHRM) PNGARG((png_structp png_ptr,
2451                 png_infop info_ptr, double *white_x, double *white_y, double *red_x,
2452                 double *red_y, double *green_x, double *green_y, double *blue_x,
2453                 double *blue_y));
2454 #endif
2455 #ifdef PNG_FIXED_POINT_SUPPORTED
2456 extern PNG_EXPORT(png_uint_32, png_get_cHRM_fixed) PNGARG((png_structp png_ptr,
2457                 png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point
2458                 *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y,
2459                 png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point
2460                 *int_blue_x, png_fixed_point *int_blue_y));
2461 #endif
2462 #endif
2463
2464 #ifdef PNG_cHRM_SUPPORTED
2465 #ifdef PNG_FLOATING_POINT_SUPPORTED
2466 extern PNG_EXPORT(void, png_set_cHRM) PNGARG((png_structp png_ptr,
2467                 png_infop info_ptr, double white_x, double white_y, double red_x,
2468                 double red_y, double green_x, double green_y, double blue_x, double blue_y));
2469 #endif
2470 #ifdef PNG_FIXED_POINT_SUPPORTED
2471 extern PNG_EXPORT(void, png_set_cHRM_fixed) PNGARG((png_structp png_ptr,
2472                 png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y,
2473                 png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
2474                 int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
2475                 png_fixed_point int_blue_y));
2476 #endif
2477 #endif
2478
2479 #ifdef PNG_gAMA_SUPPORTED
2480 #ifdef PNG_FLOATING_POINT_SUPPORTED
2481 extern PNG_EXPORT(png_uint_32, png_get_gAMA) PNGARG((png_structp png_ptr,
2482                 png_infop info_ptr, double *file_gamma));
2483 #endif
2484 extern PNG_EXPORT(png_uint_32, png_get_gAMA_fixed) PNGARG((png_structp png_ptr,
2485                 png_infop info_ptr, png_fixed_point *int_file_gamma));
2486 #endif
2487
2488 #ifdef PNG_gAMA_SUPPORTED
2489 #ifdef PNG_FLOATING_POINT_SUPPORTED
2490 extern PNG_EXPORT(void, png_set_gAMA) PNGARG((png_structp png_ptr,
2491                 png_infop info_ptr, double file_gamma));
2492 #endif
2493 extern PNG_EXPORT(void, png_set_gAMA_fixed) PNGARG((png_structp png_ptr,
2494                 png_infop info_ptr, png_fixed_point int_file_gamma));
2495 #endif
2496
2497 #ifdef PNG_hIST_SUPPORTED
2498 extern PNG_EXPORT(png_uint_32, png_get_hIST) PNGARG((png_structp png_ptr,
2499                 png_infop info_ptr, png_uint_16p *hist));
2500 #endif
2501
2502 #ifdef PNG_hIST_SUPPORTED
2503 extern PNG_EXPORT(void, png_set_hIST) PNGARG((png_structp png_ptr,
2504                 png_infop info_ptr, png_uint_16p hist));
2505 #endif
2506
2507 extern PNG_EXPORT(png_uint_32, png_get_IHDR) PNGARG((png_structp png_ptr,
2508                 png_infop info_ptr, png_uint_32 *width, png_uint_32 *height,
2509                 int *bit_depth, int *color_type, int *interlace_method,
2510                 int *compression_method, int *filter_method));
2511
2512 extern PNG_EXPORT(void, png_set_IHDR) PNGARG((png_structp png_ptr,
2513                 png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,
2514                 int color_type, int interlace_method, int compression_method,
2515                 int filter_method));
2516
2517 #ifdef PNG_oFFs_SUPPORTED
2518 extern PNG_EXPORT(png_uint_32, png_get_oFFs) PNGARG((png_structp png_ptr,
2519                 png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y,
2520                 int *unit_type));
2521 #endif
2522
2523 #ifdef PNG_oFFs_SUPPORTED
2524 extern PNG_EXPORT(void, png_set_oFFs) PNGARG((png_structp png_ptr,
2525                 png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y,
2526                 int unit_type));
2527 #endif
2528
2529 #ifdef PNG_pCAL_SUPPORTED
2530 extern PNG_EXPORT(png_uint_32, png_get_pCAL) PNGARG((png_structp png_ptr,
2531                 png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1,
2532                 int *type, int *nparams, png_charp *units, png_charpp *params));
2533 #endif
2534
2535 #ifdef PNG_pCAL_SUPPORTED
2536 extern PNG_EXPORT(void, png_set_pCAL) PNGARG((png_structp png_ptr,
2537                 png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1,
2538                 int type, int nparams, png_charp units, png_charpp params));
2539 #endif
2540
2541 #ifdef PNG_pHYs_SUPPORTED
2542 extern PNG_EXPORT(png_uint_32, png_get_pHYs) PNGARG((png_structp png_ptr,
2543                 png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
2544 #endif
2545
2546 #ifdef PNG_pHYs_SUPPORTED
2547 extern PNG_EXPORT(void, png_set_pHYs) PNGARG((png_structp png_ptr,
2548                 png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));
2549 #endif
2550
2551 extern PNG_EXPORT(png_uint_32, png_get_PLTE) PNGARG((png_structp png_ptr,
2552                 png_infop info_ptr, png_colorp *palette, int *num_palette));
2553
2554 extern PNG_EXPORT(void, png_set_PLTE) PNGARG((png_structp png_ptr,
2555                 png_infop info_ptr, png_colorp palette, int num_palette));
2556
2557 #ifdef PNG_sBIT_SUPPORTED
2558 extern PNG_EXPORT(png_uint_32, png_get_sBIT) PNGARG((png_structp png_ptr,
2559                 png_infop info_ptr, png_color_8p *sig_bit));
2560 #endif
2561
2562 #ifdef PNG_sBIT_SUPPORTED
2563 extern PNG_EXPORT(void, png_set_sBIT) PNGARG((png_structp png_ptr,
2564                 png_infop info_ptr, png_color_8p sig_bit));
2565 #endif
2566
2567 #ifdef PNG_sRGB_SUPPORTED
2568 extern PNG_EXPORT(png_uint_32, png_get_sRGB) PNGARG((png_structp png_ptr,
2569                 png_infop info_ptr, int *intent));
2570 #endif
2571
2572 #ifdef PNG_sRGB_SUPPORTED
2573 extern PNG_EXPORT(void, png_set_sRGB) PNGARG((png_structp png_ptr,
2574                 png_infop info_ptr, int intent));
2575 extern PNG_EXPORT(void, png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr,
2576                 png_infop info_ptr, int intent));
2577 #endif
2578
2579 #ifdef PNG_iCCP_SUPPORTED
2580 extern PNG_EXPORT(png_uint_32, png_get_iCCP) PNGARG((png_structp png_ptr,
2581                 png_infop info_ptr, png_charpp name, int *compression_type,
2582                 png_charpp profile, png_uint_32 *proflen));
2583 /* Note to maintainer: profile should be png_bytepp */
2584 #endif
2585
2586 #ifdef PNG_iCCP_SUPPORTED
2587 extern PNG_EXPORT(void, png_set_iCCP) PNGARG((png_structp png_ptr,
2588                 png_infop info_ptr, png_charp name, int compression_type,
2589                 png_charp profile, png_uint_32 proflen));
2590 /* Note to maintainer: profile should be png_bytep */
2591 #endif
2592
2593 #ifdef PNG_sPLT_SUPPORTED
2594 extern PNG_EXPORT(png_uint_32, png_get_sPLT) PNGARG((png_structp png_ptr,
2595                 png_infop info_ptr, png_sPLT_tpp entries));
2596 #endif
2597
2598 #ifdef PNG_sPLT_SUPPORTED
2599 extern PNG_EXPORT(void, png_set_sPLT) PNGARG((png_structp png_ptr,
2600                 png_infop info_ptr, png_sPLT_tp entries, int nentries));
2601 #endif
2602
2603 #ifdef PNG_TEXT_SUPPORTED
2604 /* png_get_text also returns the number of text chunks in *num_text */
2605 extern PNG_EXPORT(png_uint_32, png_get_text) PNGARG((png_structp png_ptr,
2606                 png_infop info_ptr, png_textp *text_ptr, int *num_text));
2607 #endif
2608
2609 /*
2610  *  Note while png_set_text() will accept a structure whose text,
2611  *  language, and  translated keywords are NULL pointers, the structure
2612  *  returned by png_get_text will always contain regular
2613  *  zero-terminated C strings.  They might be empty strings but
2614  *  they will never be NULL pointers.
2615  */
2616
2617 #ifdef PNG_TEXT_SUPPORTED
2618 extern PNG_EXPORT(void, png_set_text) PNGARG((png_structp png_ptr,
2619                 png_infop info_ptr, png_textp text_ptr, int num_text));
2620 #endif
2621
2622 #ifdef PNG_tIME_SUPPORTED
2623 extern PNG_EXPORT(png_uint_32, png_get_tIME) PNGARG((png_structp png_ptr,
2624                 png_infop info_ptr, png_timep *mod_time));
2625 #endif
2626
2627 #ifdef PNG_tIME_SUPPORTED
2628 extern PNG_EXPORT(void, png_set_tIME) PNGARG((png_structp png_ptr,
2629                 png_infop info_ptr, png_timep mod_time));
2630 #endif
2631
2632 #ifdef PNG_tRNS_SUPPORTED
2633 extern PNG_EXPORT(png_uint_32, png_get_tRNS) PNGARG((png_structp png_ptr,
2634                 png_infop info_ptr, png_bytep *trans, int *num_trans,
2635                 png_color_16p *trans_values));
2636 #endif
2637
2638 #ifdef PNG_tRNS_SUPPORTED
2639 extern PNG_EXPORT(void, png_set_tRNS) PNGARG((png_structp png_ptr,
2640                 png_infop info_ptr, png_bytep trans, int num_trans,
2641                 png_color_16p trans_values));
2642 #endif
2643
2644 #ifdef PNG_tRNS_SUPPORTED
2645 #endif
2646
2647 #ifdef PNG_sCAL_SUPPORTED
2648 #ifdef PNG_FLOATING_POINT_SUPPORTED
2649 extern PNG_EXPORT(png_uint_32, png_get_sCAL) PNGARG((png_structp png_ptr,
2650                 png_infop info_ptr, int *unit, double *width, double *height));
2651 #else
2652 #ifdef PNG_FIXED_POINT_SUPPORTED
2653 extern PNG_EXPORT(png_uint_32, png_get_sCAL_s) PNGARG((png_structp png_ptr,
2654                 png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight));
2655 #endif
2656 #endif
2657 #endif /* PNG_sCAL_SUPPORTED */
2658
2659 #ifdef PNG_sCAL_SUPPORTED
2660 #ifdef PNG_FLOATING_POINT_SUPPORTED
2661 extern PNG_EXPORT(void, png_set_sCAL) PNGARG((png_structp png_ptr,
2662                 png_infop info_ptr, int unit, double width, double height));
2663 #else
2664 #ifdef PNG_FIXED_POINT_SUPPORTED
2665 extern PNG_EXPORT(void, png_set_sCAL_s) PNGARG((png_structp png_ptr,
2666                 png_infop info_ptr, int unit, png_charp swidth, png_charp sheight));
2667 #endif
2668 #endif
2669 #endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */
2670
2671 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
2672 /* Provide a list of chunks and how they are to be handled, if the built-in
2673    handling or default unknown chunk handling is not desired.  Any chunks not
2674    listed will be handled in the default manner.  The IHDR and IEND chunks
2675    must not be listed.
2676       keep = 0: follow default behaviour
2677            = 1: do not keep
2678            = 2: keep only if safe-to-copy
2679            = 3: keep even if unsafe-to-copy
2680 */
2681 extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp
2682                 png_ptr, int keep, png_bytep chunk_list, int num_chunks));
2683 PNG_EXPORT(int, png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep
2684                 chunk_name));
2685 #endif
2686 #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
2687 extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr,
2688                 png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns));
2689 extern PNG_EXPORT(void, png_set_unknown_chunk_location)
2690 PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location));
2691 extern PNG_EXPORT(png_uint_32, png_get_unknown_chunks) PNGARG((png_structp
2692                 png_ptr, png_infop info_ptr, png_unknown_chunkpp entries));
2693 #endif
2694
2695 /* Png_free_data() will turn off the "valid" flag for anything it frees.
2696  * If you need to turn it off for a chunk that your application has freed,
2697  * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK);
2698  */
2699 extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr,
2700                 png_infop info_ptr, int mask));
2701
2702 #ifdef PNG_INFO_IMAGE_SUPPORTED
2703 /* The "params" pointer is currently not used and is for future expansion. */
2704 extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr,
2705                 png_infop info_ptr,
2706                 int transforms,
2707                 png_voidp params));
2708 extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr,
2709                 png_infop info_ptr,
2710                 int transforms,
2711                 png_voidp params));
2712 #endif
2713
2714 /* Define PNG_DEBUG at compile time for debugging information.  Higher
2715  * numbers for PNG_DEBUG mean more debugging information.  This has
2716  * only been added since version 0.95 so it is not implemented throughout
2717  * libpng yet, but more support will be added as needed.
2718  */
2719 #ifdef PNG_DEBUG
2720 #if (PNG_DEBUG > 0)
2721 #if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)
2722 #include <crtdbg.h>
2723 #if (PNG_DEBUG > 1)
2724 #ifndef _DEBUG
2725 #  define _DEBUG
2726 #endif
2727 #ifndef png_debug
2728 #define png_debug(l,m)  _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)
2729 #endif
2730 #ifndef png_debug1
2731 #define png_debug1(l,m,p1)  _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)
2732 #endif
2733 #ifndef png_debug2
2734 #define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)
2735 #endif
2736 #endif
2737 #else /* PNG_DEBUG_FILE || !_MSC_VER */
2738 #ifndef PNG_DEBUG_FILE
2739 #define PNG_DEBUG_FILE stderr
2740 #endif /* PNG_DEBUG_FILE */
2741
2742 #if (PNG_DEBUG > 1)
2743 /* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on non-ISO
2744  * compilers.
2745  */
2746 #  ifdef __STDC__
2747 #    ifndef png_debug
2748 #      define png_debug(l,m) \
2749        { \
2750        int num_tabs=l; \
2751        fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
2752          (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \
2753        }
2754 #    endif
2755 #    ifndef png_debug1
2756 #      define png_debug1(l,m,p1) \
2757        { \
2758        int num_tabs=l; \
2759        fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
2760          (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \
2761        }
2762 #    endif
2763 #    ifndef png_debug2
2764 #      define png_debug2(l,m,p1,p2) \
2765        { \
2766        int num_tabs=l; \
2767        fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
2768          (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \
2769        }
2770 #    endif
2771 #  else /* __STDC __ */
2772 #    ifndef png_debug
2773 #      define png_debug(l,m) \
2774        { \
2775        int num_tabs=l; \
2776        char format[256]; \
2777        snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
2778          (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
2779          m,PNG_STRING_NEWLINE); \
2780        fprintf(PNG_DEBUG_FILE,format); \
2781        }
2782 #    endif
2783 #    ifndef png_debug1
2784 #      define png_debug1(l,m,p1) \
2785        { \
2786        int num_tabs=l; \
2787        char format[256]; \
2788        snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
2789          (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
2790          m,PNG_STRING_NEWLINE); \
2791        fprintf(PNG_DEBUG_FILE,format,p1); \
2792        }
2793 #    endif
2794 #    ifndef png_debug2
2795 #      define png_debug2(l,m,p1,p2) \
2796        { \
2797        int num_tabs=l; \
2798        char format[256]; \
2799        snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
2800          (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
2801          m,PNG_STRING_NEWLINE); \
2802        fprintf(PNG_DEBUG_FILE,format,p1,p2); \
2803        }
2804 #    endif
2805 #  endif /* __STDC __ */
2806 #endif /* (PNG_DEBUG > 1) */
2807
2808 #endif /* _MSC_VER */
2809 #endif /* (PNG_DEBUG > 0) */
2810 #endif /* PNG_DEBUG */
2811 #ifndef png_debug
2812 #define png_debug(l, m)
2813 #endif
2814 #ifndef png_debug1
2815 #define png_debug1(l, m, p1)
2816 #endif
2817 #ifndef png_debug2
2818 #define png_debug2(l, m, p1, p2)
2819 #endif
2820
2821 extern PNG_EXPORT(png_charp, png_get_copyright) PNGARG((png_structp png_ptr));
2822 extern PNG_EXPORT(png_charp, png_get_header_ver) PNGARG((png_structp png_ptr));
2823 extern PNG_EXPORT(png_charp,
2824                   png_get_header_version) PNGARG((png_structp png_ptr));
2825 extern PNG_EXPORT(png_charp, png_get_libpng_ver) PNGARG((png_structp png_ptr));
2826
2827 #ifdef PNG_MNG_FEATURES_SUPPORTED
2828 extern PNG_EXPORT(png_uint_32, png_permit_mng_features) PNGARG((png_structp
2829                 png_ptr, png_uint_32 mng_features_permitted));
2830 #endif
2831
2832 /* For use in png_set_keep_unknown, added to version 1.2.6 */
2833 #define PNG_HANDLE_CHUNK_AS_DEFAULT   0
2834 #define PNG_HANDLE_CHUNK_NEVER        1
2835 #define PNG_HANDLE_CHUNK_IF_SAFE      2
2836 #define PNG_HANDLE_CHUNK_ALWAYS       3
2837
2838 /* Added to version 1.2.0 */
2839 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
2840 #ifdef PNG_MMX_CODE_SUPPORTED
2841 #define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED  0x01  /* not user-settable */
2842 #define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU    0x02  /* not user-settable */
2843 #define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW  0x04
2844 #define PNG_ASM_FLAG_MMX_READ_INTERLACE    0x08
2845 #define PNG_ASM_FLAG_MMX_READ_FILTER_SUB   0x10
2846 #define PNG_ASM_FLAG_MMX_READ_FILTER_UP    0x20
2847 #define PNG_ASM_FLAG_MMX_READ_FILTER_AVG   0x40
2848 #define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80
2849 #define PNG_ASM_FLAGS_INITIALIZED          0x80000000  /* not user-settable */
2850
2851 #define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW  \
2852                            | PNG_ASM_FLAG_MMX_READ_INTERLACE    \
2853                            | PNG_ASM_FLAG_MMX_READ_FILTER_SUB   \
2854                            | PNG_ASM_FLAG_MMX_READ_FILTER_UP    \
2855                            | PNG_ASM_FLAG_MMX_READ_FILTER_AVG   \
2856                            | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH )
2857 #define PNG_MMX_WRITE_FLAGS ( 0 )
2858
2859 #define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \
2860                       | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU   \
2861                       | PNG_MMX_READ_FLAGS                \
2862                       | PNG_MMX_WRITE_FLAGS )
2863
2864 #define PNG_SELECT_READ   1
2865 #define PNG_SELECT_WRITE  2
2866 #endif /* PNG_MMX_CODE_SUPPORTED */
2867
2868 #ifndef PNG_1_0_X
2869 /* pngget.c */
2870 extern PNG_EXPORT(png_uint_32, png_get_mmx_flagmask)
2871 PNGARG((int flag_select, int *compilerID));
2872
2873 /* pngget.c */
2874 extern PNG_EXPORT(png_uint_32, png_get_asm_flagmask)
2875 PNGARG((int flag_select));
2876
2877 /* pngget.c */
2878 extern PNG_EXPORT(png_uint_32, png_get_asm_flags)
2879 PNGARG((png_structp png_ptr));
2880
2881 /* pngget.c */
2882 extern PNG_EXPORT(png_byte, png_get_mmx_bitdepth_threshold)
2883 PNGARG((png_structp png_ptr));
2884
2885 /* pngget.c */
2886 extern PNG_EXPORT(png_uint_32, png_get_mmx_rowbytes_threshold)
2887 PNGARG((png_structp png_ptr));
2888
2889 /* pngset.c */
2890 extern PNG_EXPORT(void, png_set_asm_flags)
2891 PNGARG((png_structp png_ptr, png_uint_32 asm_flags));
2892
2893 /* pngset.c */
2894 extern PNG_EXPORT(void, png_set_mmx_thresholds)
2895 PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold,
2896         png_uint_32 mmx_rowbytes_threshold));
2897
2898 #endif /* PNG_1_0_X */
2899
2900 #ifndef PNG_1_0_X
2901 /* png.c, pnggccrd.c, or pngvcrd.c */
2902 extern PNG_EXPORT(int, png_mmx_support) PNGARG((void));
2903 #endif /* PNG_1_0_X */
2904 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
2905
2906 /* Strip the prepended error numbers ("#nnn ") from error and warning
2907  * messages before passing them to the error or warning handler.
2908  */
2909 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
2910 extern PNG_EXPORT(void, png_set_strip_error_numbers) PNGARG((png_structp
2911                 png_ptr, png_uint_32 strip_mode));
2912 #endif
2913
2914 /* Added at libpng-1.2.6 */
2915 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
2916 extern PNG_EXPORT(void, png_set_user_limits) PNGARG((png_structp
2917                 png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max));
2918 extern PNG_EXPORT(png_uint_32, png_get_user_width_max) PNGARG((png_structp
2919                 png_ptr));
2920 extern PNG_EXPORT(png_uint_32, png_get_user_height_max) PNGARG((png_structp
2921                 png_ptr));
2922 #endif
2923 /* Maintainer: Put new public prototypes here ^, in libpng.3, and in
2924  * project defs
2925  */
2926
2927 #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
2928 /* With these routines we avoid an integer divide, which will be slower on
2929  * most machines.  However, it does take more operations than the corresponding
2930  * divide method, so it may be slower on a few RISC systems.  There are two
2931  * shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
2932  *
2933  * Note that the rounding factors are NOT supposed to be the same!  128 and
2934  * 32768 are correct for the NODIV code; 127 and 32767 are correct for the
2935  * standard method.
2936  *
2937  * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
2938  */
2939
2940 /* fg and bg should be in `gamma 1.0' space; alpha is the opacity          */
2941
2942 #  define png_composite(composite, fg, alpha, bg)                            \
2943      { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \
2944                         +        (png_uint_16)(bg)*(png_uint_16)(255 -       \
2945                         (png_uint_16)(alpha)) + (png_uint_16)128);           \
2946        (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
2947
2948 #  define png_composite_16(composite, fg, alpha, bg)                         \
2949      { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \
2950                         + (png_uint_32)(bg)*(png_uint_32)(65535L -           \
2951                         (png_uint_32)(alpha)) + (png_uint_32)32768L);        \
2952        (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
2953
2954 #else  /* Standard method using integer division */
2955
2956 #  define png_composite(composite, fg, alpha, bg)                            \
2957      (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) +    \
2958        (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) +       \
2959        (png_uint_16)127) / 255)
2960
2961 #  define png_composite_16(composite, fg, alpha, bg)                         \
2962      (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
2963        (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) +      \
2964        (png_uint_32)32767) / (png_uint_32)65535L)
2965
2966 #endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
2967
2968 /* Inline macros to do direct reads of bytes from the input buffer.  These
2969  * require that you are using an architecture that uses PNG byte ordering
2970  * (MSB first) and supports unaligned data storage.  I think that PowerPC
2971  * in big-endian mode and 680x0 are the only ones that will support this.
2972  * The x86 line of processors definitely do not.  The png_get_int_32()
2973  * routine also assumes we are using two's complement format for negative
2974  * values, which is almost certainly true.
2975  */
2976 #ifdef PNG_READ_BIG_ENDIAN_SUPPORTED
2977 #  define png_get_uint_32(buf) ( *((png_uint_32p) (buf)))
2978 #  define png_get_uint_16(buf) ( *((png_uint_16p) (buf)))
2979 #  define png_get_int_32(buf)  ( *((png_int_32p)  (buf)))
2980 #else
2981 extern PNG_EXPORT(png_uint_32, png_get_uint_32) PNGARG((png_bytep buf));
2982 extern PNG_EXPORT(png_uint_16, png_get_uint_16) PNGARG((png_bytep buf));
2983 extern PNG_EXPORT(png_int_32, png_get_int_32) PNGARG((png_bytep buf));
2984 #endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */
2985 extern PNG_EXPORT(png_uint_32, png_get_uint_31)
2986 PNGARG((png_structp png_ptr, png_bytep buf));
2987 /* No png_get_int_16 -- may be added if there's a real need for it. */
2988
2989 /* Place a 32-bit number into a buffer in PNG byte order (big-endian).
2990  */
2991 extern PNG_EXPORT(void, png_save_uint_32)
2992 PNGARG((png_bytep buf, png_uint_32 i));
2993 extern PNG_EXPORT(void, png_save_int_32)
2994 PNGARG((png_bytep buf, png_int_32 i));
2995
2996 /* Place a 16-bit number into a buffer in PNG byte order.
2997  * The parameter is declared unsigned int, not png_uint_16,
2998  * just to avoid potential problems on pre-ANSI C compilers.
2999  */
3000 extern PNG_EXPORT(void, png_save_uint_16)
3001 PNGARG((png_bytep buf, unsigned int i));
3002 /* No png_save_int_16 -- may be added if there's a real need for it. */
3003
3004 /* ************************************************************************* */
3005
3006 /* These next functions are used internally in the code.  They generally
3007  * shouldn't be used unless you are writing code to add or replace some
3008  * functionality in libpng.  More information about most functions can
3009  * be found in the files where the functions are located.
3010  */
3011
3012
3013 /* Various modes of operation, that are visible to applications because
3014  * they are used for unknown chunk location.
3015  */
3016 #define PNG_HAVE_IHDR               0x01
3017 #define PNG_HAVE_PLTE               0x02
3018 #define PNG_HAVE_IDAT               0x04
3019 #define PNG_AFTER_IDAT              0x08 /* Have complete zlib datastream */
3020 #define PNG_HAVE_IEND               0x10
3021
3022 #ifdef PNG_INTERNAL
3023
3024 /* More modes of operation.  Note that after an init, mode is set to
3025  * zero automatically when the structure is created.
3026  */
3027 #define PNG_HAVE_gAMA               0x20
3028 #define PNG_HAVE_cHRM               0x40
3029 #define PNG_HAVE_sRGB               0x80
3030 #define PNG_HAVE_CHUNK_HEADER      0x100
3031 #define PNG_WROTE_tIME             0x200
3032 #define PNG_WROTE_INFO_BEFORE_PLTE 0x400
3033 #define PNG_BACKGROUND_IS_GRAY     0x800
3034 #define PNG_HAVE_PNG_SIGNATURE    0x1000
3035 #define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
3036
3037 /* Flags for the transformations the PNG library does on the image data */
3038 #define PNG_BGR                0x0001
3039 #define PNG_INTERLACE          0x0002
3040 #define PNG_PACK               0x0004
3041 #define PNG_SHIFT              0x0008
3042 #define PNG_SWAP_BYTES         0x0010
3043 #define PNG_INVERT_MONO        0x0020
3044 #define PNG_DITHER             0x0040
3045 #define PNG_BACKGROUND         0x0080
3046 #define PNG_BACKGROUND_EXPAND  0x0100
3047 /*   0x0200 unused */
3048 #define PNG_16_TO_8            0x0400
3049 #define PNG_RGBA               0x0800
3050 #define PNG_EXPAND             0x1000
3051 #define PNG_GAMMA              0x2000
3052 #define PNG_GRAY_TO_RGB        0x4000
3053 #define PNG_FILLER             0x8000L
3054 #define PNG_PACKSWAP          0x10000L
3055 #define PNG_SWAP_ALPHA        0x20000L
3056 #define PNG_STRIP_ALPHA       0x40000L
3057 #define PNG_INVERT_ALPHA      0x80000L
3058 #define PNG_USER_TRANSFORM   0x100000L
3059 #define PNG_RGB_TO_GRAY_ERR  0x200000L
3060 #define PNG_RGB_TO_GRAY_WARN 0x400000L
3061 #define PNG_RGB_TO_GRAY      0x600000L  /* two bits, RGB_TO_GRAY_ERR|WARN */
3062 /*    0x800000L     Unused */
3063 #define PNG_ADD_ALPHA       0x1000000L  /* Added to libpng-1.2.7 */
3064 #define PNG_EXPAND_tRNS     0x2000000L  /* Added to libpng-1.2.9 */
3065 #define PNG_PREMULTIPLY_ALPHA 0x4000000L  /* Added to libpng-1.2.41 */
3066 /* by volker */
3067 /*   0x8000000L  unused */
3068 /*  0x10000000L  unused */
3069 /*  0x20000000L  unused */
3070 /*  0x40000000L  unused */
3071
3072 /* Flags for png_create_struct */
3073 #define PNG_STRUCT_PNG   0x0001
3074 #define PNG_STRUCT_INFO  0x0002
3075
3076 /* Scaling factor for filter heuristic weighting calculations */
3077 #define PNG_WEIGHT_SHIFT 8
3078 #define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))
3079 #define PNG_COST_SHIFT 3
3080 #define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))
3081
3082 /* Flags for the png_ptr->flags rather than declaring a byte for each one */
3083 #define PNG_FLAG_ZLIB_CUSTOM_STRATEGY     0x0001
3084 #define PNG_FLAG_ZLIB_CUSTOM_LEVEL        0x0002
3085 #define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL    0x0004
3086 #define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS  0x0008
3087 #define PNG_FLAG_ZLIB_CUSTOM_METHOD       0x0010
3088 #define PNG_FLAG_ZLIB_FINISHED            0x0020
3089 #define PNG_FLAG_ROW_INIT                 0x0040
3090 #define PNG_FLAG_FILLER_AFTER             0x0080
3091 #define PNG_FLAG_CRC_ANCILLARY_USE        0x0100
3092 #define PNG_FLAG_CRC_ANCILLARY_NOWARN     0x0200
3093 #define PNG_FLAG_CRC_CRITICAL_USE         0x0400
3094 #define PNG_FLAG_CRC_CRITICAL_IGNORE      0x0800
3095 #define PNG_FLAG_FREE_PLTE                0x1000
3096 #define PNG_FLAG_FREE_TRNS                0x2000
3097 #define PNG_FLAG_FREE_HIST                0x4000
3098 #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS      0x8000L
3099 #define PNG_FLAG_KEEP_UNSAFE_CHUNKS       0x10000L
3100 #define PNG_FLAG_LIBRARY_MISMATCH         0x20000L
3101 #define PNG_FLAG_STRIP_ERROR_NUMBERS      0x40000L
3102 #define PNG_FLAG_STRIP_ERROR_TEXT         0x80000L
3103 #define PNG_FLAG_MALLOC_NULL_MEM_OK       0x100000L
3104 #define PNG_FLAG_ADD_ALPHA                0x200000L  /* Added to libpng-1.2.8 */
3105 #define PNG_FLAG_STRIP_ALPHA              0x400000L  /* Added to libpng-1.2.8 */
3106 /*      0x800000L  unused */
3107 /*     0x1000000L  unused */
3108 /*     0x2000000L  unused */
3109 /*     0x4000000L  unused */
3110 /*     0x8000000L  unused */
3111 /*    0x10000000L  unused */
3112 /*    0x20000000L  unused */
3113 /*    0x40000000L  unused */
3114
3115 #define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
3116                                      PNG_FLAG_CRC_ANCILLARY_NOWARN)
3117
3118 #define PNG_FLAG_CRC_CRITICAL_MASK  (PNG_FLAG_CRC_CRITICAL_USE | \
3119                                      PNG_FLAG_CRC_CRITICAL_IGNORE)
3120
3121 #define PNG_FLAG_CRC_MASK           (PNG_FLAG_CRC_ANCILLARY_MASK | \
3122                                      PNG_FLAG_CRC_CRITICAL_MASK)
3123
3124 /* Save typing and make code easier to understand */
3125
3126 #define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \
3127    abs((int)((c1).green) - (int)((c2).green)) + \
3128    abs((int)((c1).blue) - (int)((c2).blue)))
3129
3130 /* Added to libpng-1.2.6 JB */
3131 #define PNG_ROWBYTES(pixel_bits, width) \
3132     ((pixel_bits) >= 8 ? \
3133     ((width) * (((png_uint_32)(pixel_bits)) >> 3)) : \
3134     (( ((width) * ((png_uint_32)(pixel_bits))) + 7) >> 3) )
3135
3136 /* PNG_OUT_OF_RANGE returns true if value is outside the range
3137  * ideal-delta..ideal+delta.  Each argument is evaluated twice.
3138  * "ideal" and "delta" should be constants, normally simple
3139  * integers, "value" a variable. Added to libpng-1.2.6 JB
3140  */
3141 #define PNG_OUT_OF_RANGE(value, ideal, delta) \
3142         ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) )
3143
3144 /* Variables declared in png.c - only it needs to define PNG_NO_EXTERN */
3145 #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
3146 /* Place to hold the signature string for a PNG file. */
3147 #ifdef PNG_USE_GLOBAL_ARRAYS
3148 PNG_EXPORT_VAR (PNG_CONST png_byte FARDATA) png_sig[8];
3149 #else
3150 #endif
3151 #endif /* PNG_NO_EXTERN */
3152
3153 /* Constant strings for known chunk types.  If you need to add a chunk,
3154  * define the name here, and add an invocation of the macro in png.c and
3155  * wherever it's needed.
3156  */
3157 #define PNG_IHDR png_byte png_IHDR[5] = { 73,  72,  68,  82, '\0'}
3158 #define PNG_IDAT png_byte png_IDAT[5] = { 73,  68,  65,  84, '\0'}
3159 #define PNG_IEND png_byte png_IEND[5] = { 73,  69,  78,  68, '\0'}
3160 #define PNG_PLTE png_byte png_PLTE[5] = { 80,  76,  84,  69, '\0'}
3161 #define PNG_bKGD png_byte png_bKGD[5] = { 98,  75,  71,  68, '\0'}
3162 #define PNG_cHRM png_byte png_cHRM[5] = { 99,  72,  82,  77, '\0'}
3163 #define PNG_gAMA png_byte png_gAMA[5] = {103,  65,  77,  65, '\0'}
3164 #define PNG_hIST png_byte png_hIST[5] = {104,  73,  83,  84, '\0'}
3165 #define PNG_iCCP png_byte png_iCCP[5] = {105,  67,  67,  80, '\0'}
3166 #define PNG_iTXt png_byte png_iTXt[5] = {105,  84,  88, 116, '\0'}
3167 #define PNG_oFFs png_byte png_oFFs[5] = {111,  70,  70, 115, '\0'}
3168 #define PNG_pCAL png_byte png_pCAL[5] = {112,  67,  65,  76, '\0'}
3169 #define PNG_sCAL png_byte png_sCAL[5] = {115,  67,  65,  76, '\0'}
3170 #define PNG_pHYs png_byte png_pHYs[5] = {112,  72,  89, 115, '\0'}
3171 #define PNG_sBIT png_byte png_sBIT[5] = {115,  66,  73,  84, '\0'}
3172 #define PNG_sPLT png_byte png_sPLT[5] = {115,  80,  76,  84, '\0'}
3173 #define PNG_sRGB png_byte png_sRGB[5] = {115,  82,  71,  66, '\0'}
3174 #define PNG_tEXt png_byte png_tEXt[5] = {116,  69,  88, 116, '\0'}
3175 #define PNG_tIME png_byte png_tIME[5] = {116,  73,  77,  69, '\0'}
3176 #define PNG_tRNS png_byte png_tRNS[5] = {116,  82,  78,  83, '\0'}
3177 #define PNG_zTXt png_byte png_zTXt[5] = {122,  84,  88, 116, '\0'}
3178
3179 #ifdef PNG_USE_GLOBAL_ARRAYS
3180 PNG_EXPORT_VAR (png_byte FARDATA) png_IHDR[5];
3181 PNG_EXPORT_VAR (png_byte FARDATA) png_IDAT[5];
3182 PNG_EXPORT_VAR (png_byte FARDATA) png_IEND[5];
3183 PNG_EXPORT_VAR (png_byte FARDATA) png_PLTE[5];
3184 PNG_EXPORT_VAR (png_byte FARDATA) png_bKGD[5];
3185 PNG_EXPORT_VAR (png_byte FARDATA) png_cHRM[5];
3186 PNG_EXPORT_VAR (png_byte FARDATA) png_gAMA[5];
3187 PNG_EXPORT_VAR (png_byte FARDATA) png_hIST[5];
3188 PNG_EXPORT_VAR (png_byte FARDATA) png_iCCP[5];
3189 PNG_EXPORT_VAR (png_byte FARDATA) png_iTXt[5];
3190 PNG_EXPORT_VAR (png_byte FARDATA) png_oFFs[5];
3191 PNG_EXPORT_VAR (png_byte FARDATA) png_pCAL[5];
3192 PNG_EXPORT_VAR (png_byte FARDATA) png_sCAL[5];
3193 PNG_EXPORT_VAR (png_byte FARDATA) png_pHYs[5];
3194 PNG_EXPORT_VAR (png_byte FARDATA) png_sBIT[5];
3195 PNG_EXPORT_VAR (png_byte FARDATA) png_sPLT[5];
3196 PNG_EXPORT_VAR (png_byte FARDATA) png_sRGB[5];
3197 PNG_EXPORT_VAR (png_byte FARDATA) png_tEXt[5];
3198 PNG_EXPORT_VAR (png_byte FARDATA) png_tIME[5];
3199 PNG_EXPORT_VAR (png_byte FARDATA) png_tRNS[5];
3200 PNG_EXPORT_VAR (png_byte FARDATA) png_zTXt[5];
3201 #endif /* PNG_USE_GLOBAL_ARRAYS */
3202
3203 #if defined(PNG_1_0_X) || defined (PNG_1_2_X)
3204 /* Initialize png_ptr struct for reading, and allocate any other memory.
3205  * (old interface - DEPRECATED - use png_create_read_struct instead).
3206  */
3207 extern PNG_EXPORT(void, png_read_init) PNGARG((png_structp png_ptr))
3208 PNG_DEPRECATED;
3209 #undef png_read_init
3210 #define png_read_init(png_ptr) png_read_init_3(&png_ptr, \
3211     PNG_LIBPNG_VER_STRING,  png_sizeof(png_struct));
3212 #endif
3213
3214 extern PNG_EXPORT(void, png_read_init_3) PNGARG((png_structpp ptr_ptr,
3215                 png_const_charp user_png_ver, png_size_t png_struct_size));
3216 #if defined(PNG_1_0_X) || defined (PNG_1_2_X)
3217 extern PNG_EXPORT(void, png_read_init_2) PNGARG((png_structp png_ptr,
3218                 png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t
3219                 png_info_size));
3220 #endif
3221
3222 #if defined(PNG_1_0_X) || defined (PNG_1_2_X)
3223 /* Initialize png_ptr struct for writing, and allocate any other memory.
3224  * (old interface - DEPRECATED - use png_create_write_struct instead).
3225  */
3226 extern PNG_EXPORT(void, png_write_init) PNGARG((png_structp png_ptr))
3227 PNG_DEPRECATED;
3228 #undef png_write_init
3229 #define png_write_init(png_ptr) png_write_init_3(&png_ptr, \
3230     PNG_LIBPNG_VER_STRING, png_sizeof(png_struct));
3231 #endif
3232
3233 extern PNG_EXPORT(void, png_write_init_3) PNGARG((png_structpp ptr_ptr,
3234                 png_const_charp user_png_ver, png_size_t png_struct_size));
3235 extern PNG_EXPORT(void, png_write_init_2) PNGARG((png_structp png_ptr,
3236                 png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t
3237                 png_info_size));
3238
3239 /* Allocate memory for an internal libpng struct */
3240 PNG_EXTERN png_voidp png_create_struct PNGARG((int type)) PNG_PRIVATE;
3241
3242 /* Free memory from internal libpng struct */
3243 PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)) PNG_PRIVATE;
3244
3245 PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr
3246                 malloc_fn, png_voidp mem_ptr)) PNG_PRIVATE;
3247 PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr,
3248                 png_free_ptr free_fn, png_voidp mem_ptr)) PNG_PRIVATE;
3249
3250 /* Free any memory that info_ptr points to and reset struct. */
3251 PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,
3252                                         png_infop info_ptr)) PNG_PRIVATE;
3253
3254 #ifndef PNG_1_0_X
3255 /* Function to allocate memory for zlib. */
3256 PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items,
3257                                      uInt size)) PNG_PRIVATE;
3258
3259 /* Function to free memory for zlib */
3260 PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)) PNG_PRIVATE;
3261
3262 #ifdef PNG_SIZE_T
3263 /* Function to convert a sizeof an item to png_sizeof item */
3264 PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size))
3265 PNG_PRIVATE;
3266 #endif
3267
3268 /* Next four functions are used internally as callbacks.  PNGAPI is required
3269  * but not PNG_EXPORT.  PNGAPI added at libpng version 1.2.3.
3270  */
3271
3272 PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr,
3273                 png_bytep data, png_size_t length)) PNG_PRIVATE;
3274
3275 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
3276 PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr,
3277                 png_bytep buffer, png_size_t length)) PNG_PRIVATE;
3278 #endif
3279
3280 PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr,
3281                 png_bytep data, png_size_t length)) PNG_PRIVATE;
3282
3283 #ifdef PNG_WRITE_FLUSH_SUPPORTED
3284 #ifdef PNG_STDIO_SUPPORTED
3285 PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr))
3286 PNG_PRIVATE;
3287 #endif
3288 #endif
3289 #else /* PNG_1_0_X */
3290 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
3291 PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr,
3292                 png_bytep buffer, png_size_t length)) PNG_PRIVATE;
3293 #endif
3294 #endif /* PNG_1_0_X */
3295
3296 /* Reset the CRC variable */
3297 PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3298
3299 /* Write the "data" buffer to whatever output you are using. */
3300 PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
3301                                        png_size_t length)) PNG_PRIVATE;
3302
3303 /* Read data from whatever input you are using into the "data" buffer */
3304 PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data,
3305                                       png_size_t length)) PNG_PRIVATE;
3306
3307 /* Read bytes into buf, and update png_ptr->crc */
3308 PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf,
3309                                      png_size_t length)) PNG_PRIVATE;
3310
3311 /* Decompress data in a chunk that uses compression */
3312 #if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \
3313     defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED)
3314 PNG_EXTERN void png_decompress_chunk PNGARG((png_structp png_ptr,
3315                 int comp_type, png_size_t chunklength,
3316                 png_size_t prefix_length, png_size_t *data_length)) PNG_PRIVATE;
3317 #endif
3318
3319 /* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
3320 PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)
3321                                      PNG_PRIVATE);
3322
3323 /* Read the CRC from the file and compare it to the libpng calculated CRC */
3324 PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3325
3326 /* Calculate the CRC over a section of data.  Note that we are only
3327  * passing a maximum of 64K on systems that have this as a memory limit,
3328  * since this is the maximum buffer size we can specify.
3329  */
3330 PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr,
3331                 png_size_t length)) PNG_PRIVATE;
3332
3333 #ifdef PNG_WRITE_FLUSH_SUPPORTED
3334 PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3335 #endif
3336
3337 /* Simple function to write the signature */
3338 PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3339
3340 /* Write various chunks */
3341
3342 /* Write the IHDR chunk, and update the png_struct with the necessary
3343  * information.
3344  */
3345 PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width,
3346                                        png_uint_32 height,
3347                                        int bit_depth, int color_type, int compression_method, int filter_method,
3348                                        int interlace_method)) PNG_PRIVATE;
3349
3350 PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette,
3351                                        png_uint_32 num_pal)) PNG_PRIVATE;
3352
3353 PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data,
3354                                        png_size_t length)) PNG_PRIVATE;
3355
3356 PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3357
3358 #ifdef PNG_WRITE_gAMA_SUPPORTED
3359 #ifdef PNG_FLOATING_POINT_SUPPORTED
3360 PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma))
3361 PNG_PRIVATE;
3362 #endif
3363 #ifdef PNG_FIXED_POINT_SUPPORTED
3364 PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr,
3365                 png_fixed_point file_gamma)) PNG_PRIVATE;
3366 #endif
3367 #endif
3368
3369 #ifdef PNG_WRITE_sBIT_SUPPORTED
3370 PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit,
3371                                        int color_type)) PNG_PRIVATE;
3372 #endif
3373
3374 #ifdef PNG_WRITE_cHRM_SUPPORTED
3375 #ifdef PNG_FLOATING_POINT_SUPPORTED
3376 PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr,
3377                                        double white_x, double white_y,
3378                                        double red_x, double red_y, double green_x, double green_y,
3379                                        double blue_x, double blue_y)) PNG_PRIVATE;
3380 #endif
3381 #ifdef PNG_FIXED_POINT_SUPPORTED
3382 PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr,
3383                 png_fixed_point int_white_x, png_fixed_point int_white_y,
3384                 png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
3385                 int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
3386                 png_fixed_point int_blue_y)) PNG_PRIVATE;
3387 #endif
3388 #endif
3389
3390 #ifdef PNG_WRITE_sRGB_SUPPORTED
3391 PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,
3392                                        int intent)) PNG_PRIVATE;
3393 #endif
3394
3395 #ifdef PNG_WRITE_iCCP_SUPPORTED
3396 PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr,
3397                                        png_charp name, int compression_type,
3398                                        png_charp profile, int proflen)) PNG_PRIVATE;
3399 /* Note to maintainer: profile should be png_bytep */
3400 #endif
3401
3402 #ifdef PNG_WRITE_sPLT_SUPPORTED
3403 PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr,
3404                                        png_sPLT_tp palette)) PNG_PRIVATE;
3405 #endif
3406
3407 #ifdef PNG_WRITE_tRNS_SUPPORTED
3408 PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans,
3409                                        png_color_16p values, int number, int color_type)) PNG_PRIVATE;
3410 #endif
3411
3412 #ifdef PNG_WRITE_bKGD_SUPPORTED
3413 PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr,
3414                                        png_color_16p values, int color_type)) PNG_PRIVATE;
3415 #endif
3416
3417 #ifdef PNG_WRITE_hIST_SUPPORTED
3418 PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist,
3419                                        int num_hist)) PNG_PRIVATE;
3420 #endif
3421
3422 #if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \
3423     defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
3424 PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr,
3425                 png_charp key, png_charpp new_key)) PNG_PRIVATE;
3426 #endif
3427
3428 #ifdef PNG_WRITE_tEXt_SUPPORTED
3429 PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key,
3430                                        png_charp text, png_size_t text_len)) PNG_PRIVATE;
3431 #endif
3432
3433 #ifdef PNG_WRITE_zTXt_SUPPORTED
3434 PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key,
3435                                        png_charp text, png_size_t text_len, int compression)) PNG_PRIVATE;
3436 #endif
3437
3438 #ifdef PNG_WRITE_iTXt_SUPPORTED
3439 PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr,
3440                                        int compression, png_charp key, png_charp lang, png_charp lang_key,
3441                                        png_charp text)) PNG_PRIVATE;
3442 #endif
3443
3444 #ifdef PNG_TEXT_SUPPORTED  /* Added at version 1.0.14 and 1.2.4 */
3445 PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr,
3446                                       png_infop info_ptr, png_textp text_ptr, int num_text)) PNG_PRIVATE;
3447 #endif
3448
3449 #ifdef PNG_WRITE_oFFs_SUPPORTED
3450 PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr,
3451                                        png_int_32 x_offset, png_int_32 y_offset, int unit_type)) PNG_PRIVATE;
3452 #endif
3453
3454 #ifdef PNG_WRITE_pCAL_SUPPORTED
3455 PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose,
3456                                        png_int_32 X0, png_int_32 X1, int type, int nparams,
3457                                        png_charp units, png_charpp params)) PNG_PRIVATE;
3458 #endif
3459
3460 #ifdef PNG_WRITE_pHYs_SUPPORTED
3461 PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr,
3462                                        png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,
3463                                        int unit_type)) PNG_PRIVATE;
3464 #endif
3465
3466 #ifdef PNG_WRITE_tIME_SUPPORTED
3467 PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr,
3468                                        png_timep mod_time)) PNG_PRIVATE;
3469 #endif
3470
3471 #ifdef PNG_WRITE_sCAL_SUPPORTED
3472 #if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO)
3473 PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr,
3474                                        int unit, double width, double height)) PNG_PRIVATE;
3475 #else
3476 #ifdef PNG_FIXED_POINT_SUPPORTED
3477 PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr,
3478                                         int unit, png_charp width, png_charp height)) PNG_PRIVATE;
3479 #endif
3480 #endif
3481 #endif
3482
3483 /* Called when finished processing a row of data */
3484 PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3485
3486 /* Internal use only.   Called before first row of data */
3487 PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3488
3489 #ifdef PNG_READ_GAMMA_SUPPORTED
3490 PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3491 #endif
3492
3493 /* Combine a row of data, dealing with alpha, etc. if requested */
3494 PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row,
3495                                         int mask)) PNG_PRIVATE;
3496
3497 #ifdef PNG_READ_INTERLACING_SUPPORTED
3498 /* Expand an interlaced row */
3499 /* OLD pre-1.0.9 interface:
3500 PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info,
3501    png_bytep row, int pass, png_uint_32 transformations)) PNG_PRIVATE;
3502  */
3503 PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3504 #endif
3505
3506 /* GRR TO DO (2.0 or whenever):  simplify other internal calling interfaces */
3507
3508 #ifdef PNG_WRITE_INTERLACING_SUPPORTED
3509 /* Grab pixels out of a row for an interlaced pass */
3510 PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info,
3511                 png_bytep row, int pass)) PNG_PRIVATE;
3512 #endif
3513
3514 /* Unfilter a row */
3515 PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr,
3516                 png_row_infop row_info, png_bytep row, png_bytep prev_row,
3517                 int filter)) PNG_PRIVATE;
3518
3519 /* Choose the best filter to use and filter the row data */
3520 PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr,
3521                 png_row_infop row_info)) PNG_PRIVATE;
3522
3523 /* Write out the filtered row. */
3524 PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr,
3525                 png_bytep filtered_row)) PNG_PRIVATE;
3526 /* Finish a row while reading, dealing with interlacing passes, etc. */
3527 PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr));
3528
3529 /* Initialize the row buffers, etc. */
3530 PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3531 /* Optional call to update the users info structure */
3532 PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,
3533                 png_infop info_ptr)) PNG_PRIVATE;
3534
3535 /* These are the functions that do the transformations */
3536 #ifdef PNG_READ_FILLER_SUPPORTED
3537 PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info,
3538                 png_bytep row, png_uint_32 filler, png_uint_32 flags)) PNG_PRIVATE;
3539 #endif
3540
3541 #ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
3542 PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info,
3543                 png_bytep row)) PNG_PRIVATE;
3544 #endif
3545
3546 #ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
3547 PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info,
3548                 png_bytep row)) PNG_PRIVATE;
3549 #endif
3550
3551 #ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
3552 PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info,
3553                 png_bytep row)) PNG_PRIVATE;
3554 #endif
3555
3556 #ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
3557 PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info,
3558                 png_bytep row)) PNG_PRIVATE;
3559 #endif
3560
3561 #if defined(PNG_WRITE_FILLER_SUPPORTED) || \
3562     defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
3563 PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
3564                 png_bytep row, png_uint_32 flags)) PNG_PRIVATE;
3565 #endif
3566
3567 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
3568 PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info,
3569                                     png_bytep row)) PNG_PRIVATE;
3570 #endif
3571
3572 #if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
3573 PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info,
3574                                         png_bytep row)) PNG_PRIVATE;
3575 #endif
3576
3577 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
3578 PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop
3579                 row_info, png_bytep row)) PNG_PRIVATE;
3580 #endif
3581
3582 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
3583 PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info,
3584                 png_bytep row)) PNG_PRIVATE;
3585 #endif
3586
3587 #ifdef PNG_READ_PACK_SUPPORTED
3588 PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info,
3589                                       png_bytep row)) PNG_PRIVATE;
3590 #endif
3591
3592 #ifdef PNG_READ_SHIFT_SUPPORTED
3593 PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row,
3594                                        png_color_8p sig_bits)) PNG_PRIVATE;
3595 #endif
3596
3597 #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
3598 PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info,
3599                                       png_bytep row)) PNG_PRIVATE;
3600 #endif
3601
3602 #ifdef PNG_READ_16_TO_8_SUPPORTED
3603 PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info,
3604                                     png_bytep row)) PNG_PRIVATE;
3605 #endif
3606
3607 #ifdef PNG_READ_DITHER_SUPPORTED
3608 PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info,
3609                                       png_bytep row, png_bytep palette_lookup,
3610                                       png_bytep dither_lookup)) PNG_PRIVATE;
3611
3612 #  ifdef PNG_CORRECT_PALETTE_SUPPORTED
3613 PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr,
3614                 png_colorp palette, int num_palette)) PNG_PRIVATE;
3615 #  endif
3616 #endif
3617
3618 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
3619 PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info,
3620                                    png_bytep row)) PNG_PRIVATE;
3621 #endif
3622
3623 #ifdef PNG_WRITE_PACK_SUPPORTED
3624 PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info,
3625                                     png_bytep row, png_uint_32 bit_depth)) PNG_PRIVATE;
3626 #endif
3627
3628 #ifdef PNG_WRITE_SHIFT_SUPPORTED
3629 PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row,
3630                                      png_color_8p bit_depth)) PNG_PRIVATE;
3631 #endif
3632
3633 #ifdef PNG_READ_BACKGROUND_SUPPORTED
3634 #ifdef PNG_READ_GAMMA_SUPPORTED
3635 PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
3636                 png_color_16p trans_values, png_color_16p background,
3637                 png_color_16p background_1,
3638                 png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1,
3639                 png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1,
3640                 png_uint_16pp gamma_16_to_1, int gamma_shift)) PNG_PRIVATE;
3641 #else
3642 PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
3643                 png_color_16p trans_values, png_color_16p background)) PNG_PRIVATE;
3644 #endif
3645 #endif
3646
3647 #ifdef PNG_READ_GAMMA_SUPPORTED
3648 PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row,
3649                                      png_bytep gamma_table, png_uint_16pp gamma_16_table,
3650                                      int gamma_shift)) PNG_PRIVATE;
3651 #endif
3652
3653 #ifdef PNG_READ_EXPAND_SUPPORTED
3654 PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info,
3655                 png_bytep row, png_colorp palette, png_bytep trans,
3656                 int num_trans)) PNG_PRIVATE;
3657 PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info,
3658                                       png_bytep row, png_color_16p trans_value)) PNG_PRIVATE;
3659 #endif
3660
3661 /* The following decodes the appropriate chunks, and does error correction,
3662  * then calls the appropriate callback for the chunk if it is valid.
3663  */
3664
3665 /* Decode the IHDR chunk */
3666 PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr,
3667                                         png_uint_32 length)) PNG_PRIVATE;
3668 PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr,
3669                                         png_uint_32 length));
3670 PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr,
3671                                         png_uint_32 length));
3672
3673 #ifdef PNG_READ_bKGD_SUPPORTED
3674 PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr,
3675                                         png_uint_32 length)) PNG_PRIVATE;
3676 #endif
3677
3678 #ifdef PNG_READ_cHRM_SUPPORTED
3679 PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr,
3680                                         png_uint_32 length)) PNG_PRIVATE;
3681 #endif
3682
3683 #ifdef PNG_READ_gAMA_SUPPORTED
3684 PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr,
3685                                         png_uint_32 length)) PNG_PRIVATE;
3686 #endif
3687
3688 #ifdef PNG_READ_hIST_SUPPORTED
3689 PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,
3690                                         png_uint_32 length)) PNG_PRIVATE;
3691 #endif
3692
3693 #ifdef PNG_READ_iCCP_SUPPORTED
3694 extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
3695                                     png_uint_32 length));
3696 #endif /* PNG_READ_iCCP_SUPPORTED */
3697
3698 #ifdef PNG_READ_iTXt_SUPPORTED
3699 PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
3700                                         png_uint_32 length)) PNG_PRIVATE;
3701 #endif
3702
3703 #ifdef PNG_READ_oFFs_SUPPORTED
3704 PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr,
3705                                         png_uint_32 length)) PNG_PRIVATE;
3706 #endif
3707
3708 #ifdef PNG_READ_pCAL_SUPPORTED
3709 PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
3710                                         png_uint_32 length)) PNG_PRIVATE;
3711 #endif
3712
3713 #ifdef PNG_READ_pHYs_SUPPORTED
3714 PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr,
3715                                         png_uint_32 length)) PNG_PRIVATE;
3716 #endif
3717
3718 #ifdef PNG_READ_sBIT_SUPPORTED
3719 PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr,
3720                                         png_uint_32 length)) PNG_PRIVATE;
3721 #endif
3722
3723 #ifdef PNG_READ_sCAL_SUPPORTED
3724 PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
3725                                         png_uint_32 length)) PNG_PRIVATE;
3726 #endif
3727
3728 #ifdef PNG_READ_sPLT_SUPPORTED
3729 extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
3730                                     png_uint_32 length)) PNG_PRIVATE;
3731 #endif /* PNG_READ_sPLT_SUPPORTED */
3732
3733 #ifdef PNG_READ_sRGB_SUPPORTED
3734 PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr,
3735                                         png_uint_32 length)) PNG_PRIVATE;
3736 #endif
3737
3738 #ifdef PNG_READ_tEXt_SUPPORTED
3739 PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr,
3740                                         png_uint_32 length)) PNG_PRIVATE;
3741 #endif
3742
3743 #ifdef PNG_READ_tIME_SUPPORTED
3744 PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr,
3745                                         png_uint_32 length)) PNG_PRIVATE;
3746 #endif
3747
3748 #ifdef PNG_READ_tRNS_SUPPORTED
3749 PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr,
3750                                         png_uint_32 length)) PNG_PRIVATE;
3751 #endif
3752
3753 #ifdef PNG_READ_zTXt_SUPPORTED
3754 PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
3755                                         png_uint_32 length)) PNG_PRIVATE;
3756 #endif
3757
3758 PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
3759                 png_infop info_ptr, png_uint_32 length)) PNG_PRIVATE;
3760
3761 PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr,
3762                 png_bytep chunk_name)) PNG_PRIVATE;
3763
3764 /* Handle the transformations for reading and writing */
3765 PNG_EXTERN void png_do_read_transformations
3766 PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3767 PNG_EXTERN void png_do_write_transformations
3768 PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3769
3770 PNG_EXTERN void png_init_read_transformations
3771 PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3772
3773 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
3774 PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr,
3775                 png_infop info_ptr)) PNG_PRIVATE;
3776 PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr,
3777                 png_infop info_ptr)) PNG_PRIVATE;
3778 PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3779 PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr,
3780                 png_uint_32 length)) PNG_PRIVATE;
3781 PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3782 PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3783 PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr,
3784                 png_bytep buffer, png_size_t buffer_length)) PNG_PRIVATE;
3785 PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3786 PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr,
3787                 png_bytep buffer, png_size_t buffer_length)) PNG_PRIVATE;
3788 PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3789 PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr,
3790                 png_infop info_ptr, png_uint_32 length)) PNG_PRIVATE;
3791 PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr,
3792                 png_infop info_ptr)) PNG_PRIVATE;
3793 PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr,
3794                 png_infop info_ptr)) PNG_PRIVATE;
3795 PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr,
3796                 png_bytep row)) PNG_PRIVATE;
3797 PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr,
3798                 png_infop info_ptr)) PNG_PRIVATE;
3799 PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr,
3800                 png_infop info_ptr)) PNG_PRIVATE;
3801 PNG_EXTERN void png_read_push_finish_row
3802 PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3803 #ifdef PNG_READ_tEXt_SUPPORTED
3804 PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr,
3805                 png_infop info_ptr, png_uint_32 length)) PNG_PRIVATE;
3806 PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr,
3807                 png_infop info_ptr)) PNG_PRIVATE;
3808 #endif
3809 #ifdef PNG_READ_zTXt_SUPPORTED
3810 PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr,
3811                 png_infop info_ptr, png_uint_32 length)) PNG_PRIVATE;
3812 PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr,
3813                 png_infop info_ptr)) PNG_PRIVATE;
3814 #endif
3815 #ifdef PNG_READ_iTXt_SUPPORTED
3816 PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr,
3817                 png_infop info_ptr, png_uint_32 length)) PNG_PRIVATE;
3818 PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr,
3819                 png_infop info_ptr)) PNG_PRIVATE;
3820 #endif
3821
3822 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
3823
3824 #ifdef PNG_MNG_FEATURES_SUPPORTED
3825 PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info,
3826                 png_bytep row)) PNG_PRIVATE;
3827 PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info,
3828                 png_bytep row)) PNG_PRIVATE;
3829 #endif
3830
3831 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
3832 #ifdef PNG_MMX_CODE_SUPPORTED
3833 /* png.c */ /* PRIVATE */
3834 PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3835 #endif
3836 #endif
3837
3838
3839 /* The following six functions will be exported in libpng-1.4.0. */
3840 #if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
3841 PNG_EXTERN png_uint_32 png_get_pixels_per_inch PNGARG((png_structp png_ptr,
3842                 png_infop info_ptr));
3843
3844 PNG_EXTERN png_uint_32 png_get_x_pixels_per_inch PNGARG((png_structp png_ptr,
3845                 png_infop info_ptr));
3846
3847 PNG_EXTERN png_uint_32 png_get_y_pixels_per_inch PNGARG((png_structp png_ptr,
3848                 png_infop info_ptr));
3849
3850 PNG_EXTERN float png_get_x_offset_inches PNGARG((png_structp png_ptr,
3851                 png_infop info_ptr));
3852
3853 PNG_EXTERN float png_get_y_offset_inches PNGARG((png_structp png_ptr,
3854                 png_infop info_ptr));
3855
3856 #ifdef PNG_pHYs_SUPPORTED
3857 PNG_EXTERN png_uint_32 png_get_pHYs_dpi PNGARG((png_structp png_ptr,
3858                 png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
3859 #endif /* PNG_pHYs_SUPPORTED */
3860 #endif  /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
3861
3862 /* Read the chunk header (length + type name) */
3863 PNG_EXTERN png_uint_32 png_read_chunk_header
3864 PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3865
3866 /* Added at libpng version 1.2.34 */
3867 #ifdef PNG_cHRM_SUPPORTED
3868 PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structp png_ptr,
3869                 png_fixed_point int_white_x, png_fixed_point int_white_y,
3870                 png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
3871                 int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
3872                 png_fixed_point int_blue_y)) PNG_PRIVATE;
3873 #endif
3874
3875 #ifdef PNG_cHRM_SUPPORTED
3876 #ifdef PNG_CHECK_cHRM_SUPPORTED
3877 /* Added at libpng version 1.2.34 */
3878 PNG_EXTERN void png_64bit_product PNGARG((long v1, long v2,
3879                 unsigned long *hi_product, unsigned long *lo_product)) PNG_PRIVATE;
3880 #endif
3881 #endif
3882
3883 /* Added at libpng version 1.2.41 */
3884 PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr,
3885                                        png_uint_32 width, png_uint_32 height, int bit_depth,
3886                                        int color_type, int interlace_type, int compression_type,
3887                                        int filter_type)) PNG_PRIVATE;
3888
3889 /* Added at libpng version 1.2.41 */
3890 PNG_EXTERN png_voidp png_calloc PNGARG((png_structp png_ptr,
3891                                         png_uint_32 size));
3892
3893 /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
3894
3895 #endif /* PNG_INTERNAL */
3896
3897 #ifdef __cplusplus
3898 }
3899 #endif
3900
3901 #endif /* PNG_VERSION_INFO_ONLY */
3902 /* Do not put anything past this line */
3903 #endif /* PNG_H */