|
roentgen |
b75cab |
.\" $Id: TIFFRGBAImage.3tiff,v 1.2 2005-11-02 11:07:18 dron Exp $
|
|
roentgen |
b75cab |
.\"
|
|
roentgen |
b75cab |
.\" Copyright (c) 1991-1997 Sam Leffler
|
|
roentgen |
b75cab |
.\" Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
|
roentgen |
b75cab |
.\"
|
|
roentgen |
b75cab |
.\" Permission to use, copy, modify, distribute, and sell this software and
|
|
roentgen |
b75cab |
.\" its documentation for any purpose is hereby granted without fee, provided
|
|
roentgen |
b75cab |
.\" that (i) the above copyright notices and this permission notice appear in
|
|
roentgen |
b75cab |
.\" all copies of the software and related documentation, and (ii) the names of
|
|
roentgen |
b75cab |
.\" Sam Leffler and Silicon Graphics may not be used in any advertising or
|
|
roentgen |
b75cab |
.\" publicity relating to the software without the specific, prior written
|
|
roentgen |
b75cab |
.\" permission of Sam Leffler and Silicon Graphics.
|
|
roentgen |
b75cab |
.\"
|
|
roentgen |
b75cab |
.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
|
roentgen |
b75cab |
.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
|
roentgen |
b75cab |
.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
|
roentgen |
b75cab |
.\"
|
|
roentgen |
b75cab |
.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
|
roentgen |
b75cab |
.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
|
roentgen |
b75cab |
.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
roentgen |
b75cab |
.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
|
roentgen |
b75cab |
.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
|
roentgen |
b75cab |
.\" OF THIS SOFTWARE.
|
|
roentgen |
b75cab |
.\"
|
|
roentgen |
b75cab |
.if n .po 0
|
|
roentgen |
b75cab |
.TH TIFFRGBAImage 3TIFF "October 29, 2004" "libtiff"
|
|
roentgen |
b75cab |
.SH NAME
|
|
roentgen |
b75cab |
TIFFRGBAImageOK, TIFFRGBAImageBegin, TIFFRGBAImageGet, TIFFRGBAImageEnd
|
|
roentgen |
b75cab |
\- read and decode an image into a raster
|
|
roentgen |
b75cab |
.SH SYNOPSIS
|
|
roentgen |
b75cab |
.B "#include <tiffio.h>"</tiffio.h>
|
|
roentgen |
b75cab |
.sp
|
|
roentgen |
b75cab |
.B "typedef unsigned char TIFFRGBValue;"
|
|
roentgen |
b75cab |
.B "typedef struct _TIFFRGBAImage TIFFRGBAImage;"
|
|
roentgen |
b75cab |
.sp
|
|
roentgen |
b75cab |
.BI "int TIFFRGBAImageOK(TIFF *" tif ", char " emsg[1024] ")"
|
|
roentgen |
b75cab |
.br
|
|
roentgen |
b75cab |
.BI "int TIFFRGBAImageBegin(TIFFRGBAImage *" img ", TIFF* " tif ", int " stopOnError ", char " emsg[1024] ")"
|
|
roentgen |
b75cab |
.br
|
|
roentgen |
b75cab |
.BI "int TIFFRGBAImageGet(TIFFRGBAImage *" img ", uint32* " raster ", uint32 " width " , uint32 " height ")"
|
|
roentgen |
b75cab |
.br
|
|
roentgen |
b75cab |
.BI "void TIFFRGBAImageEnd(TIFFRGBAImage *" img ")"
|
|
roentgen |
b75cab |
.br
|
|
roentgen |
b75cab |
.SH DESCRIPTION
|
|
roentgen |
b75cab |
The routines described here provide a high-level interface
|
|
roentgen |
b75cab |
through which
|
|
roentgen |
b75cab |
.SM TIFF
|
|
roentgen |
b75cab |
images may be read into memory.
|
|
roentgen |
b75cab |
Images may be strip- or tile-based and have a variety of different
|
|
roentgen |
b75cab |
characteristics: bits/sample, samples/pixel, photometric, etc.
|
|
roentgen |
b75cab |
Decoding state is encapsulated in a
|
|
roentgen |
b75cab |
.I TIFFRGBAImage
|
|
roentgen |
b75cab |
structure making it possible to capture state for multiple images
|
|
roentgen |
b75cab |
and quickly switch between them.
|
|
roentgen |
b75cab |
The target raster format can be customized to a particular application's
|
|
roentgen |
b75cab |
needs by installing custom routines that manipulate image data
|
|
roentgen |
b75cab |
according to application requirements.
|
|
roentgen |
b75cab |
.PP
|
|
roentgen |
b75cab |
The default usage for these routines is: check if an image can
|
|
roentgen |
b75cab |
be processed using
|
|
roentgen |
b75cab |
.IR TIFFRGBAImageOK ,
|
|
roentgen |
b75cab |
construct a decoder state block using
|
|
roentgen |
b75cab |
.IR TIFFRGBAImageBegin ,
|
|
roentgen |
b75cab |
read and decode an image into a target raster using
|
|
roentgen |
b75cab |
.IR TIFFRGBAImageGet ,
|
|
roentgen |
b75cab |
and then
|
|
roentgen |
b75cab |
release resources using
|
|
roentgen |
b75cab |
.IR TIFFRGBAImageEnd .
|
|
roentgen |
b75cab |
.I TIFFRGBAImageGet
|
|
roentgen |
b75cab |
can be called multiple times to decode an image using different
|
|
roentgen |
b75cab |
state parameters.
|
|
roentgen |
b75cab |
If multiple images are to be displayed and there is not enough
|
|
roentgen |
b75cab |
space for each of the decoded rasters, multiple state blocks can
|
|
roentgen |
b75cab |
be managed and then calls can be made to
|
|
roentgen |
b75cab |
.I TIFFRGBAImageGet
|
|
roentgen |
b75cab |
as needed to display an image.
|
|
roentgen |
b75cab |
.PP
|
|
roentgen |
b75cab |
The generated raster is assumed to be an array of
|
|
roentgen |
b75cab |
.I width
|
|
roentgen |
b75cab |
times
|
|
roentgen |
b75cab |
.I height
|
|
roentgen |
b75cab |
32-bit entries, where
|
|
roentgen |
b75cab |
.I width
|
|
roentgen |
b75cab |
must be less than or equal to the width of the image (\c
|
|
roentgen |
b75cab |
.I height
|
|
roentgen |
b75cab |
may be any non-zero size).
|
|
roentgen |
b75cab |
If the raster dimensions are smaller than the image, the image data
|
|
roentgen |
b75cab |
is cropped to the raster bounds.
|
|
roentgen |
b75cab |
If the raster height is greater than that of the image, then the
|
|
roentgen |
b75cab |
image data are placed in the lower part of the raster.
|
|
roentgen |
b75cab |
(Note that the raster is assume to be organized such that the pixel
|
|
roentgen |
b75cab |
at location (\fIx\fP,\fIy\fP) is \fIraster\fP[\fIy\fP*\fIwidth\fP+\fIx\fP];
|
|
roentgen |
b75cab |
with the raster origin in the
|
|
roentgen |
b75cab |
.B lower-left
|
|
roentgen |
b75cab |
hand corner.)
|
|
roentgen |
b75cab |
.PP
|
|
roentgen |
b75cab |
Raster pixels are 8-bit packed red, green, blue, alpha samples.
|
|
roentgen |
b75cab |
The macros
|
|
roentgen |
b75cab |
.IR TIFFGetR ,
|
|
roentgen |
b75cab |
.IR TIFFGetG ,
|
|
roentgen |
b75cab |
.IR TIFFGetB ,
|
|
roentgen |
b75cab |
and
|
|
roentgen |
b75cab |
.I TIFFGetA
|
|
roentgen |
b75cab |
should be used to access individual samples.
|
|
roentgen |
b75cab |
Images without Associated Alpha matting information have a constant
|
|
roentgen |
b75cab |
Alpha of 1.0 (255).
|
|
roentgen |
b75cab |
.PP
|
|
roentgen |
b75cab |
.I TIFFRGBAImageGet
|
|
roentgen |
b75cab |
converts non-8-bit images by scaling sample values.
|
|
roentgen |
b75cab |
Palette, grayscale, bilevel,
|
|
roentgen |
b75cab |
.SM CMYK\c
|
|
roentgen |
b75cab |
, and YCbCr images are converted to
|
|
roentgen |
b75cab |
.SM RGB
|
|
roentgen |
b75cab |
transparently.
|
|
roentgen |
b75cab |
Raster pixels are returned uncorrected by any colorimetry information
|
|
roentgen |
b75cab |
present in the directory.
|
|
roentgen |
b75cab |
.PP
|
|
roentgen |
b75cab |
The parameter
|
|
roentgen |
b75cab |
.I stopOnError
|
|
roentgen |
b75cab |
specifies how to act if an error is encountered while reading
|
|
roentgen |
b75cab |
the image.
|
|
roentgen |
b75cab |
If
|
|
roentgen |
b75cab |
.I stopOnError
|
|
roentgen |
b75cab |
is non-zero, then an error will terminate the operation; otherwise
|
|
roentgen |
b75cab |
.I TIFFRGBAImageGet
|
|
roentgen |
b75cab |
will continue processing data until all the possible data in the
|
|
roentgen |
b75cab |
image have been requested.
|
|
roentgen |
b75cab |
.SH "ALTERNATE RASTER FORMATS"
|
|
roentgen |
b75cab |
To use the core support for reading and processing
|
|
roentgen |
b75cab |
.SM TIFF
|
|
roentgen |
b75cab |
images, but write the resulting raster data in a different format
|
|
roentgen |
b75cab |
one need only override the ``\fIput methods\fP'' used to store raster data.
|
|
roentgen |
b75cab |
These methods are are defined in the
|
|
roentgen |
b75cab |
.I TIFFRGBAImage
|
|
roentgen |
b75cab |
structure and initially setup by
|
|
roentgen |
b75cab |
.I TIFFRGBAImageBegin
|
|
roentgen |
b75cab |
to point to routines that pack raster data in the default
|
|
roentgen |
b75cab |
.SM ABGR
|
|
roentgen |
b75cab |
pixel format.
|
|
roentgen |
b75cab |
Two different routines are used according to the physical organization
|
|
roentgen |
b75cab |
of the image data in the file:
|
|
roentgen |
b75cab |
.IR PlanarConfiguration =1
|
|
roentgen |
b75cab |
(packed samples),
|
|
roentgen |
b75cab |
and
|
|
roentgen |
b75cab |
.IR PlanarConfiguration =2
|
|
roentgen |
b75cab |
(separated samples).
|
|
roentgen |
b75cab |
Note that this mechanism can be used to transform the data before
|
|
roentgen |
b75cab |
storing it in the raster.
|
|
roentgen |
b75cab |
For example one can convert data
|
|
roentgen |
b75cab |
to colormap indices for display on a colormap display.
|
|
roentgen |
b75cab |
.SH "SIMULTANEOUS RASTER STORE AND DISPLAY"
|
|
roentgen |
b75cab |
It is simple to display an image as it is being read into memory
|
|
roentgen |
b75cab |
by overriding the put methods as described above for supporting
|
|
roentgen |
b75cab |
alternate raster formats.
|
|
roentgen |
b75cab |
Simply keep a reference to the default put methods setup by
|
|
roentgen |
b75cab |
.I TIFFRGBAImageBegin
|
|
roentgen |
b75cab |
and then invoke them before or after each display operation.
|
|
roentgen |
b75cab |
For example, the
|
|
roentgen |
b75cab |
.IR tiffgt (1)
|
|
roentgen |
b75cab |
utility uses the following put method to update the display as
|
|
roentgen |
b75cab |
the raster is being filled:
|
|
roentgen |
b75cab |
.sp
|
|
roentgen |
b75cab |
.nf
|
|
roentgen |
b75cab |
.ft C
|
|
roentgen |
b75cab |
static void
|
|
roentgen |
b75cab |
putContigAndDraw(TIFFRGBAImage* img, uint32* raster,
|
|
roentgen |
b75cab |
uint32 x, uint32 y, uint32 w, uint32 h,
|
|
roentgen |
b75cab |
int32 fromskew, int32 toskew,
|
|
roentgen |
b75cab |
unsigned char* cp)
|
|
roentgen |
b75cab |
{
|
|
roentgen |
b75cab |
(*putContig)(img, raster, x, y, w, h, fromskew, toskew, cp);
|
|
roentgen |
b75cab |
if (x+w == width) {
|
|
roentgen |
b75cab |
w = width;
|
|
roentgen |
b75cab |
if (img->orientation == ORIENTATION_TOPLEFT)
|
|
roentgen |
b75cab |
lrectwrite(0, y-(h-1), w-1, y, raster-x-(h-1)*w);
|
|
roentgen |
b75cab |
else
|
|
roentgen |
b75cab |
lrectwrite(0, y, w-1, y+h-1, raster);
|
|
roentgen |
b75cab |
}
|
|
roentgen |
b75cab |
}
|
|
roentgen |
b75cab |
.ft R
|
|
roentgen |
b75cab |
.fi
|
|
roentgen |
b75cab |
.sp
|
|
roentgen |
b75cab |
(the original routine provided by the library is saved in the
|
|
roentgen |
b75cab |
variable
|
|
roentgen |
b75cab |
.IR putContig .)
|
|
roentgen |
b75cab |
.SH "SUPPORTING ADDITIONAL TIFF FORMATS"
|
|
roentgen |
b75cab |
The
|
|
roentgen |
b75cab |
.I TIFFRGBAImage
|
|
roentgen |
b75cab |
routines support the most commonly encountered flavors of
|
|
roentgen |
b75cab |
.SM TIFF.
|
|
roentgen |
b75cab |
It is possible to extend this support by overriding the ``\fIget method\fP''
|
|
roentgen |
b75cab |
invoked by
|
|
roentgen |
b75cab |
.I TIFFRGBAImageGet
|
|
roentgen |
b75cab |
to read
|
|
roentgen |
b75cab |
.SM TIFF
|
|
roentgen |
b75cab |
image data.
|
|
roentgen |
b75cab |
Details of doing this are a bit involved, it is best to make a copy
|
|
roentgen |
b75cab |
of an existing get method and modify it to suit the needs of an
|
|
roentgen |
b75cab |
application.
|
|
roentgen |
b75cab |
.SH NOTES
|
|
roentgen |
b75cab |
Samples must be either 1, 2, 4, 8, or 16 bits.
|
|
roentgen |
b75cab |
Colorimetric samples/pixel must be either 1, 3, or 4 (i.e.
|
|
roentgen |
b75cab |
.I SamplesPerPixel
|
|
roentgen |
b75cab |
minus
|
|
roentgen |
b75cab |
.IR ExtraSamples ).
|
|
roentgen |
b75cab |
.PP
|
|
roentgen |
b75cab |
Palette image colormaps that appear to be incorrectly written
|
|
roentgen |
b75cab |
as 8-bit values are automatically scaled to 16-bits.
|
|
roentgen |
b75cab |
.SH "RETURN VALUES"
|
|
roentgen |
b75cab |
All routines return
|
|
roentgen |
b75cab |
1 if the operation was successful.
|
|
roentgen |
b75cab |
Otherwise, 0 is returned if an error was encountered and
|
|
roentgen |
b75cab |
.I stopOnError
|
|
roentgen |
b75cab |
is zero.
|
|
roentgen |
b75cab |
.SH DIAGNOSTICS
|
|
roentgen |
b75cab |
All error messages are directed to the
|
|
roentgen |
b75cab |
.IR TIFFError (3TIFF)
|
|
roentgen |
b75cab |
routine.
|
|
roentgen |
b75cab |
.PP
|
|
roentgen |
b75cab |
.BR "Sorry, can not handle %d-bit pictures" .
|
|
roentgen |
b75cab |
The image had
|
|
roentgen |
b75cab |
.I BitsPerSample
|
|
roentgen |
b75cab |
other than 1, 2, 4, 8, or 16.
|
|
roentgen |
b75cab |
.PP
|
|
roentgen |
b75cab |
.BR "Sorry, can not handle %d-channel images" .
|
|
roentgen |
b75cab |
The image had
|
|
roentgen |
b75cab |
.I SamplesPerPixel
|
|
roentgen |
b75cab |
other than 1, 3, or 4.
|
|
roentgen |
b75cab |
.PP
|
|
roentgen |
b75cab |
\fBMissing needed "PhotometricInterpretation" tag\fP.
|
|
roentgen |
b75cab |
The image did not have a tag that describes how to display
|
|
roentgen |
b75cab |
the data.
|
|
roentgen |
b75cab |
.PP
|
|
roentgen |
b75cab |
\fBNo "PhotometricInterpretation" tag, assuming RGB\fP.
|
|
roentgen |
b75cab |
The image was missing a tag that describes how to display it,
|
|
roentgen |
b75cab |
but because it has 3 or 4 samples/pixel, it is assumed to be
|
|
roentgen |
b75cab |
.SM RGB.
|
|
roentgen |
b75cab |
.PP
|
|
roentgen |
b75cab |
\fBNo "PhotometricInterpretation" tag, assuming min-is-black\fP.
|
|
roentgen |
b75cab |
The image was missing a tag that describes how to display it,
|
|
roentgen |
b75cab |
but because it has 1 sample/pixel, it is assumed to be a grayscale
|
|
roentgen |
b75cab |
or bilevel image.
|
|
roentgen |
b75cab |
.PP
|
|
roentgen |
b75cab |
.BR "No space for photometric conversion table" .
|
|
roentgen |
b75cab |
There was insufficient memory for a table used to convert
|
|
roentgen |
b75cab |
image samples to 8-bit
|
|
roentgen |
b75cab |
.SM RGB.
|
|
roentgen |
b75cab |
.PP
|
|
roentgen |
b75cab |
\fBMissing required "Colormap" tag\fP.
|
|
roentgen |
b75cab |
A Palette image did not have a required
|
|
roentgen |
b75cab |
.I Colormap
|
|
roentgen |
b75cab |
tag.
|
|
roentgen |
b75cab |
.PP
|
|
roentgen |
b75cab |
.BR "No space for tile buffer" .
|
|
roentgen |
b75cab |
There was insufficient memory to allocate an i/o buffer.
|
|
roentgen |
b75cab |
.PP
|
|
roentgen |
b75cab |
.BR "No space for strip buffer" .
|
|
roentgen |
b75cab |
There was insufficient memory to allocate an i/o buffer.
|
|
roentgen |
b75cab |
.PP
|
|
roentgen |
b75cab |
.BR "Can not handle format" .
|
|
roentgen |
b75cab |
The image has a format (combination of
|
|
roentgen |
b75cab |
.IR BitsPerSample ,
|
|
roentgen |
b75cab |
.IR SamplesPerPixel ,
|
|
roentgen |
b75cab |
and
|
|
roentgen |
b75cab |
.IR PhotometricInterpretation )
|
|
roentgen |
b75cab |
that can not be handled.
|
|
roentgen |
b75cab |
.PP
|
|
roentgen |
b75cab |
.BR "No space for B&W mapping table" .
|
|
roentgen |
b75cab |
There was insufficient memory to allocate a table used to map
|
|
roentgen |
b75cab |
grayscale data to
|
|
roentgen |
b75cab |
.SM RGB.
|
|
roentgen |
b75cab |
.PP
|
|
roentgen |
b75cab |
.BR "No space for Palette mapping table" .
|
|
roentgen |
b75cab |
There was insufficient memory to allocate a table used to map
|
|
roentgen |
b75cab |
data to 8-bit
|
|
roentgen |
b75cab |
.SM RGB.
|
|
roentgen |
b75cab |
.SH "SEE ALSO"
|
|
roentgen |
b75cab |
.BR TIFFOpen (3TIFF),
|
|
roentgen |
b75cab |
.BR TIFFReadRGBAImage (3TIFF),
|
|
roentgen |
b75cab |
.BR TIFFReadRGBAImageOriented (3TIFF),
|
|
roentgen |
b75cab |
.BR TIFFReadRGBAStrip (3TIFF),
|
|
roentgen |
b75cab |
.BR TIFFReadRGBATile (3TIFF),
|
|
roentgen |
b75cab |
.BR libtiff (3TIFF)
|
|
roentgen |
b75cab |
.PP
|
|
roentgen |
b75cab |
Libtiff library home page:
|
|
roentgen |
b75cab |
.BR http://www.remotesensing.org/libtiff/
|