summaryrefslogtreecommitdiff
path: root/doc/static/man/TIFFRGBAImage.3tiff.html
blob: 90bb5dc34d894af383b0c5e6bca7eb62de5b1956 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
<!-- Creator     : groff version 1.22.4 -->
<!-- CreationDate: Sat Jun  4 16:23:27 2022 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="generator" content="groff -Thtml, see www.gnu.org">
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta name="Content-Style" content="text/css">
<style type="text/css">
       p       { margin-top: 0; margin-bottom: 0; vertical-align: top }
       pre     { margin-top: 0; margin-bottom: 0; vertical-align: top }
       table   { margin-top: 0; margin-bottom: 0; vertical-align: top }
       h1      { text-align: center }
</style>
<title>TIFFRGBAImage</title>

</head>
<body>

<h1 align="center">TIFFRGBAImage</h1>

<a href="#NAME">NAME</a><br>
<a href="#SYNOPSIS">SYNOPSIS</a><br>
<a href="#DESCRIPTION">DESCRIPTION</a><br>
<a href="#ALTERNATE RASTER FORMATS">ALTERNATE RASTER FORMATS</a><br>
<a href="#SIMULTANEOUS RASTER STORE AND DISPLAY">SIMULTANEOUS RASTER STORE AND DISPLAY</a><br>
<a href="#SUPPORTING ADDITIONAL TIFF FORMATS">SUPPORTING ADDITIONAL TIFF FORMATS</a><br>
<a href="#NOTES">NOTES</a><br>
<a href="#RETURN VALUES">RETURN VALUES</a><br>
<a href="#DIAGNOSTICS">DIAGNOSTICS</a><br>
<a href="#SEE ALSO">SEE ALSO</a><br>

<hr>


<h2>NAME
<a name="NAME"></a>
</h2>



<p style="margin-left:11%; margin-top: 1em">TIFFRGBAImageOK,
TIFFRGBAImageBegin, TIFFRGBAImageGet, TIFFRGBAImageEnd
&minus; read and decode an image into a raster</p>

<h2>SYNOPSIS
<a name="SYNOPSIS"></a>
</h2>


<p style="margin-left:11%; margin-top: 1em"><b>#include
&lt;tiffio.h&gt;</b></p>

<p style="margin-left:11%; margin-top: 1em"><b>typedef
unsigned char TIFFRGBValue; typedef struct _TIFFRGBAImage
TIFFRGBAImage;</b></p>

<p style="margin-left:11%; margin-top: 1em"><b>int
TIFFRGBAImageOK(TIFF *</b><i>tif</i><b>, char</b>
<i>emsg[1024]</i><b>) <br>
int TIFFRGBAImageBegin(TIFFRGBAImage *</b><i>img</i><b>,
TIFF*</b> <i>tif</i><b>, int</b> <i>stopOnError</i><b>,
char</b> <i>emsg[1024]</i><b>) <br>
int TIFFRGBAImageGet(TIFFRGBAImage *</b><i>img</i><b>,
uint32_t*</b> <i>raster</i><b>, uint32_t</b> <i>width</i>
<b>, uint32_t</b> <i>height</i><b>) <br>
void TIFFRGBAImageEnd(TIFFRGBAImage
*</b><i>img</i><b>)</b></p>

<h2>DESCRIPTION
<a name="DESCRIPTION"></a>
</h2>


<p style="margin-left:11%; margin-top: 1em">The routines
described here provide a high-level interface through which
<small>TIFF</small> images may be read into memory. Images
may be strip- or tile-based and have a variety of different
characteristics: bits/sample, samples/pixel, photometric,
etc. Decoding state is encapsulated in a
<i>TIFFRGBAImage</i> structure making it possible to capture
state for multiple images and quickly switch between them.
The target raster format can be customized to a particular
application&rsquo;s needs by installing custom routines that
manipulate image data according to application
requirements.</p>

<p style="margin-left:11%; margin-top: 1em">The default
usage for these routines is: check if an image can be
processed using <i>TIFFRGBAImageOK</i>, construct a decoder
state block using <i>TIFFRGBAImageBegin</i>, read and decode
an image into a target raster using <i>TIFFRGBAImageGet</i>,
and then release resources using <i>TIFFRGBAImageEnd</i>.
<i>TIFFRGBAImageGet</i> can be called multiple times to
decode an image using different state parameters. If
multiple images are to be displayed and there is not enough
space for each of the decoded rasters, multiple state blocks
can be managed and then calls can be made to
<i>TIFFRGBAImageGet</i> as needed to display an image.</p>

