tiffio.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  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_t on 32bit machines, int64_t on 64bit machines
  60. */
  61. typedef TIFF_SSIZE_T tmsize_t;
  62. #define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
  63. typedef uint64_t toff_t; /* file offset */
  64. /* the following are deprecated and should be replaced by their defining
  65. counterparts */
  66. typedef uint32_t ttag_t; /* directory tag */
  67. typedef uint32_t tdir_t; /* directory index */
  68. typedef uint16_t tsample_t; /* sample number */
  69. typedef uint32_t tstrile_t; /* strip or tile number */
  70. typedef tstrile_t tstrip_t; /* strip number */
  71. typedef tstrile_t ttile_t; /* tile number */
  72. typedef tmsize_t tsize_t; /* i/o size in bytes */
  73. typedef void *tdata_t; /* image data ref */
  74. /*
  75. * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c
  76. * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c).
  77. *
  78. * By default tif_unix.c is assumed.
  79. */
  80. #if defined(_WIN32)
  81. #if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && \
  82. !defined(USE_WIN32_FILEIO)
  83. #define AVOID_WIN32_FILEIO
  84. #endif
  85. #endif
  86. #if defined(USE_WIN32_FILEIO)
  87. #define VC_EXTRALEAN
  88. #include <windows.h>
  89. #ifdef _WIN32
  90. DECLARE_HANDLE(thandle_t); /* Win32 file handle */
  91. #else
  92. typedef HFILE thandle_t; /* client data handle */
  93. #endif /* _WIN32 */
  94. #else
  95. typedef void *thandle_t; /* client data handle */
  96. #endif /* USE_WIN32_FILEIO */
  97. /*
  98. * Flags to pass to TIFFPrintDirectory to control
  99. * printing of data structures that are potentially
  100. * very large. Bit-or these flags to enable printing
  101. * multiple items.
  102. */
  103. #define TIFFPRINT_NONE 0x0 /* no extra info */
  104. #define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */
  105. #define TIFFPRINT_CURVES 0x2 /* color/gray response curves */
  106. #define TIFFPRINT_COLORMAP 0x4 /* colormap */
  107. #define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */
  108. #define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */
  109. #define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */
  110. /*
  111. * Colour conversion stuff
  112. */
  113. /* reference white */
  114. #define D65_X0 (95.0470F)
  115. #define D65_Y0 (100.0F)
  116. #define D65_Z0 (108.8827F)
  117. #define D50_X0 (96.4250F)
  118. #define D50_Y0 (100.0F)
  119. #define D50_Z0 (82.4680F)
  120. /* Structure for holding information about a display device. */
  121. typedef unsigned char TIFFRGBValue; /* 8-bit samples */
  122. typedef struct
  123. {
  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_t d_Vrwr; /* Pixel values for ref. white */
  129. uint32_t d_Vrwg;
  130. uint32_t 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
  139. { /* YCbCr->RGB support */
  140. TIFFRGBValue *clamptab; /* range clamping table */
  141. int *Cr_r_tab;
  142. int *Cb_b_tab;
  143. int32_t *Cr_g_tab;
  144. int32_t *Cb_g_tab;
  145. int32_t *Y_tab;
  146. } TIFFYCbCrToRGB;
  147. typedef struct
  148. { /* CIE Lab 1976->RGB support */
  149. int range; /* Size of conversion table */
  150. #define CIELABTORGB_TABLE_RANGE 1500
  151. float rstep, gstep, bstep;
  152. float X0, Y0, Z0; /* Reference white point */
  153. TIFFDisplay display;
  154. float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */
  155. float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */
  156. float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */
  157. } TIFFCIELabToRGB;
  158. /*
  159. * RGBA-style image support.
  160. */
  161. typedef struct _TIFFRGBAImage TIFFRGBAImage;
  162. /*
  163. * The image reading and conversion routines invoke
  164. * ``put routines'' to copy/image/whatever tiles of
  165. * raw image data. A default set of routines are
  166. * provided to convert/copy raw image data to 8-bit
  167. * packed ABGR format rasters. Applications can supply
  168. * alternate routines that unpack the data into a
  169. * different format or, for example, unpack the data
  170. * and draw the unpacked raster on the display.
  171. */
  172. typedef void (*tileContigRoutine)(TIFFRGBAImage *, uint32_t *, uint32_t,
  173. uint32_t, uint32_t, uint32_t, int32_t,
  174. int32_t, unsigned char *);
  175. typedef void (*tileSeparateRoutine)(TIFFRGBAImage *, uint32_t *, uint32_t,
  176. uint32_t, uint32_t, uint32_t, int32_t,
  177. int32_t, unsigned char *, unsigned char *,
  178. unsigned char *, unsigned char *);
  179. /*
  180. * RGBA-reader state.
  181. */
  182. struct _TIFFRGBAImage
  183. {
  184. TIFF *tif; /* image handle */
  185. int stoponerr; /* stop on read error */
  186. int isContig; /* data is packed/separate */
  187. int alpha; /* type of alpha data present */
  188. uint32_t width; /* image width */
  189. uint32_t height; /* image height */
  190. uint16_t bitspersample; /* image bits/sample */
  191. uint16_t samplesperpixel; /* image samples/pixel */
  192. uint16_t orientation; /* image orientation */
  193. uint16_t req_orientation; /* requested orientation */
  194. uint16_t photometric; /* image photometric interp */
  195. uint16_t *redcmap; /* colormap palette */
  196. uint16_t *greencmap;
  197. uint16_t *bluecmap;
  198. /* get image data routine */
  199. int (*get)(TIFFRGBAImage *, uint32_t *, uint32_t, uint32_t);
  200. /* put decoded strip/tile */
  201. union
  202. {
  203. void (*any)(TIFFRGBAImage *);
  204. tileContigRoutine contig;
  205. tileSeparateRoutine separate;
  206. } put;
  207. TIFFRGBValue *Map; /* sample mapping array */
  208. uint32_t **BWmap; /* black&white map */
  209. uint32_t **PALmap; /* palette image map */
  210. TIFFYCbCrToRGB *ycbcr; /* YCbCr conversion state */
  211. TIFFCIELabToRGB *cielab; /* CIE L*a*b conversion state */
  212. uint8_t *UaToAa; /* Unassociated alpha to associated alpha conversion LUT */
  213. uint8_t *Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */
  214. int row_offset;
  215. int col_offset;
  216. };
  217. /*
  218. * Macros for extracting components from the
  219. * packed ABGR form returned by TIFFReadRGBAImage.
  220. */
  221. #define TIFFGetR(abgr) ((abgr)&0xff)
  222. #define TIFFGetG(abgr) (((abgr) >> 8) & 0xff)
  223. #define TIFFGetB(abgr) (((abgr) >> 16) & 0xff)
  224. #define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)
  225. /*
  226. * A CODEC is a software package that implements decoding,
  227. * encoding, or decoding+encoding of a compression algorithm.
  228. * The library provides a collection of builtin codecs.
  229. * More codecs may be registered through calls to the library
  230. * and/or the builtin implementations may be overridden.
  231. */
  232. typedef int (*TIFFInitMethod)(TIFF *, int);
  233. typedef struct
  234. {
  235. char *name;
  236. uint16_t scheme;
  237. TIFFInitMethod init;
  238. } TIFFCodec;
  239. typedef struct
  240. {
  241. uint32_t uNum;
  242. uint32_t uDenom;
  243. } TIFFRational_t;
  244. #include <stdarg.h>
  245. #include <stdio.h>
  246. /* share internal LogLuv conversion routines? */
  247. #ifndef LOGLUV_PUBLIC
  248. #define LOGLUV_PUBLIC 1
  249. #endif
  250. #if defined(__GNUC__) || defined(__clang__) || defined(__attribute__)
  251. #define TIFF_ATTRIBUTE(x) __attribute__(x)
  252. #else
  253. #define TIFF_ATTRIBUTE(x) /*nothing*/
  254. #endif
  255. #if defined(c_plusplus) || defined(__cplusplus)
  256. extern "C"
  257. {
  258. #endif
  259. typedef void (*TIFFErrorHandler)(const char *, const char *, va_list);
  260. typedef void (*TIFFErrorHandlerExt)(thandle_t, const char *, const char *,
  261. va_list);
  262. typedef int (*TIFFErrorHandlerExtR)(TIFF *, void *user_data, const char *,
  263. const char *, va_list);
  264. typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void *, tmsize_t);
  265. typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
  266. typedef int (*TIFFCloseProc)(thandle_t);
  267. typedef toff_t (*TIFFSizeProc)(thandle_t);
  268. typedef int (*TIFFMapFileProc)(thandle_t, void **base, toff_t *size);
  269. typedef void (*TIFFUnmapFileProc)(thandle_t, void *base, toff_t size);
  270. typedef void (*TIFFExtendProc)(TIFF *);
  271. extern const char *TIFFGetVersion(void);
  272. extern const TIFFCodec *TIFFFindCODEC(uint16_t);
  273. extern TIFFCodec *TIFFRegisterCODEC(uint16_t, const char *, TIFFInitMethod);
  274. extern void TIFFUnRegisterCODEC(TIFFCodec *);
  275. extern int TIFFIsCODECConfigured(uint16_t);
  276. extern TIFFCodec *TIFFGetConfiguredCODECs(void);
  277. /*
  278. * Auxiliary functions.
  279. */
  280. #ifndef TIFF_DO_NOT_USE_NON_EXT_ALLOC_FUNCTIONS
  281. extern void *_TIFFmalloc(tmsize_t s);
  282. extern void *_TIFFcalloc(tmsize_t nmemb, tmsize_t siz);
  283. extern void *_TIFFrealloc(void *p, tmsize_t s);
  284. extern void _TIFFfree(void *p);
  285. #endif
  286. extern void _TIFFmemset(void *p, int v, tmsize_t c);
  287. extern void _TIFFmemcpy(void *d, const void *s, tmsize_t c);
  288. extern int _TIFFmemcmp(const void *p1, const void *p2, tmsize_t c);
  289. /*
  290. ** Stuff, related to tag handling and creating custom tags.
  291. */
  292. extern int TIFFGetTagListCount(TIFF *);
  293. extern uint32_t TIFFGetTagListEntry(TIFF *, int tag_index);
  294. #define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
  295. #define TIFF_VARIABLE -1 /* marker for variable length tags */
  296. #define TIFF_SPP -2 /* marker for SamplesPerPixel tags */
  297. #define TIFF_VARIABLE2 -3 /* marker for uint32_t var-length tags */
  298. #define FIELD_CUSTOM 65
  299. typedef struct _TIFFField TIFFField;
  300. typedef struct _TIFFFieldArray TIFFFieldArray;
  301. extern const TIFFField *TIFFFindField(TIFF *, uint32_t, TIFFDataType);
  302. extern const TIFFField *TIFFFieldWithTag(TIFF *, uint32_t);
  303. extern const TIFFField *TIFFFieldWithName(TIFF *, const char *);
  304. extern uint32_t TIFFFieldTag(const TIFFField *);
  305. extern const char *TIFFFieldName(const TIFFField *);
  306. extern TIFFDataType TIFFFieldDataType(const TIFFField *);
  307. extern int TIFFFieldPassCount(const TIFFField *);
  308. extern int TIFFFieldReadCount(const TIFFField *);
  309. extern int TIFFFieldWriteCount(const TIFFField *);
  310. extern int
  311. TIFFFieldSetGetSize(const TIFFField *); /* returns internal storage size of
  312. TIFFSetGetFieldType in bytes. */
  313. extern int TIFFFieldSetGetCountSize(
  314. const TIFFField *); /* returns size of count parameter 0=none,
  315. 2=uint16_t, 4=uint32_t */
  316. extern int TIFFFieldIsAnonymous(const TIFFField *);
  317. typedef int (*TIFFVSetMethod)(TIFF *, uint32_t, va_list);
  318. typedef int (*TIFFVGetMethod)(TIFF *, uint32_t, va_list);
  319. typedef void (*TIFFPrintMethod)(TIFF *, FILE *, long);
  320. typedef struct
  321. {
  322. TIFFVSetMethod vsetfield; /* tag set routine */
  323. TIFFVGetMethod vgetfield; /* tag get routine */
  324. TIFFPrintMethod printdir; /* directory print routine */
  325. } TIFFTagMethods;
  326. extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *);
  327. extern void *TIFFGetClientInfo(TIFF *, const char *);
  328. extern void TIFFSetClientInfo(TIFF *, void *, const char *);
  329. extern void TIFFCleanup(TIFF *tif);
  330. extern void TIFFClose(TIFF *tif);
  331. extern int TIFFFlush(TIFF *tif);
  332. extern int TIFFFlushData(TIFF *tif);
  333. extern int TIFFGetField(TIFF *tif, uint32_t tag, ...);
  334. extern int TIFFVGetField(TIFF *tif, uint32_t tag, va_list ap);
  335. extern int TIFFGetFieldDefaulted(TIFF *tif, uint32_t tag, ...);
  336. extern int TIFFVGetFieldDefaulted(TIFF *tif, uint32_t tag, va_list ap);
  337. extern int TIFFReadDirectory(TIFF *tif);
  338. extern int TIFFReadCustomDirectory(TIFF *tif, toff_t diroff,
  339. const TIFFFieldArray *infoarray);
  340. extern int TIFFReadEXIFDirectory(TIFF *tif, toff_t diroff);
  341. extern int TIFFReadGPSDirectory(TIFF *tif, toff_t diroff);
  342. extern uint64_t TIFFScanlineSize64(TIFF *tif);
  343. extern tmsize_t TIFFScanlineSize(TIFF *tif);
  344. extern uint64_t TIFFRasterScanlineSize64(TIFF *tif);
  345. extern tmsize_t TIFFRasterScanlineSize(TIFF *tif);
  346. extern uint64_t TIFFStripSize64(TIFF *tif);
  347. extern tmsize_t TIFFStripSize(TIFF *tif);
  348. extern uint64_t TIFFRawStripSize64(TIFF *tif, uint32_t strip);
  349. extern tmsize_t TIFFRawStripSize(TIFF *tif, uint32_t strip);
  350. extern uint64_t TIFFVStripSize64(TIFF *tif, uint32_t nrows);
  351. extern tmsize_t TIFFVStripSize(TIFF *tif, uint32_t nrows);
  352. extern uint64_t TIFFTileRowSize64(TIFF *tif);
  353. extern tmsize_t TIFFTileRowSize(TIFF *tif);
  354. extern uint64_t TIFFTileSize64(TIFF *tif);
  355. extern tmsize_t TIFFTileSize(TIFF *tif);
  356. extern uint64_t TIFFVTileSize64(TIFF *tif, uint32_t nrows);
  357. extern tmsize_t TIFFVTileSize(TIFF *tif, uint32_t nrows);
  358. extern uint32_t TIFFDefaultStripSize(TIFF *tif, uint32_t request);
  359. extern void TIFFDefaultTileSize(TIFF *, uint32_t *, uint32_t *);
  360. extern int TIFFFileno(TIFF *);
  361. extern int TIFFSetFileno(TIFF *, int);
  362. extern thandle_t TIFFClientdata(TIFF *);
  363. extern thandle_t TIFFSetClientdata(TIFF *, thandle_t);
  364. extern int TIFFGetMode(TIFF *);
  365. extern int TIFFSetMode(TIFF *, int);
  366. extern int TIFFIsTiled(TIFF *);
  367. extern int TIFFIsByteSwapped(TIFF *);
  368. extern int TIFFIsUpSampled(TIFF *);
  369. extern int TIFFIsMSB2LSB(TIFF *);
  370. extern int TIFFIsBigEndian(TIFF *);
  371. extern int TIFFIsBigTIFF(TIFF *);
  372. extern TIFFReadWriteProc TIFFGetReadProc(TIFF *);
  373. extern TIFFReadWriteProc TIFFGetWriteProc(TIFF *);
  374. extern TIFFSeekProc TIFFGetSeekProc(TIFF *);
  375. extern TIFFCloseProc TIFFGetCloseProc(TIFF *);
  376. extern TIFFSizeProc TIFFGetSizeProc(TIFF *);
  377. extern TIFFMapFileProc TIFFGetMapFileProc(TIFF *);
  378. extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF *);
  379. extern uint32_t TIFFCurrentRow(TIFF *);
  380. extern tdir_t TIFFCurrentDirectory(TIFF *);
  381. extern tdir_t TIFFNumberOfDirectories(TIFF *);
  382. extern uint64_t TIFFCurrentDirOffset(TIFF *);
  383. extern uint32_t TIFFCurrentStrip(TIFF *);
  384. extern uint32_t TIFFCurrentTile(TIFF *tif);
  385. extern int TIFFReadBufferSetup(TIFF *tif, void *bp, tmsize_t size);
  386. extern int TIFFWriteBufferSetup(TIFF *tif, void *bp, tmsize_t size);
  387. extern int TIFFSetupStrips(TIFF *);
  388. extern int TIFFWriteCheck(TIFF *, int, const char *);
  389. extern void TIFFFreeDirectory(TIFF *);
  390. extern int TIFFCreateDirectory(TIFF *);
  391. extern int TIFFCreateCustomDirectory(TIFF *, const TIFFFieldArray *);
  392. extern int TIFFCreateEXIFDirectory(TIFF *);
  393. extern int TIFFCreateGPSDirectory(TIFF *);
  394. extern int TIFFLastDirectory(TIFF *);
  395. extern int TIFFSetDirectory(TIFF *, tdir_t);
  396. extern int TIFFSetSubDirectory(TIFF *, uint64_t);
  397. extern int TIFFUnlinkDirectory(TIFF *, tdir_t);
  398. extern int TIFFSetField(TIFF *, uint32_t, ...);
  399. extern int TIFFVSetField(TIFF *, uint32_t, va_list);
  400. extern int TIFFUnsetField(TIFF *, uint32_t);
  401. extern int TIFFWriteDirectory(TIFF *);
  402. extern int TIFFWriteCustomDirectory(TIFF *, uint64_t *);
  403. extern int TIFFCheckpointDirectory(TIFF *);
  404. extern int TIFFRewriteDirectory(TIFF *);
  405. extern int TIFFDeferStrileArrayWriting(TIFF *);
  406. extern int TIFFForceStrileArrayWriting(TIFF *);
  407. #if defined(c_plusplus) || defined(__cplusplus)
  408. extern void TIFFPrintDirectory(TIFF *, FILE *, long = 0);
  409. extern int TIFFReadScanline(TIFF *tif, void *buf, uint32_t row,
  410. uint16_t sample = 0);
  411. extern int TIFFWriteScanline(TIFF *tif, void *buf, uint32_t row,
  412. uint16_t sample = 0);
  413. extern int TIFFReadRGBAImage(TIFF *, uint32_t, uint32_t, uint32_t *,
  414. int = 0);
  415. extern int TIFFReadRGBAImageOriented(TIFF *, uint32_t, uint32_t, uint32_t *,
  416. int = ORIENTATION_BOTLEFT, int = 0);
  417. #else
  418. extern void TIFFPrintDirectory(TIFF *, FILE *, long);
  419. extern int TIFFReadScanline(TIFF *tif, void *buf, uint32_t row,
  420. uint16_t sample);
  421. extern int TIFFWriteScanline(TIFF *tif, void *buf, uint32_t row,
  422. uint16_t sample);
  423. extern int TIFFReadRGBAImage(TIFF *, uint32_t, uint32_t, uint32_t *, int);
  424. extern int TIFFReadRGBAImageOriented(TIFF *, uint32_t, uint32_t, uint32_t *,
  425. int, int);
  426. #endif
  427. extern int TIFFReadRGBAStrip(TIFF *, uint32_t, uint32_t *);
  428. extern int TIFFReadRGBATile(TIFF *, uint32_t, uint32_t, uint32_t *);
  429. extern int TIFFReadRGBAStripExt(TIFF *, uint32_t, uint32_t *,
  430. int stop_on_error);
  431. extern int TIFFReadRGBATileExt(TIFF *, uint32_t, uint32_t, uint32_t *,
  432. int stop_on_error);
  433. extern int TIFFRGBAImageOK(TIFF *, char[1024]);
  434. extern int TIFFRGBAImageBegin(TIFFRGBAImage *, TIFF *, int, char[1024]);
  435. extern int TIFFRGBAImageGet(TIFFRGBAImage *, uint32_t *, uint32_t,
  436. uint32_t);
  437. extern void TIFFRGBAImageEnd(TIFFRGBAImage *);
  438. extern const char *TIFFFileName(TIFF *);
  439. extern const char *TIFFSetFileName(TIFF *, const char *);
  440. extern void TIFFError(const char *, const char *, ...)
  441. TIFF_ATTRIBUTE((__format__(__printf__, 2, 3)));
  442. extern void TIFFErrorExt(thandle_t, const char *, const char *, ...)
  443. TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
  444. extern void TIFFWarning(const char *, const char *, ...)
  445. TIFF_ATTRIBUTE((__format__(__printf__, 2, 3)));
  446. extern void TIFFWarningExt(thandle_t, const char *, const char *, ...)
  447. TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
  448. extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler);
  449. extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt);
  450. extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler);
  451. extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt);
  452. extern void TIFFWarningExtR(TIFF *, const char *, const char *, ...)
  453. TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
  454. extern void TIFFErrorExtR(TIFF *, const char *, const char *, ...)
  455. TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
  456. typedef struct TIFFOpenOptions TIFFOpenOptions;
  457. extern TIFFOpenOptions *TIFFOpenOptionsAlloc(void);
  458. extern void TIFFOpenOptionsFree(TIFFOpenOptions *);
  459. extern void
  460. TIFFOpenOptionsSetMaxSingleMemAlloc(TIFFOpenOptions *opts,
  461. tmsize_t max_single_mem_alloc);
  462. extern void
  463. TIFFOpenOptionsSetMaxCumulatedMemAlloc(TIFFOpenOptions *opts,
  464. tmsize_t max_cumulated_mem_alloc);
  465. extern void
  466. TIFFOpenOptionsSetErrorHandlerExtR(TIFFOpenOptions *opts,
  467. TIFFErrorHandlerExtR handler,
  468. void *errorhandler_user_data);
  469. extern void
  470. TIFFOpenOptionsSetWarningHandlerExtR(TIFFOpenOptions *opts,
  471. TIFFErrorHandlerExtR handler,
  472. void *warnhandler_user_data);
  473. extern TIFF *TIFFOpen(const char *, const char *);
  474. extern TIFF *TIFFOpenExt(const char *, const char *, TIFFOpenOptions *opts);
  475. #ifdef _WIN32
  476. extern TIFF *TIFFOpenW(const wchar_t *, const char *);
  477. extern TIFF *TIFFOpenWExt(const wchar_t *, const char *,
  478. TIFFOpenOptions *opts);
  479. #endif /* _WIN32 */
  480. extern TIFF *TIFFFdOpen(int, const char *, const char *);
  481. extern TIFF *TIFFFdOpenExt(int, const char *, const char *,
  482. TIFFOpenOptions *opts);
  483. extern TIFF *TIFFClientOpen(const char *, const char *, thandle_t,
  484. TIFFReadWriteProc, TIFFReadWriteProc,
  485. TIFFSeekProc, TIFFCloseProc, TIFFSizeProc,
  486. TIFFMapFileProc, TIFFUnmapFileProc);
  487. extern TIFF *TIFFClientOpenExt(const char *, const char *, thandle_t,
  488. TIFFReadWriteProc, TIFFReadWriteProc,
  489. TIFFSeekProc, TIFFCloseProc, TIFFSizeProc,
  490. TIFFMapFileProc, TIFFUnmapFileProc,
  491. TIFFOpenOptions *opts);
  492. extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc);
  493. extern uint32_t TIFFComputeTile(TIFF *tif, uint32_t x, uint32_t y,
  494. uint32_t z, uint16_t s);
  495. extern int TIFFCheckTile(TIFF *tif, uint32_t x, uint32_t y, uint32_t z,
  496. uint16_t s);
  497. extern uint32_t TIFFNumberOfTiles(TIFF *);
  498. extern tmsize_t TIFFReadTile(TIFF *tif, void *buf, uint32_t x, uint32_t y,
  499. uint32_t z, uint16_t s);
  500. extern tmsize_t TIFFWriteTile(TIFF *tif, void *buf, uint32_t x, uint32_t y,
  501. uint32_t z, uint16_t s);
  502. extern uint32_t TIFFComputeStrip(TIFF *, uint32_t, uint16_t);
  503. extern uint32_t TIFFNumberOfStrips(TIFF *);
  504. extern tmsize_t TIFFReadEncodedStrip(TIFF *tif, uint32_t strip, void *buf,
  505. tmsize_t size);
  506. extern tmsize_t TIFFReadRawStrip(TIFF *tif, uint32_t strip, void *buf,
  507. tmsize_t size);
  508. extern tmsize_t TIFFReadEncodedTile(TIFF *tif, uint32_t tile, void *buf,
  509. tmsize_t size);
  510. extern tmsize_t TIFFReadRawTile(TIFF *tif, uint32_t tile, void *buf,
  511. tmsize_t size);
  512. extern int TIFFReadFromUserBuffer(TIFF *tif, uint32_t strile, void *inbuf,
  513. tmsize_t insize, void *outbuf,
  514. tmsize_t outsize);
  515. extern tmsize_t TIFFWriteEncodedStrip(TIFF *tif, uint32_t strip, void *data,
  516. tmsize_t cc);
  517. extern tmsize_t TIFFWriteRawStrip(TIFF *tif, uint32_t strip, void *data,
  518. tmsize_t cc);
  519. extern tmsize_t TIFFWriteEncodedTile(TIFF *tif, uint32_t tile, void *data,
  520. tmsize_t cc);
  521. extern tmsize_t TIFFWriteRawTile(TIFF *tif, uint32_t tile, void *data,
  522. tmsize_t cc);
  523. extern int TIFFDataWidth(
  524. TIFFDataType); /* table of tag datatype widths within TIFF file. */
  525. extern void TIFFSetWriteOffset(TIFF *tif, toff_t off);
  526. extern void TIFFSwabShort(uint16_t *);
  527. extern void TIFFSwabLong(uint32_t *);
  528. extern void TIFFSwabLong8(uint64_t *);
  529. extern void TIFFSwabFloat(float *);
  530. extern void TIFFSwabDouble(double *);
  531. extern void TIFFSwabArrayOfShort(uint16_t *wp, tmsize_t n);
  532. extern void TIFFSwabArrayOfTriples(uint8_t *tp, tmsize_t n);
  533. extern void TIFFSwabArrayOfLong(uint32_t *lp, tmsize_t n);
  534. extern void TIFFSwabArrayOfLong8(uint64_t *lp, tmsize_t n);
  535. extern void TIFFSwabArrayOfFloat(float *fp, tmsize_t n);
  536. extern void TIFFSwabArrayOfDouble(double *dp, tmsize_t n);
  537. extern void TIFFReverseBits(uint8_t *cp, tmsize_t n);
  538. extern const unsigned char *TIFFGetBitRevTable(int);
  539. extern uint64_t TIFFGetStrileOffset(TIFF *tif, uint32_t strile);
  540. extern uint64_t TIFFGetStrileByteCount(TIFF *tif, uint32_t strile);
  541. extern uint64_t TIFFGetStrileOffsetWithErr(TIFF *tif, uint32_t strile,
  542. int *pbErr);
  543. extern uint64_t TIFFGetStrileByteCountWithErr(TIFF *tif, uint32_t strile,
  544. int *pbErr);
  545. #ifdef LOGLUV_PUBLIC
  546. #define U_NEU 0.210526316
  547. #define V_NEU 0.473684211
  548. #define UVSCALE 410.
  549. extern double LogL16toY(int);
  550. extern double LogL10toY(int);
  551. extern void XYZtoRGB24(float *, uint8_t *);
  552. extern int uv_decode(double *, double *, int);
  553. extern void LogLuv24toXYZ(uint32_t, float *);
  554. extern void LogLuv32toXYZ(uint32_t, float *);
  555. #if defined(c_plusplus) || defined(__cplusplus)
  556. extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER);
  557. extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER);
  558. extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER);
  559. extern uint32_t LogLuv24fromXYZ(float *, int = SGILOGENCODE_NODITHER);
  560. extern uint32_t LogLuv32fromXYZ(float *, int = SGILOGENCODE_NODITHER);
  561. #else
  562. extern int LogL16fromY(double, int);
  563. extern int LogL10fromY(double, int);
  564. extern int uv_encode(double, double, int);
  565. extern uint32_t LogLuv24fromXYZ(float *, int);
  566. extern uint32_t LogLuv32fromXYZ(float *, int);
  567. #endif
  568. #endif /* LOGLUV_PUBLIC */
  569. extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB *, const TIFFDisplay *,
  570. float *);
  571. extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32_t, int32_t, int32_t,
  572. float *, float *, float *);
  573. extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, uint32_t *,
  574. uint32_t *, uint32_t *);
  575. extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB *, float *, float *);
  576. extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32_t, int32_t, int32_t,
  577. uint32_t *, uint32_t *, uint32_t *);
  578. /****************************************************************************
  579. * O B S O L E T E D I N T E R F A C E S
  580. *
  581. * Don't use this stuff in your applications, it may be removed in the
  582. *future libtiff versions.
  583. ****************************************************************************/
  584. typedef struct
  585. {
  586. ttag_t field_tag; /* field's tag */
  587. short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */
  588. short field_writecount; /* write count/TIFF_VARIABLE */
  589. TIFFDataType field_type; /* type of associated data */
  590. unsigned short field_bit; /* bit in fieldsset bit vector */
  591. unsigned char field_oktochange; /* if true, can change while writing */
  592. unsigned char field_passcount; /* if true, pass dir count on set */
  593. char *field_name; /* ASCII name */
  594. } TIFFFieldInfo;
  595. extern int TIFFMergeFieldInfo(TIFF *, const TIFFFieldInfo[], uint32_t);
  596. #if defined(c_plusplus) || defined(__cplusplus)
  597. }
  598. #endif
  599. #endif /* _TIFFIO_ */