1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
|
/* ************************************************************************** */
/* * For conditions of distribution and use, * */
/* * see copyright notice in libmng.h * */
/* ************************************************************************** */
/* * * */
/* * project : libmng * */
/* * file : libmng_types.h copyright (c) 2000 G.Juyn * */
/* * version : 1.0.3 * */
/* * * */
/* * purpose : type specifications * */
/* * * */
/* * author : G.Juyn * */
/* * web : http://www.3-t.com * */
/* * email : mailto:info@3-t.com * */
/* * * */
/* * comment : Specification of the types used by the library * */
/* * Creates platform-independant structure * */
/* * * */
/* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */
/* * - added iteratechunk callback definition * */
/* * 0.5.1 - 05/08/2000 - G.Juyn * */
/* * - improved definitions for DLL support * */
/* * - added 8-bit palette definition * */
/* * - added general array definitions * */
/* * - added MNG_NULL definition * */
/* * - changed strict-ANSI stuff * */
/* * 0.5.1 - 05/11/2000 - G.Juyn * */
/* * - changed most callback prototypes to allow the app * */
/* * to report errors during callback processing * */
/* * 0.5.1 - 05/16/2000 - G.Juyn * */
/* * - moved standard header includes into this file * */
/* * (stdlib/mem for mem-mngmt & math for fp gamma-calc) * */
/* * * */
/* * 0.5.2 - 05/18/2000 - G.Juyn * */
/* * - B003 - fixed problem with <mem.h> being proprietary * */
/* * to Borland platform * */
/* * - added helper definitions for JNG (IJG-based) * */
/* * - fixed support for IJGSRC6B * */
/* * 0.5.2 - 05/24/2000 - G.Juyn * */
/* * - added default IJG compression parameters and such * */
/* * 0.5.2 - 05/31/2000 - G.Juyn * */
/* * - fixed inclusion for memcpy (contributed by Tim Rowley) * */
/* * - added mng_int32p (contributed by Tim Rowley) * */
/* * 0.5.2 - 06/02/2000 - G.Juyn * */
/* * - removed SWAP_ENDIAN reference (contributed by Tim Rowley)* */
/* * - added getalphaline callback for RGB8_A8 canvasstyle * */
/* * * */
/* * 0.5.3 - 06/21/2000 - G.Juyn * */
/* * - added speedtype to facilitate testing * */
/* * 0.5.3 - 06/27/2000 - G.Juyn * */
/* * - added typedef for mng_size_t * */
/* * - changed size parameter for memory callbacks to * */
/* * mng_size_t * */
/* * 0.5.3 - 06/28/2000 - G.Juyn * */
/* * - changed definition of 32-bit ints (64-bit platforms) * */
/* * - changed definition of mng_handle (64-bit platforms) * */
/* * 0.5.3 - 06/29/2000 - G.Juyn * */
/* * - changed definition of mng_handle (again) * */
/* * - swapped refresh parameters * */
/* * - added inclusion of stdlib.h for abs() * */
/* * * */
/* * 0.9.0 - 06/30/2000 - G.Juyn * */
/* * - changed refresh parameters to 'x,y,width,height' * */
/* * 0.9.1 - 07/10/2000 - G.Juyn * */
/* * - added suspendbuffer constants * */
/* * 0.9.1 - 07/15/2000 - G.Juyn * */
/* * - added callbacks for SAVE/SEEK processing * */
/* * * */
/* * 0.9.2 - 08/05/2000 - G.Juyn * */
/* * - changed file-prefixes * */
/* * * */
/* * 0.9.3 - 08/07/2000 - G.Juyn * */
/* * - B111300 - fixup for improved portability * */
/* * 0.9.3 - 08/12/2000 - G.Juyn * */
/* * - added workaround for faulty PhotoShop iCCP chunk * */
/* * 0.9.3 - 09/11/2000 - G.Juyn * */
/* * - added export of zlib functions from windows dll * */
/* * - fixed inclusion parameters once again to make those * */
/* * external libs work together * */
/* * - re-fixed fixed inclusion parameters * */
/* * (these freeking libraries make me mad) * */
/* * 0.9.3 - 10/11/2000 - G.Juyn * */
/* * - added support for nEED * */
/* * 0.9.3 - 10/17/2000 - G.Juyn * */
/* * - added callback to process non-critical unknown chunks * */
/* * * */
/* * 0.9.4 - 11/20/2000 - R.Giles * */
/* * - fixed inclusion of lcms header for non-windows platforms * */
/* * 0.9.4 - 12/12/2000 - G.Juyn * */
/* * - changed callback convention for MSVC (Thanks Chad) * */
/* * 0.9.4 - 12/16/2000 - G.Juyn * */
/* * - fixed mixup of data- & function-pointers (thanks Dimitri)* */
/* * * */
/* * 1.0.1 - 02/08/2001 - G.Juyn * */
/* * - added MEND processing callback * */
/* * * */
/* * 1.0.2 - 06/23/2001 - G.Juyn * */
/* * - added processterm callback * */
/* * * */
/* * 1.0.3 - 08/06/2001 - G.Juyn * */
/* * - changed inclusion of lcms.h for Linux platforms * */
/* * * */
/* ************************************************************************** */
#ifndef _libmng_types_h_
#define _libmng_types_h_
/* ************************************************************************** */
#ifdef __BORLANDC__
#pragma option -AT /* turn off strict ANSI-C for the moment */
#endif
#ifndef WIN32
#if defined(_WIN32) || defined(__WIN32__) || defined(_Windows) || defined(_WINDOWS)
#define WIN32 /* gather them into a single define */
#endif
#endif
/* ************************************************************************** */
/* * * */
/* * Here's where the external & standard libs are embedded * */
/* * * */
/* * (it can be a bit of a pain in the lower-back to get them to work * */
/* * together) * */
/* * * */
/* ************************************************************************** */
#ifdef WIN32 /* only include needed stuff */
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#endif
#ifdef MNG_USE_DLL
#ifdef MNG_SKIP_ZLIB
#undef MNG_INCLUDE_ZLIB
#endif
#ifdef MNG_SKIP_LCMS
#undef MNG_INCLUDE_LCMS
#endif
#ifdef MNG_SKIP_IJG6B
#undef MNG_INCLUDE_IJG6B
#endif
#endif
#ifdef MNG_INCLUDE_ZLIB /* zlib by Mark Adler & Jean-loup Gailly */
#include "zlib.h"
#endif
#ifdef MNG_INCLUDE_LCMS /* little cms by Marti Maria Saguer */
#ifndef ZLIB_DLL
#undef FAR
#endif
#if defined(WIN32) || defined(linux) /* different header locations */
#include "lcms.h"
#else
#include "lcms/lcms.h"
#endif
#endif /* MNG_INCLUDE_LCMS */
#ifdef MNG_INCLUDE_IJG6B /* IJG's jpgsrc6b */
#include <stdio.h>
#ifdef MNG_USE_SETJMP
#include <setjmp.h> /* needed for error-recovery (blergh) */
#else
#ifdef WIN32
#define USE_WINDOWS_MESSAGEBOX /* display a messagebox under Windoze */
#endif
#endif /* MNG_USE_SETJMP */
#ifdef FAR
#undef FAR /* possibly defined by zlib or lcms */
#endif
#include "jpeglib.h" /* all that for JPEG support :-) */
#endif /* MNG_INCLUDE_IJG6B */
#if defined(MNG_INTERNAL_MEMMNGMT) || defined(MNG_INCLUDE_FILTERS)
#include <stdlib.h> /* "calloc" & "free" & "abs" */
#endif
#include <limits.h> /* get proper integer widths */
#ifdef WIN32
/* B003 */
#if defined __BORLANDC__
#include <mem.h> /* defines "memcpy" for BCB */
#else
#include <memory.h> /* defines "memcpy" for other win32 platforms */
#endif
/* B003 */
#ifdef MNG_CHECK_BAD_ICCP
#include <string.h> /* strncmp() */
#endif
#else
#ifdef BSD
#include <strings.h> /* defines "memcpy" for BSD (?) */
#else
#include <string.h> /* defines "memcpy" for all others (???) */
#endif
#endif
#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY)
#include <math.h> /* fp gamma-calculation */
#endif
/* ************************************************************************** */
/* * * */
/* * Platform-dependant stuff * */
/* * * */
/* ************************************************************************** */
/* TODO: this may require some elaboration for other platforms;
only works with BCB for now */
#ifndef MNG_DLL
#if defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL)
#define MNG_DLL
#endif
#endif
#if defined(MNG_DLL) && defined(WIN32) /* setup DLL calling conventions */
#define MNG_DECL __stdcall
#if defined(MNG_BUILD_DLL)
#define MNG_EXT __declspec(dllexport)
#elif defined(MNG_USE_DLL)
#define MNG_EXT __declspec(dllimport)
#else
#define MNG_EXT
#endif
#ifdef MNG_STRICT_ANSI
#undef MNG_STRICT_ANSI /* can't do strict-ANSI with this DLL-stuff */
#endif
#else
#define MNG_DECL /* dummies for non-DLL */
#define MNG_EXT
#endif /* MNG_DLL && WIN32 */
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
#pragma option -A /* now force ANSI-C from here on */
#endif
/* ************************************************************************** */
#if USHRT_MAX == 0xffffffffU /* get the proper 32-bit width !!! */
typedef unsigned short mng_uint32;
typedef signed short mng_int32;
#elif UINT_MAX == 0xffffffffU
typedef unsigned int mng_uint32;
typedef signed int mng_int32;
#elif ULONG_MAX == 0xffffffffU
typedef unsigned long mng_uint32;
typedef signed long mng_int32;
#else
#error "Sorry, I can't tqfind any 32-bit integers on this platform."
#endif
typedef signed short mng_int16; /* other basic integers */
typedef unsigned short mng_uint16;
typedef signed char mng_int8;
typedef unsigned char mng_uint8;
typedef double mng_float; /* basic float */
typedef size_t mng_size_t; /* size field for memory allocation */
typedef char * mng_pchar; /* string */
typedef void * mng_ptr; /* generic pointer */
typedef void (*mng_fptr) (void); /* generic function pointer */
/* ************************************************************************** */
/* * * */
/* * Platform-independant from here * */
/* * * */
/* ************************************************************************** */
typedef mng_uint32 * mng_uint32p; /* pointer to unsigned longs */
typedef mng_int32 * mng_int32p; /* pointer to longs */
typedef mng_uint16 * mng_uint16p; /* pointer to unsigned words */
typedef mng_uint8 * mng_uint8p; /* pointer to unsigned bytes */
typedef mng_int8 mng_bool; /* booleans */
struct mng_data_struct;
typedef struct mng_data_struct * mng_handle; /* generic handle */
typedef mng_int32 mng_retcode; /* generic return code */
typedef mng_int32 mng_chunkid; /* 4-byte chunkname identifier */
typedef mng_ptr mng_chunkp; /* pointer to a chunk-structure */
typedef mng_ptr mng_objectp; /* pointer to an object-structure */
typedef mng_chunkid * mng_chunkidp; /* pointer to chunkid */
typedef struct { /* 8-bit palette element */
mng_uint8 iRed;
mng_uint8 iGreen;
mng_uint8 iBlue;
} mng_palette8e;
typedef mng_palette8e mng_palette8[256]; /* 8-bit palette */
typedef mng_palette8e * mng_palette8ep;
typedef mng_uint8 mng_uint8arr[256]; /* generic arrays */
typedef mng_uint8 mng_uint8arr4[4];
typedef mng_uint16 mng_uint16arr[256];
typedef mng_uint32 mng_uint32arr2[2];
/* ************************************************************************** */
#define MNG_FALSE 0
#define MNG_TRUE 1
#define MNG_NULL 0
#define MNG_SUSPENDBUFFERSIZE 32768
#define MNG_SUSPENDRETQUESTSIZE 1024
/* ************************************************************************** */
#ifdef MNG_INCLUDE_ZLIB
/* size of temporary zlib buffer for deflate processing */
#define MNG_ZLIB_MAXBUF 8192
/* default zlib compression parameters for deflateinit2 */
#define MNG_ZLIB_LEVEL 9 /* level */
#define MNG_ZLIB_METHOD Z_DEFLATED /* method */
#define MNG_ZLIB_WINDOWBITS 15 /* window size */
#define MNG_ZLIB_MEMLEVEL 9 /* memory level */
#define MNG_ZLIB_STRATEGY Z_DEFAULT_STRATEGY /* strategy */
#define MNG_MAX_IDAT_SIZE 4096 /* maximum size of IDAT data */
#endif /* MNG_INCLUDE_ZLIB */
/* ************************************************************************** */
#ifdef MNG_INCLUDE_JNG
#ifdef MNG_INCLUDE_IJG6B /* IJG helper defs */
typedef struct jpeg_compress_struct mngjpeg_comp;
typedef struct jpeg_decompress_struct mngjpeg_decomp;
typedef struct jpeg_error_mgr mngjpeg_error;
typedef struct jpeg_source_mgr mngjpeg_source;
typedef mngjpeg_comp * mngjpeg_compp;
typedef mngjpeg_decomp * mngjpeg_decompp;
typedef mngjpeg_error * mngjpeg_errorp;
typedef mngjpeg_source * mngjpeg_sourcep;
typedef J_DCT_METHOD mngjpeg_dctmethod;
/* default IJG parameters for compression */
#define MNG_JPEG_DCT JDCT_DEFAULT /* DCT algorithm (JDCT_ISLOW) */
#define MNG_JPEG_TQUALITY 100 /* quality 0..100; 100=best */
#define MNG_JPEG_SMOOTHING 0 /* default no smoothing */
#define MNG_JPEG_PROGRESSIVE MNG_FALSE /* default is just baseline */
#define MNG_JPEG_OPTIMIZED MNG_FALSE /* default is not optimized */
#endif /* MNG_INCLUDE_IJG6B */
#define MNG_JPEG_MAXBUF 65500 /* max size of temp JPEG buffer */
#define MNG_MAX_JDAT_SIZE 4096 /* maximum size of JDAT data */
#endif /* MNG_INCLUDE_JNG */
/* ************************************************************************** */
#ifdef MNG_INCLUDE_LCMS
typedef cmsHPROFILE mng_cmsprof; /* little CMS helper defs */
typedef cmsHTRANSFORM mng_cmstrans;
typedef cmsCIExyY mng_CIExyY;
typedef cmsCIExyYTRIPLE mng_CIExyYTRIPLE;
typedef LPGAMMATABLE mng_gammatabp;
#endif /* MNG_INCLUDE_LCMS */
/* ************************************************************************** */
/* enumeration of known graphics types */
enum mng_imgtypes {mng_it_unknown, mng_it_png, mng_it_mng, mng_it_jng};
typedef enum mng_imgtypes mng_imgtype;
/* enumeration of animation speed-types */
enum mng_speedtypes {mng_st_normal, mng_st_fast, mng_st_slow, mng_st_slowest};
typedef enum mng_speedtypes mng_speedtype;
/* ************************************************************************** */
/* memory management callbacks */
typedef mng_ptr (MNG_DECL *mng_memalloc) (mng_size_t iLen);
typedef void (MNG_DECL *mng_memfree) (mng_ptr iPtr,
mng_size_t iLen);
/* I/O management callbacks */
typedef mng_bool (MNG_DECL *mng_openstream) (mng_handle hHandle);
typedef mng_bool (MNG_DECL *mng_closestream) (mng_handle hHandle);
typedef mng_bool (MNG_DECL *mng_readdata) (mng_handle hHandle,
mng_ptr pBuf,
mng_uint32 iBuflen,
mng_uint32p pRead);
typedef mng_bool (MNG_DECL *mng_writedata) (mng_handle hHandle,
mng_ptr pBuf,
mng_uint32 iBuflen,
mng_uint32p pWritten);
/* error & trace processing callbacks */
typedef mng_bool (MNG_DECL *mng_errorproc) (mng_handle hHandle,
mng_int32 iErrorcode,
mng_int8 iSeverity,
mng_chunkid iChunkname,
mng_uint32 iChunkseq,
mng_int32 iExtra1,
mng_int32 iExtra2,
mng_pchar zErrortext);
typedef mng_bool (MNG_DECL *mng_traceproc) (mng_handle hHandle,
mng_int32 iFuncnr,
mng_int32 iFuncseq,
mng_pchar zFuncname);
/* read processing callbacks */
typedef mng_bool (MNG_DECL *mng_processheader) (mng_handle hHandle,
mng_uint32 iWidth,
mng_uint32 iHeight);
typedef mng_bool (MNG_DECL *mng_processtext) (mng_handle hHandle,
mng_uint8 iType,
mng_pchar zKeyword,
mng_pchar zText,
mng_pchar zLanguage,
mng_pchar zTranslation);
typedef mng_bool (MNG_DECL *mng_processsave) (mng_handle hHandle);
typedef mng_bool (MNG_DECL *mng_processseek) (mng_handle hHandle,
mng_pchar zName);
typedef mng_bool (MNG_DECL *mng_processneed) (mng_handle hHandle,
mng_pchar zKeyword);
typedef mng_bool (MNG_DECL *mng_processmend) (mng_handle hHandle,
mng_uint32 iIterationsdone,
mng_uint32 iIterationsleft);
typedef mng_bool (MNG_DECL *mng_processunknown) (mng_handle hHandle,
mng_chunkid iChunkid,
mng_uint32 iRawlen,
mng_ptr pRawdata);
typedef mng_bool (MNG_DECL *mng_processterm) (mng_handle hHandle,
mng_uint8 iTermaction,
mng_uint8 iIteraction,
mng_uint32 iDelay,
mng_uint32 iItermax);
/* display processing callbacks */
typedef mng_ptr (MNG_DECL *mng_getcanvasline) (mng_handle hHandle,
mng_uint32 iLinenr);
typedef mng_ptr (MNG_DECL *mng_getbkgdline) (mng_handle hHandle,
mng_uint32 iLinenr);
typedef mng_ptr (MNG_DECL *mng_getalphaline) (mng_handle hHandle,
mng_uint32 iLinenr);
typedef mng_bool (MNG_DECL *mng_refresh) (mng_handle hHandle,
mng_uint32 iX,
mng_uint32 iY,
mng_uint32 iWidth,
mng_uint32 iHeight);
/* timer management callbacks */
typedef mng_uint32 (MNG_DECL *mng_gettickcount) (mng_handle hHandle);
typedef mng_bool (MNG_DECL *mng_settimer) (mng_handle hHandle,
mng_uint32 iMsecs);
/* color management callbacks */
typedef mng_bool (MNG_DECL *mng_processgamma) (mng_handle hHandle,
mng_uint32 iGamma);
typedef mng_bool (MNG_DECL *mng_processchroma) (mng_handle hHandle,
mng_uint32 iWhitepointx,
mng_uint32 iWhitepointy,
mng_uint32 iRedx,
mng_uint32 iRedy,
mng_uint32 iGreenx,
mng_uint32 iGreeny,
mng_uint32 iBluex,
mng_uint32 iBluey);
typedef mng_bool (MNG_DECL *mng_processsrgb) (mng_handle hHandle,
mng_uint8 iRenderingintent);
typedef mng_bool (MNG_DECL *mng_processiccp) (mng_handle hHandle,
mng_uint32 iProfilesize,
mng_ptr pProfile);
typedef mng_bool (MNG_DECL *mng_processarow) (mng_handle hHandle,
mng_uint32 iRowsamples,
mng_bool bIsRGBA16,
mng_ptr pRow);
/* chunk access callback(s) */
typedef mng_bool (MNG_DECL *mng_iteratechunk) (mng_handle hHandle,
mng_handle hChunk,
mng_chunkid iChunkid,
mng_uint32 iChunkseq);
/* ************************************************************************** */
#endif /* _libmng_types_h_ */
/* ************************************************************************** */
/* * end of file * */
/* ************************************************************************** */
|