Source code of Windows XP (NT5)
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.

507 lines
17 KiB

  1. //***************************************************************************
  2. //
  3. // IMAGE.h
  4. //
  5. // Proposed new interface!
  6. //
  7. // Include file for the Image API Library.
  8. // This is the external containing header data required
  9. // by the outside world.
  10. //
  11. // Revision History
  12. // 17-Nov-95 TerryJ Original
  13. // 04-Jan-96 TerryJ Code cleaned up. Memory mode added.
  14. // 16-Jan-96 TerryJ Registry validation capacity added.
  15. //
  16. //
  17. //***************************************************************************
  18. #ifndef _IMAGEFILELIB_H
  19. #define _IMAGEFILELIB_H
  20. #include "msffdefs.h" //include platform dependent defs
  21. #ifdef _MAC
  22. #include <Macname1.h>
  23. #include "Types.h"
  24. #include "Files.h"
  25. #include <Macname2.h>
  26. #endif // _MAC
  27. #ifdef __cplusplus
  28. extern "C" { // Assume C declarations for C++
  29. #endif // __cplusplus
  30. /***********
  31. | IFLMODE: Open modes
  32. \***********/
  33. typedef enum
  34. {
  35. IFLM_READ =0x00,
  36. IFLM_WRITE =0x01,
  37. IFLM_MEMORY =0x80, // OR to operate in memory
  38. IFLM_EXTRACT_ALPHA =0x40, // OR to extract separate image and alpha channel info
  39. IFLM_CHUNKY_ALPHA =0x20, //OR to extract RGBA chunky data
  40. } IFLMODE;
  41. /***********
  42. | IFLCLASS: Image classes
  43. \***********/
  44. typedef enum
  45. {
  46. IFLCL_BILEVEL = 0, // 1 BPP
  47. IFLCL_GRAY = 1, // 2,4,6,8 BPP
  48. IFLCL_GRAYA =11, // 16 BPP chunky
  49. IFLCL_PALETTE = 2, // 2,4,6,8 BPP
  50. IFLCL_RGB = 3, // 24 BPP chunky
  51. IFLCL_RGBPLANAR = 4, // 24 BPP in 8 bit planes
  52. IFLCL_RGBA = 5, // 32 BPP chunky
  53. IFLCL_RGBAPLANAR = 6, // 32 BPP in four 8 bit planes
  54. IFLCL_CMYK = 7,
  55. IFLCL_YCC = 8,
  56. IFLCL_CIELAB = 9,
  57. IFLCL_NONE =10 // no class set! (error)
  58. } IFLCLASS;
  59. typedef enum
  60. {
  61. IFLTF_NONE =0,
  62. IFLTF_STRIPS =1,
  63. IFLTF_TILES =2
  64. } IFLTILEFORMAT;
  65. /***********
  66. | IFLCOMMAND: Commands to IFL_Control
  67. \***********/
  68. typedef enum
  69. {
  70. IFLCMD_GETERROR =0, // get error code
  71. IFLCMD_GETLINESIZE =1, // compute line size
  72. IFLCMD_PALETTE =2, // get or set palette or map
  73. IFLCMD_SETPACKMODE =3, // set mode for packing/unpacking pixels
  74. IFLCMD_RESOLUTION =7, // get dots per meter
  75. IFLCMD_GETNUMIMAGES =10, // get the number of images
  76. IFLCMD_IMAGESEEK =11, // seek to the next image
  77. IFLCMD_DELETE =12, // delete current image
  78. IFLCMD_TILEFORMAT =13, // set/get the tiling format
  79. IFLCMD_YCCINFO =14, // set/get YCC information
  80. IFLCMD_YCCRGBCONVERT =15, // set/get YCC/RGB conversion state
  81. IFLCMD_COLORIMETRY =16, // set/get Colorimetry info
  82. IFLCMD_CMYKINFO =17, // set/get CMYK specific data
  83. IFLCMD_BKGD_IDX =18, // set/get background color by index
  84. IFLCMD_BKGD_RGB =19, // set/get background color
  85. IFLCMD_TRANS_IDX =20, // set/get transparency color index
  86. IFLCMD_TRANS_RGB =21, // set/get transparency color
  87. IFLCMD_TRANS_MASK_INFO =22, // set/get transparency mask info
  88. IFLCMD_TRANS_MASK =23, // set/get transparency mask
  89. IFLCMD_ALPHA_PALETTE_INFO =24, // set/get alpha palette info
  90. IFLCMD_ALPHA_PALETTE =25, // set/get alpha palette
  91. IFLCMD_ALPHA_CHANNEL_INFO =26, // set/get alpha channel info
  92. IFLCMD_ALPHA_CHANNEL =27, // set/get alpha channel
  93. IFLCMD_GAMMA_VALUE =28, // set/get gamma value
  94. IFLCMD_FIRST_TEXT =29, // get first text string
  95. IFLCMD_NEXT_TEXT =30, // get next text strings.
  96. IFLCMD_DATETIME_STRUCT =31, // retrieve date/time as a structure.
  97. IFLCMD_TIFF =0x4000, // TIFF specific commands
  98. IFLCMD_TIFFTAG =0x4001,
  99. IFLCMD_TIFFTAGDATA =0x4002,
  100. IFLCMD_PCX =0x4200, // PCX specific commands
  101. IFLCMD_BMP =0x4400, // BMP specific commands
  102. IFLCMD_BMP_VERSION =0x4401, // Windows os2 1.2 os2 2.0 versions
  103. IFLCMD_TGA =0x4800, // TGA specific commands
  104. IFLCMD_GIF =0x4E00, // GIF specific commands
  105. IFLCMD_GIF_WHITE_IS_ZERO =0x4E01, // White == 0 in GIF file
  106. IFLCMD_JPEG =0x5700, // WPG specific commands
  107. IFLCMD_JPEGQ =0x5701, // Quality
  108. IFLCMD_PCD =0x5800, // Kodak PCD specific commands
  109. IFLCMD_PCDGETTRANSFORM =0x5801,
  110. IFLCMD_PCDSETTRANSFORM =0x5802,
  111. IFLCMD_PCDSETCLASS =0x5803,
  112. IFLCMD_PNG =0x5900, // PNG specific commands
  113. IFLCMD_PNG_SET_FILTER =0x590A, // Set PNG filter type
  114. IFLCMD_PNG_sBIT =0x590B, // set/get PNG sBIT chunk
  115. IFLCMD_GETDATASIZE =0x8000 // OR with this to get the size
  116. } IFLCOMMAND;
  117. typedef IFLCOMMAND IFLCMD; // this is done as backwards
  118. // compatibility and may be able
  119. // to be eliminated eventually
  120. /***********
  121. | IFLDESC: Available description strings (use as bitfields)
  122. \***********/
  123. typedef enum
  124. {
  125. IFLDESC_NONE =0, // no descriptions supported
  126. IFLDESC_DESCRIPTION =1, // image description field (TIFF TGA PNG)
  127. IFLDESC_SOFTWARENAME =2, // software name (TIFF TGA) Software (PNG)
  128. IFLDESC_ARTISTNAME =4, // artist name (TIFF TGA) Author (PNG)
  129. IFLDESC_DOCUMENTNAME =8, // the document name field Title (PNG)
  130. IFLDESC_DATETIME =16, // the date/time field
  131. IFLDESC_COPYRIGHT =32, // copyright notice (PNG)
  132. IFLDESC_DISCLAIMER =64, // Legal disclaimer (PNG)
  133. IFLDESC_WARNING =128, // content warning (PNG)
  134. IFLDESC_SOURCE =256, // source device (PNG)
  135. IFLDESC_COMMENT =512, // misc comment (PNG)
  136. } IFLDESC;
  137. /***********
  138. | IFLPACKMODE: Packing modes
  139. \***********/
  140. typedef enum
  141. {
  142. IFLPM_PACKED =0,
  143. IFLPM_UNPACKED =1,
  144. IFLPM_LEFTJUSTIFIED =2,
  145. IFLPM_NORMALIZED =3,
  146. IFLPM_RAW =4
  147. } IFLPACKMODE;
  148. /***********
  149. | IFLSEQUENCE: Line sequences
  150. \***********/
  151. typedef enum
  152. {
  153. IFLSEQ_TOPDOWN =0, // most
  154. IFLSEQ_BOTTOMUP =1, // BMP and TGA compressed
  155. IFLSEQ_GIF_INTERLACED =2, // for GIF
  156. IFLSEQ_ADAM7_INTERLACED = 3 // for PNG
  157. } IFLSEQUENCE;
  158. /***********
  159. | IFLERROR: Possible errors
  160. \***********/
  161. typedef enum
  162. {
  163. IFLERR_NONE =0, // no error
  164. IFLERR_HANDLELIMIT =1, // too many open files
  165. IFLERR_PARAMETER =2, // programmer error
  166. IFLERR_NOTSUPPORTED =3, // feature not supported by format
  167. IFLERR_NOTAVAILABLE =4, // item not available
  168. IFLERR_MEMORY =5, // insufficient memory
  169. IFLERR_IMAGE =6, // bad image data (decompression error)
  170. IFLERR_HEADER =7, // header has bad fields
  171. IFLERR_IO_OPEN =8, // error on open()
  172. IFLERR_IO_CLOSE =9, // error on close()
  173. IFLERR_IO_READ =10, // error on read()
  174. IFLERR_IO_WRITE =11, // error on write()
  175. IFLERR_IO_SEEK =12, // error on lseek()
  176. } IFLERROR;
  177. typedef enum // new error messages to go here. This error
  178. // info is maintained here rather than IFLERROR
  179. // to retain backwards compatibility
  180. {
  181. IFLEXTERR_NONE,
  182. IFLEXTERR_NO_DLL, // open
  183. IFLEXTERR_NO_LIBRARY, // open: no library specified
  184. IFLEXTERR_BAD_DLL, // DLL doesn't have right entry points
  185. IFLEXTERR_CANNOT_IMPORT, // open
  186. IFLEXTERR_CANNOT_EXPORT, // open
  187. IFLEXTERR_CANNOT_COMPRESS, // open
  188. IFLEXTERR_BAD_FORMAT, // read
  189. IFLEXTERR_UNKNOWN_VARIANT, // open/read: for example, JFIFs and
  190. // BMPs have many variants - some may
  191. // not be supported
  192. IFLEXTERR_SHARING_VIOLATION, // read
  193. IFLEXTERR_NO_BACKGROUND_COLOR, // read: no background color specified
  194. // when doing transparencies
  195. IFLEXTERR_BACKGROUND_NOT_SUPPORTED, // background colors not supported
  196. // (currently) by this format
  197. IFLEXTERR_NO_FILE, // file doesn't exist
  198. IFLEXTERR_END_OF_FILE, // read
  199. IFLEXTERR_MEMORY, // insufficient memory
  200. IFLEXTERR_DESC_CANNOT_GET, // file is write mode: can't get descriptions
  201. IFLEXTERR_DESC_CANNOT_SET, // file is read mode: can't set descriptions
  202. IFLEXTERR_NO_PATH_IN_REGISTRY, // the filter path isn't in the registry
  203. IFLEXTERR_NOT_IFL_HANDLE, // the pointer passed isn't an IFLHANDLE
  204. IFLEXTERR_REGISTRY_DAMAGED, // entry in registry not correct format
  205. IFLEXTERR_BAD_COMPRESSION, // error in data compression; cannot read.
  206. } IFLEXTERROR;
  207. /***********
  208. | IFLCOMPRESSION: Compression options
  209. \***********/
  210. typedef enum
  211. {
  212. IFLCOMP_NONE =0, // no compression
  213. IFLCOMP_DEFAULT =1, // whatever is defined for the format
  214. IFLCOMP_RLE =2, // various RLE schemes (PACKBITS in TIFF)
  215. IFLCOMP_CCITT1D =3, // TIFF modified G3
  216. IFLCOMP_CCITTG3 =4, // TIFF raw G3
  217. IFLCOMP_CCITTG4 =5, // TIFF G4
  218. IFLCOMP_LZW =6, // Lempel-Zif
  219. IFLCOMP_LZWHPRED =7, // LZW with TIFF horizontal differencing
  220. IFLCOMP_JPEG =8 // JPEG compression
  221. } IFLCOMPRESSION;
  222. /***********
  223. | Date Time structure for IFL
  224. \***********/
  225. typedef struct
  226. {
  227. short Year;
  228. short Month;
  229. short Day;
  230. short Hour;
  231. short Minute;
  232. short Second;
  233. } IFL_DATETIME;
  234. /***********
  235. | RGB color structure for IFL
  236. \***********/
  237. typedef struct // rgb color values
  238. {
  239. BYTE bRed;
  240. BYTE bGreen;
  241. BYTE bBlue;
  242. } IFLCOLORRGB;
  243. typedef struct // new color struct capable of 16 bit values.
  244. {
  245. WORD wRed;
  246. WORD wGreen;
  247. WORD wBlue;
  248. } IFLCOLOR;
  249. /***********
  250. | Types for multiple images
  251. \***********/
  252. typedef enum
  253. {
  254. IFLIT_PRIMARY =0,
  255. IFLIT_THUMBNAIL =1,
  256. IFLIT_MASK =2
  257. } IFLIMAGETYPE;
  258. /***********
  259. | Bitmap types
  260. \***********/
  261. typedef enum
  262. {
  263. IFLBV_WIN_3 =0x10, // Windows 3.x
  264. IFLBV_OS2_1 =0x20, // OS2 1.2
  265. IFLBV_OS2_2S =0x40, // OS2 2.0 single image
  266. IFLBV_OS2_2M =0x41 // OS2 2.0 multiple image
  267. } IFLBMPVERSION;
  268. /***********
  269. | Capabilities Type, for interpreting Registry info
  270. \***********/
  271. typedef enum
  272. {
  273. IFLCAP_NOT_AVAILABLE =0x0000, // if option not available
  274. // ** compression options **
  275. IFLCAP_COMPNONE =0x0001,
  276. IFLCAP_COMPRLE =0x0002,
  277. IFLCAP_COMPG3 =0x0004,
  278. IFLCAP_COMPG4 =0x0008,
  279. IFLCAP_COMPLZW =0x0010,
  280. IFLCAP_COMPLZWPRED =0x0020,
  281. IFLCAP_COMPJPEG =0x0040,
  282. IFLCAP_COMPDEFAULT =0x0080,
  283. // ** bit plane options ** // note that for RGB, RGB QUAD
  284. IFLCAP_1BPP =0x0001, // and RGBA bit plane depth must
  285. IFLCAP_2BPP =0x0002, // be multiplied by 3, 4 and 4
  286. IFLCAP_3BPP =0x0004, // respectively for the full
  287. IFLCAP_4BPP =0x0008, // pixel depth size.
  288. IFLCAP_5BPP =0x0010,
  289. IFLCAP_6BPP =0x0020,
  290. IFLCAP_7BPP =0x0040,
  291. IFLCAP_8BPP =0x0080,
  292. IFLCAP_8BPP_QUAD =0x0100,
  293. IFLCAP_12BPP =0x0200,
  294. IFLCAP_16BPP =0x0400,
  295. // ** Transparency options
  296. IFLCAP_NO_TRANS =0x0000,
  297. IFLCAP_1BITMASK =0x0001,
  298. IFLCAP_ALPHACHANNEL =0x0002,
  299. IFLCAP_ALPHAPALETTE =0x0004,
  300. IFLCAP_TRANSCOLOR =0x0008,
  301. } IFLCAPABILITIES;
  302. /***********
  303. | Alpha/Transparency info structs
  304. \***********/
  305. typedef struct
  306. {
  307. DWORD dwWidth;
  308. DWORD dwHeight;
  309. } IFL_TRANS_MASK_INFO;
  310. typedef struct
  311. {
  312. DWORD dwWidth;
  313. DWORD dwHeight;
  314. WORD wBitsPerPixel;
  315. } IFL_ALPHA_CHANNEL_INFO;
  316. typedef struct
  317. {
  318. char *szKey;
  319. char *szText;
  320. } IFL_COMMENT_STRING;
  321. typedef struct
  322. {
  323. unsigned char bPNGType;
  324. unsigned char bGrayBits;
  325. unsigned char bRedBits;
  326. unsigned char bGreenBits;
  327. unsigned char bBlueBits;
  328. unsigned char bAlphaBits;
  329. } IFLPNGsBIT;
  330. /***********
  331. | Handle types
  332. | Use FILTERHANDLE to access filters
  333. \***********/
  334. typedef void far * IFLHANDLE; // handle is a void pointer to hide the
  335. // details of the file handle from other
  336. // programmers.
  337. /* -------- new stuff ---------------------- */
  338. typedef enum
  339. {
  340. IFLT_UNKNOWN, // unknown or unsupported file type
  341. IFLT_GIF,
  342. IFLT_BMP,
  343. IFLT_JPEG,
  344. IFLT_TIFF,
  345. IFLT_PNG,
  346. IFLT_PCD,
  347. IFLT_PCX,
  348. IFLT_TGA,
  349. IFLT_PICT
  350. } IFLTYPE;
  351. /***********
  352. | IFL virtual (memory) mode types
  353. \***********/
  354. // internal virtual (memory) file i/o routine pointers
  355. typedef int (__cdecl _vopen) (LPSTR, int, int);
  356. typedef int (__cdecl _vclose) (int);
  357. typedef int (__cdecl _vread) (int, LPVOID, int);
  358. typedef int (__cdecl _vwrite) (int, LPVOID, int);
  359. typedef long (__cdecl _vlseek) (int, long, int);
  360. // structure used to hold virtual (memory) i/o functions
  361. // when using IFLM_MEMORY mode.
  362. typedef struct ImageIOFuncs
  363. {
  364. _vopen *vopen;
  365. _vclose *vclose;
  366. _vread *vread;
  367. _vwrite *vwrite;
  368. _vlseek *vlseek;
  369. LPVOID userdata;
  370. } IFLIOF, far * LPIFLIOF;
  371. // structure used to hold virtual (memory) memory info
  372. // when using IFLM_MEMORY mode.
  373. typedef struct ImageMemStruct
  374. {
  375. long pos;
  376. long alloced;
  377. long length;
  378. LPVOID data;
  379. } IFLIOM, far * LPIFLIOM;
  380. /***********
  381. | IFL function prototypes
  382. \***********/
  383. IFLERROR HILAPI iflOpen(IFLHANDLE iflh, LPSTR FileName, IFLMODE Mode);
  384. IFLERROR HILAPI iflClose(IFLHANDLE iflh);
  385. IFLERROR HILAPI iflRead(IFLHANDLE iflh, LPBYTE Buffer, int NumLines);
  386. IFLERROR HILAPI iflWrite(IFLHANDLE iflh, LPBYTE Buffer, int NumLines);
  387. IFLERROR HILAPI iflSeek(IFLHANDLE iflh, int Line);
  388. IFLERROR HILAPI iflControl(IFLHANDLE iflh, IFLCMD Command, short sParam, long lParam, LPVOID pParam);
  389. // new commands (general)
  390. IFLERROR HILAPI iflImageType(LPSTR FileName, IFLTYPE *ImageType);
  391. IFLTYPE HILAPI iflTypeFromExtension (char far * Filename);
  392. void iflGetLibName(IFLTYPE fileType, LPSTR libName);
  393. IFLERROR HILAPI iflFilterCap(IFLTYPE ImageType, IFLCLASS ImageClass,
  394. WORD *Color, WORD *Compression,
  395. WORD *Transparency);
  396. IFLERROR HILAPI iflInstalledFilterQuery(IFLTYPE filterType,
  397. BOOL *bImports,
  398. BOOL *bExports);
  399. IFLERROR HILAPI iflExtensionCount(IFLTYPE filterType,
  400. short *sCount);
  401. IFLERROR HILAPI iflExtensionQuery(IFLTYPE filterType,
  402. short sExtNum,
  403. LPSTR szExtension);
  404. IFLERROR HILAPI iflFormatNameQuery(IFLTYPE filterType,
  405. LPSTR szFormatName,
  406. short sFormatNameSize);
  407. IFLEXTERROR HILAPI iflGetExtendedError(IFLHANDLE iflh);
  408. // description manipulation
  409. IFLERROR HILAPI iflGetDesc(IFLHANDLE iflh, IFLDESC DescType, LPSTR *pDescription);
  410. IFLERROR HILAPI iflPutDesc(IFLHANDLE iflh, IFLDESC DescType, LPSTR Description);
  411. IFLERROR HILAPI iflSupportedDesc(IFLHANDLE iflh, IFLDESC *Supports);
  412. // handle manipulation
  413. IFLHANDLE HILAPI iflCreateReadHandle( IFLTYPE ImageType);
  414. IFLHANDLE HILAPI iflCreateWriteHandle(int Width, // Width of image in pixels
  415. int Height, // Height of image in pixels
  416. IFLCLASS ImageClass, // image class
  417. int BitsPerSample, // Number of bits per sample
  418. IFLCOMPRESSION Compression, // defined above
  419. IFLTYPE ImageType // Type of image (GIF, PCX, etc)
  420. );
  421. IFLERROR HILAPI iflFreeHandle(IFLHANDLE iflh);
  422. // background manipulation
  423. IFLERROR HILAPI iflGetBackgroundColor(IFLHANDLE iflh, IFLCOLOR *clBackColor);
  424. IFLERROR HILAPI iflSetBackgroundColor(IFLHANDLE iflh, IFLCOLOR clBackColor);
  425. IFLERROR HILAPI iflSetBackgroundColorByIndex(IFLHANDLE iflh, short iColorIndex);
  426. // accessors and manipulators
  427. #ifdef _MAC
  428. IFLERROR HILAPI iflSetMacCreator(OSType OSCreator);
  429. #endif // _MAC
  430. IFLCLASS HILAPI iflGetClass(IFLHANDLE iflh);
  431. int HILAPI iflGetHeight(IFLHANDLE iflh);
  432. int HILAPI iflGetWidth(IFLHANDLE iflh);
  433. int HILAPI iflGetRasterLineCount(IFLHANDLE iflh);
  434. IFLSEQUENCE HILAPI iflGetSequence(IFLHANDLE iflh);
  435. IFLERROR HILAPI iflSetSequence(IFLHANDLE iflh, IFLSEQUENCE iflsSeq);
  436. IFLCOMPRESSION HILAPI iflGetCompression(IFLHANDLE iflh);
  437. int HILAPI iflGetBitsPerChannel(IFLHANDLE iflh);
  438. int HILAPI iflGetBitsPerPixel(IFLHANDLE iflh);
  439. IFLTYPE HILAPI iflGetImageType(IFLHANDLE iflh);
  440. #ifdef __cplusplus
  441. }
  442. #endif // __cplusplus
  443. #endif // _IMAGEFILELIB_H
  444. /////////////////////////////////////////////////////////////////////////////