tiffio.h 29 KB

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