tiffio.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. /*
  2. * Copyright (c) 1988-1997 Sam Leffler
  3. * Copyright (c) 1991-1997 Silicon Graphics, Inc.
  4. *
  5. * Permission to use, copy, modify, distribute, and sell this software and
  6. * its documentation for any purpose is hereby granted without fee, provided
  7. * that (i) the above copyright notices and this permission notice appear in
  8. * all copies of the software and related documentation, and (ii) the names of
  9. * Sam Leffler and Silicon Graphics may not be used in any advertising or
  10. * publicity relating to the software without the specific, prior written
  11. * permission of Sam Leffler and Silicon Graphics.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
  14. * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
  15. * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
  16. *
  17. * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  18. * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  19. * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  20. * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
  21. * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  22. * OF THIS SOFTWARE.
  23. */
  24. #ifndef _TIFFIO_
  25. #define _TIFFIO_
  26. /*
  27. * TIFF I/O Library Definitions.
  28. */
  29. #include "tiff.h"
  30. #include "tiffvers.h"
  31. /*
  32. * TIFF is defined as an incomplete type to hide the
  33. * library's internal data structures from clients.
  34. */
  35. typedef struct tiff TIFF;
  36. /*
  37. * The following typedefs define the intrinsic size of
  38. * data types used in the *exported* interfaces. These
  39. * definitions depend on the proper definition of types
  40. * in tiff.h. Note also that the varargs interface used
  41. * to pass tag types and values uses the types defined in
  42. * tiff.h directly.
  43. *
  44. * NB: ttag_t is unsigned int and not unsigned short because
  45. * ANSI C requires that the type before the ellipsis be a
  46. * promoted type (i.e. one of int, unsigned int, pointer,
  47. * or double) and because we defined pseudo-tags that are
  48. * outside the range of legal Aldus-assigned tags.
  49. * NB: tsize_t is signed and not unsigned because some functions
  50. * return -1.
  51. * NB: toff_t is not off_t for many reasons; TIFFs max out at
  52. * 32-bit file offsets, and BigTIFF maxes out at 64-bit
  53. * offsets being the most important, and to ensure use of
  54. * a consistently unsigned type across architectures.
  55. * Prior to libtiff 4.0, this was an unsigned 32 bit type.
  56. */
  57. /*
  58. * this is the machine addressing size type, only it's signed, so make it
  59. * int32 on 32bit machines, int64 on 64bit machines
  60. */
  61. typedef TIFF_SSIZE_T tmsize_t;
  62. typedef uint64 toff_t; /* file offset */
  63. /* the following are deprecated and should be replaced by their defining
  64. counterparts */
  65. typedef uint32 ttag_t; /* directory tag */
  66. typedef uint16 tdir_t; /* directory index */
  67. typedef uint16 tsample_t; /* sample number */
  68. typedef uint32 tstrile_t; /* strip or tile number */
  69. typedef tstrile_t tstrip_t; /* strip number */
  70. typedef tstrile_t ttile_t; /* tile number */
  71. typedef tmsize_t tsize_t; /* i/o size in bytes */
  72. typedef void* tdata_t; /* image data ref */
  73. #if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32))
  74. #define __WIN32__
  75. #endif
  76. /*
  77. * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c
  78. * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c).
  79. *
  80. * By default tif_unix.c is assumed.
  81. */
  82. #if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows)
  83. # if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO)
  84. # define AVOID_WIN32_FILEIO
  85. # endif
  86. #endif
  87. #if defined(USE_WIN32_FILEIO)
  88. # define VC_EXTRALEAN
  89. # include <windows.h>
  90. # ifdef __WIN32__
  91. DECLARE_HANDLE(thandle_t); /* Win32 file handle */
  92. # else
  93. typedef HFILE thandle_t; /* client data handle */
  94. # endif /* __WIN32__ */
  95. #else
  96. typedef void* thandle_t; /* client data handle */
  97. #endif /* USE_WIN32_FILEIO */
  98. /*
  99. * Flags to pass to TIFFPrintDirectory to control
  100. * printing of data structures that are potentially
  101. * very large. Bit-or these flags to enable printing
  102. * multiple items.
  103. */
  104. #define TIFFPRINT_NONE 0x0 /* no extra info */
  105. #define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */
  106. #define TIFFPRINT_CURVES 0x2 /* color/gray response curves */
  107. #define TIFFPRINT_COLORMAP 0x4 /* colormap */
  108. #define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */
  109. #define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */
  110. #define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */
  111. /*
  112. * Colour conversion stuff
  113. */
  114. /* reference white */
  115. #define D65_X0 (95.0470F)
  116. #define D65_Y0 (100.0F)
  117. #define D65_Z0 (108.8827F)
  118. #define D50_X0 (96.4250F)
  119. #define D50_Y0 (100.0F)
  120. #define D50_Z0 (82.4680F)
  121. /* Structure for holding information about a display device. */
  122. typedef unsigned char TIFFRGBValue; /* 8-bit samples */
  123. typedef struct {
  124. float d_mat[3][3]; /* XYZ -> luminance matrix */
  125. float d_YCR; /* Light o/p for reference white */
  126. float d_YCG;
  127. float d_YCB;
  128. uint32 d_Vrwr; /* Pixel values for ref. white */
  129. uint32 d_Vrwg;
  130. uint32 d_Vrwb;
  131. float d_Y0R; /* Residual light for black pixel */
  132. float d_Y0G;
  133. float d_Y0B;
  134. float d_gammaR; /* Gamma values for the three guns */
  135. float d_gammaG;
  136. float d_gammaB;
  137. } TIFFDisplay;
  138. typedef struct { /* YCbCr->RGB support */
  139. TIFFRGBValue* clamptab; /* range clamping table */
  140. int* Cr_r_tab;
  141. int* Cb_b_tab;
  142. int32* Cr_g_tab;
  143. int32* Cb_g_tab;
  144. int32* Y_tab;
  145. } TIFFYCbCrToRGB;
  146. typedef struct { /* CIE Lab 1976->RGB support */
  147. int range; /* Size of conversion table */
  148. #define CIELABTORGB_TABLE_RANGE 1500
  149. float rstep, gstep, bstep;
  150. float X0, Y0, Z0; /* Reference white point */
  151. TIFFDisplay display;
  152. float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */
  153. float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */
  154. float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */
  155. } TIFFCIELabToRGB;
  156. /*
  157. * RGBA-style image support.
  158. */
  159. typedef struct _TIFFRGBAImage TIFFRGBAImage;
  160. /*
  161. * The image reading and conversion routines invoke
  162. * ``put routines'' to copy/image/whatever tiles of
  163. * raw image data. A default set of routines are
  164. * provided to convert/copy raw image data to 8-bit
  165. * packed ABGR format rasters. Applications can supply
  166. * alternate routines that unpack the data into a
  167. * different format or, for example, unpack the data
  168. * and draw the unpacked raster on the display.
  169. */
  170. typedef void (*tileContigRoutine)
  171. (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
  172. unsigned char*);
  173. typedef void (*tileSeparateRoutine)
  174. (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
  175. unsigned char*, unsigned char*, unsigned char*, unsigned char*);
  176. /*
  177. * RGBA-reader state.
  178. */
  179. struct _TIFFRGBAImage {
  180. TIFF* tif; /* image handle */
  181. int stoponerr; /* stop on read error */
  182. int isContig; /* data is packed/separate */
  183. int alpha; /* type of alpha data present */
  184. uint32 width; /* image width */
  185. uint32 height; /* image height */
  186. uint16 bitspersample; /* image bits/sample */
  187. uint16 samplesperpixel; /* image samples/pixel */
  188. uint16 orientation; /* image orientation */
  189. uint16 req_orientation; /* requested orientation */
  190. uint16 photometric; /* image photometric interp */
  191. uint16* redcmap; /* colormap palette */
  192. uint16* greencmap;
  193. uint16* bluecmap;
  194. /* get image data routine */
  195. int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32);
  196. /* put decoded strip/tile */
  197. union {
  198. void (*any)(TIFFRGBAImage*);
  199. tileContigRoutine contig;
  200. tileSeparateRoutine separate;
  201. } put;
  202. TIFFRGBValue* Map; /* sample mapping array */
  203. uint32** BWmap; /* black&white map */
  204. uint32** PALmap; /* palette image map */
  205. TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */
  206. TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */
  207. uint8* UaToAa; /* Unassociated alpha to associated alpha conversion LUT */
  208. uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */
  209. int row_offset;
  210. int col_offset;
  211. };
  212. /*
  213. * Macros for extracting components from the
  214. * packed ABGR form returned by TIFFReadRGBAImage.
  215. */
  216. #define TIFFGetR(abgr) ((abgr) & 0xff)
  217. #define TIFFGetG(abgr) (((abgr) >> 8) & 0xff)
  218. #define TIFFGetB(abgr) (((abgr) >> 16) & 0xff)
  219. #define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)
  220. /*
  221. * A CODEC is a software package that implements decoding,
  222. * encoding, or decoding+encoding of a compression algorithm.
  223. * The library provides a collection of builtin codecs.
  224. * More codecs may be registered through calls to the library
  225. * and/or the builtin implementations may be overridden.
  226. */
  227. typedef int (*TIFFInitMethod)(TIFF*, int);
  228. typedef struct {
  229. char* name;
  230. uint16 scheme;
  231. TIFFInitMethod init;
  232. } TIFFCodec;
  233. #include <stdio.h>
  234. #include <stdarg.h>
  235. /* share internal LogLuv conversion routines? */
  236. #ifndef LOGLUV_PUBLIC
  237. #define LOGLUV_PUBLIC 1
  238. #endif
  239. #if !defined(__GNUC__) && !defined(__attribute__)
  240. # define __attribute__(x) /*nothing*/
  241. #endif
  242. #if defined(c_plusplus) || defined(__cplusplus)
  243. extern "C" {
  244. #endif
  245. typedef void (*TIFFErrorHandler)(const char*, const char*, va_list);
  246. typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list);
  247. typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_t);
  248. typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
  249. typedef int (*TIFFCloseProc)(thandle_t);
  250. typedef toff_t (*TIFFSizeProc)(thandle_t);
  251. typedef int (*TIFFMapFileProc)(thandle_t, void** base, toff_t* size);
  252. typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size);
  253. typedef void (*TIFFExtendProc)(TIFF*);
  254. extern const char* TIFFGetVersion(void);
  255. extern const TIFFCodec* TIFFFindCODEC(uint16);
  256. extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod);
  257. extern void TIFFUnRegisterCODEC(TIFFCodec*);
  258. extern int TIFFIsCODECConfigured(uint16);
  259. extern TIFFCodec* TIFFGetConfiguredCODECs(void);
  260. /*
  261. * Auxiliary functions.
  262. */
  263. extern void* _TIFFmalloc(tmsize_t s);
  264. extern void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz);
  265. extern void* _TIFFrealloc(void* p, tmsize_t s);
  266. extern void _TIFFmemset(void* p, int v, tmsize_t c);
  267. extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c);
  268. extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c);
  269. extern void _TIFFfree(void* p);
  270. /*
  271. ** Stuff, related to tag handling and creating custom tags.
  272. */
  273. extern int TIFFGetTagListCount( TIFF * );
  274. extern uint32 TIFFGetTagListEntry( TIFF *, int tag_index );
  275. #define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
  276. #define TIFF_VARIABLE -1 /* marker for variable length tags */
  277. #define TIFF_SPP -2 /* marker for SamplesPerPixel tags */
  278. #define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */
  279. #define FIELD_CUSTOM 65
  280. typedef struct _TIFFField TIFFField;
  281. typedef struct _TIFFFieldArray TIFFFieldArray;
  282. extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType);
  283. extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32);
  284. extern const TIFFField* TIFFFieldWithName(TIFF*, const char *);
  285. extern uint32 TIFFFieldTag(const TIFFField*);
  286. extern const char* TIFFFieldName(const TIFFField*);
  287. extern TIFFDataType TIFFFieldDataType(const TIFFField*);
  288. extern int TIFFFieldPassCount(const TIFFField*);
  289. extern int TIFFFieldReadCount(const TIFFField*);
  290. extern int TIFFFieldWriteCount(const TIFFField*);
  291. typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list);
  292. typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list);
  293. typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long);
  294. typedef struct {
  295. TIFFVSetMethod vsetfield; /* tag set routine */
  296. TIFFVGetMethod vgetfield; /* tag get routine */
  297. TIFFPrintMethod printdir; /* directory print routine */
  298. } TIFFTagMethods;
  299. extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *);
  300. extern void *TIFFGetClientInfo(TIFF *, const char *);
  301. extern void TIFFSetClientInfo(TIFF *, void *, const char *);
  302. extern void TIFFCleanup(TIFF* tif);
  303. extern void TIFFClose(TIFF* tif);
  304. extern int TIFFFlush(TIFF* tif);
  305. extern int TIFFFlushData(TIFF* tif);
  306. extern int TIFFGetField(TIFF* tif, uint32 tag, ...);
  307. extern int TIFFVGetField(TIFF* tif, uint32 tag, va_list ap);
  308. extern int TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...);
  309. extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap);
  310. extern int TIFFReadDirectory(TIFF* tif);
  311. extern int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray);
  312. extern int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff);
  313. extern uint64 TIFFScanlineSize64(TIFF* tif);
  314. extern tmsize_t TIFFScanlineSize(TIFF* tif);
  315. extern uint64 TIFFRasterScanlineSize64(TIFF* tif);
  316. extern tmsize_t TIFFRasterScanlineSize(TIFF* tif);
  317. extern uint64 TIFFStripSize64(TIFF* tif);
  318. extern tmsize_t TIFFStripSize(TIFF* tif);
  319. extern uint64 TIFFRawStripSize64(TIFF* tif, uint32 strip);
  320. extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32 strip);
  321. extern uint64 TIFFVStripSize64(TIFF* tif, uint32 nrows);
  322. extern tmsize_t TIFFVStripSize(TIFF* tif, uint32 nrows);
  323. extern uint64 TIFFTileRowSize64(TIFF* tif);
  324. extern tmsize_t TIFFTileRowSize(TIFF* tif);
  325. extern uint64 TIFFTileSize64(TIFF* tif);
  326. extern tmsize_t TIFFTileSize(TIFF* tif);
  327. extern uint64 TIFFVTileSize64(TIFF* tif, uint32 nrows);
  328. extern tmsize_t TIFFVTileSize(TIFF* tif, uint32 nrows);
  329. extern uint32 TIFFDefaultStripSize(TIFF* tif, uint32 request);
  330. extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*);
  331. extern int TIFFFileno(TIFF*);
  332. extern int TIFFSetFileno(TIFF*, int);
  333. extern thandle_t TIFFClientdata(TIFF*);
  334. extern thandle_t TIFFSetClientdata(TIFF*, thandle_t);
  335. extern int TIFFGetMode(TIFF*);
  336. extern int TIFFSetMode(TIFF*, int);
  337. extern int TIFFIsTiled(TIFF*);
  338. extern int TIFFIsByteSwapped(TIFF*);
  339. extern int TIFFIsUpSampled(TIFF*);
  340. extern int TIFFIsMSB2LSB(TIFF*);
  341. extern int TIFFIsBigEndian(TIFF*);
  342. extern TIFFReadWriteProc TIFFGetReadProc(TIFF*);
  343. extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*);
  344. extern TIFFSeekProc TIFFGetSeekProc(TIFF*);
  345. extern TIFFCloseProc TIFFGetCloseProc(TIFF*);
  346. extern TIFFSizeProc TIFFGetSizeProc(TIFF*);
  347. extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*);
  348. extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*);
  349. extern uint32 TIFFCurrentRow(TIFF*);
  350. extern uint16 TIFFCurrentDirectory(TIFF*);
  351. extern uint16 TIFFNumberOfDirectories(TIFF*);
  352. extern uint64 TIFFCurrentDirOffset(TIFF*);
  353. extern uint32 TIFFCurrentStrip(TIFF*);
  354. extern uint32 TIFFCurrentTile(TIFF* tif);
  355. extern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size);
  356. extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size);
  357. extern int TIFFSetupStrips(TIFF *);
  358. extern int TIFFWriteCheck(TIFF*, int, const char *);
  359. extern void TIFFFreeDirectory(TIFF*);
  360. extern int TIFFCreateDirectory(TIFF*);
  361. extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*);
  362. extern int TIFFCreateEXIFDirectory(TIFF*);
  363. extern int TIFFLastDirectory(TIFF*);
  364. extern int TIFFSetDirectory(TIFF*, uint16);
  365. extern int TIFFSetSubDirectory(TIFF*, uint64);
  366. extern int TIFFUnlinkDirectory(TIFF*, uint16);
  367. extern int TIFFSetField(TIFF*, uint32, ...);
  368. extern int TIFFVSetField(TIFF*, uint32, va_list);
  369. extern int TIFFUnsetField(TIFF*, uint32);
  370. extern int TIFFWriteDirectory(TIFF *);
  371. extern int TIFFWriteCustomDirectory(TIFF *, uint64 *);
  372. extern int TIFFCheckpointDirectory(TIFF *);
  373. extern int TIFFRewriteDirectory(TIFF *);
  374. extern int TIFFDeferStrileArrayWriting(TIFF *);
  375. extern int TIFFForceStrileArrayWriting(TIFF* );
  376. #if defined(c_plusplus) || defined(__cplusplus)
  377. extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0);
  378. extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0);
  379. extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0);
  380. extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0);
  381. extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*,
  382. int = ORIENTATION_BOTLEFT, int = 0);
  383. #else
  384. extern void TIFFPrintDirectory(TIFF*, FILE*, long);
  385. extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample);
  386. extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample);
  387. extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int);
  388. extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int);
  389. #endif
  390. extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * );
  391. extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * );
  392. extern int TIFFReadRGBAStripExt(TIFF*, uint32, uint32 *, int stop_on_error );
  393. extern int TIFFReadRGBATileExt(TIFF*, uint32, uint32, uint32 *, int stop_on_error );
  394. extern int TIFFRGBAImageOK(TIFF*, char [1024]);
  395. extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]);
  396. extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32);
  397. extern void TIFFRGBAImageEnd(TIFFRGBAImage*);
  398. extern TIFF* TIFFOpen(const char*, const char*);
  399. # ifdef __WIN32__
  400. extern TIFF* TIFFOpenW(const wchar_t*, const char*);
  401. # endif /* __WIN32__ */
  402. extern TIFF* TIFFFdOpen(int, const char*, const char*);
  403. extern TIFF* TIFFClientOpen(const char*, const char*,
  404. thandle_t,
  405. TIFFReadWriteProc, TIFFReadWriteProc,
  406. TIFFSeekProc, TIFFCloseProc,
  407. TIFFSizeProc,
  408. TIFFMapFileProc, TIFFUnmapFileProc);
  409. extern const char* TIFFFileName(TIFF*);
  410. extern const char* TIFFSetFileName(TIFF*, const char *);
  411. extern void TIFFError(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3)));
  412. extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4)));
  413. extern void TIFFWarning(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3)));
  414. extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4)));
  415. extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler);
  416. extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt);
  417. extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler);
  418. extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt);
  419. extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc);
  420. extern uint32 TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s);
  421. extern int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s);
  422. extern uint32 TIFFNumberOfTiles(TIFF*);
  423. extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s);
  424. extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s);
  425. extern uint32 TIFFComputeStrip(TIFF*, uint32, uint16);
  426. extern uint32 TIFFNumberOfStrips(TIFF*);
  427. extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size);
  428. extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size);
  429. extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size);
  430. extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size);
  431. extern int TIFFReadFromUserBuffer(TIFF* tif, uint32 strile,
  432. void* inbuf, tmsize_t insize,
  433. void* outbuf, tmsize_t outsize);
  434. extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc);
  435. extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc);
  436. extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc);
  437. extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc);
  438. extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */
  439. extern void TIFFSetWriteOffset(TIFF* tif, toff_t off);
  440. extern void TIFFSwabShort(uint16*);
  441. extern void TIFFSwabLong(uint32*);
  442. extern void TIFFSwabLong8(uint64*);
  443. extern void TIFFSwabFloat(float*);
  444. extern void TIFFSwabDouble(double*);
  445. extern void TIFFSwabArrayOfShort(uint16* wp, tmsize_t n);
  446. extern void TIFFSwabArrayOfTriples(uint8* tp, tmsize_t n);
  447. extern void TIFFSwabArrayOfLong(uint32* lp, tmsize_t n);
  448. extern void TIFFSwabArrayOfLong8(uint64* lp, tmsize_t n);
  449. extern void TIFFSwabArrayOfFloat(float* fp, tmsize_t n);
  450. extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n);
  451. extern void TIFFReverseBits(uint8* cp, tmsize_t n);
  452. extern const unsigned char* TIFFGetBitRevTable(int);
  453. extern uint64 TIFFGetStrileOffset(TIFF *tif, uint32 strile);
  454. extern uint64 TIFFGetStrileByteCount(TIFF *tif, uint32 strile);
  455. extern uint64 TIFFGetStrileOffsetWithErr(TIFF *tif, uint32 strile, int *pbErr);
  456. extern uint64 TIFFGetStrileByteCountWithErr(TIFF *tif, uint32 strile, int *pbErr);
  457. #ifdef LOGLUV_PUBLIC
  458. #define U_NEU 0.210526316
  459. #define V_NEU 0.473684211
  460. #define UVSCALE 410.
  461. extern double LogL16toY(int);
  462. extern double LogL10toY(int);
  463. extern void XYZtoRGB24(float*, uint8*);
  464. extern int uv_decode(double*, double*, int);
  465. extern void LogLuv24toXYZ(uint32, float*);
  466. extern void LogLuv32toXYZ(uint32, float*);
  467. #if defined(c_plusplus) || defined(__cplusplus)
  468. extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER);
  469. extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER);
  470. extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER);
  471. extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER);
  472. extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER);
  473. #else
  474. extern int LogL16fromY(double, int);
  475. extern int LogL10fromY(double, int);
  476. extern int uv_encode(double, double, int);
  477. extern uint32 LogLuv24fromXYZ(float*, int);
  478. extern uint32 LogLuv32fromXYZ(float*, int);
  479. #endif
  480. #endif /* LOGLUV_PUBLIC */
  481. extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*);
  482. extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32,
  483. float *, float *, float *);
  484. extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float,
  485. uint32 *, uint32 *, uint32 *);
  486. extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*);
  487. extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32,
  488. uint32 *, uint32 *, uint32 *);
  489. /****************************************************************************
  490. * O B S O L E T E D I N T E R F A C E S
  491. *
  492. * Don't use this stuff in your applications, it may be removed in the future
  493. * libtiff versions.
  494. ****************************************************************************/
  495. typedef struct {
  496. ttag_t field_tag; /* field's tag */
  497. short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */
  498. short field_writecount; /* write count/TIFF_VARIABLE */
  499. TIFFDataType field_type; /* type of associated data */
  500. unsigned short field_bit; /* bit in fieldsset bit vector */
  501. unsigned char field_oktochange; /* if true, can change while writing */
  502. unsigned char field_passcount; /* if true, pass dir count on set */
  503. char *field_name; /* ASCII name */
  504. } TIFFFieldInfo;
  505. extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32);
  506. #if defined(c_plusplus) || defined(__cplusplus)
  507. }
  508. #endif
  509. #endif /* _TIFFIO_ */
  510. /* vim: set ts=8 sts=8 sw=8 noet: */
  511. /*
  512. * Local Variables:
  513. * mode: c
  514. * c-basic-offset: 8
  515. * fill-column: 78
  516. * End:
  517. */