libtiff/html/man/TIFFRGBAImage.3t.html

366 lines
14 KiB
HTML
Raw Normal View History

2002-10-07 09:47:36 -04:00
<html>
<head>
<meta name="generator" content="groff -Thtml, see www.gnu.org">
<meta name="Content-Style" content="text/css">
<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="#BUGS">BUGS</a><br>
<a href="#SEE ALSO">SEE ALSO</a><br>
<hr>
2003-11-27 10:07:01 -05:00
<!-- Creator : groff version 1.17.2 -->
<!-- CreationDate: Thu Nov 27 17:58:04 2003 -->
2002-10-07 09:47:36 -04:00
<a name="NAME"></a>
<h2>NAME</h2>
2003-11-27 10:07:01 -05:00
<table width="100%" border=0 rules="none" frame="void"
2002-10-07 09:47:36 -04:00
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
2003-11-27 10:07:01 -05:00
<td width="10%"></td><td width="90%">
TIFFRGBAImage - read and decode an image into a raster</td></table>
2002-10-07 09:47:36 -04:00
<a name="SYNOPSIS"></a>
<h2>SYNOPSIS</h2>
2003-11-27 10:07:01 -05:00
<table width="100%" border=0 rules="none" frame="void"
2002-10-07 09:47:36 -04:00
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
2003-11-27 10:07:01 -05:00
<td width="10%"></td><td width="90%">
2002-10-07 09:47:36 -04:00
<pre><b>#include &lt;tiffio.h&gt;
typedef unsigned char TIFFRGBValue;
typedef struct _TIFFRGBAImage TIFFRGBAImage;
int TIFFRGBAImageOK(TIFF* tif, char emsg[1024]);
int TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stopOnError, char emsg[1024]);
int TIFFRGBAImageGet(TIFFRGBAImage* img, uint32* raster, uint32 width, uint32 height);
void TIFFRGBAImageEnd(TIFFRGBAImage* img);
2003-11-27 10:07:01 -05:00
</b></pre></td></table>
2002-10-07 09:47:36 -04:00
<a name="DESCRIPTION"></a>
<h2>DESCRIPTION</h2>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
2003-11-27 10:07:01 -05:00
<td width="10%"></td><td width="90%">
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,
2002-10-07 09:47:36 -04:00
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
2003-11-27 10:07:01 -05:00
customized to a particular application's needs by installing
custom routines that manipulate image data according to
application requirements.</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
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.</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
The generated raster is assumed to be an array of
2002-10-07 09:47:36 -04:00
<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
2003-11-27 10:07:01 -05:00
raster origin in the <b>lower-left</b> hand
corner.)</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
Raster pixels are 8-bit packed red, green, blue, alpha
2002-10-07 09:47:36 -04:00
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
2003-11-27 10:07:01 -05:00
matting information have a constant Alpha of 1.0
(255).</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
<i>TIFFRGBAImageGet</i> converts non-8-bit images by scaling
sample values. Palette, grayscale, bilevel,
2002-10-07 09:47:36 -04:00
<small>CMYK</small> , and YCbCr images are converted to
<small>RGB</small> transparently. Raster pixels are returned
uncorrected by any colorimetry information present in the
2003-11-27 10:07:01 -05:00
directory.</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
The paramater <i>stopOnError</i> specifies how to act if an
error is encountered while reading the image. If
2002-10-07 09:47:36 -04:00
<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
2003-11-27 10:07:01 -05:00
image have been requested.</td></table>
2002-10-07 09:47:36 -04:00
<a name="ALTERNATE RASTER FORMATS"></a>
<h2>ALTERNATE RASTER FORMATS</h2>
2003-11-27 10:07:01 -05:00
<table width="100%" border=0 rules="none" frame="void"
2002-10-07 09:47:36 -04:00
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
2003-11-27 10:07:01 -05:00
<td width="10%"></td><td width="90%">
To use the core support for reading and processing
2002-10-07 09:47:36 -04:00
<small>TIFF</small> images, but write the resulting raster
data in a different format one need only override the
2003-11-27 10:07:01 -05:00
``<i>put methods</i>'' 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.</td></table>
2002-10-07 09:47:36 -04:00
<a name="SIMULTANEOUS RASTER STORE AND DISPLAY"></a>
<h2>SIMULTANEOUS RASTER STORE AND DISPLAY</h2>
2003-11-27 10:07:01 -05:00
<table width="100%" border=0 rules="none" frame="void"
2002-10-07 09:47:36 -04:00
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
2003-11-27 10:07:01 -05:00
<td width="10%"></td><td width="90%">
It is simple to display an image as it is being read into
2002-10-07 09:47:36 -04:00
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
2003-11-27 10:07:01 -05:00
update the display as the raster is being
filled:</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
<pre>
static void
1999-11-22 23:29:23 -05:00
putContigAndDraw(TIFFRGBAImage* img, uint32* raster,
uint32 x, uint32 y, uint32 w, uint32 h,
int32 fromskew, int32 toskew,
unsigned char* cp)
{
(*putContig)(img, raster, x, y, w, h, fromskew, toskew, cp);
if (x+w == width) {
2002-10-07 09:47:36 -04:00
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);
1999-11-22 23:29:23 -05:00
}
}
2003-11-27 10:07:01 -05:00
</pre>(the original routine provided by the library is saved in the variable <i>putContig</i>.)</td></table>
2002-10-07 09:47:36 -04:00
<a name="SUPPORTING ADDITIONAL TIFF FORMATS"></a>
<h2>SUPPORTING ADDITIONAL TIFF FORMATS</h2>
2003-11-27 10:07:01 -05:00
<table width="100%" border=0 rules="none" frame="void"
2002-10-07 09:47:36 -04:00
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
2003-11-27 10:07:01 -05:00
<td width="10%"></td><td width="90%">
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 ``<i>get
method</i>'' 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.</td></table>
2002-10-07 09:47:36 -04:00
<a name="NOTES"></a>
<h2>NOTES</h2>
2003-11-27 10:07:01 -05:00
<table width="100%" border=0 rules="none" frame="void"
2002-10-07 09:47:36 -04:00
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
2003-11-27 10:07:01 -05:00
<td width="10%"></td><td width="90%">
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>).</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
Palettte image colormaps that appear to be incorrectly
2002-10-07 09:47:36 -04:00
written as 8-bit values are automatically scaled to
2003-11-27 10:07:01 -05:00
16-bits.</td></table>
2002-10-07 09:47:36 -04:00
<a name="RETURN VALUES"></a>
<h2>RETURN VALUES</h2>
2003-11-27 10:07:01 -05:00
<table width="100%" border=0 rules="none" frame="void"
2002-10-07 09:47:36 -04:00
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
2003-11-27 10:07:01 -05:00
<td width="10%"></td><td width="90%">
All routines return 1 if the operation was successful.
1999-11-22 23:29:23 -05:00
Otherwise, 0 is returned if an error was encountered and
2003-11-27 10:07:01 -05:00
<i>stopOnError</i> is zero.</td></table>
2002-10-07 09:47:36 -04:00
<a name="DIAGNOSTICS"></a>
<h2>DIAGNOSTICS</h2>
2003-11-27 10:07:01 -05:00
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
All error messages are directed to the <i>TIFFError</i>(3T)
routine.</td></table>
<table width="100%" border=0 rules="none" frame="void"
2002-10-07 09:47:36 -04:00
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
2003-11-27 10:07:01 -05:00
<td width="10%"></td><td width="90%">
<b>Sorry, can not handle %d-bit pictures</b>. The image had
<i>BitsPerSample</i> other than 1, 2, 4, 8, or
16.</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
<b>Sorry, can not handle %d-channel images</b>. The image
had <i>SamplesPerPixel</i> other than 1, 3, or
4.</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
<b>Missing needed &quot;PhotometricInterpretation&quot;
2002-10-07 09:47:36 -04:00
tag</b>. The image did not have a tag that describes how to
2003-11-27 10:07:01 -05:00
display the data.</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
<b>No &quot;PhotometricInterpretation&quot; tag, assuming
2002-10-07 09:47:36 -04:00
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
2003-11-27 10:07:01 -05:00
assumed to be <small>RGB.</small></td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
<b>No &quot;PhotometricInterpretation&quot; tag, assuming
2002-10-07 09:47:36 -04:00
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
2003-11-27 10:07:01 -05:00
assumed to be a grayscale or bilevel image.</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
<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></td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
<b>Missing required &quot;Colormap&quot; tag</b>. A Palette
image did not have a required <i>Colormap</i>
tag.</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
<b>No space for tile buffer</b>. There was insufficient
memory to allocate an i/o buffer.</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
<b>No space for strip buffer</b>. There was insufficient
memory to allocate an i/o buffer.</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
<b>Can not handle format</b>. The image has a format
2002-10-07 09:47:36 -04:00
(combination of <i>BitsPerSample</i>,
<i>SamplesPerPixel</i>, and
<i>PhotometricInterpretation</i>) that can not be
2003-11-27 10:07:01 -05:00
handled.</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
<b>No space for B&amp;W mapping table</b>. There was
2002-10-07 09:47:36 -04:00
insufficient memory to allocate a table used to map
2003-11-27 10:07:01 -05:00
grayscale data to <small>RGB.</small></td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
<b>No space for Palette mapping table</b>. There was
2002-10-07 09:47:36 -04:00
insufficient memory to allocate a table used to map data to
2003-11-27 10:07:01 -05:00
8-bit <small>RGB.</small></td></table>
2002-10-07 09:47:36 -04:00
<a name="BUGS"></a>
<h2>BUGS</h2>
2003-11-27 10:07:01 -05:00
<table width="100%" border=0 rules="none" frame="void"
2002-10-07 09:47:36 -04:00
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
2003-11-27 10:07:01 -05:00
<td width="10%"></td><td width="90%">
Orientations other than bottom-left, or top-left are not
handled correctly.</td></table>
2002-10-07 09:47:36 -04:00
<a name="SEE ALSO"></a>
<h2>SEE ALSO</h2>
2003-11-27 10:07:01 -05:00
<table width="100%" border=0 rules="none" frame="void"
2002-10-07 09:47:36 -04:00
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
2003-11-27 10:07:01 -05:00
<td width="10%"></td><td width="90%">
<i>libtiff</i>(3T), <i>TIFFOpen</i>(3T),
2002-10-07 09:47:36 -04:00
<i>TIFFReadRGBAImage</i>(3T), <i>TIFFReadRGBAStrip</i>(3T),
2003-11-27 10:07:01 -05:00
<i>TIFFReadRGBATile</i>(3T)</td></table>
2002-10-07 09:47:36 -04:00
<hr>
</body>
</html>