<p style="margin-left:11%; margin-top: 1em">The generated
raster is assumed to be an array of <i>width</i> times
<i>height</i> 32-bit entries, where <i>width</i> must be
less than or equal to the width of the image (<i>height</i>
may be any non-zero size). If the raster dimensions are
smaller than the image, the image data is cropped to the
raster bounds. If the raster height is greater than that of
the image, then the image data are placed in the lower part
of the raster. (Note that the raster is assume to be
organized such that the pixel at location
(<i>x</i>,<i>y</i>) is
<i>raster</i>[<i>y</i>*<i>width</i>+<i>x</i>]; with the
raster origin in the <b>lower-left</b> hand corner.)</p>

<p style="margin-left:11%; margin-top: 1em">Raster pixels
are 8-bit packed red, green, blue, alpha samples. The macros
<i>TIFFGetR</i>, <i>TIFFGetG</i>, <i>TIFFGetB</i>, and
<i>TIFFGetA</i> should be used to access individual samples.
Images without Associated Alpha matting information have a
constant Alpha of 1.0 (255).</p>


<p style="margin-left:11%; margin-top: 1em"><i>TIFFRGBAImageGet</i>
converts non-8-bit images by scaling sample values. Palette,
grayscale, bilevel, <small>CMYK, and YCbCr images are
converted to RGB</small> transparently. Raster pixels are
returned uncorrected by any colorimetry information present
in the directory.</p>

<p style="margin-left:11%; margin-top: 1em">The parameter
<i>stopOnError</i> specifies how to act if an error is
encountered while reading the image. If <i>stopOnError</i>
is non-zero, then an error will terminate the operation;
otherwise <i>TIFFRGBAImageGet</i> will continue processing
data until all the possible data in the image have been
requested.</p>

<h2>ALTERNATE RASTER FORMATS
<a name="ALTERNATE RASTER FORMATS"></a>
</h2>


<p style="margin-left:11%; margin-top: 1em">To use the core
support for reading and processing <small>TIFF</small>
images, but write the resulting raster data in a different
format one need only override the &lsquo;&lsquo;<i>put
methods</i>&rsquo;&rsquo; used to store raster data. These
methods are are defined in the <i>TIFFRGBAImage</i>
structure and initially setup by <i>TIFFRGBAImageBegin</i>
to point to routines that pack raster data in the default
<small>ABGR</small> pixel format. Two different routines are
used according to the physical organization of the image
data in the file: <i>PlanarConfiguration</i>=1 (packed
samples), and <i>PlanarConfiguration</i>=2 (separated
samples). Note that this mechanism can be used to transform
the data before storing it in the raster. For example one
can convert data to colormap indices for display on a
colormap display.</p>

<h2>SIMULTANEOUS RASTER STORE AND DISPLAY
<a name="SIMULTANEOUS RASTER STORE AND DISPLAY"></a>
</h2>


<p style="margin-left:11%; margin-top: 1em">It is simple to
display an image as it is being read into memory by
overriding the put methods as described above for supporting
alternate raster formats. Simply keep a reference to the
default put methods setup by <i>TIFFRGBAImageBegin</i> and
then invoke them before or after each display operation. For
example, the <i>tiffgt</i>(1) utility uses the following put
method to update the display as the raster is being
filled:</p>

<pre style="margin-left:11%; margin-top: 1em">static void
putContigAndDraw(TIFFRGBAImage* img, uint32_t* raster,
    uint32_t x, uint32_t y, uint32_t w, uint32_t h,
    int32_t fromskew, int32_t toskew,
    unsigned char* cp)
{
    (*putContig)(img, raster, x, y, w, h, fromskew, toskew, cp);
    if (x+w == width) {
     w = width;
     if (img-&gt;orientation == ORIENTATION_TOPLEFT)
         lrectwrite(0, y-(h-1), w-1, y, raster-x-(h-1)*w);
     else
         lrectwrite(0, y, w-1, y+h-1, raster);
    }
}</pre>


<p style="margin-left:11%; margin-top: 1em">(the original
routine provided by the library is saved in the variable
<i>putContig</i>.)</p>

<h2>SUPPORTING ADDITIONAL TIFF FORMATS
<a name="SUPPORTING ADDITIONAL TIFF FORMATS"></a>
</h2>


