Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

391 lines
16 KiB

  1. /*----------------------------------------------------------------------------
  2. ;
  3. ; jgdw.h -- JGDW decoder API
  4. ;
  5. ; Copyright (c) 1994-1996 Johnson-Grace Company, all rights reserved
  6. ;
  7. ; This file contains all the defines necessary to interface the
  8. ; Johnson-Grace decompressor.
  9. ;
  10. ;---------------------------------------------------------------------------*/
  11. #ifndef JGDW_H
  12. #define JGDW_H 1
  13. #ifdef _MAC
  14. #include <Types.h>
  15. #include <Palettes.h>
  16. #include <QuickDraw.h>
  17. #include <QDOffscreen.h>
  18. #else
  19. #pragma warning(disable:4201)
  20. #include <windows.h>
  21. #pragma warning(default:4201)
  22. #endif
  23. #include "jgtypes.h"
  24. #ifdef __cplusplus
  25. extern "C" { /* Indicate C declarations for C++ */
  26. #endif
  27. #define JG_ARTIMAGE_INFO JG_RAWIMAGE_INFO
  28. #define JgGetImageHandleDIB JgGetImage
  29. #define JgGetMaskDIB JgGetMask
  30. #define NormalUpdateRect OldRect
  31. #ifdef _MAC
  32. #define JGDW_CALL
  33. typedef struct JGDW_RECORD_TAG JGDW_RECORD;
  34. typedef JGDW_RECORD JGPTR JGDW_HDEC;
  35. typedef GWorldPtr JGDW_HBITMAP;
  36. typedef Rect JGDW_RECT;
  37. typedef RGBColor JGDW_COLOR;
  38. typedef ColorInfo JGDW_PALETTEENTRY;
  39. #else
  40. #if defined(_WIN32) || defined(__FLAT__) /* 16/32 bit compatibility */
  41. #ifndef JGDW_DECLSPEC
  42. #define JGDW_DECLSPEC __declspec(dllimport)
  43. #endif
  44. #define JGDW_CALL JGDW_DECLSPEC WINAPI
  45. #else
  46. #ifndef JGDW_DECLSPEC
  47. #define JGDW_DECLSPEC _export
  48. #endif
  49. #define JGDW_CALL JGDW_DECLSPEC WINAPI
  50. #endif
  51. typedef HGLOBAL JGDW_HDEC;
  52. typedef HGLOBAL JGDW_HBITMAP;
  53. typedef RECT JGDW_RECT;
  54. typedef PALETTEENTRY JGDW_COLOR;
  55. typedef PALETTEENTRY JGDW_PALETTEENTRY;
  56. #endif
  57. typedef struct JGDW_CONTEXT JGDW_CONTEXT;
  58. typedef JGDW_CONTEXT JGPTR JGDW_HCONTEXT;
  59. #define JG_HEADER_SIZE 40 /* Min # of bytes for JgQueryArtImage() */
  60. /*
  61. ** Note: the Decode library returns status codes as integers.
  62. ** Zero is returned for success. A non-zero return means that some
  63. ** exception occurred. Non-documented exceptions should be treated as
  64. ** non-recoverable errors. In this case the application should print the
  65. ** full integer value to aid support after the product is in the field.
  66. **
  67. ** The application can determine the class of the exception by masking
  68. ** off the high order bits of the word. See JgTypes.h for JG_ERR_xxx
  69. ** defines.
  70. **
  71. ** Final Note: Currently all nonzero returns should be treated as
  72. ** non-recoverable errors.
  73. */
  74. #define JGD_STATUS_SUCCESS 0
  75. #define JGD_STATUS_MEMERR (300 | JG_ERR_MEMORY)
  76. #define JGD_STATUS_BADARG (301 | JG_ERR_ARG)
  77. #define JGD_STATUS_ERROR (302 | JG_ERR_STATUS)
  78. #define JGD_STATUS_NOPALETTE (303 | JG_ERR_STATUS)
  79. #define JGD_STATUS_BADDATA (304 | JG_ERR_DATA)
  80. #define JGD_STATUS_IERROR (305 | JG_ERR_CHECK)
  81. #define JGD_STATUS_TOOWIDE (306 | JG_ERR_ARG)
  82. /* Not Valid because not enough data */
  83. #define JGD_STATUS_INVALID (307 | JG_ERR_ARG)
  84. /* Unsupported version of compression */
  85. #define JGD_STATUS_BADVERSION (308 | JG_ERR_VERSION)
  86. /* Unsupported Sub Version of file */
  87. #define JGD_STATUS_BADSUBVER (309 | JG_ERR_VERSION)
  88. /* File segments in wrong order */
  89. #define JGD_STATUS_BADORDER (310 | JG_ERR_DATA)
  90. /* Segment is shorter than expected */
  91. #define JGD_STATUS_SHORTSEG (311 | JG_ERR_DATA)
  92. /* Input Buffer is shorter than necessary */
  93. #define JGD_STATUS_SHORTBUF (312 | JG_ERR_DATA)
  94. /* Decodeable with some degradation */
  95. #define JGD_STATUS_OLDRESOURCE (313 | JG_ERR_STATUS)
  96. /* Decodeable with extreme degradation */
  97. #define JGD_STATUS_NORESOURCE (314 | JG_ERR_STATUS)
  98. /* Not decodeable because missing resource */
  99. #define JGD_STATUS_BADRESOURCE (315 | JG_ERR_STATUS)
  100. /* Resource not found */
  101. #define JGD_STATUS_NOTFOUND (316 | JG_ERR_STATUS)
  102. /* The Resource data is corrupted */
  103. #define JGD_STATUS_BADRCDATA (317 | JG_ERR_DATA)
  104. #define JGD_STATUS_READY (318 | JG_ERR_STATUS)
  105. #define JGD_STATUS_WAITING (319 | JG_ERR_STATUS)
  106. #define JGD_STATUS_DONE (320 | JG_ERR_STATUS)
  107. /* CB Patterns Missing */
  108. #define JGD_STATUS_NOPATTERNS (321 | JG_ERR_STATUS)
  109. /* Data is not in ART format */
  110. #define JGD_STATUS_NOTART (322 | JG_ERR_STATUS)
  111. /* End of file found */
  112. #define JGD_STATUS_EOF (323 | JG_ERR_STATUS)
  113. /* Result is too big */
  114. #define JGD_STATUS_TOOBIG (324 | JG_ERR_STATUS)
  115. /* Invalid state for requested operation */
  116. #define JGD_STATUS_BADSTATE (325 | JG_ERR_STATE)
  117. /* Invalid or corrupted handle */
  118. #define JGD_STATUS_BADHANDLE (326 | JGD_STATUS_BADARG)
  119. #define JGD_STATUS_LIB_NOT_FOUND (327 | JG_ERR_STATUS)
  120. #define JGD_STATUS_UNSUPPORTED (328 | JG_ERR_DATA)
  121. #define JGD_STATUS_UNKNOWN (329 | JG_ERR_DATA)
  122. #define JGD_STATUS_OBSOLETE (330 | JG_ERR_VERSION)
  123. #define JGD_STATUS_BADGAMMA (331 | JG_ERR_ARG) /* Bad gamma argument(s) */
  124. /*
  125. ** These defines are used to select the various image decoding options.
  126. */
  127. #define JG_OPTION_DITHER 0x0001 /* To Request dithering */
  128. #define JG_OPTION_USEDEFAULT_PALETTE 0x0002 /* To force Default Palette */
  129. #define JG_OPTION_FULLIMAGE 0x0008 /* To request full image */
  130. #define JG_OPTION_BACKGROUNDCOLOR 0x10 /* To enable Background color */
  131. #define JG_OPTION_INHIBIT_AUDIO 0x20 /* To disable audio, if any */
  132. #define JG_OPTION_ONEPASS 0x0080 /* To request one pass decoding. */
  133. #define JG_OPTION_MASK_BITMAP 0x0100 /* Create transparency mask 1=opaque */
  134. #define JG_OPTION_IMAGEFORMAT 0x0200 /* Decode specific image format */
  135. #define JG_OPTION_GAMMACORRECT 0x0400 /* Perform gamma correction */
  136. #define JG_OPTION_COMMONDEVICE 0x0800 /* Mac only: use common GDevice */
  137. #define JG_OPTION_TRANSINDEX 0x1000 /* Enables TransIndex field */
  138. /*
  139. ** These defines indicate the type of palettizing actually done by
  140. ** the decoder. They are returned in JgGetImageInfo().
  141. */
  142. #define JG_PALETTE_MODE_OFF 0 /* No Palette, 24-bit */
  143. #define JG_PALETTE_MODE_OPT 1 /* Use Optimal Palette, if Possible */
  144. #define JG_PALETTE_MODE_DEFAULT 2 /* Use the input default palette */
  145. #define JG_PALETTE_MODE_332 3 /* Use the standard 332 palette */
  146. #define JG_POSTSCALE_LONGSIDE 0x0001 /* Do Post Scaling by long side */
  147. #define JG_POSTSCALE_X 0x0002 /* Do Post Scaling in X */
  148. #define JG_POSTSCALE_Y 0x0004 /* Do Post Scaling in Y */
  149. #define JG_POSTSCALE_BESTFIT 0x0008 /* Do Post Scale with BestFit method */
  150. // Use these defines for both GammaIn and GammaOut
  151. #define JG_GAMMA_NONE 100 /* No gamma correction */
  152. #define JG_GAMMA_MAC 180 /* Correction required for Mac = 1.8 */
  153. #define JG_GAMMA_PC 250 /* Correction required for PC = 2.5 */
  154. typedef struct {
  155. UINTW nSize; /* Size of this structure, set be caller */
  156. UINTW ColorDepth; /* Color depth to use (4, 8, or 24) */
  157. UINTW DecodeOptions; /* Decoding Options */
  158. JGDW_PALETTEENTRY JGPTR DefaultPalette; /* Default Palette, or NULL if none */
  159. UINTW PaletteSize; /* Size of Default Palette, if any */
  160. UINTW SplashDupFactor; /* Replication Factor of Miniature in Full */
  161. /* image; 0=Off, >100=Full Size */
  162. JGBOOL bTrueSplash; /* Save splash image until completely rdy */
  163. UINTW PostScaleFlags; /* Defines Post Scale. Or of JG_POSTSCALE_xxx */
  164. UINTW ScaledLongSide; /* Used for Post scale, for JG_POSTSCALE_LONGSIDE */
  165. UINTW ScaledX; /* Used for Post scale, for JG_POSTSCALE_X */
  166. UINTW ScaledY; /* Used for Post scale, for JG_POSTSCALE_Y */
  167. JGDW_COLOR BackgroundColor; /* Used to specify background color */
  168. UINTW AudioOptions; /* Defined elsewhere (in JGAW.H) */
  169. JGFOURCHAR ImageFormat;/* Specify image format or 'auto' for autodetect */
  170. UINTW GammaIn; /* Default input gamma correction */
  171. UINTW GammaOut; /* Desired output gamma correction */
  172. UINTW TransIndex; /* Make this color transparent */
  173. } JG_DECOMPRESS_INIT;
  174. typedef struct {
  175. UINTW nSize; /* Size of this structure, set by caller */
  176. JGBOOL bError; /* Out: True if error detected which
  177. prevents further decoding */
  178. JGBOOL bImageDone; /* True if no further input required */
  179. JGBOOL bNewNormalPixels; /* True if Pixels ready in normal image */
  180. JGBOOL Reserved1;
  181. JGDW_RECT OldRect; /* For compatibility */
  182. JGDW_RECT UpdateRect; /* Update region of image */
  183. UINTW PaletteMode; /* Type of palettizing being done */
  184. JGERR iErrorReason; /* Status code for error, if any */
  185. JGFOURCHAR ImageFormat; /* Format of compressed image */
  186. UINTW PaletteColors; /* Number of colors in palette */
  187. UINTW TransIndex; /* Index of transparent color (0xffff=none) */
  188. } JG_DECOMPRESS_INFO;
  189. typedef struct {
  190. UINTW nSize; /* Size of this structure, set by caller */
  191. UINTW Version; /* File's Version */
  192. UINTW SubVersion; /* File's SubVersion */
  193. JGBOOL Decodeable; /* Nonzero if file can be decoded */
  194. /* The following elements are only */
  195. /* Valid if the image is decodeable */
  196. UINTW Rows; /* Actual Rows at compress time */
  197. UINTW Cols; /* Actual Cols at compress time */
  198. JGBOOL HasPalette; /* If Nonzero, image contains a palette */
  199. JGBOOL HasOverlays; /* If Nonzero, image has enhancements */
  200. JGFOURCHAR ImageFormat; /* Four-character image type code */
  201. UINTW ColorDepth; /* Native color depth of image */
  202. } JG_RAWIMAGE_INFO;
  203. /*
  204. ** The following are prototypes to Decoder functions.
  205. */
  206. #ifdef __CFM68K__
  207. #pragma import on
  208. #endif
  209. //JGERR JGDW_CALL JgSetMemCallbacks(
  210. // void * (* JGFUNC memAlloc)(UINT32 size), /* malloc */
  211. // void (* JGFUNC memFree)(void *ptr) /* free */
  212. //);
  213. JGERR JGDW_CALL JgSetDecompressResourceBuffer(
  214. UINT8 JGPTR pBuffer, /* The pointer to the resource buffer */
  215. UINT32 BufSize /* The size of the buffer */
  216. );
  217. /* The pointer returned by JgGetDecompressCaps points to an array of */
  218. /* JG_READER_DESC structures. A last dummy element exists with .nSize == 0 */
  219. JGERR JGDW_CALL JgGetDecompressCaps(
  220. JG_READER_DESC JGPTR JGPTR FormatList /* Pointer to reader list. */
  221. );
  222. JGERR JGDW_CALL JgCreateDecompressContext(
  223. JGDW_HCONTEXT JGPTR hContext, // OUT: context handle
  224. JG_DECOMPRESS_INIT JGPTR InitStruct // IN: filled init structure
  225. );
  226. JGERR JGDW_CALL JgCreateDecompressor(
  227. JGDW_HDEC JGPTR hDec, // OUT: decompression handle
  228. JGDW_HCONTEXT hContext, // IN: context handle
  229. JG_DECOMPRESS_INIT JGPTR Init // IN: null, or override of context
  230. );
  231. JGERR JGDW_CALL JgDestroyDecompressor(
  232. JGDW_HDEC hDec // IN: decompression handle
  233. );
  234. JGERR JGDW_CALL JgDestroyDecompressContext(
  235. JGDW_HCONTEXT hContext // IN: context handle
  236. );
  237. JGERR JGDW_CALL JgInitDecompress(
  238. JGDW_HDEC JGPTR hJgImageOutput, /* A pntr to recve the Img handle. */
  239. JG_DECOMPRESS_INIT JGPTR InitStruct /* A filled init structure */
  240. );
  241. JGERR JGDW_CALL JgQueryArtImage(
  242. UINT8 JGHPTR pBuf, /* First bytes of the compressed image */
  243. UINT32 nBufSize /* Size of Buffer */
  244. );
  245. JGERR JGDW_CALL JgGetImageInfo(
  246. UINT8 JGHPTR pBuf, /* First bytes of the compressed image */
  247. UINT32 nBufSize, /* Number of bytes in buffer */
  248. JG_RAWIMAGE_INFO JGPTR Info
  249. );
  250. JGERR JGDW_CALL JgDecompressDone(
  251. JGDW_HDEC hJgImage /* Handle to Decompress Struct */
  252. );
  253. JGERR JGDW_CALL JgGetImage(
  254. JGDW_HDEC hJgImage, /* Handle to Decompression Structure */
  255. JGDW_HBITMAP JGPTR hBitmap /* Output Handle to bitmap, if it exists */
  256. );
  257. JGERR JGDW_CALL JgDecompressImageBlock(
  258. JGDW_HDEC hJgImage, /* Handle to Decompress Struct */
  259. UINT8 JGHPTR pImageBuf, /* Input buffer of compressed image data */
  260. UINT32 nBufSize, /* Number of bytes of data in buffer */
  261. JGBOOL JGPTR bNewData /* True if new data are available */
  262. );
  263. JGERR JGDW_CALL JgGetDecompressInfo(
  264. JGDW_HDEC hJgImage, /* Handle to Decompress Struct */
  265. JG_DECOMPRESS_INFO JGPTR Info /* Out: Filled Info struct */
  266. );
  267. JGERR JGDW_CALL JgGetDecoderVersion(
  268. char JGPTR Version
  269. );
  270. JGERR JGDW_CALL JgGetMiniatureOffset(
  271. UINT8 JGHPTR pBuf, /* Entire compressed image */
  272. UINT32 nBufSize, /* Size of compressed image */
  273. UINT32 JGPTR Offset /* Output Offset to End of Miniature */
  274. );
  275. JGERR JGDW_CALL JgGetMask(
  276. JGDW_HDEC hJgImage, /* Handle to Decompression Structure */
  277. JGDW_HBITMAP JGPTR hMask /* Output Handle to Mask, if it exists */
  278. );
  279. JGERR JGDW_CALL JgSetDebug(JGDW_HDEC hJgVars,
  280. UINTW DebugOptions);
  281. /*
  282. ** New (8/95) Lossless decompression definitions.
  283. */
  284. #ifndef JG_LOSSLESS_INFO_DEFINED // (also defined in jgew.h)
  285. #define JG_LOSSLESS_INFO_DEFINED 1
  286. typedef struct {
  287. UINT16 nSize; /* Size of structure in bytes */
  288. INT16 SearchSize; /* (Compression control) */
  289. UINT32 CompressedSize; /* Total compressed block bytes */
  290. UINT32 CompressedSoFar; /* Compressed processed so far */
  291. UINT32 CompressedLastCall; /* Compressed processed last call */
  292. UINT32 DecompressedSize; /* Total decompressed block bytes */
  293. UINT32 DecompressedSoFar; /* Decompressed processed so far */
  294. UINT32 DecompressedLastCall; /* Decompressed processed last call */
  295. } JG_LOSSLESS_INFO;
  296. #endif
  297. typedef void JGPTR JG_LOSSLESS_HDEC; /* lossless decompression handle type */
  298. JGERR JGDW_CALL JgLosslessDecompressQuery( /* Interrogate lossless stream */
  299. UINT8 JGHPTR InBuffer, /* IN: Beginning of compressed stream */
  300. UINT32 InBufferSize, /* IN: Bytes in InBuffer (0-n) */
  301. JG_LOSSLESS_INFO JGPTR LosslessInfo); /* OUT: Stream info returned here */
  302. JGERR JGDW_CALL JgLosslessDecompressCreate( /* Create decompression handle */
  303. JG_LOSSLESS_HDEC JGPTR DecHandle); /* IN: Pointer to new handle */
  304. void JGDW_CALL JgLosslessDecompressDestroy( /* Destroy decompression handle */
  305. JG_LOSSLESS_HDEC DecHandle); /* IN: Handle from decompress create */
  306. JGERR JGDW_CALL JgLosslessDecompressReset( /* Reset existing handle */
  307. JG_LOSSLESS_HDEC DecHandle); /* IN: Handle from decompress create */
  308. JGERR JGDW_CALL JgLosslessDecompressBlock( /* decompress block of data */
  309. JG_LOSSLESS_HDEC DecHandle, /* IN: Handle from decompress create */
  310. UINT8 JGHPTR InBuffer, /* IN: Input (compressed) data */
  311. UINT32 InBufferSize, /* IN: Bytes at *InBuffer (0-n) */
  312. UINT8 JGHPTR OutBuffer, /* OUT: Output (decompressed result) buff */
  313. UINT32 OutBufferSize, /* IN: Free bytes at *OutBuffer */
  314. JG_LOSSLESS_INFO JGPTR LosslessInfo); /* OUT: Updated info returned here */
  315. JGERR JGDW_CALL JgLosslessDecompressPartitionReset( /* new partition reset */
  316. JG_LOSSLESS_HDEC DecHandle); /* IN: Handle from decompress create */
  317. #ifdef __CFM68K__
  318. #pragma import off
  319. #endif
  320. #ifdef __cplusplus
  321. }
  322. #endif
  323. #endif