|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
<meta content="groff -Thtml, see www.gnu.org" name="generator">
|
|
kusano |
7d535a |
<meta content="text/css" name="Content-Style">
|
|
kusano |
7d535a |
<title>TIFFRGBAImage</title>
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
TIFFRGBAImage
|
|
kusano |
7d535a |
NAME
|
|
kusano |
7d535a |
SYNOPSIS
|
|
kusano |
7d535a |
DESCRIPTION
|
|
kusano |
7d535a |
ALTERNATE RASTER FORMATS
|
|
kusano |
7d535a |
SIMULTANEOUS RASTER STORE AND DISPLAY
|
|
kusano |
7d535a |
SUPPORTING ADDITIONAL TIFF FORMATS
|
|
kusano |
7d535a |
NOTES
|
|
kusano |
7d535a |
RETURN VALUES
|
|
kusano |
7d535a |
DIAGNOSTICS
|
|
kusano |
7d535a |
SEE ALSO
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
NAME
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
cols="2" cellspacing="0" cellpadding="0">
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
TIFFRGBAImageOK, TIFFRGBAImageBegin, TIFFRGBAImageGet,
|
|
kusano |
7d535a |
TIFFRGBAImageEnd − read and decode an image into a
|
|
kusano |
7d535a |
raster
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
SYNOPSIS
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
cols="2" cellspacing="0" cellpadding="0">
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#include <tiffio.h>
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
typedef unsigned char TIFFRGBValue; typedef struct
|
|
kusano |
7d535a |
_TIFFRGBAImage TIFFRGBAImage;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
int TIFFRGBAImageOK(TIFF *tif, char
|
|
kusano |
7d535a |
emsg[1024])
|
|
kusano |
7d535a |
int TIFFRGBAImageBegin(TIFFRGBAImage *img,
|
|
kusano |
7d535a |
TIFF* tif, int stopOnError,
|
|
kusano |
7d535a |
char emsg[1024])
|
|
kusano |
7d535a |
int TIFFRGBAImageGet(TIFFRGBAImage *img,
|
|
kusano |
7d535a |
uint32* raster, uint32 width ,
|
|
kusano |
7d535a |
uint32 height)
|
|
kusano |
7d535a |
void TIFFRGBAImageEnd(TIFFRGBAImage
|
|
kusano |
7d535a |
*img)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
DESCRIPTION
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
cols="2" cellspacing="0" cellpadding="0">
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The routines described here provide a high-level
|
|
kusano |
7d535a |
interface through which <small>TIFF</small> images may be
|
|
kusano |
7d535a |
read into memory. Images may be strip- or tile-based and
|
|
kusano |
7d535a |
have a variety of different characteristics: bits/sample,
|
|
kusano |
7d535a |
samples/pixel, photometric, etc. Decoding state is
|
|
kusano |
7d535a |
encapsulated in a TIFFRGBAImage structure making it
|
|
kusano |
7d535a |
possible to capture state for multiple images and quickly
|
|
kusano |
7d535a |
switch between them. The target raster format can be
|
|
kusano |
7d535a |
customized to a particular application’s needs by
|
|
kusano |
7d535a |
installing custom routines that manipulate image data
|
|
kusano |
7d535a |
according to application requirements.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The default usage for these routines is: check if an
|
|
kusano |
7d535a |
image can be processed using TIFFRGBAImageOK,
|
|
kusano |
7d535a |
construct a decoder state block using
|
|
kusano |
7d535a |
TIFFRGBAImageBegin, read and decode an image into a
|
|
kusano |
7d535a |
target raster using TIFFRGBAImageGet, and then
|
|
kusano |
7d535a |
release resources using TIFFRGBAImageEnd.
|
|
kusano |
7d535a |
TIFFRGBAImageGet can be called multiple times to
|
|
kusano |
7d535a |
decode an image using different state parameters. If
|
|
kusano |
7d535a |
multiple images are to be displayed and there is not enough
|
|
kusano |
7d535a |
space for each of the decoded rasters, multiple state blocks
|
|
kusano |
7d535a |
can be managed and then calls can be made to
|
|
kusano |
7d535a |
TIFFRGBAImageGet as needed to display an image.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The generated raster is assumed to be an array of
|
|
kusano |
7d535a |
width times height 32-bit entries, where
|
|
kusano |
7d535a |
width must be less than or equal to the width of the
|
|
kusano |
7d535a |
image (height may be any non-zero size). If the
|
|
kusano |
7d535a |
raster dimensions are smaller than the image, the image data
|
|
kusano |
7d535a |
is cropped to the raster bounds. If the raster height is
|
|
kusano |
7d535a |
greater than that of the image, then the image data are
|
|
kusano |
7d535a |
placed in the lower part of the raster. (Note that the
|
|
kusano |
7d535a |
raster is assume to be organized such that the pixel at
|
|
kusano |
7d535a |
location (x,y) is
|
|
kusano |
7d535a |
raster[y*width+x]; with the
|
|
kusano |
7d535a |
raster origin in the lower-left hand corner.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Raster pixels are 8-bit packed red, green, blue, alpha
|
|
kusano |
7d535a |
samples. The macros TIFFGetR, TIFFGetG,
|
|
kusano |
7d535a |
TIFFGetB, and TIFFGetA should be used to
|
|
kusano |
7d535a |
access individual samples. Images without Associated Alpha
|
|
kusano |
7d535a |
matting information have a constant Alpha of 1.0 (255).
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
TIFFRGBAImageGet converts non-8-bit images by
|
|
kusano |
7d535a |
scaling sample values. Palette, grayscale, bilevel,
|
|
kusano |
7d535a |
<small>CMYK</small> , and YCbCr images are converted to
|
|
kusano |
7d535a |
<small>RGB</small> transparently. Raster pixels are returned
|
|
kusano |
7d535a |
uncorrected by any colorimetry information present in the
|
|
kusano |
7d535a |
directory.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The parameter stopOnError specifies how to act if
|
|
kusano |
7d535a |
an error is encountered while reading the image. If
|
|
kusano |
7d535a |
stopOnError is non-zero, then an error will terminate
|
|
kusano |
7d535a |
the operation; otherwise TIFFRGBAImageGet will
|
|
kusano |
7d535a |
continue processing data until all the possible data in the
|
|
kusano |
7d535a |
image have been requested.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
ALTERNATE RASTER FORMATS
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
cols="2" cellspacing="0" cellpadding="0">
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
To use the core support for reading and processing
|
|
kusano |
7d535a |
<small>TIFF</small> images, but write the resulting raster
|
|
kusano |
7d535a |
data in a different format one need only override the
|
|
kusano |
7d535a |
‘‘put methods’’ used to store
|
|
kusano |
7d535a |
raster data. These methods are are defined in the
|
|
kusano |
7d535a |
TIFFRGBAImage structure and initially setup by
|
|
kusano |
7d535a |
TIFFRGBAImageBegin to point to routines that pack
|
|
kusano |
7d535a |
raster data in the default <small>ABGR</small> pixel format.
|
|
kusano |
7d535a |
Two different routines are used according to the physical
|
|
kusano |
7d535a |
organization of the image data in the file:
|
|
kusano |
7d535a |
PlanarConfiguration=1 (packed samples), and
|
|
kusano |
7d535a |
PlanarConfiguration=2 (separated samples). Note that
|
|
kusano |
7d535a |
this mechanism can be used to transform the data before
|
|
kusano |
7d535a |
storing it in the raster. For example one can convert data
|
|
kusano |
7d535a |
to colormap indices for display on a colormap display.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
SIMULTANEOUS RASTER STORE AND DISPLAY
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
cols="2" cellspacing="0" cellpadding="0">
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
It is simple to display an image as it is being read into
|
|
kusano |
7d535a |
memory by overriding the put methods as described above for
|
|
kusano |
7d535a |
supporting alternate raster formats. Simply keep a reference
|
|
kusano |
7d535a |
to the default put methods setup by
|
|
kusano |
7d535a |
TIFFRGBAImageBegin and then invoke them before or
|
|
kusano |
7d535a |
after each display operation. For example, the
|
|
kusano |
7d535a |
tiffgt(1) utility uses the following put method to
|
|
kusano |
7d535a |
update the display as the raster is being filled:
|
|
kusano |
7d535a |
|
|
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 |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
(the original routine provided by the library is saved in
|
|
kusano |
7d535a |
the variable putContig.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
SUPPORTING ADDITIONAL TIFF FORMATS
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
cols="2" cellspacing="0" cellpadding="0">
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The TIFFRGBAImage routines support the most
|
|
kusano |
7d535a |
commonly encountered flavors of <small>TIFF.</small> It is
|
|
kusano |
7d535a |
possible to extend this support by overriding the
|
|
kusano |
7d535a |
‘‘get method’’ invoked by
|
|
kusano |
7d535a |
TIFFRGBAImageGet to read <small>TIFF</small> image
|
|
kusano |
7d535a |
data. Details of doing this are a bit involved, it is best
|
|
kusano |
7d535a |
to make a copy of an existing get method and modify it to
|
|
kusano |
7d535a |
suit the needs of an application.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
NOTES
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
cols="2" cellspacing="0" cellpadding="0">
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
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 |
SamplesPerPixel minus ExtraSamples).
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Palette image colormaps that appear to be incorrectly
|
|
kusano |
7d535a |
written as 8-bit values are automatically scaled to
|
|
kusano |
7d535a |
16-bits.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
RETURN VALUES
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
cols="2" cellspacing="0" cellpadding="0">
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
All routines return 1 if the operation was successful.
|
|
kusano |
7d535a |
Otherwise, 0 is returned if an error was encountered and
|
|
kusano |
7d535a |
stopOnError is zero.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
DIAGNOSTICS
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
cols="2" cellspacing="0" cellpadding="0">
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
All error messages are directed to the
|
|
kusano |
7d535a |
TIFFError(3TIFF) routine.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Sorry, can not handle %d-bit pictures. The image
|
|
kusano |
7d535a |
had BitsPerSample other than 1, 2, 4, 8, or 16.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Sorry, can not handle %d-channel images. The image
|
|
kusano |
7d535a |
had SamplesPerPixel other than 1, 3, or 4.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Missing needed "PhotometricInterpretation"
|
|
kusano |
7d535a |
tag. The image did not have a tag that describes how to
|
|
kusano |
7d535a |
display the data.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
No "PhotometricInterpretation" tag, assuming
|
|
kusano |
7d535a |
RGB. The image was missing a tag that describes how to
|
|
kusano |
7d535a |
display it, but because it has 3 or 4 samples/pixel, it is
|
|
kusano |
7d535a |
assumed to be <small>RGB.</small>
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
No "PhotometricInterpretation" tag, assuming
|
|
kusano |
7d535a |
min-is-black. The image was missing a tag that describes
|
|
kusano |
7d535a |
how to display it, but because it has 1 sample/pixel, it is
|
|
kusano |
7d535a |
assumed to be a grayscale or bilevel image.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
No space for photometric conversion table. There
|
|
kusano |
7d535a |
was insufficient memory for a table used to convert image
|
|
kusano |
7d535a |
samples to 8-bit <small>RGB.</small>
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Missing required "Colormap" tag. A
|
|
kusano |
7d535a |
Palette image did not have a required Colormap
|
|
kusano |
7d535a |
tag.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
No space for tile buffer. There was insufficient
|
|
kusano |
7d535a |
memory to allocate an i/o buffer.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
No space for strip buffer. There was insufficient
|
|
kusano |
7d535a |
memory to allocate an i/o buffer.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Can not handle format. The image has a format
|
|
kusano |
7d535a |
(combination of BitsPerSample,
|
|
kusano |
7d535a |
SamplesPerPixel, and
|
|
kusano |
7d535a |
PhotometricInterpretation) that can not be
|
|
kusano |
7d535a |
handled.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
No space for B&W mapping table. There was
|
|
kusano |
7d535a |
insufficient memory to allocate a table used to map
|
|
kusano |
7d535a |
grayscale data to <small>RGB.</small>
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
No space for Palette mapping table. There was
|
|
kusano |
7d535a |
insufficient memory to allocate a table used to map data to
|
|
kusano |
7d535a |
8-bit <small>RGB.</small>
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
SEE ALSO
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
cols="2" cellspacing="0" cellpadding="0">
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
TIFFOpen(3TIFF), TIFFReadRGBAImage(3TIFF),
|
|
kusano |
7d535a |
TIFFReadRGBAImageOriented(3TIFF),
|
|
kusano |
7d535a |
TIFFReadRGBAStrip(3TIFF),
|
|
kusano |
7d535a |
TIFFReadRGBATile(3TIFF), libtiff(3TIFF)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Libtiff library home page:
|
|
kusano |
7d535a |
http://www.remotesensing.org/libtiff/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|