<p style="margin-left:11%; margin-top: 1em">The
<i>TIFFRGBAImage</i> routines support the most commonly
encountered flavors of <small>TIFF.</small> It is possible
to extend this support by overriding the
&lsquo;&lsquo;<i>get method</i>&rsquo;&rsquo; invoked by
<i>TIFFRGBAImageGet</i> to read <small>TIFF</small> image
data. Details of doing this are a bit involved, it is best
to make a copy of an existing get method and modify it to
suit the needs of an application.</p>

<h2>NOTES
<a name="NOTES"></a>
</h2>


<p style="margin-left:11%; margin-top: 1em">Samples must be
either 1, 2, 4, 8, or 16 bits. Colorimetric samples/pixel
must be either 1, 3, or 4 (i.e. <i>SamplesPerPixel</i> minus
<i>ExtraSamples</i>).</p>

<p style="margin-left:11%; margin-top: 1em">Palette image
colormaps that appear to be incorrectly written as 8-bit
values are automatically scaled to 16-bits.</p>

<h2>RETURN VALUES
<a name="RETURN VALUES"></a>
</h2>


<p style="margin-left:11%; margin-top: 1em">All routines
return 1 if the operation was successful. Otherwise, 0 is
returned if an error was encountered and <i>stopOnError</i>
is zero.</p>

<h2>DIAGNOSTICS
<a name="DIAGNOSTICS"></a>
</h2>


<p style="margin-left:11%; margin-top: 1em">All error
messages are directed to the <i>TIFFError</i>(3TIFF)
routine.</p>

<p style="margin-left:11%; margin-top: 1em"><b>Sorry, can
not handle %d-bit pictures</b>. The image had
<i>BitsPerSample</i> other than 1, 2, 4, 8, or 16.</p>

<p style="margin-left:11%; margin-top: 1em"><b>Sorry, can
not handle %d-channel images</b>. The image had
<i>SamplesPerPixel</i> other than 1, 3, or 4.</p>

<p style="margin-left:11%; margin-top: 1em"><b>Missing
needed &quot;PhotometricInterpretation&quot; tag</b>. The
image did not have a tag that describes how to display the
data.</p>

<p style="margin-left:11%; margin-top: 1em"><b>No
&quot;PhotometricInterpretation&quot; tag, assuming RGB</b>.
The image was missing a tag that describes how to display
it, but because it has 3 or 4 samples/pixel, it is assumed
to be <small>RGB.</small></p>

<p style="margin-left:11%; margin-top: 1em"><b>No
&quot;PhotometricInterpretation&quot; tag, assuming
min-is-black</b>. The image was missing a tag that describes
how to display it, but because it has 1 sample/pixel, it is
assumed to be a grayscale or bilevel image.</p>

<p style="margin-left:11%; margin-top: 1em"><b>No space for
photometric conversion table</b>. There was insufficient
memory for a table used to convert image samples to 8-bit
<small>RGB.</small></p>

<p style="margin-left:11%; margin-top: 1em"><b>Missing
required &quot;Colormap&quot; tag</b>. A Palette image did
not have a required <i>Colormap</i> tag.</p>

<p style="margin-left:11%; margin-top: 1em"><b>No space for
tile buffer</b>. There was insufficient memory to allocate
an i/o buffer.</p>

<p style="margin-left:11%; margin-top: 1em"><b>No space for
strip buffer</b>. There was insufficient memory to allocate
an i/o buffer.</p>

<p style="margin-left:11%; margin-top: 1em"><b>Can not
handle format</b>. The image has a format (combination of
<i>BitsPerSample</i>, <i>SamplesPerPixel</i>, and
<i>PhotometricInterpretation</i>) that can not be
handled.</p>

<p style="margin-left:11%; margin-top: 1em"><b>No space for
B&amp;W mapping table</b>. There was insufficient memory to
allocate a table used to map grayscale data to
<small>RGB.</small></p>

<p style="margin-left:11%; margin-top: 1em"><b>No space for
Palette mapping table</b>. There was insufficient memory to
allocate a table used to map data to 8-bit
<small>RGB.</small></p>

<h2>SEE ALSO
<a name="SEE ALSO"></a>
</h2>



<p style="margin-left:11%; margin-top: 1em"><b>TIFFOpen</b>(3TIFF),
<b>TIFFReadRGBAImage</b>(3TIFF),
<b>TIFFReadRGBAImageOriented</b>(3TIFF),
<b>TIFFReadRGBAStrip</b>(3TIFF),
<b>TIFFReadRGBATile</b>(3TIFF), <b>libtiff</b>(3TIFF)</p>

<p style="margin-left:11%; margin-top: 1em">Libtiff library
home page: <b>http://www.simplesystems.org/libtiff/</b></p>
<hr>
</body>
</html>