0
|
1 |
/* ************************************************************************** */
|
|
2 |
/* * For conditions of distribution and use, * */
|
|
3 |
/* * see copyright notice in libmng.h * */
|
|
4 |
/* ************************************************************************** */
|
|
5 |
/* * * */
|
|
6 |
/* * project : libmng * */
|
|
7 |
/* * file : libmng_chunk_io.h copyright (c) 2000-2007 G.Juyn * */
|
|
8 |
/* * version : 1.0.109 * */
|
|
9 |
/* * * */
|
|
10 |
/* * purpose : Chunk I/O routines (definition) * */
|
|
11 |
/* * * */
|
|
12 |
/* * author : G.Juyn * */
|
|
13 |
/* * * */
|
|
14 |
/* * comment : Definition of the chunk input/output routines * */
|
|
15 |
/* * * */
|
|
16 |
/* * changes : 0.5.1 - 05/04/2000 - G.Juyn * */
|
|
17 |
/* * - changed CRC initialization to use dynamic structure * */
|
|
18 |
/* * (wasn't thread-safe the old way !) * */
|
|
19 |
/* * 0.5.1 - 05/08/2000 - G.Juyn * */
|
|
20 |
/* * - changed write routines definition * */
|
|
21 |
/* * - changed strict-ANSI stuff * */
|
|
22 |
/* * * */
|
|
23 |
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
|
|
24 |
/* * - changed file-prefixes * */
|
|
25 |
/* * * */
|
|
26 |
/* * 0.9.3 - 08/26/2000 - G.Juyn * */
|
|
27 |
/* * - added MAGN chunk * */
|
|
28 |
/* * 0.9.3 - 10/16/2000 - G.Juyn * */
|
|
29 |
/* * - added support for JDAA * */
|
|
30 |
/* * * */
|
|
31 |
/* * 1.0.5 - 08/19/2002 - G.Juyn * */
|
|
32 |
/* * - B597134 - libmng pollutes the linker namespace * */
|
|
33 |
/* * 1.0.5 - 09/14/2002 - G.Juyn * */
|
|
34 |
/* * - added event handling for dynamic MNG * */
|
|
35 |
/* * * */
|
|
36 |
/* * 1.0.6 - 07/07/2003 - G.R-P * */
|
|
37 |
/* * - added SKIP_CHUNK and NO_DELTA_PNG support * */
|
|
38 |
/* * 1.0.6 - 07/29/2003 - G.R-P * */
|
|
39 |
/* * - added conditionals around PAST chunk support * */
|
|
40 |
/* * * */
|
|
41 |
/* * 1.0.7 - 03/24/2004 - G.R-P * */
|
|
42 |
/* * - fixed SKIPCHUNK_itXT and SKIPCHUNK_ztXT typos * */
|
|
43 |
/* * * */
|
|
44 |
/* * 1.0.9 - 12/07/2004 - G.Juyn * */
|
|
45 |
/* * - added conditional MNG_OPTIMIZE_CHUNKREADER * */
|
|
46 |
/* * * */
|
|
47 |
/* * 1.0.10 - 04/08/2007 - G.Juyn * */
|
|
48 |
/* * - added support for mPNG proposal * */
|
|
49 |
/* * 1.0.10 - 04/12/2007 - G.Juyn * */
|
|
50 |
/* * - added support for ANG proposal * */
|
|
51 |
/* * * */
|
|
52 |
/* ************************************************************************** */
|
|
53 |
|
|
54 |
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
|
|
55 |
#pragma option -A /* force ANSI-C */
|
|
56 |
#endif
|
|
57 |
|
|
58 |
#ifndef _libmng_chunk_io_h_
|
|
59 |
#define _libmng_chunk_io_h_
|
|
60 |
|
|
61 |
/* ************************************************************************** */
|
|
62 |
|
|
63 |
mng_uint32 mng_crc (mng_datap pData,
|
|
64 |
mng_uint8p buf,
|
|
65 |
mng_int32 len);
|
|
66 |
|
|
67 |
/* ************************************************************************** */
|
|
68 |
|
|
69 |
#ifdef MNG_INCLUDE_READ_PROCS
|
|
70 |
|
|
71 |
/* ************************************************************************** */
|
|
72 |
|
|
73 |
mng_retcode mng_inflate_buffer (mng_datap pData,
|
|
74 |
mng_uint8p pInbuf,
|
|
75 |
mng_uint32 iInsize,
|
|
76 |
mng_uint8p *pOutbuf,
|
|
77 |
mng_uint32 *iOutsize,
|
|
78 |
mng_uint32 *iRealsize);
|
|
79 |
|
|
80 |
/* ************************************************************************** */
|
|
81 |
|
|
82 |
#define READ_CHUNK(n) mng_retcode n (mng_datap pData, \
|
|
83 |
mng_chunkp pHeader, \
|
|
84 |
mng_uint32 iRawlen, \
|
|
85 |
mng_uint8p pRawdata, \
|
|
86 |
mng_chunkp* ppChunk)
|
|
87 |
|
|
88 |
#ifdef MNG_OPTIMIZE_CHUNKREADER
|
|
89 |
READ_CHUNK (mng_read_general) ;
|
|
90 |
#endif
|
|
91 |
|
|
92 |
READ_CHUNK (mng_read_ihdr) ;
|
|
93 |
READ_CHUNK (mng_read_plte) ;
|
|
94 |
READ_CHUNK (mng_read_idat) ;
|
|
95 |
READ_CHUNK (mng_read_iend) ;
|
|
96 |
READ_CHUNK (mng_read_trns) ;
|
|
97 |
READ_CHUNK (mng_read_gama) ;
|
|
98 |
READ_CHUNK (mng_read_chrm) ;
|
|
99 |
READ_CHUNK (mng_read_srgb) ;
|
|
100 |
#ifndef MNG_SKIPCHUNK_iCCP
|
|
101 |
READ_CHUNK (mng_read_iccp) ;
|
|
102 |
#endif
|
|
103 |
#ifndef MNG_SKIPCHUNK_tEXt
|
|
104 |
READ_CHUNK (mng_read_text) ;
|
|
105 |
#endif
|
|
106 |
#ifndef MNG_SKIPCHUNK_zTXt
|
|
107 |
READ_CHUNK (mng_read_ztxt) ;
|
|
108 |
#endif
|
|
109 |
#ifndef MNG_SKIPCHUNK_iTXt
|
|
110 |
READ_CHUNK (mng_read_itxt) ;
|
|
111 |
#endif
|
|
112 |
#ifndef MNG_SKIPCHUNK_bKGD
|
|
113 |
READ_CHUNK (mng_read_bkgd) ;
|
|
114 |
#endif
|
|
115 |
#ifndef MNG_SKIPCHUNK_pHYs
|
|
116 |
READ_CHUNK (mng_read_phys) ;
|
|
117 |
#endif
|
|
118 |
#ifndef MNG_SKIPCHUNK_sBIT
|
|
119 |
READ_CHUNK (mng_read_sbit) ;
|
|
120 |
#endif
|
|
121 |
#ifndef MNG_SKIPCHUNK_sPLT
|
|
122 |
READ_CHUNK (mng_read_splt) ;
|
|
123 |
#endif
|
|
124 |
#ifndef MNG_SKIPCHUNK_hIST
|
|
125 |
READ_CHUNK (mng_read_hist) ;
|
|
126 |
#endif
|
|
127 |
#ifndef MNG_SKIPCHUNK_tIME
|
|
128 |
READ_CHUNK (mng_read_time) ;
|
|
129 |
#endif
|
|
130 |
READ_CHUNK (mng_read_mhdr) ;
|
|
131 |
READ_CHUNK (mng_read_mend) ;
|
|
132 |
READ_CHUNK (mng_read_loop) ;
|
|
133 |
READ_CHUNK (mng_read_endl) ;
|
|
134 |
READ_CHUNK (mng_read_defi) ;
|
|
135 |
READ_CHUNK (mng_read_basi) ;
|
|
136 |
READ_CHUNK (mng_read_clon) ;
|
|
137 |
#ifndef MNG_SKIPCHUNK_PAST
|
|
138 |
READ_CHUNK (mng_read_past) ;
|
|
139 |
#endif
|
|
140 |
READ_CHUNK (mng_read_disc) ;
|
|
141 |
READ_CHUNK (mng_read_back) ;
|
|
142 |
READ_CHUNK (mng_read_fram) ;
|
|
143 |
READ_CHUNK (mng_read_move) ;
|
|
144 |
READ_CHUNK (mng_read_clip) ;
|
|
145 |
READ_CHUNK (mng_read_show) ;
|
|
146 |
READ_CHUNK (mng_read_term) ;
|
|
147 |
READ_CHUNK (mng_read_save) ;
|
|
148 |
READ_CHUNK (mng_read_seek) ;
|
|
149 |
#ifndef MNG_SKIPCHUNK_eXPI
|
|
150 |
READ_CHUNK (mng_read_expi) ;
|
|
151 |
#endif
|
|
152 |
#ifndef MNG_SKIPCHUNK_fPRI
|
|
153 |
READ_CHUNK (mng_read_fpri) ;
|
|
154 |
#endif
|
|
155 |
#ifndef MNG_SKIPCHUNK_pHYg
|
|
156 |
READ_CHUNK (mng_read_phyg) ;
|
|
157 |
#endif
|
|
158 |
#ifdef MNG_INCLUDE_JNG
|
|
159 |
READ_CHUNK (mng_read_jhdr) ;
|
|
160 |
READ_CHUNK (mng_read_jdaa) ;
|
|
161 |
READ_CHUNK (mng_read_jdat) ;
|
|
162 |
READ_CHUNK (mng_read_jsep) ;
|
|
163 |
#endif
|
|
164 |
#ifndef MNG_NO_DELTA_PNG
|
|
165 |
READ_CHUNK (mng_read_dhdr) ;
|
|
166 |
READ_CHUNK (mng_read_prom) ;
|
|
167 |
READ_CHUNK (mng_read_ipng) ;
|
|
168 |
READ_CHUNK (mng_read_pplt) ;
|
|
169 |
#ifdef MNG_INCLUDE_JNG
|
|
170 |
READ_CHUNK (mng_read_ijng) ;
|
|
171 |
#endif
|
|
172 |
READ_CHUNK (mng_read_drop) ;
|
|
173 |
READ_CHUNK (mng_read_dbyk) ;
|
|
174 |
READ_CHUNK (mng_read_ordr) ;
|
|
175 |
#endif
|
|
176 |
READ_CHUNK (mng_read_magn) ;
|
|
177 |
#ifndef MNG_SKIPCHUNK_nEED
|
|
178 |
READ_CHUNK (mng_read_need) ;
|
|
179 |
#endif
|
|
180 |
#ifdef MNG_INCLUDE_MPNG_PROPOSAL
|
|
181 |
READ_CHUNK (mng_read_mpng) ;
|
|
182 |
#endif
|
|
183 |
#ifndef MNG_SKIPCHUNK_evNT
|
|
184 |
READ_CHUNK (mng_read_evnt) ;
|
|
185 |
#endif
|
|
186 |
READ_CHUNK (mng_read_unknown) ;
|
|
187 |
|
|
188 |
/* ************************************************************************** */
|
|
189 |
|
|
190 |
#else /* MNG_INCLUDE_READ_PROCS */
|
|
191 |
#define mng_read_ihdr 0
|
|
192 |
#define mng_read_plte 0
|
|
193 |
#define mng_read_idat 0
|
|
194 |
#define mng_read_iend 0
|
|
195 |
#define mng_read_trns 0
|
|
196 |
#define mng_read_gama 0
|
|
197 |
#define mng_read_chrm 0
|
|
198 |
#define mng_read_srgb 0
|
|
199 |
#define mng_read_iccp 0
|
|
200 |
#define mng_read_text 0
|
|
201 |
#define mng_read_ztxt 0
|
|
202 |
#define mng_read_itxt 0
|
|
203 |
#define mng_read_bkgd 0
|
|
204 |
#define mng_read_phys 0
|
|
205 |
#define mng_read_sbit 0
|
|
206 |
#define mng_read_splt 0
|
|
207 |
#define mng_read_hist 0
|
|
208 |
#define mng_read_time 0
|
|
209 |
#define mng_read_mhdr 0
|
|
210 |
#define mng_read_mend 0
|
|
211 |
#define mng_read_loop 0
|
|
212 |
#define mng_read_endl 0
|
|
213 |
#define mng_read_defi 0
|
|
214 |
#define mng_read_basi 0
|
|
215 |
#define mng_read_clon 0
|
|
216 |
#ifndef MNG_SKIPCHUNK_PAST
|
|
217 |
#define mng_read_past 0
|
|
218 |
#endif
|
|
219 |
#define mng_read_disc 0
|
|
220 |
#define mng_read_back 0
|
|
221 |
#define mng_read_fram 0
|
|
222 |
#define mng_read_move 0
|
|
223 |
#define mng_read_clip 0
|
|
224 |
#define mng_read_show 0
|
|
225 |
#define mng_read_term 0
|
|
226 |
#define mng_read_save 0
|
|
227 |
#define mng_read_seek 0
|
|
228 |
#define mng_read_expi 0
|
|
229 |
#define mng_read_fpri 0
|
|
230 |
#define mng_read_phyg 0
|
|
231 |
#ifdef MNG_INCLUDE_JNG
|
|
232 |
#define mng_read_jhdr 0
|
|
233 |
#define mng_read_jdaa 0
|
|
234 |
#define mng_read_jdat 0
|
|
235 |
#define mng_read_jsep 0
|
|
236 |
#endif
|
|
237 |
#ifndef MNG_NO_DELTA_PNG
|
|
238 |
#define mng_read_dhdr 0
|
|
239 |
#define mng_read_prom 0
|
|
240 |
#define mng_read_ipng 0
|
|
241 |
#define mng_read_pplt 0
|
|
242 |
#ifdef MNG_INCLUDE_JNG
|
|
243 |
#define mng_read_ijng 0
|
|
244 |
#endif
|
|
245 |
#define mng_read_drop 0
|
|
246 |
#define mng_read_dbyk 0
|
|
247 |
#define mng_read_ordr 0
|
|
248 |
#endif
|
|
249 |
#define mng_read_magn 0
|
|
250 |
#define mng_read_need 0
|
|
251 |
#ifdef MNG_INCLUDE_MPNG_PROPOSAL
|
|
252 |
#define mng_read_mpng 0
|
|
253 |
#endif
|
|
254 |
#define mng_read_evnt 0
|
|
255 |
#define mng_read_unknown 0
|
|
256 |
#endif /* MNG_INCLUDE_READ_PROCS */
|
|
257 |
|
|
258 |
/* ************************************************************************** */
|
|
259 |
|
|
260 |
#ifdef MNG_INCLUDE_WRITE_PROCS
|
|
261 |
|
|
262 |
#define WRITE_CHUNK(n) mng_retcode n (mng_datap pData, \
|
|
263 |
mng_chunkp pChunk)
|
|
264 |
|
|
265 |
WRITE_CHUNK (mng_write_ihdr) ;
|
|
266 |
WRITE_CHUNK (mng_write_plte) ;
|
|
267 |
WRITE_CHUNK (mng_write_idat) ;
|
|
268 |
WRITE_CHUNK (mng_write_iend) ;
|
|
269 |
WRITE_CHUNK (mng_write_trns) ;
|
|
270 |
WRITE_CHUNK (mng_write_gama) ;
|
|
271 |
WRITE_CHUNK (mng_write_chrm) ;
|
|
272 |
WRITE_CHUNK (mng_write_srgb) ;
|
|
273 |
WRITE_CHUNK (mng_write_iccp) ;
|
|
274 |
WRITE_CHUNK (mng_write_text) ;
|
|
275 |
WRITE_CHUNK (mng_write_ztxt) ;
|
|
276 |
WRITE_CHUNK (mng_write_itxt) ;
|
|
277 |
WRITE_CHUNK (mng_write_bkgd) ;
|
|
278 |
WRITE_CHUNK (mng_write_phys) ;
|
|
279 |
WRITE_CHUNK (mng_write_sbit) ;
|
|
280 |
WRITE_CHUNK (mng_write_splt) ;
|
|
281 |
WRITE_CHUNK (mng_write_hist) ;
|
|
282 |
WRITE_CHUNK (mng_write_time) ;
|
|
283 |
WRITE_CHUNK (mng_write_mhdr) ;
|
|
284 |
WRITE_CHUNK (mng_write_mend) ;
|
|
285 |
WRITE_CHUNK (mng_write_loop) ;
|
|
286 |
WRITE_CHUNK (mng_write_endl) ;
|
|
287 |
WRITE_CHUNK (mng_write_defi) ;
|
|
288 |
WRITE_CHUNK (mng_write_basi) ;
|
|
289 |
WRITE_CHUNK (mng_write_clon) ;
|
|
290 |
#ifndef MNG_SKIPCHUNK_PAST
|
|
291 |
WRITE_CHUNK (mng_write_past) ;
|
|
292 |
#endif
|
|
293 |
WRITE_CHUNK (mng_write_disc) ;
|
|
294 |
WRITE_CHUNK (mng_write_back) ;
|
|
295 |
WRITE_CHUNK (mng_write_fram) ;
|
|
296 |
WRITE_CHUNK (mng_write_move) ;
|
|
297 |
WRITE_CHUNK (mng_write_clip) ;
|
|
298 |
WRITE_CHUNK (mng_write_show) ;
|
|
299 |
WRITE_CHUNK (mng_write_term) ;
|
|
300 |
WRITE_CHUNK (mng_write_save) ;
|
|
301 |
WRITE_CHUNK (mng_write_seek) ;
|
|
302 |
WRITE_CHUNK (mng_write_expi) ;
|
|
303 |
WRITE_CHUNK (mng_write_fpri) ;
|
|
304 |
WRITE_CHUNK (mng_write_phyg) ;
|
|
305 |
#ifdef MNG_INCLUDE_JNG
|
|
306 |
WRITE_CHUNK (mng_write_jhdr) ;
|
|
307 |
WRITE_CHUNK (mng_write_jdaa) ;
|
|
308 |
WRITE_CHUNK (mng_write_jdat) ;
|
|
309 |
WRITE_CHUNK (mng_write_jsep) ;
|
|
310 |
#endif
|
|
311 |
#ifndef MNG_NO_DELTA_PNG
|
|
312 |
WRITE_CHUNK (mng_write_dhdr) ;
|
|
313 |
WRITE_CHUNK (mng_write_prom) ;
|
|
314 |
WRITE_CHUNK (mng_write_ipng) ;
|
|
315 |
WRITE_CHUNK (mng_write_pplt) ;
|
|
316 |
#ifdef MNG_INCLUDE_JNG
|
|
317 |
WRITE_CHUNK (mng_write_ijng) ;
|
|
318 |
#endif
|
|
319 |
WRITE_CHUNK (mng_write_drop) ;
|
|
320 |
WRITE_CHUNK (mng_write_dbyk) ;
|
|
321 |
WRITE_CHUNK (mng_write_ordr) ;
|
|
322 |
#endif
|
|
323 |
WRITE_CHUNK (mng_write_magn) ;
|
|
324 |
WRITE_CHUNK (mng_write_need) ;
|
|
325 |
#ifdef MNG_INCLUDE_MPNG_PROPOSAL
|
|
326 |
WRITE_CHUNK (mng_write_mpng) ;
|
|
327 |
#endif
|
|
328 |
#ifdef MNG_INCLUDE_ANG_PROPOSAL
|
|
329 |
WRITE_CHUNK (mng_write_ahdr) ;
|
|
330 |
WRITE_CHUNK (mng_write_adat) ;
|
|
331 |
#endif
|
|
332 |
WRITE_CHUNK (mng_write_evnt) ;
|
|
333 |
WRITE_CHUNK (mng_write_unknown) ;
|
|
334 |
|
|
335 |
/* ************************************************************************** */
|
|
336 |
|
|
337 |
#else /* MNG_INCLUDE_WRITE_PROCS */
|
|
338 |
#define mng_write_ihdr 0
|
|
339 |
#define mng_write_plte 0
|
|
340 |
#define mng_write_idat 0
|
|
341 |
#define mng_write_iend 0
|
|
342 |
#define mng_write_trns 0
|
|
343 |
#define mng_write_gama 0
|
|
344 |
#define mng_write_chrm 0
|
|
345 |
#define mng_write_srgb 0
|
|
346 |
#define mng_write_iccp 0
|
|
347 |
#define mng_write_text 0
|
|
348 |
#define mng_write_ztxt 0
|
|
349 |
#define mng_write_itxt 0
|
|
350 |
#define mng_write_bkgd 0
|
|
351 |
#define mng_write_phys 0
|
|
352 |
#define mng_write_sbit 0
|
|
353 |
#define mng_write_splt 0
|
|
354 |
#define mng_write_hist 0
|
|
355 |
#define mng_write_time 0
|
|
356 |
#define mng_write_mhdr 0
|
|
357 |
#define mng_write_mend 0
|
|
358 |
#define mng_write_loop 0
|
|
359 |
#define mng_write_endl 0
|
|
360 |
#define mng_write_defi 0
|
|
361 |
#define mng_write_basi 0
|
|
362 |
#define mng_write_clon 0
|
|
363 |
#ifndef MNG_SKIPCHUNK_PAST
|
|
364 |
#define mng_write_past 0
|
|
365 |
#endif
|
|
366 |
#define mng_write_disc 0
|
|
367 |
#define mng_write_back 0
|
|
368 |
#define mng_write_fram 0
|
|
369 |
#define mng_write_move 0
|
|
370 |
#define mng_write_clip 0
|
|
371 |
#define mng_write_show 0
|
|
372 |
#define mng_write_term 0
|
|
373 |
#define mng_write_save 0
|
|
374 |
#define mng_write_seek 0
|
|
375 |
#define mng_write_expi 0
|
|
376 |
#define mng_write_fpri 0
|
|
377 |
#define mng_write_phyg 0
|
|
378 |
#ifdef MNG_INCLUDE_JNG
|
|
379 |
#define mng_write_jhdr 0
|
|
380 |
#define mng_write_jdaa 0
|
|
381 |
#define mng_write_jdat 0
|
|
382 |
#define mng_write_jsep 0
|
|
383 |
#endif
|
|
384 |
#ifndef MNG_NO_DELTA_PNG
|
|
385 |
#define mng_write_dhdr 0
|
|
386 |
#define mng_write_prom 0
|
|
387 |
#define mng_write_ipng 0
|
|
388 |
#define mng_write_pplt 0
|
|
389 |
#ifdef MNG_INCLUDE_JNG
|
|
390 |
#define mng_write_ijng 0
|
|
391 |
#endif
|
|
392 |
#define mng_write_drop 0
|
|
393 |
#define mng_write_dbyk 0
|
|
394 |
#define mng_write_ordr 0
|
|
395 |
#endif
|
|
396 |
#define mng_write_magn 0
|
|
397 |
#define mng_write_need 0
|
|
398 |
#ifdef MNG_INCLUDE_MPNG_PROPOSAL
|
|
399 |
#define mng_write_mpng 0
|
|
400 |
#endif
|
|
401 |
#ifdef MNG_INCLUDE_ANG_PROPOSAL
|
|
402 |
#define mng_write_adat 0
|
|
403 |
#define mng_write_ahdr 0
|
|
404 |
#endif
|
|
405 |
#define mng_write_evnt 0
|
|
406 |
#define mng_write_unknown 0
|
|
407 |
#endif /* MNG_INCLUDE_WRITE_PROCS */
|
|
408 |
|
|
409 |
/* ************************************************************************** */
|
|
410 |
|
|
411 |
#endif /* _libmng_chunk_io_h_ */
|
|
412 |
|
|
413 |
/* ************************************************************************** */
|
|
414 |
/* * end of file * */
|
|
415 |
/* ************************************************************************** */
|