Misc. Reference Manual Pages TIFFOpen(3tiff)
NAME
TIFFOpen, TIFFFdOpen, TIFFClientOpen - open a TIFF file for
reading or writingSYNOPSIS
#include
TIFF* TIFFOpen(const char* filename, const char* mode)TIFF* TIFFFdOpen(const int fd, const char* filename, const char* mode)
typedef tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t);
typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
typedef int (*TIFFCloseProc)(thandle_t);
typedef toff_t (*TIFFSizeProc)(thandle_t);
typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*);
typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t);
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) TIFFOpen opens a TIFF file whose name is filename and returns a handle to be used in subsequent calls to routines in libtiff. If the open operation fails, then zero is returned. The mode parameter specifies whether the file is to be opened for reading ("r"), writing ("w"), or appending ("a") and, optionally, whether to override certain default aspects of library operation (see below). When a file is opened for appending, existing data is not touched. Instead, new data is written as additional subfiles. If an existing file is opened for writing, all previous data is overwritten. If a file is opened for reading, the first TIFF directory in the file is automatically read. See also TIFFSetDirectory(3tiff) for information on how to read directories other than the first. If a file is opened for writing or appending, a default directory is automatically created for writing subsequent data. This directory has all of the default values specified in TIFF Revision 6.0: +o BitsPerSample=1 +o ThreshHolding=bilevel art scan +o FillOrder=1 (most significant bit of each data byte is filled first) +o SunOS 5.10 Last change: 05 Apr 2004 1 Misc. Reference Manual Pages TIFFOpen(3tiff) Orientation=1 (the 0th row represents the visual top of the image, and the 0th column represents the visualleft-hand side)
+o SamplesPerPixel=1 +o RowsPerStrip=infinity +o ResolutionUnit=2 (inches) +o Compression=1 (no compression) To alter these values, or to define values for additional fields, TIFFSetField(3tiff) must be used.TIFFFdOpen is like TIFFOpen except that TIFFFdOpen opens a
TIFF file given an open file descriptor fd. The file name and mode must reflect that of the open descriptor. Theobject associated with the file descriptor must support ran-
dom access.TIFFClientOpen is like TIFFOpen except that the caller sup-
plies a collection of functions that the library uses toperform UNIX-like I/O operations:
+o readproc and writeproc are called to read and write data at the current file position. +o seekproc is called to change the current file position. See also lseek(2).+o closeproc is invoked to release any resources associ-
ated with an open file. +o sizeproc is invoked to obtain the size in bytes of a file. +o mapproc and unmapproc are called to map and unmap thecontents of a file in memory. See also mmap(2) and mun-
map(2). +o The clientdata parameter is an opaque "handle" passedto the client-specified routines that are passed as
parameters to TIFFClientOpen. Byte Order The TIFF specification (all versions) states that compliant readers must be capable of reading images written in either byte order. However, some software that claims to support the reading of TIFF images is incapable of reading images in SunOS 5.10 Last change: 05 Apr 2004 2 Misc. Reference Manual Pages TIFFOpen(3tiff) anything but the native CPU byte order on which the software was written. By default, the library creates new files withthe native byte-order of the CPU on which the application is
run. This ensures optimal performance and is portable to any application that conforms to the TIFF specification. Toforce the library to use a specific byte-order when creating
a new file, the "b" and "l" option flags may be included in the call to open a file. For example, "wb" or "wl". DiagnosticsAll error messages are directed to the TIFFError(3tiff) rou-
tine. Likewise, warning messages are directed to the TIFFWarning(3tiff) routine."%s": Bad mode. The specified mode parameter is not
one of "r" (read), "w" (write), or "a" (append).%s: Cannot open. TIFFOpen() is unable to open the
specified filename for reading or writing. Cannot read TIFF header.An error occurred while attempting to read the header information. Error writing TIFF headerA.n error occurred while writing the default header information for a new file.Not a TIFF file, bad magiTchenummabgeirc %ndum(b0exr%xi)n.the header was
not (hex) 0x4d4d or (hex) 0x4949.Not a TIFF file, bad versTihoenvneurmsbieorn %fdie(l0dx%ixn).the header was
not 42 (decimal). Cannot append to file thaAtfhialse owpiptohsiatebybtyeteorodredreirnigngo.pposite to the native byte ordering of the current machine was opened forappending ("a"). This is a limita-
tion of the library. SunOS 5.10 Last change: 05 Apr 2004 3 Misc. Reference Manual Pages TIFFOpen(3tiff) The open mode parameter can include the following flags in addition to the "r", "w", and "a" flags. Note however thatoption flags must follow the read-write-append specifica-
tion. B Force image data that is read or written to be treated with bits filled from Most Significant Bit (MSB) to Least Significant Bit (LSB). This is the default. b When creating a new file, forceinformation to be written with Big-
Endian byte order (but see the Byte Order section of this reference page). By default, the library creates new files using the native CPU byte order. C Enable the use of "strip chopping" when reading images that are comprised of a single strip or tile of uncompressed data. Strip chopping is a mechanism by which the libraryautomatically converts the single-
strip image to multiple strips, each of which has about 8 Kilobytes of data. This facility can be useful in reducing the amount of memory used to read an image because the library normally reads each strip in itsentirety. Strip chopping does how-
ever alter the apparent contents of the image because when an image is divided into multiple strips, the image looks as though the underlying file contains multiple separate strips. Finally, note that default handling of strip chopping is acompile-time configuration parame-
ter. The default behaviour, for backwards compatibility, is to enable strip chopping. SunOS 5.10 Last change: 05 Apr 2004 4 Misc. Reference Manual Pages TIFFOpen(3tiff) c Disable the use of strip chopping when reading images. H Force image data that is read or written to be treated with bits filled in the same order as the native CPU. L Force image data that is read or written to be treated with bits filled from Least Significant Bit (LSB) to Most Significant Bit (MSB). Note that this is the opposite to the way that the library has worked from its inception. l When creating a new file, force information to be written withLittle-Endian byte order (but see
the Byte Order section of this reference page). By default, the library creates new files using the native CPU byte order.M Enable the use of memory-mapped
files for images opened as read-
only. If the underlying system doesnot support memory-mapped files, or
if the specific image being openedcannot be memory-mapped, the library
uses the normal system interface for reading information. By default, thelibrary attempts to use memory-
mapped files.m Disable the use of memory-mapped
files. SunOS 5.10 Last change: 05 Apr 2004 5 Misc. Reference Manual Pages TIFFOpen(3tiff)Upon successful completion, TIFFOpen, TIFFFdOpen, and
TIFFClientOpen return a TIFF pointer. Otherwise, NULL is returned.See attributes(5) for descriptions of the following attri-
butes:____________________________________________________________
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|_____________________________|_____________________________|
| Availability | image/library/libtiff ||_____________________________|_____________________________|
| Interface stability | Uncommitted ||_____________________________|_____________________________|
libtiff(3), TIFFClose(3tiff) This man page was originally written by Sam Leffler. Updated by Breda McColgan, Sun Microsystems Inc., 2004. SunOS 5.10 Last change: 05 Apr 2004 6