Eneboo - Documentación para desarrolladores
|
00001 /* ************************************************************************** */ 00002 /* * For conditions of distribution and use, * */ 00003 /* * see copyright notice in libmng.h * */ 00004 /* ************************************************************************** */ 00005 /* * * */ 00006 /* * project : libmng * */ 00007 /* * file : libmng_types.h copyright (c) 2000 G.Juyn * */ 00008 /* * version : 1.0.3 * */ 00009 /* * * */ 00010 /* * purpose : type specifications * */ 00011 /* * * */ 00012 /* * author : G.Juyn * */ 00013 /* * web : http://www.3-t.com * */ 00014 /* * email : mailto:info@3-t.com * */ 00015 /* * * */ 00016 /* * comment : Specification of the types used by the library * */ 00017 /* * Creates platform-independant structure * */ 00018 /* * * */ 00019 /* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */ 00020 /* * - added iteratechunk callback definition * */ 00021 /* * 0.5.1 - 05/08/2000 - G.Juyn * */ 00022 /* * - improved definitions for DLL support * */ 00023 /* * - added 8-bit palette definition * */ 00024 /* * - added general array definitions * */ 00025 /* * - added MNG_NULL definition * */ 00026 /* * - changed strict-ANSI stuff * */ 00027 /* * 0.5.1 - 05/11/2000 - G.Juyn * */ 00028 /* * - changed most callback prototypes to allow the app * */ 00029 /* * to report errors during callback processing * */ 00030 /* * 0.5.1 - 05/16/2000 - G.Juyn * */ 00031 /* * - moved standard header includes into this file * */ 00032 /* * (stdlib/mem for mem-mngmt & math for fp gamma-calc) * */ 00033 /* * * */ 00034 /* * 0.5.2 - 05/18/2000 - G.Juyn * */ 00035 /* * - B003 - fixed problem with <mem.h> being proprietary * */ 00036 /* * to Borland platform * */ 00037 /* * - added helper definitions for JNG (IJG-based) * */ 00038 /* * - fixed support for IJGSRC6B * */ 00039 /* * 0.5.2 - 05/24/2000 - G.Juyn * */ 00040 /* * - added default IJG compression parameters and such * */ 00041 /* * 0.5.2 - 05/31/2000 - G.Juyn * */ 00042 /* * - fixed inclusion for memcpy (contributed by Tim Rowley) * */ 00043 /* * - added mng_int32p (contributed by Tim Rowley) * */ 00044 /* * 0.5.2 - 06/02/2000 - G.Juyn * */ 00045 /* * - removed SWAP_ENDIAN reference (contributed by Tim Rowley)* */ 00046 /* * - added getalphaline callback for RGB8_A8 canvasstyle * */ 00047 /* * * */ 00048 /* * 0.5.3 - 06/21/2000 - G.Juyn * */ 00049 /* * - added speedtype to facilitate testing * */ 00050 /* * 0.5.3 - 06/27/2000 - G.Juyn * */ 00051 /* * - added typedef for mng_size_t * */ 00052 /* * - changed size parameter for memory callbacks to * */ 00053 /* * mng_size_t * */ 00054 /* * 0.5.3 - 06/28/2000 - G.Juyn * */ 00055 /* * - changed definition of 32-bit ints (64-bit platforms) * */ 00056 /* * - changed definition of mng_handle (64-bit platforms) * */ 00057 /* * 0.5.3 - 06/29/2000 - G.Juyn * */ 00058 /* * - changed definition of mng_handle (again) * */ 00059 /* * - swapped refresh parameters * */ 00060 /* * - added inclusion of stdlib.h for abs() * */ 00061 /* * * */ 00062 /* * 0.9.0 - 06/30/2000 - G.Juyn * */ 00063 /* * - changed refresh parameters to 'x,y,width,height' * */ 00064 /* * 0.9.1 - 07/10/2000 - G.Juyn * */ 00065 /* * - added suspendbuffer constants * */ 00066 /* * 0.9.1 - 07/15/2000 - G.Juyn * */ 00067 /* * - added callbacks for SAVE/SEEK processing * */ 00068 /* * * */ 00069 /* * 0.9.2 - 08/05/2000 - G.Juyn * */ 00070 /* * - changed file-prefixes * */ 00071 /* * * */ 00072 /* * 0.9.3 - 08/07/2000 - G.Juyn * */ 00073 /* * - B111300 - fixup for improved portability * */ 00074 /* * 0.9.3 - 08/12/2000 - G.Juyn * */ 00075 /* * - added workaround for faulty PhotoShop iCCP chunk * */ 00076 /* * 0.9.3 - 09/11/2000 - G.Juyn * */ 00077 /* * - added export of zlib functions from windows dll * */ 00078 /* * - fixed inclusion parameters once again to make those * */ 00079 /* * external libs work together * */ 00080 /* * - re-fixed fixed inclusion parameters * */ 00081 /* * (these freeking libraries make me mad) * */ 00082 /* * 0.9.3 - 10/11/2000 - G.Juyn * */ 00083 /* * - added support for nEED * */ 00084 /* * 0.9.3 - 10/17/2000 - G.Juyn * */ 00085 /* * - added callback to process non-critical unknown chunks * */ 00086 /* * * */ 00087 /* * 0.9.4 - 11/20/2000 - R.Giles * */ 00088 /* * - fixed inclusion of lcms header for non-windows platforms * */ 00089 /* * 0.9.4 - 12/12/2000 - G.Juyn * */ 00090 /* * - changed callback convention for MSVC (Thanks Chad) * */ 00091 /* * 0.9.4 - 12/16/2000 - G.Juyn * */ 00092 /* * - fixed mixup of data- & function-pointers (thanks Dimitri)* */ 00093 /* * * */ 00094 /* * 1.0.1 - 02/08/2001 - G.Juyn * */ 00095 /* * - added MEND processing callback * */ 00096 /* * * */ 00097 /* * 1.0.2 - 06/23/2001 - G.Juyn * */ 00098 /* * - added processterm callback * */ 00099 /* * * */ 00100 /* * 1.0.3 - 08/06/2001 - G.Juyn * */ 00101 /* * - changed inclusion of lcms.h for Linux platforms * */ 00102 /* * * */ 00103 /* ************************************************************************** */ 00104 00105 #ifndef _libmng_types_h_ 00106 #define _libmng_types_h_ 00107 00108 /* ************************************************************************** */ 00109 00110 #ifdef __BORLANDC__ 00111 #pragma option -AT /* turn off strict ANSI-C for the moment */ 00112 #endif 00113 00114 #ifndef WIN32 00115 #if defined(_WIN32) || defined(__WIN32__) || defined(_Windows) || defined(_WINDOWS) 00116 #define WIN32 /* gather them into a single define */ 00117 #endif 00118 #endif 00119 00120 /* ************************************************************************** */ 00121 /* * * */ 00122 /* * Here's where the external & standard libs are embedded * */ 00123 /* * * */ 00124 /* * (it can be a bit of a pain in the lower-back to get them to work * */ 00125 /* * together) * */ 00126 /* * * */ 00127 /* ************************************************************************** */ 00128 00129 #ifdef WIN32 /* only include needed stuff */ 00130 #ifndef WIN32_LEAN_AND_MEAN 00131 #define WIN32_LEAN_AND_MEAN 00132 #endif 00133 #endif 00134 00135 #ifdef MNG_USE_DLL 00136 #ifdef MNG_SKIP_ZLIB 00137 #undef MNG_INCLUDE_ZLIB 00138 #endif 00139 #ifdef MNG_SKIP_LCMS 00140 #undef MNG_INCLUDE_LCMS 00141 #endif 00142 #ifdef MNG_SKIP_IJG6B 00143 #undef MNG_INCLUDE_IJG6B 00144 #endif 00145 #endif 00146 00147 #ifdef MNG_INCLUDE_ZLIB /* zlib by Mark Adler & Jean-loup Gailly */ 00148 #include "zlib.h" 00149 #endif 00150 00151 #ifdef MNG_INCLUDE_LCMS /* little cms by Marti Maria Saguer */ 00152 #ifndef ZLIB_DLL 00153 #undef FAR 00154 #endif 00155 #if defined(WIN32) || defined(linux) /* different header locations */ 00156 #include "lcms.h" 00157 #else 00158 #include "lcms/lcms.h" 00159 #endif 00160 #endif /* MNG_INCLUDE_LCMS */ 00161 00162 #ifdef MNG_INCLUDE_IJG6B /* IJG's jpgsrc6b */ 00163 #include <stdio.h> 00164 #ifdef MNG_USE_SETJMP 00165 #include <setjmp.h> /* needed for error-recovery (blergh) */ 00166 #else 00167 #ifdef WIN32 00168 #define USE_WINDOWS_MESSAGEBOX /* display a messagebox under Windoze */ 00169 #endif 00170 #endif /* MNG_USE_SETJMP */ 00171 #ifdef FAR 00172 #undef FAR /* possibly defined by zlib or lcms */ 00173 #endif 00174 #include "jpeglib.h" /* all that for JPEG support :-) */ 00175 #endif /* MNG_INCLUDE_IJG6B */ 00176 00177 #if defined(MNG_INTERNAL_MEMMNGMT) || defined(MNG_INCLUDE_FILTERS) 00178 #include <stdlib.h> /* "calloc" & "free" & "abs" */ 00179 #endif 00180 00181 #include <limits.h> /* get proper integer widths */ 00182 00183 #ifdef WIN32 00184 /* B003 */ 00185 #if defined __BORLANDC__ 00186 #include <mem.h> /* defines "memcpy" for BCB */ 00187 #else 00188 #include <memory.h> /* defines "memcpy" for other win32 platforms */ 00189 #endif 00190 /* B003 */ 00191 #ifdef MNG_CHECK_BAD_ICCP 00192 #include <string.h> /* strncmp() */ 00193 #endif 00194 #else 00195 #ifdef BSD 00196 #include <strings.h> /* defines "memcpy" for BSD (?) */ 00197 #else 00198 #include <string.h> /* defines "memcpy" for all others (???) */ 00199 #endif 00200 #endif 00201 00202 #if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) 00203 #include <math.h> /* fp gamma-calculation */ 00204 #endif 00205 00206 /* ************************************************************************** */ 00207 /* * * */ 00208 /* * Platform-dependant stuff * */ 00209 /* * * */ 00210 /* ************************************************************************** */ 00211 00212 /* TODO: this may require some elaboration for other platforms; 00213 only works with BCB for now */ 00214 00215 #ifndef MNG_DLL 00216 #if defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL) 00217 #define MNG_DLL 00218 #endif 00219 #endif 00220 00221 #if defined(MNG_DLL) && defined(WIN32) /* setup DLL calling conventions */ 00222 #define MNG_DECL __stdcall 00223 #if defined(MNG_BUILD_DLL) 00224 #define MNG_EXT __declspec(dllexport) 00225 #elif defined(MNG_USE_DLL) 00226 #define MNG_EXT __declspec(dllimport) 00227 #else 00228 #define MNG_EXT 00229 #endif 00230 #ifdef MNG_STRICT_ANSI 00231 #undef MNG_STRICT_ANSI /* can't do strict-ANSI with this DLL-stuff */ 00232 #endif 00233 #else 00234 #define MNG_DECL /* dummies for non-DLL */ 00235 #define MNG_EXT 00236 #endif /* MNG_DLL && WIN32 */ 00237 00238 #if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) 00239 #pragma option -A /* now force ANSI-C from here on */ 00240 #endif 00241 00242 /* ************************************************************************** */ 00243 00244 #if USHRT_MAX == 0xffffffffU /* get the proper 32-bit width !!! */ 00245 typedef unsigned short mng_uint32; 00246 typedef signed short mng_int32; 00247 #elif UINT_MAX == 0xffffffffU 00248 typedef unsigned int mng_uint32; 00249 typedef signed int mng_int32; 00250 #elif ULONG_MAX == 0xffffffffU 00251 typedef unsigned long mng_uint32; 00252 typedef signed long mng_int32; 00253 #else 00254 #error "Sorry, I can't find any 32-bit integers on this platform." 00255 #endif 00256 00257 typedef signed short mng_int16; /* other basic integers */ 00258 typedef unsigned short mng_uint16; 00259 typedef signed char mng_int8; 00260 typedef unsigned char mng_uint8; 00261 00262 typedef double mng_float; /* basic float */ 00263 00264 typedef size_t mng_size_t; /* size field for memory allocation */ 00265 00266 typedef char * mng_pchar; /* string */ 00267 typedef void * mng_ptr; /* generic pointer */ 00268 typedef void (*mng_fptr) (void); /* generic function pointer */ 00269 00270 /* ************************************************************************** */ 00271 /* * * */ 00272 /* * Platform-independant from here * */ 00273 /* * * */ 00274 /* ************************************************************************** */ 00275 00276 typedef mng_uint32 * mng_uint32p; /* pointer to unsigned longs */ 00277 typedef mng_int32 * mng_int32p; /* pointer to longs */ 00278 typedef mng_uint16 * mng_uint16p; /* pointer to unsigned words */ 00279 typedef mng_uint8 * mng_uint8p; /* pointer to unsigned bytes */ 00280 00281 typedef mng_int8 mng_bool; /* booleans */ 00282 00283 struct mng_data_struct; 00284 typedef struct mng_data_struct * mng_handle; /* generic handle */ 00285 00286 typedef mng_int32 mng_retcode; /* generic return code */ 00287 typedef mng_int32 mng_chunkid; /* 4-byte chunkname identifier */ 00288 typedef mng_ptr mng_chunkp; /* pointer to a chunk-structure */ 00289 typedef mng_ptr mng_objectp; /* pointer to an object-structure */ 00290 00291 typedef mng_chunkid * mng_chunkidp; /* pointer to chunkid */ 00292 00293 typedef struct { /* 8-bit palette element */ 00294 mng_uint8 iRed; 00295 mng_uint8 iGreen; 00296 mng_uint8 iBlue; 00297 } mng_palette8e; 00298 typedef mng_palette8e mng_palette8[256]; /* 8-bit palette */ 00299 typedef mng_palette8e * mng_palette8ep; 00300 00301 typedef mng_uint8 mng_uint8arr[256]; /* generic arrays */ 00302 typedef mng_uint8 mng_uint8arr4[4]; 00303 typedef mng_uint16 mng_uint16arr[256]; 00304 typedef mng_uint32 mng_uint32arr2[2]; 00305 00306 /* ************************************************************************** */ 00307 00308 #define MNG_FALSE 0 00309 #define MNG_TRUE 1 00310 #define MNG_NULL 0 00311 00312 #define MNG_SUSPENDBUFFERSIZE 32768 00313 #define MNG_SUSPENDREQUESTSIZE 1024 00314 00315 /* ************************************************************************** */ 00316 00317 #ifdef MNG_INCLUDE_ZLIB 00318 00319 /* size of temporary zlib buffer for deflate processing */ 00320 #define MNG_ZLIB_MAXBUF 8192 00321 00322 /* default zlib compression parameters for deflateinit2 */ 00323 #define MNG_ZLIB_LEVEL 9 /* level */ 00324 #define MNG_ZLIB_METHOD Z_DEFLATED /* method */ 00325 #define MNG_ZLIB_WINDOWBITS 15 /* window size */ 00326 #define MNG_ZLIB_MEMLEVEL 9 /* memory level */ 00327 #define MNG_ZLIB_STRATEGY Z_DEFAULT_STRATEGY /* strategy */ 00328 00329 #define MNG_MAX_IDAT_SIZE 4096 /* maximum size of IDAT data */ 00330 00331 #endif /* MNG_INCLUDE_ZLIB */ 00332 00333 /* ************************************************************************** */ 00334 00335 #ifdef MNG_INCLUDE_JNG 00336 00337 #ifdef MNG_INCLUDE_IJG6B /* IJG helper defs */ 00338 typedef struct jpeg_compress_struct mngjpeg_comp; 00339 typedef struct jpeg_decompress_struct mngjpeg_decomp; 00340 typedef struct jpeg_error_mgr mngjpeg_error; 00341 typedef struct jpeg_source_mgr mngjpeg_source; 00342 00343 typedef mngjpeg_comp * mngjpeg_compp; 00344 typedef mngjpeg_decomp * mngjpeg_decompp; 00345 typedef mngjpeg_error * mngjpeg_errorp; 00346 typedef mngjpeg_source * mngjpeg_sourcep; 00347 00348 typedef J_DCT_METHOD mngjpeg_dctmethod; 00349 00350 /* default IJG parameters for compression */ 00351 #define MNG_JPEG_DCT JDCT_DEFAULT /* DCT algorithm (JDCT_ISLOW) */ 00352 #define MNG_JPEG_QUALITY 100 /* quality 0..100; 100=best */ 00353 #define MNG_JPEG_SMOOTHING 0 /* default no smoothing */ 00354 #define MNG_JPEG_PROGRESSIVE MNG_FALSE /* default is just baseline */ 00355 #define MNG_JPEG_OPTIMIZED MNG_FALSE /* default is not optimized */ 00356 #endif /* MNG_INCLUDE_IJG6B */ 00357 00358 #define MNG_JPEG_MAXBUF 65500 /* max size of temp JPEG buffer */ 00359 #define MNG_MAX_JDAT_SIZE 4096 /* maximum size of JDAT data */ 00360 00361 #endif /* MNG_INCLUDE_JNG */ 00362 00363 /* ************************************************************************** */ 00364 00365 #ifdef MNG_INCLUDE_LCMS 00366 typedef cmsHPROFILE mng_cmsprof; /* little CMS helper defs */ 00367 typedef cmsHTRANSFORM mng_cmstrans; 00368 typedef cmsCIExyY mng_CIExyY; 00369 typedef cmsCIExyYTRIPLE mng_CIExyYTRIPLE; 00370 typedef LPGAMMATABLE mng_gammatabp; 00371 #endif /* MNG_INCLUDE_LCMS */ 00372 00373 /* ************************************************************************** */ 00374 00375 /* enumeration of known graphics types */ 00376 enum mng_imgtypes {mng_it_unknown, mng_it_png, mng_it_mng, mng_it_jng}; 00377 typedef enum mng_imgtypes mng_imgtype; 00378 00379 /* enumeration of animation speed-types */ 00380 enum mng_speedtypes {mng_st_normal, mng_st_fast, mng_st_slow, mng_st_slowest}; 00381 typedef enum mng_speedtypes mng_speedtype; 00382 00383 /* ************************************************************************** */ 00384 00385 /* memory management callbacks */ 00386 typedef mng_ptr (MNG_DECL *mng_memalloc) (mng_size_t iLen); 00387 typedef void (MNG_DECL *mng_memfree) (mng_ptr iPtr, 00388 mng_size_t iLen); 00389 00390 /* I/O management callbacks */ 00391 typedef mng_bool (MNG_DECL *mng_openstream) (mng_handle hHandle); 00392 typedef mng_bool (MNG_DECL *mng_closestream) (mng_handle hHandle); 00393 typedef mng_bool (MNG_DECL *mng_readdata) (mng_handle hHandle, 00394 mng_ptr pBuf, 00395 mng_uint32 iBuflen, 00396 mng_uint32p pRead); 00397 typedef mng_bool (MNG_DECL *mng_writedata) (mng_handle hHandle, 00398 mng_ptr pBuf, 00399 mng_uint32 iBuflen, 00400 mng_uint32p pWritten); 00401 00402 /* error & trace processing callbacks */ 00403 typedef mng_bool (MNG_DECL *mng_errorproc) (mng_handle hHandle, 00404 mng_int32 iErrorcode, 00405 mng_int8 iSeverity, 00406 mng_chunkid iChunkname, 00407 mng_uint32 iChunkseq, 00408 mng_int32 iExtra1, 00409 mng_int32 iExtra2, 00410 mng_pchar zErrortext); 00411 typedef mng_bool (MNG_DECL *mng_traceproc) (mng_handle hHandle, 00412 mng_int32 iFuncnr, 00413 mng_int32 iFuncseq, 00414 mng_pchar zFuncname); 00415 00416 /* read processing callbacks */ 00417 typedef mng_bool (MNG_DECL *mng_processheader) (mng_handle hHandle, 00418 mng_uint32 iWidth, 00419 mng_uint32 iHeight); 00420 typedef mng_bool (MNG_DECL *mng_processtext) (mng_handle hHandle, 00421 mng_uint8 iType, 00422 mng_pchar zKeyword, 00423 mng_pchar zText, 00424 mng_pchar zLanguage, 00425 mng_pchar zTranslation); 00426 typedef mng_bool (MNG_DECL *mng_processsave) (mng_handle hHandle); 00427 typedef mng_bool (MNG_DECL *mng_processseek) (mng_handle hHandle, 00428 mng_pchar zName); 00429 typedef mng_bool (MNG_DECL *mng_processneed) (mng_handle hHandle, 00430 mng_pchar zKeyword); 00431 typedef mng_bool (MNG_DECL *mng_processmend) (mng_handle hHandle, 00432 mng_uint32 iIterationsdone, 00433 mng_uint32 iIterationsleft); 00434 typedef mng_bool (MNG_DECL *mng_processunknown) (mng_handle hHandle, 00435 mng_chunkid iChunkid, 00436 mng_uint32 iRawlen, 00437 mng_ptr pRawdata); 00438 typedef mng_bool (MNG_DECL *mng_processterm) (mng_handle hHandle, 00439 mng_uint8 iTermaction, 00440 mng_uint8 iIteraction, 00441 mng_uint32 iDelay, 00442 mng_uint32 iItermax); 00443 00444 /* display processing callbacks */ 00445 typedef mng_ptr (MNG_DECL *mng_getcanvasline) (mng_handle hHandle, 00446 mng_uint32 iLinenr); 00447 typedef mng_ptr (MNG_DECL *mng_getbkgdline) (mng_handle hHandle, 00448 mng_uint32 iLinenr); 00449 typedef mng_ptr (MNG_DECL *mng_getalphaline) (mng_handle hHandle, 00450 mng_uint32 iLinenr); 00451 typedef mng_bool (MNG_DECL *mng_refresh) (mng_handle hHandle, 00452 mng_uint32 iX, 00453 mng_uint32 iY, 00454 mng_uint32 iWidth, 00455 mng_uint32 iHeight); 00456 00457 /* timer management callbacks */ 00458 typedef mng_uint32 (MNG_DECL *mng_gettickcount) (mng_handle hHandle); 00459 typedef mng_bool (MNG_DECL *mng_settimer) (mng_handle hHandle, 00460 mng_uint32 iMsecs); 00461 00462 /* color management callbacks */ 00463 typedef mng_bool (MNG_DECL *mng_processgamma) (mng_handle hHandle, 00464 mng_uint32 iGamma); 00465 typedef mng_bool (MNG_DECL *mng_processchroma) (mng_handle hHandle, 00466 mng_uint32 iWhitepointx, 00467 mng_uint32 iWhitepointy, 00468 mng_uint32 iRedx, 00469 mng_uint32 iRedy, 00470 mng_uint32 iGreenx, 00471 mng_uint32 iGreeny, 00472 mng_uint32 iBluex, 00473 mng_uint32 iBluey); 00474 typedef mng_bool (MNG_DECL *mng_processsrgb) (mng_handle hHandle, 00475 mng_uint8 iRenderingintent); 00476 typedef mng_bool (MNG_DECL *mng_processiccp) (mng_handle hHandle, 00477 mng_uint32 iProfilesize, 00478 mng_ptr pProfile); 00479 typedef mng_bool (MNG_DECL *mng_processarow) (mng_handle hHandle, 00480 mng_uint32 iRowsamples, 00481 mng_bool bIsRGBA16, 00482 mng_ptr pRow); 00483 00484 /* chunk access callback(s) */ 00485 typedef mng_bool (MNG_DECL *mng_iteratechunk) (mng_handle hHandle, 00486 mng_handle hChunk, 00487 mng_chunkid iChunkid, 00488 mng_uint32 iChunkseq); 00489 00490 /* ************************************************************************** */ 00491 00492 #endif /* _libmng_types_h_ */ 00493 00494 /* ************************************************************************** */ 00495 /* * end of file * */ 00496 /* ************************************************************************** */ 00497