]> git.saurik.com Git - wxWidgets.git/blame - src/tiff/man/TIFFOpen.3tiff
missing commit
[wxWidgets.git] / src / tiff / man / TIFFOpen.3tiff
CommitLineData
80ed523f 1.\" $Id: TIFFOpen.3tiff,v 1.2 2005-07-01 12:36:22 dron Exp $
8414a40c
VZ
2.\"
3.\" Copyright (c) 1988-1997 Sam Leffler
4.\" Copyright (c) 1991-1997 Silicon Graphics, Inc.
5.\"
6.\" Permission to use, copy, modify, distribute, and sell this software and
7.\" its documentation for any purpose is hereby granted without fee, provided
8.\" that (i) the above copyright notices and this permission notice appear in
9.\" all copies of the software and related documentation, and (ii) the names of
10.\" Sam Leffler and Silicon Graphics may not be used in any advertising or
11.\" publicity relating to the software without the specific, prior written
12.\" permission of Sam Leffler and Silicon Graphics.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
15.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
16.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
17.\"
18.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
19.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
20.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
21.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
22.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
23.\" OF THIS SOFTWARE.
24.\"
25.if n .po 0
26.TH TIFFOpen 3TIFF "July 1, 2005" "libtiff"
27.SH NAME
28TIFFOpen, TIFFFdOpen, TIFFClientOpen \- open a
29.SM TIFF
30file for reading or writing
31.SH SYNOPSIS
32.B "#include <tiffio.h>"
33.sp
34.BI "TIFF* TIFFOpen(const char *" filename ", const char *" mode ")"
35.br
36.BI "TIFF* TIFFFdOpen(const int " fd ", const char *" filename ", const char *" mode ")"
37.sp
38.B "typedef tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t);"
39.br
40.B "typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);"
41.br
42.B "typedef int (*TIFFCloseProc)(thandle_t);"
43.br
44.B "typedef toff_t (*TIFFSizeProc)(thandle_t);"
45.br
46.B "typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*);"
47.br
48.B "typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t);"
49.sp
50.BI "TIFF* TIFFClientOpen(const char *" filename ", const char *" mode ", thandle_t " clientdata ", TIFFReadWriteProc " readproc ", TIFFReadWriteProc " writeproc ", TIFFSeekProc " seekproc ", TIFFCloseProc " closeproc ", TIFFSizeProc " sizeproc ", TIFFMapFileProc " mapproc ", TIFFUnmapFileProc " unmapproc ")"
51.SH DESCRIPTION
52.IR TIFFOpen
53opens a
54.SM TIFF
55file whose name is
56.I filename
57and returns a handle to be used in subsequent calls to routines in
58.IR libtiff .
59If the open operation fails, then zero is returned.
60The
61.I mode
62parameter specifies if the file is to be opened for reading (``r''),
63writing (``w''), or appending (``a'') and, optionally, whether
64to override certain default aspects of library operation (see below).
65When a file is opened for appending, existing data will not
66be touched; instead new data will be written as additional subfiles.
67If an existing file is opened for writing, all previous data is
68overwritten.
69.PP
70If a file is opened for reading, the first
71.SM TIFF
72directory in the file is automatically read
73(also see
74.IR TIFFSetDirectory (3TIFF)
75for reading directories other than the first).
76If a file is opened for writing or appending, a default directory
77is automatically created for writing subsequent data.
78This directory has all the default values specified in
79.SM TIFF
80Revision 6.0:
81.IR BitsPerSample =1,
82.IR ThreshHolding "=bilevel art scan,"
83.IR FillOrder =1
84(most significant bit of each data byte is filled first),
85.IR Orientation =1
86(the 0th row represents the visual top of the image, and the 0th
87column represents the visual left hand side),
88.IR SamplesPerPixel =1,
89.IR RowsPerStrip =infinity,
90.IR ResolutionUnit =2
91(inches), and
92.IR Compression =1
93(no compression).
94To alter these values, or to define values for additional fields,
95.IR TIFFSetField (3TIFF)
96must be used.
97.PP
98.IR TIFFFdOpen
99is like
100.IR TIFFOpen
101except that it opens a
102.SM TIFF
103file given an open file descriptor
104.IR fd .
105The file's name and mode must reflect that of the open descriptor.
106The object associated with the file descriptor
107.BR "must support random access" .
108.PP
109.IR TIFFClientOpen
110is like
111.IR TIFFOpen
112except that the caller supplies a collection of functions that the
113library will use to do \s-1UNIX\s+1-like I/O operations.
114The
115.I readproc
116and
117.I writeproc
118are called to read and write data at the current file position.
119.I seekproc
120is called to change the current file position a la
121.IR lseek (2).
122.I closeproc
123is invoked to release any resources associated with an open file.
124.I sizeproc
125is invoked to obtain the size in bytes of a file.
126.I mapproc
127and
128.I unmapproc
129are called to map and unmap a file's contents in memory; c.f.
130.IR mmap (2)
131and
132.IR munmap (2).
133The
134.I clientdata
135parameter is an opaque ``handle'' passed to the client-specified
136routines passed as parameters to
137.IR TIFFClientOpen .
138.SH OPTIONS
139The open mode parameter can include the following flags in
140addition to the ``r'', ``w'', and ``a'' flags.
141Note however that option flags must follow the read-write-append
142specification.
143.TP
144.B l
145When creating a new file force information be written with
146Little-Endian byte order (but see below).
147By default the library will create new files using the native
148.SM CPU
149byte order.
150.TP
151.B b
152When creating a new file force information be written with
153Big-Endian byte order (but see below).
154By default the library will create new files using the native
155.SM CPU
156byte order.
157.TP
158.B L
159Force image data that is read or written to be treated with
160bits filled from Least Significant Bit (\s-1LSB\s+1) to
161Most Significant Bit (\s-1MSB\s+1).
162Note that this is the opposite to the way the library has
163worked from its inception.
164.TP
165.B B
166Force image data that is read or written to be treated with
167bits filled from Most Significant Bit (\s-1MSB\s+1) to
168Least Significant Bit (\s-1LSB\s+1); this is the default.
169.TP
170.B H
171Force image data that is read or written to be treated with
172bits filled in the same order as the native
173.SM CPU.
174.TP
175.B M
176Enable the use of memory-mapped files for images opened read-only.
177If the underlying system does not support memory-mapped files
178or if the specific image being opened cannot be memory-mapped
179then the library will fallback to using the normal system interface
180for reading information.
181By default the library will attempt to use memory-mapped files.
182.TP
183.B m
184Disable the use of memory-mapped files.
185.TP
186.B C
187Enable the use of ``strip chopping'' when reading images
188that are comprised of a single strip or tile of uncompressed data.
189Strip chopping is a mechanism by which the library will automatically
190convert the single-strip image to multiple strips,
191each of which has about 8 Kilobytes of data.
192This facility can be useful in reducing the amount of memory used
193to read an image because the library normally reads each strip
194in its entirety.
195Strip chopping does however alter the apparent contents of the
196image because when an image is divided into multiple strips it
197looks as though the underlying file contains multiple separate
198strips.
199Finally, note that default handling of strip chopping is a compile-time
200configuration parameter.
201The default behaviour, for backwards compatibility, is to enable
202strip chopping.
203.TP
204.B c
205Disable the use of strip chopping when reading images.
206.TP
207.B h
208Read TIFF header only, do not load the first image directory. That could be
209useful in case of the broken first directory. We can open the file and proceed
210to the other directories.
211.SH "BYTE ORDER"
212The
213.SM TIFF
214specification (\fBall versions\fP) states that compliant readers
215.IR "must be capable of reading images written in either byte order" .
216Nonetheless some software that claims to support the reading of
217.SM TIFF
218images is incapable of reading images in anything but the native
219.SM CPU
220byte order on which the software was written.
221(Especially notorious
222are applications written to run on Intel-based machines.)
223By default the library will create new files with the native
224byte-order of the
225.SM CPU
226on which the application is run.
227This ensures optimal performance and is portable to any application
228that conforms to the TIFF specification.
229To force the library to use a specific byte-order when creating
230a new file the ``b'' and ``l'' option flags may be included in
231the call to open a file; for example, ``wb'' or ``wl''.
232.SH "RETURN VALUES"
233Upon successful completion
234.IR TIFFOpen ,
235.IR TIFFFdOpen ,
236and
237.IR TIFFClientOpen
238return a
239.SM TIFF
240pointer.
241Otherwise, NULL is returned.
242.SH DIAGNOSTICS
243All error messages are directed to the
244.IR TIFFError (3TIFF)
245routine.
246Likewise, warning messages are directed to the
247.IR TIFFWarning (3TIFF)
248routine.
249.PP
250\fB"%s": Bad mode\fP.
251The specified
252.I mode
253parameter was not one of ``r'' (read), ``w'' (write), or ``a'' (append).
254.PP
255.BR "%s: Cannot open" .
256.IR TIFFOpen ()
257was unable to open the specified filename for read/writing.
258.PP
259.BR "Cannot read TIFF header" .
260An error occurred while attempting to read the header information.
261.PP
262.BR "Error writing TIFF header" .
263An error occurred while writing the default header information
264for a new file.
265.PP
266.BR "Not a TIFF file, bad magic number %d (0x%x)" .
267The magic number in the header was not (hex)
2680x4d4d or (hex) 0x4949.
269.PP
270.BR "Not a TIFF file, bad version number %d (0x%x)" .
271The version field in the header was not 42 (decimal).
272.PP
273.BR "Cannot append to file that has opposite byte ordering" .
274A file with a byte ordering opposite to the native byte
275ordering of the current machine was opened for appending (``a'').
276This is a limitation of the library.
277.SH "SEE ALSO"
278.IR libtiff (3TIFF),
279.IR TIFFClose (3TIFF)