TIFFOpen.3tiff.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. <!-- Creator : groff version 1.18.1 -->
  2. <!-- CreationDate: Sat Feb 24 18:37:16 2007 -->
  3. <html>
  4. <head>
  5. <meta name="generator" content="groff -Thtml, see www.gnu.org">
  6. <meta name="Content-Style" content="text/css">
  7. <title>TIFFOpen</title>
  8. </head>
  9. <body>
  10. <h1 align=center>TIFFOpen</h1>
  11. <a href="#NAME">NAME</a><br>
  12. <a href="#SYNOPSIS">SYNOPSIS</a><br>
  13. <a href="#DESCRIPTION">DESCRIPTION</a><br>
  14. <a href="#OPTIONS">OPTIONS</a><br>
  15. <a href="#BYTE ORDER">BYTE ORDER</a><br>
  16. <a href="#RETURN VALUES">RETURN VALUES</a><br>
  17. <a href="#DIAGNOSTICS">DIAGNOSTICS</a><br>
  18. <a href="#SEE ALSO">SEE ALSO</a><br>
  19. <hr>
  20. <a name="NAME"></a>
  21. <h2>NAME</h2>
  22. <!-- INDENTATION -->
  23. <table width="100%" border=0 rules="none" frame="void"
  24. cols="2" cellspacing="0" cellpadding="0">
  25. <tr valign="top" align="left">
  26. <td width="8%"></td>
  27. <td width="91%">
  28. <p>TIFFOpen, TIFFFdOpen, TIFFClientOpen &minus; open a
  29. <small>TIFF</small> file for reading or writing</p>
  30. </td>
  31. </table>
  32. <a name="SYNOPSIS"></a>
  33. <h2>SYNOPSIS</h2>
  34. <!-- INDENTATION -->
  35. <table width="100%" border=0 rules="none" frame="void"
  36. cols="2" cellspacing="0" cellpadding="0">
  37. <tr valign="top" align="left">
  38. <td width="8%"></td>
  39. <td width="91%">
  40. <p><b>#include &lt;tiffio.h&gt;</b></p>
  41. <!-- INDENTATION -->
  42. <p><b>TIFF* TIFFOpen(const char *</b><i>filename</i><b>,
  43. const char *</b><i>mode</i><b>)<br>
  44. TIFF* TIFFFdOpen(const int</b> <i>fd</i><b>, const char
  45. *</b><i>filename</i><b>, const char
  46. *</b><i>mode</i><b>)</b></p>
  47. <!-- INDENTATION -->
  48. <p><b>typedef tsize_t (*TIFFReadWriteProc)(thandle_t,
  49. tdata_t, tsize_t);<br>
  50. typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);<br>
  51. typedef int (*TIFFCloseProc)(thandle_t);<br>
  52. typedef toff_t (*TIFFSizeProc)(thandle_t);<br>
  53. typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*,
  54. toff_t*);<br>
  55. typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t,
  56. toff_t);</b></p>
  57. <!-- INDENTATION -->
  58. <p><b>TIFF* TIFFClientOpen(const char
  59. *</b><i>filename</i><b>, const char *</b><i>mode</i><b>,
  60. thandle_t</b> <i>clientdata</i><b>, TIFFReadWriteProc</b>
  61. <i>readproc</i><b>, TIFFReadWriteProc</b>
  62. <i>writeproc</i><b>, TIFFSeekProc</b> <i>seekproc</i><b>,
  63. TIFFCloseProc</b> <i>closeproc</i><b>, TIFFSizeProc</b>
  64. <i>sizeproc</i><b>, TIFFMapFileProc</b> <i>mapproc</i><b>,
  65. TIFFUnmapFileProc</b> <i>unmapproc</i><b>)</b></p>
  66. </td>
  67. </table>
  68. <a name="DESCRIPTION"></a>
  69. <h2>DESCRIPTION</h2>
  70. <!-- INDENTATION -->
  71. <table width="100%" border=0 rules="none" frame="void"
  72. cols="2" cellspacing="0" cellpadding="0">
  73. <tr valign="top" align="left">
  74. <td width="8%"></td>
  75. <td width="91%">
  76. <p><i>TIFFOpen</i> opens a <small>TIFF</small> file whose
  77. name is <i>filename</i> and returns a handle to be used in
  78. subsequent calls to routines in <i>libtiff</i>. If the open
  79. operation fails, then zero is returned. The <i>mode</i>
  80. parameter specifies if the file is to be opened for reading
  81. (&lsquo;&lsquo;r&rsquo;&rsquo;), writing
  82. (&lsquo;&lsquo;w&rsquo;&rsquo;), or appending
  83. (&lsquo;&lsquo;a&rsquo;&rsquo;) and, optionally, whether to
  84. override certain default aspects of library operation (see
  85. below). When a file is opened for appending, existing data
  86. will not be touched; instead new data will be written as
  87. additional subfiles. If an existing file is opened for
  88. writing, all previous data is overwritten.</p>
  89. <!-- INDENTATION -->
  90. <p>If a file is opened for reading, the first
  91. <small>TIFF</small> directory in the file is automatically
  92. read (also see <i>TIFFSetDirectory</i>(3TIFF) for reading
  93. directories other than the first). If a file is opened for
  94. writing or appending, a default directory is automatically
  95. created for writing subsequent data. This directory has all
  96. the default values specified in <small>TIFF</small> Revision
  97. 6.0: <i>BitsPerSample</i>=1, <i>ThreshHolding</i>=bilevel
  98. art scan, <i>FillOrder</i>=1 (most significant bit of each
  99. data byte is filled first), <i>Orientation</i>=1 (the 0th
  100. row represents the visual top of the image, and the 0th
  101. column represents the visual left hand side),
  102. <i>SamplesPerPixel</i>=1, <i>RowsPerStrip</i>=infinity,
  103. <i>ResolutionUnit</i>=2 (inches), and <i>Compression</i>=1
  104. (no compression). To alter these values, or to define values
  105. for additional fields, <i>TIFFSetField</i>(3TIFF) must be
  106. used.</p>
  107. <!-- INDENTATION -->
  108. <p><i>TIFFFdOpen</i> is like <i>TIFFOpen</i> except that it
  109. opens a <small>TIFF</small> file given an open file
  110. descriptor <i>fd</i>. The file&rsquo;s name and mode must
  111. reflect that of the open descriptor. The object associated
  112. with the file descriptor <b>must support random
  113. access</b>.</p>
  114. <!-- INDENTATION -->
  115. <p><i>TIFFClientOpen</i> is like <i>TIFFOpen</i> except that
  116. the caller supplies a collection of functions that the
  117. library will use to do <small>UNIX</small> -like I/O
  118. operations. The <i>readproc</i> and <i>writeproc</i> are
  119. called to read and write data at the current file position.
  120. <i>seekproc</i> is called to change the current file
  121. position a la <i>lseek</i>(2). <i>closeproc</i> is invoked
  122. to release any resources associated with an open file.
  123. <i>sizeproc</i> is invoked to obtain the size in bytes of a
  124. file. <i>mapproc</i> and <i>unmapproc</i> are called to map
  125. and unmap a file&rsquo;s contents in memory; c.f.
  126. <i>mmap</i>(2) and <i>munmap</i>(2). The <i>clientdata</i>
  127. parameter is an opaque &lsquo;&lsquo;handle&rsquo;&rsquo;
  128. passed to the client-specified routines passed as parameters
  129. to <i>TIFFClientOpen</i>.</p>
  130. </td>
  131. </table>
  132. <a name="OPTIONS"></a>
  133. <h2>OPTIONS</h2>
  134. <!-- INDENTATION -->
  135. <table width="100%" border=0 rules="none" frame="void"
  136. cols="2" cellspacing="0" cellpadding="0">
  137. <tr valign="top" align="left">
  138. <td width="8%"></td>
  139. <td width="91%">
  140. <p>The open mode parameter can include the following flags
  141. in addition to the &lsquo;&lsquo;r&rsquo;&rsquo;,
  142. &lsquo;&lsquo;w&rsquo;&rsquo;, and
  143. &lsquo;&lsquo;a&rsquo;&rsquo; flags. Note however that
  144. option flags must follow the read-write-append
  145. specification.</p>
  146. </td>
  147. </table>
  148. <!-- TABS -->
  149. <table width="100%" border=0 rules="none" frame="void"
  150. cols="5" cellspacing="0" cellpadding="0">
  151. <tr valign="top" align="left">
  152. <td width="10%"></td>
  153. <td width="2%">
  154. <p><b>l</b></p>
  155. </td>
  156. <td width="6%"></td>
  157. <td width="80%">
  158. <p>When creating a new file force information be written
  159. with Little-Endian byte order (but see below). By default
  160. the library will create new files using the native
  161. <small>CPU</small> byte order.</p>
  162. </td>
  163. <td width="0%">
  164. </td>
  165. <tr valign="top" align="left">
  166. <td width="10%"></td>
  167. <td width="2%">
  168. <p><b>b</b></p>
  169. </td>
  170. <td width="6%"></td>
  171. <td width="80%">
  172. <p>When creating a new file force information be written
  173. with Big-Endian byte order (but see below). By default the
  174. library will create new files using the native
  175. <small>CPU</small> byte order.</p>
  176. </td>
  177. <td width="0%">
  178. </td>
  179. <tr valign="top" align="left">
  180. <td width="10%"></td>
  181. <td width="2%">
  182. <p><b>L</b></p>
  183. </td>
  184. <td width="6%"></td>
  185. <td width="80%">
  186. <p>Force image data that is read or written to be treated
  187. with bits filled from Least Significant Bit (
  188. <small>LSB</small> ) to Most Significant Bit (
  189. <small>MSB</small> ). Note that this is the opposite to the
  190. way the library has worked from its inception.</p>
  191. </td>
  192. <td width="0%">
  193. </td>
  194. <tr valign="top" align="left">
  195. <td width="10%"></td>
  196. <td width="2%">
  197. <p><b>B</b></p>
  198. </td>
  199. <td width="6%"></td>
  200. <td width="80%">
  201. <p>Force image data that is read or written to be treated
  202. with bits filled from Most Significant Bit (
  203. <small>MSB</small> ) to Least Significant Bit (
  204. <small>LSB</small> ); this is the default.</p>
  205. </td>
  206. <td width="0%">
  207. </td>
  208. <tr valign="top" align="left">
  209. <td width="10%"></td>
  210. <td width="2%">
  211. <p><b>H</b></p>
  212. </td>
  213. <td width="6%"></td>
  214. <td width="80%">
  215. <p>Force image data that is read or written to be treated
  216. with bits filled in the same order as the native
  217. <small>CPU.</small></p>
  218. </td>
  219. <td width="0%">
  220. </td>
  221. <tr valign="top" align="left">
  222. <td width="10%"></td>
  223. <td width="2%">
  224. <p><b>M</b></p>
  225. </td>
  226. <td width="6%"></td>
  227. <td width="80%">
  228. <p>Enable the use of memory-mapped files for images opened
  229. read-only. If the underlying system does not support
  230. memory-mapped files or if the specific image being opened
  231. cannot be memory-mapped then the library will fallback to
  232. using the normal system interface for reading information.
  233. By default the library will attempt to use memory-mapped
  234. files.</p>
  235. </td>
  236. <td width="0%">
  237. </td>
  238. <tr valign="top" align="left">
  239. <td width="10%"></td>
  240. <td width="2%">
  241. <p><b>m</b></p>
  242. </td>
  243. <td width="6%"></td>
  244. <td width="80%">
  245. <p>Disable the use of memory-mapped files.</p>
  246. </td>
  247. <td width="0%">
  248. </td>
  249. <tr valign="top" align="left">
  250. <td width="10%"></td>
  251. <td width="2%">
  252. <p><b>C</b></p>
  253. </td>
  254. <td width="6%"></td>
  255. <td width="80%">
  256. <p>Enable the use of &lsquo;&lsquo;strip
  257. chopping&rsquo;&rsquo; when reading images that are
  258. comprised of a single strip or tile of uncompressed data.
  259. Strip chopping is a mechanism by which the library will
  260. automatically convert the single-strip image to multiple
  261. strips, each of which has about 8 Kilobytes of data. This
  262. facility can be useful in reducing the amount of memory used
  263. to read an image because the library normally reads each
  264. strip in its entirety. Strip chopping does however alter the
  265. apparent contents of the image because when an image is
  266. divided into multiple strips it looks as though the
  267. underlying file contains multiple separate strips. Finally,
  268. note that default handling of strip chopping is a
  269. compile-time configuration parameter. The default behaviour,
  270. for backwards compatibility, is to enable strip
  271. chopping.</p>
  272. </td>
  273. <td width="0%">
  274. </td>
  275. <tr valign="top" align="left">
  276. <td width="10%"></td>
  277. <td width="2%">
  278. <p><b>c</b></p>
  279. </td>
  280. <td width="6%"></td>
  281. <td width="80%">
  282. <p>Disable the use of strip chopping when reading
  283. images.</p>
  284. </td>
  285. <td width="0%">
  286. </td>
  287. <tr valign="top" align="left">
  288. <td width="10%"></td>
  289. <td width="2%">
  290. <p><b>h</b></p>
  291. </td>
  292. <td width="6%"></td>
  293. <td width="80%">
  294. <p>Read TIFF header only, do not load the first image
  295. directory. That could be useful in case of the broken first
  296. directory. We can open the file and proceed to the other
  297. directories.</p>
  298. </td>
  299. <td width="0%">
  300. </td>
  301. </table>
  302. <a name="BYTE ORDER"></a>
  303. <h2>BYTE ORDER</h2>
  304. <!-- INDENTATION -->
  305. <table width="100%" border=0 rules="none" frame="void"
  306. cols="2" cellspacing="0" cellpadding="0">
  307. <tr valign="top" align="left">
  308. <td width="8%"></td>
  309. <td width="91%">
  310. <p>The <small>TIFF</small> specification (<b>all
  311. versions</b>) states that compliant readers <i>must be
  312. capable of reading images written in either byte order</i>.
  313. Nonetheless some software that claims to support the reading
  314. of <small>TIFF</small> images is incapable of reading images
  315. in anything but the native <small>CPU</small> byte order on
  316. which the software was written. (Especially notorious are
  317. applications written to run on Intel-based machines.) By
  318. default the library will create new files with the native
  319. byte-order of the <small>CPU</small> on which the
  320. application is run. This ensures optimal performance and is
  321. portable to any application that conforms to the TIFF
  322. specification. To force the library to use a specific
  323. byte-order when creating a new file the
  324. &lsquo;&lsquo;b&rsquo;&rsquo; and
  325. &lsquo;&lsquo;l&rsquo;&rsquo; option flags may be included
  326. in the call to open a file; for example,
  327. &lsquo;&lsquo;wb&rsquo;&rsquo; or
  328. &lsquo;&lsquo;wl&rsquo;&rsquo;.</p>
  329. </td>
  330. </table>
  331. <a name="RETURN VALUES"></a>
  332. <h2>RETURN VALUES</h2>
  333. <!-- INDENTATION -->
  334. <table width="100%" border=0 rules="none" frame="void"
  335. cols="2" cellspacing="0" cellpadding="0">
  336. <tr valign="top" align="left">
  337. <td width="8%"></td>
  338. <td width="91%">
  339. <p>Upon successful completion <i>TIFFOpen</i>,
  340. <i>TIFFFdOpen</i>, and <i>TIFFClientOpen</i> return a
  341. <small>TIFF</small> pointer. Otherwise, NULL is
  342. returned.</p>
  343. </td>
  344. </table>
  345. <a name="DIAGNOSTICS"></a>
  346. <h2>DIAGNOSTICS</h2>
  347. <!-- INDENTATION -->
  348. <table width="100%" border=0 rules="none" frame="void"
  349. cols="2" cellspacing="0" cellpadding="0">
  350. <tr valign="top" align="left">
  351. <td width="8%"></td>
  352. <td width="91%">
  353. <p>All error messages are directed to the
  354. <i>TIFFError</i>(3TIFF) routine. Likewise, warning messages
  355. are directed to the <i>TIFFWarning</i>(3TIFF) routine.</p>
  356. <!-- INDENTATION -->
  357. <p><b>&quot;%s&quot;: Bad mode</b>. The specified
  358. <i>mode</i> parameter was not one of
  359. &lsquo;&lsquo;r&rsquo;&rsquo; (read),
  360. &lsquo;&lsquo;w&rsquo;&rsquo; (write), or
  361. &lsquo;&lsquo;a&rsquo;&rsquo; (append).</p>
  362. <!-- INDENTATION -->
  363. <p><b>%s: Cannot open</b>. <i>TIFFOpen</i>() was unable to
  364. open the specified filename for read/writing.</p>
  365. <!-- INDENTATION -->
  366. <p><b>Cannot read TIFF header</b>. An error occurred while
  367. attempting to read the header information.</p>
  368. <!-- INDENTATION -->
  369. <p><b>Error writing TIFF header</b>. An error occurred while
  370. writing the default header information for a new file.</p>
  371. <!-- INDENTATION -->
  372. <p><b>Not a TIFF file, bad magic number %d (0x%x)</b>. The
  373. magic number in the header was not (hex) 0x4d4d or (hex)
  374. 0x4949.</p>
  375. <!-- INDENTATION -->
  376. <p><b>Not a TIFF file, bad version number %d (0x%x)</b>. The
  377. version field in the header was not 42 (decimal).</p>
  378. <!-- INDENTATION -->
  379. <p><b>Cannot append to file that has opposite byte
  380. ordering</b>. A file with a byte ordering opposite to the
  381. native byte ordering of the current machine was opened for
  382. appending (&lsquo;&lsquo;a&rsquo;&rsquo;). This is a
  383. limitation of the library.</p>
  384. </td>
  385. </table>
  386. <a name="SEE ALSO"></a>
  387. <h2>SEE ALSO</h2>
  388. <!-- INDENTATION -->
  389. <table width="100%" border=0 rules="none" frame="void"
  390. cols="2" cellspacing="0" cellpadding="0">
  391. <tr valign="top" align="left">
  392. <td width="8%"></td>
  393. <td width="91%">
  394. <p><i>libtiff</i>(3TIFF), <i>TIFFClose</i>(3TIFF)</p>
  395. </td>
  396. </table>
  397. <hr>
  398. </body>
  399. </html>