il.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: il.h /main/6 1996/09/24 17:12:23 drk $ */
  24. /**---------------------------------------------------------------------
  25. ***
  26. *** file: il.h
  27. ***
  28. *** description: Main public include file for Image Library (IL).
  29. ***
  30. ***
  31. *** (c)Copyright 1991 Hewlett-Packard Co.
  32. ***
  33. *** RESTRICTED RIGHTS LEGEND
  34. *** Use, duplication, or disclosure by the U.S. Government is subject to
  35. *** restrictions as set forth in sub-paragraph (c)(1)(ii) of the Rights in
  36. *** Technical Data and Computer Software clause in DFARS 252.227-7013.
  37. *** Hewlett-Packard Company
  38. *** 3000 Hanover Street
  39. *** Palo Alto, CA 94304 U.S.A.
  40. *** Rights for non-DOD U.S. Government Departments and Agencies are as set
  41. *** forth in FAR 52.227-19(c)(1,2).
  42. ***
  43. ***-------------------------------------------------------------------*/
  44. #ifndef IL_H
  45. #define IL_H
  46. #include <X11/Xos.h>
  47. #include <X11/Xfuncs.h>
  48. /* include Xmd.h for CARD32 and INT32 definitions */
  49. #include <X11/Xmd.h>
  50. #ifndef NeedFunctionPrototypes
  51. #if defined(FUNCPROTO) || defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
  52. #define NeedFunctionPrototypes 1
  53. #else
  54. #define NeedFunctionPrototypes 0
  55. #endif /* __STDC__ */
  56. #endif /* NeedFunctionPrototypes */
  57. #ifndef NeedWidePrototypes
  58. #if defined(NARROWPROTO)
  59. #define NeedWidePrototypes 0
  60. #else
  61. #define NeedWidePrototypes 1 /* default to make interropt. easier */
  62. #endif
  63. #endif
  64. #ifdef __cplusplus /* do not leave open across includes */
  65. extern "C" { /* for C++ V2.0 */
  66. #endif
  67. /* Values for ilImageDes. */
  68. /* ilImageDes.nSamplesPerPixel max */
  69. #define IL_MAX_SAMPLES 5
  70. /* ilImageDes.type */
  71. #define IL_BITONAL 0
  72. #define IL_GRAY 1
  73. #define IL_PALETTE 2
  74. #define IL_RGB 3
  75. #define IL_YCBCR 4
  76. /* ilImageDes.compression */
  77. #define IL_UNCOMPRESSED 0
  78. #define IL_G3 1
  79. #define IL_JPEG 2
  80. #define IL_G4 3
  81. #define IL_LZW 4
  82. #define IL_PACKBITS 5
  83. /* ilImageDes.compInfo.g3.flags masks. Use IL_G3M_TIFF for
  84. TIFF-compatible (comp 2); IL_G3M_CLASS_F for Class F (comp code 3).
  85. */
  86. #define IL_G3M_LSB_FIRST (1<<0)
  87. #define IL_G3M_2D (1<<1)
  88. #define IL_G3M_UNCOMPRESSED (1<<2)
  89. #define IL_G3M_EOL_MARKERS (1<<3)
  90. #define IL_G3M_EOL_UNALIGNED (1<<4)
  91. #define IL_G3M_K_FACTOR_2 (1<<5)
  92. #define IL_G3M_TIFF 0
  93. #define IL_G3M_CLASS_F (IL_G3M_LSB_FIRST | IL_G3M_EOL_MARKERS)
  94. /* ilImageDes.compInfo.g4.flags masks. */
  95. #define IL_G4M_LSB_FIRST (1<<0)
  96. #define IL_G4M_UNCOMPRESSED (1<<2)
  97. /* ilObject->objectType */
  98. #define IL_NULL_OBJECT 0
  99. #define IL_PIPE 1
  100. #define IL_FILE 2
  101. #define IL_INTERNAL_IMAGE 3
  102. #define IL_CLIENT_IMAGE 4
  103. #define IL_XWC 5
  104. #define IL_EFS_FILE_TYPE 6
  105. #define IL_EFS_FILE 7
  106. /* ilImageFormat->byteOrder */
  107. #define IL_MSB_FIRST 0
  108. #define IL_LSB_FIRST 1
  109. /* ilImageFormat->sampleOrder */
  110. #define IL_SAMPLE_PIXELS 0
  111. #define IL_SAMPLE_PLANES 1
  112. /* ilExecutePipe() return values */
  113. #define IL_EXECUTE_AGAIN 0
  114. #define IL_EXECUTE_COMPLETE 1
  115. #define IL_EXECUTE_ERROR 2
  116. /* ilQueryPipe() return values */
  117. #define IL_PIPE_INVALID 0
  118. #define IL_PIPE_EMPTY 1
  119. #define IL_PIPE_FORMING 2
  120. #define IL_PIPE_COMPLETE 3
  121. #define IL_PIPE_EXECUTING 4
  122. /* Value meaning "no error" for ilError: other errors in ilerrors.h */
  123. #define IL_OK 0
  124. /* option to ilConvert() */
  125. #define IL_CONVERT_NO_OPTION 0
  126. #define IL_CONVERT_THRESHOLD 1
  127. #define IL_THRESHOLD_TO_BITONAL IL_CONVERT_THRESHOLD
  128. #define IL_CONVERT_TO_PALETTE 2
  129. #define IL_CONVERT_SOFT_INVERT 3
  130. /* values for ilConvertToPaletteInfo.method */
  131. #define IL_AREA_DITHER 0
  132. #define IL_DIFFUSION 1
  133. #define IL_QUICK_DIFFUSION 2
  134. #define IL_CHOOSE_COLORS 3
  135. /* Option1 to ilScale() */
  136. #define IL_SCALE_SIMPLE 0
  137. #define IL_SCALE_SAMPLE 1
  138. #define IL_SCALE_BITONAL_TO_GRAY 2
  139. /* Options to ilMirror() */
  140. #define IL_MIRRORX 0
  141. #define IL_MIRRORY 1
  142. /* values for ilImageDes.flags */
  143. #define IL_DITHERED_PALETTE (1<<0)
  144. typedef unsigned char ilByte;
  145. typedef ilByte *ilPtr;
  146. typedef int ilBool;
  147. typedef short ilShortBool;
  148. typedef int ilError;
  149. /* ilImageDes and predefined image descriptors */
  150. typedef struct {
  151. short refBlack, refWhite;
  152. ilByte subsampleHoriz, subsampleVert;
  153. } ilYCbCrSampleInfo;
  154. typedef struct {
  155. ilYCbCrSampleInfo sample[3]; /* [Y,Cb,Cr] */
  156. short lumaRed, lumaGreen, lumaBlue; /* fractions of 10000 */
  157. short positioning; /* must be zero (0) */
  158. } ilYCbCrInfo;
  159. typedef struct {
  160. short levels[3];
  161. } ilPaletteInfo;
  162. typedef struct {
  163. unsigned long flags;
  164. } ilG3Info;
  165. typedef struct {
  166. unsigned long flags;
  167. } ilG4Info;
  168. typedef struct {
  169. short reserved; /* must be zero (0) */
  170. short process;
  171. } ilJPEGInfo;
  172. #define IL_DES_RESERVED_SIZE 4
  173. typedef struct _ilImageDes {
  174. unsigned short type;
  175. unsigned short compression;
  176. ilShortBool blackIsZero;
  177. unsigned short nSamplesPerPixel;
  178. unsigned long noLongerUsed; /* must set to 0x10001 */
  179. union {
  180. ilG3Info g3;
  181. ilG4Info g4;
  182. ilJPEGInfo JPEG;
  183. } compInfo;
  184. long reserved [IL_DES_RESERVED_SIZE];
  185. unsigned long flags;
  186. union {
  187. ilYCbCrInfo YCbCr;
  188. ilPaletteInfo palette;
  189. long filler [8];
  190. } typeInfo;
  191. long nLevelsPerSample [IL_MAX_SAMPLES];
  192. } ilImageDes;
  193. #define IL_INIT_IMAGE_DES(_pDes) { \
  194. bzero ((char *)(_pDes), sizeof (ilImageDes)); \
  195. (_pDes)->noLongerUsed = 0x10001; \
  196. }
  197. extern const ilImageDes ilBitonal0WhiteImageDes, ilGray256ImageDes, ilRGB256ImageDes;
  198. extern const ilImageDes ilPaletteImageDes, ilYCbCrImageDes, ilYCbCr2ImageDes;
  199. #define IL_DES_BITONAL (&ilBitonal0WhiteImageDes)
  200. #define IL_DES_GRAY (&ilGray256ImageDes)
  201. #define IL_DES_RGB (&ilRGB256ImageDes)
  202. #define IL_DES_PALETTE (&ilPaletteImageDes)
  203. #define IL_DES_YCBCR (&ilYCbCrImageDes)
  204. #define IL_DES_YCBCR_2 (&ilYCbCr2ImageDes)
  205. /* ilImageFormat and predefined image formats */
  206. #define IL_FORMAT_RESERVED_SIZE 4
  207. /* Byte flip table used for bitonal rotate & mirror filters and xbm decode */
  208. extern const unsigned char ilBitReverseTable [256];
  209. typedef struct {
  210. unsigned short sampleOrder;
  211. unsigned short byteOrder;
  212. unsigned short rowBitAlign;
  213. long reserved [IL_FORMAT_RESERVED_SIZE];
  214. unsigned short nBitsPerSample [IL_MAX_SAMPLES];
  215. } ilImageFormat;
  216. #define IL_INIT_IMAGE_FORMAT(_pFormat) { \
  217. bzero ((char *)(_pFormat), sizeof (ilImageFormat)); \
  218. }
  219. extern const ilImageFormat ilBitImageFormat, ilByteImageFormat,
  220. il3BytePixelImageFormat, il3BytePlaneImageFormat;
  221. #define IL_FORMAT_BIT (&ilBitImageFormat)
  222. #define IL_FORMAT_BYTE (&ilByteImageFormat)
  223. #define IL_FORMAT_3BYTE_PIXEL (&il3BytePixelImageFormat)
  224. #define IL_FORMAT_3BYTE_PLANE (&il3BytePlaneImageFormat)
  225. typedef struct {
  226. ilError error;
  227. long errorInfo;
  228. } ilContextPublicRec;
  229. typedef ilContextPublicRec *ilContext;
  230. typedef struct {
  231. ilContext context;
  232. int objectType;
  233. ilPtr pPrivate;
  234. } ilObjectPublicRec;
  235. typedef ilObjectPublicRec *ilObject;
  236. typedef ilObject ilPipe;
  237. typedef ilObject ilInternalImage;
  238. typedef ilObject ilClientImage;
  239. typedef struct {
  240. long x;
  241. long y;
  242. long width;
  243. long height;
  244. } ilRect;
  245. typedef struct {
  246. ilPtr pPixels;
  247. long nBytesPerRow;
  248. long bufferSize;
  249. long filler;
  250. } ilImagePlaneInfo;
  251. typedef struct {
  252. const ilImageDes *pDes;
  253. const ilImageFormat *pFormat;
  254. long width, height;
  255. unsigned short *pPalette;
  256. ilPtr pCompData;
  257. ilShortBool clientPalette;
  258. ilShortBool clientCompData;
  259. ilShortBool clientPixels;
  260. short filler [9];
  261. ilImagePlaneInfo plane [IL_MAX_SAMPLES];
  262. } ilImageInfo;
  263. typedef struct {
  264. short mustbezero;
  265. short Q;
  266. } ilJPEGEncodeControl;
  267. typedef struct {
  268. short method;
  269. short levels [3];
  270. short kernelSize;
  271. short dstType;
  272. ilObject mapImage;
  273. } ilConvertToPaletteInfo;
  274. #define IL_INTERNAL_VERSION 4
  275. extern ilError ilInternalCreateContext (
  276. #if NeedFunctionPrototypes
  277. int versionCheck,
  278. ilContext *pContextReturn, /* RETURNED */
  279. unsigned long mustBeZero
  280. #endif
  281. );
  282. #define IL_CREATE_CONTEXT(_pContext, _zero) \
  283. (ilInternalCreateContext (IL_INTERNAL_VERSION, \
  284. (_pContext), (_zero)))
  285. extern ilBool ilDestroyContext (
  286. #if NeedFunctionPrototypes
  287. ilContext context
  288. #endif
  289. );
  290. extern ilBool ilDestroyObject (
  291. #if NeedFunctionPrototypes
  292. ilObject object
  293. #endif
  294. );
  295. extern ilInternalImage ilCreateInternalImage (
  296. #if NeedFunctionPrototypes
  297. ilContext context,
  298. long width,
  299. long height,
  300. ilImageDes *pImageDes,
  301. unsigned long mustBeZero
  302. #endif
  303. );
  304. extern ilBool ilQueryInternalImage (
  305. #if NeedFunctionPrototypes
  306. ilInternalImage image,
  307. long *pWidth, /* RETURNED */
  308. long *pHeight, /* RETURNED */
  309. ilImageDes *pImageDes, /* RETURNED */
  310. unsigned long mustBeZero
  311. #endif
  312. );
  313. extern unsigned int ilGetPrivateType (
  314. #if NeedFunctionPrototypes
  315. ilContext context
  316. #endif
  317. );
  318. extern ilClientImage ilCreateClientImage (
  319. #if NeedFunctionPrototypes
  320. ilContext context,
  321. ilImageInfo *pInfo,
  322. unsigned long mustBeZero
  323. #endif
  324. );
  325. extern ilBool ilQueryClientImage (
  326. #if NeedFunctionPrototypes
  327. ilClientImage image,
  328. ilImageInfo **ppInfo, /* RETURNED */
  329. unsigned long mustBeZero
  330. #endif
  331. );
  332. extern ilPipe ilCreatePipe (
  333. #if NeedFunctionPrototypes
  334. ilContext context,
  335. unsigned long mustBeZero
  336. #endif
  337. );
  338. extern ilBool ilEmptyPipe (
  339. #if NeedFunctionPrototypes
  340. ilPipe pipe
  341. #endif
  342. );
  343. extern unsigned int ilQueryPipe (
  344. #if NeedFunctionPrototypes
  345. ilPipe pipe,
  346. long *pWidth, /* RETURNED */
  347. long *pHeight, /* RETURNED */
  348. ilImageDes *pImageDes /* RETURNED */
  349. #endif
  350. );
  351. extern ilBool ilAbortPipe (
  352. #if NeedFunctionPrototypes
  353. ilPipe pipe
  354. #endif
  355. );
  356. extern int ilExecutePipe (
  357. #if NeedFunctionPrototypes
  358. ilPipe pipe,
  359. long nStrips,
  360. float ratio
  361. #endif
  362. );
  363. extern ilBool ilReadImage (
  364. #if NeedFunctionPrototypes
  365. ilPipe pipe,
  366. ilObject image
  367. #endif
  368. );
  369. extern ilBool ilWriteImage (
  370. #if NeedFunctionPrototypes
  371. ilPipe pipe,
  372. ilObject image
  373. #endif
  374. );
  375. extern ilBool ilScale (
  376. #if NeedFunctionPrototypes
  377. ilPipe pipe,
  378. long dstWidth,
  379. long dstHeight,
  380. int option,
  381. void *pOptionData
  382. #endif
  383. );
  384. extern ilBool ilRotate90 (
  385. #if NeedFunctionPrototypes
  386. ilPipe pipe,
  387. int factor
  388. #endif
  389. );
  390. extern ilBool ilMirror (
  391. #if NeedFunctionPrototypes
  392. ilPipe pipe,
  393. int direction
  394. #endif
  395. );
  396. extern ilBool ilCrop (
  397. #if NeedFunctionPrototypes
  398. ilPipe pipe,
  399. ilRect *pRect
  400. #endif
  401. );
  402. extern ilBool ilMap (
  403. #if NeedFunctionPrototypes
  404. ilPipe pipe,
  405. ilClientImage mapImage
  406. #endif
  407. );
  408. extern ilBool ilConvert (
  409. #if NeedFunctionPrototypes
  410. ilPipe pipe,
  411. const ilImageDes *pDes,
  412. const ilImageFormat *pFormat,
  413. int option,
  414. void *pOptionData
  415. #endif
  416. );
  417. extern ilBool ilCompress (
  418. #if NeedFunctionPrototypes
  419. ilPipe pipe,
  420. unsigned int compression,
  421. ilPtr pData,
  422. long dstStripHeight,
  423. unsigned long mustBeZero
  424. #endif
  425. );
  426. extern ilBool ilFeedFromImage (
  427. #if NeedFunctionPrototypes
  428. ilPipe pipe,
  429. ilObject image,
  430. long height,
  431. long stripHeight,
  432. ilBool constantStrip
  433. #endif
  434. );
  435. extern int ilFeedPipe (
  436. #if NeedFunctionPrototypes
  437. ilPipe pipe,
  438. long start,
  439. long nLines,
  440. long nCompBytes,
  441. unsigned long mustBeZero
  442. #endif
  443. );
  444. extern ilPipe ilTapPipe (
  445. #if NeedFunctionPrototypes
  446. ilPipe pipe,
  447. unsigned long mustBeZero,
  448. void *mustBeNull
  449. #endif
  450. );
  451. #ifdef __cplusplus
  452. } /* for C++ V2.0 */
  453. #endif
  454. #endif