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