1 .\" $Id: TIFFRGBAImage.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $
3 .\" Copyright (c) 1991-1997 Sam Leffler
4 .\" Copyright (c) 1991-1997 Silicon Graphics, Inc.
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.
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.
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
26 .TH TIFFRGBAImage 3TIFF "October 29, 2004" "libtiff"
28 TIFFRGBAImageOK, TIFFRGBAImageBegin, TIFFRGBAImageGet, TIFFRGBAImageEnd
29 \- read and decode an image into a raster
31 .B "#include <tiffio.h>"
33 .B "typedef unsigned char TIFFRGBValue;"
34 .B "typedef struct _TIFFRGBAImage TIFFRGBAImage;"
36 .BI "int TIFFRGBAImageOK(TIFF *" tif ", char " emsg[1024] ")"
38 .BI "int TIFFRGBAImageBegin(TIFFRGBAImage *" img ", TIFF* " tif ", int " stopOnError ", char " emsg[1024] ")"
40 .BI "int TIFFRGBAImageGet(TIFFRGBAImage *" img ", uint32* " raster ", uint32 " width " , uint32 " height ")"
42 .BI "void TIFFRGBAImageEnd(TIFFRGBAImage *" img ")"
45 The routines described here provide a high-level interface
48 images may be read into memory.
49 Images may be strip- or tile-based and have a variety of different
50 characteristics: bits/sample, samples/pixel, photometric, etc.
51 Decoding state is encapsulated in a
53 structure making it possible to capture state for multiple images
54 and quickly switch between them.
55 The target raster format can be customized to a particular application's
56 needs by installing custom routines that manipulate image data
57 according to application requirements.
59 The default usage for these routines is: check if an image can
62 construct a decoder state block using
63 .IR TIFFRGBAImageBegin ,
64 read and decode an image into a target raster using
65 .IR TIFFRGBAImageGet ,
67 release resources using
68 .IR TIFFRGBAImageEnd .
70 can be called multiple times to decode an image using different
72 If multiple images are to be displayed and there is not enough
73 space for each of the decoded rasters, multiple state blocks can
74 be managed and then calls can be made to
76 as needed to display an image.
78 The generated raster is assumed to be an array of
84 must be less than or equal to the width of the image (\c
86 may be any non-zero size).
87 If the raster dimensions are smaller than the image, the image data
88 is cropped to the raster bounds.
89 If the raster height is greater than that of the image, then the
90 image data are placed in the lower part of the raster.
91 (Note that the raster is assume to be organized such that the pixel
92 at location (\fIx\fP,\fIy\fP) is \fIraster\fP[\fIy\fP*\fIwidth\fP+\fIx\fP];
93 with the raster origin in the
97 Raster pixels are 8-bit packed red, green, blue, alpha samples.
104 should be used to access individual samples.
105 Images without Associated Alpha matting information have a constant
109 converts non-8-bit images by scaling sample values.
110 Palette, grayscale, bilevel,
112 , and YCbCr images are converted to
115 Raster pixels are returned uncorrected by any colorimetry information
116 present in the directory.
120 specifies how to act if an error is encountered while reading
124 is non-zero, then an error will terminate the operation; otherwise
126 will continue processing data until all the possible data in the
127 image have been requested.
128 .SH "ALTERNATE RASTER FORMATS"
129 To use the core support for reading and processing
131 images, but write the resulting raster data in a different format
132 one need only override the ``\fIput methods\fP'' used to store raster data.
133 These methods are are defined in the
135 structure and initially setup by
136 .I TIFFRGBAImageBegin
137 to point to routines that pack raster data in the default
140 Two different routines are used according to the physical organization
141 of the image data in the file:
142 .IR PlanarConfiguration =1
145 .IR PlanarConfiguration =2
147 Note that this mechanism can be used to transform the data before
148 storing it in the raster.
149 For example one can convert data
150 to colormap indices for display on a colormap display.
151 .SH "SIMULTANEOUS RASTER STORE AND DISPLAY"
152 It is simple to display an image as it is being read into memory
153 by overriding the put methods as described above for supporting
154 alternate raster formats.
155 Simply keep a reference to the default put methods setup by
156 .I TIFFRGBAImageBegin
157 and then invoke them before or after each display operation.
160 utility uses the following put method to update the display as
161 the raster is being filled:
166 putContigAndDraw(TIFFRGBAImage* img, uint32* raster,
167 uint32 x, uint32 y, uint32 w, uint32 h,
168 int32 fromskew, int32 toskew,
171 (*putContig)(img, raster, x, y, w, h, fromskew, toskew, cp);
174 if (img->orientation == ORIENTATION_TOPLEFT)
175 lrectwrite(0, y-(h-1), w-1, y, raster-x-(h-1)*w);
177 lrectwrite(0, y, w-1, y+h-1, raster);
183 (the original routine provided by the library is saved in the
186 .SH "SUPPORTING ADDITIONAL TIFF FORMATS"
189 routines support the most commonly encountered flavors of
191 It is possible to extend this support by overriding the ``\fIget method\fP''
197 Details of doing this are a bit involved, it is best to make a copy
198 of an existing get method and modify it to suit the needs of an
201 Samples must be either 1, 2, 4, 8, or 16 bits.
202 Colorimetric samples/pixel must be either 1, 3, or 4 (i.e.
207 Palette image colormaps that appear to be incorrectly written
208 as 8-bit values are automatically scaled to 16-bits.
211 1 if the operation was successful.
212 Otherwise, 0 is returned if an error was encountered and
216 All error messages are directed to the
217 .IR TIFFError (3TIFF)
220 .BR "Sorry, can not handle %d-bit pictures" .
223 other than 1, 2, 4, 8, or 16.
225 .BR "Sorry, can not handle %d-channel images" .
228 other than 1, 3, or 4.
230 \fBMissing needed "PhotometricInterpretation" tag\fP.
231 The image did not have a tag that describes how to display
234 \fBNo "PhotometricInterpretation" tag, assuming RGB\fP.
235 The image was missing a tag that describes how to display it,
236 but because it has 3 or 4 samples/pixel, it is assumed to be
239 \fBNo "PhotometricInterpretation" tag, assuming min-is-black\fP.
240 The image was missing a tag that describes how to display it,
241 but because it has 1 sample/pixel, it is assumed to be a grayscale
244 .BR "No space for photometric conversion table" .
245 There was insufficient memory for a table used to convert
246 image samples to 8-bit
249 \fBMissing required "Colormap" tag\fP.
250 A Palette image did not have a required
254 .BR "No space for tile buffer" .
255 There was insufficient memory to allocate an i/o buffer.
257 .BR "No space for strip buffer" .
258 There was insufficient memory to allocate an i/o buffer.
260 .BR "Can not handle format" .
261 The image has a format (combination of
263 .IR SamplesPerPixel ,
265 .IR PhotometricInterpretation )
266 that can not be handled.
268 .BR "No space for B&W mapping table" .
269 There was insufficient memory to allocate a table used to map
273 .BR "No space for Palette mapping table" .
274 There was insufficient memory to allocate a table used to map
278 .BR TIFFOpen (3TIFF),
279 .BR TIFFReadRGBAImage (3TIFF),
280 .BR TIFFReadRGBAImageOriented (3TIFF),
281 .BR TIFFReadRGBAStrip (3TIFF),
282 .BR TIFFReadRGBATile (3TIFF),
285 Libtiff library home page:
286 .BR http://www.remotesensing.org/libtiff/