roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
<meta content="groff -Thtml, see www.gnu.org" name="generator">
roentgen b75cab
<meta content="text/css" name="Content-Style">
roentgen b75cab
<title>TIFFRGBAImage</title>
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

TIFFRGBAImage

roentgen b75cab
NAME
roentgen b75cab
SYNOPSIS
roentgen b75cab
DESCRIPTION
roentgen b75cab
ALTERNATE RASTER FORMATS
roentgen b75cab
SIMULTANEOUS RASTER STORE AND DISPLAY
roentgen b75cab
SUPPORTING ADDITIONAL TIFF FORMATS
roentgen b75cab
NOTES
roentgen b75cab
RETURN VALUES
roentgen b75cab
DIAGNOSTICS
roentgen b75cab
SEE ALSO
roentgen b75cab
roentgen b75cab

roentgen b75cab
roentgen b75cab

NAME

roentgen b75cab
roentgen b75cab
roentgen b75cab
       cols="2" cellspacing="0" cellpadding="0">
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

TIFFRGBAImageOK, TIFFRGBAImageBegin, TIFFRGBAImageGet,

roentgen b75cab
TIFFRGBAImageEnd − read and decode an image into a
roentgen b75cab
raster

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

SYNOPSIS

roentgen b75cab
roentgen b75cab
roentgen b75cab
       cols="2" cellspacing="0" cellpadding="0">
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

#include <tiffio.h>

roentgen b75cab
roentgen b75cab

typedef unsigned char TIFFRGBValue; typedef struct

roentgen b75cab
_TIFFRGBAImage TIFFRGBAImage;

roentgen b75cab
roentgen b75cab

int TIFFRGBAImageOK(TIFF *tif, char

roentgen b75cab
emsg[1024])
roentgen b75cab
int TIFFRGBAImageBegin(TIFFRGBAImage *img,
roentgen b75cab
TIFF* tif, int stopOnError,
roentgen b75cab
char emsg[1024])
roentgen b75cab
int TIFFRGBAImageGet(TIFFRGBAImage *img,
roentgen b75cab
uint32* raster, uint32 width ,
roentgen b75cab
uint32 height)
roentgen b75cab
void TIFFRGBAImageEnd(TIFFRGBAImage
roentgen b75cab
*img)

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

DESCRIPTION

roentgen b75cab
roentgen b75cab
roentgen b75cab
       cols="2" cellspacing="0" cellpadding="0">
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

The routines described here provide a high-level

roentgen b75cab
interface through which <small>TIFF</small> images may be
roentgen b75cab
read into memory. Images may be strip- or tile-based and
roentgen b75cab
have a variety of different characteristics: bits/sample,
roentgen b75cab
samples/pixel, photometric, etc. Decoding state is
roentgen b75cab
encapsulated in a TIFFRGBAImage structure making it
roentgen b75cab
possible to capture state for multiple images and quickly
roentgen b75cab
switch between them. The target raster format can be
roentgen b75cab
customized to a particular application’s needs by
roentgen b75cab
installing custom routines that manipulate image data
roentgen b75cab
according to application requirements.

roentgen b75cab
roentgen b75cab

The default usage for these routines is: check if an

roentgen b75cab
image can be processed using TIFFRGBAImageOK,
roentgen b75cab
construct a decoder state block using
roentgen b75cab
TIFFRGBAImageBegin, read and decode an image into a
roentgen b75cab
target raster using TIFFRGBAImageGet, and then
roentgen b75cab
release resources using TIFFRGBAImageEnd.
roentgen b75cab
TIFFRGBAImageGet can be called multiple times to
roentgen b75cab
decode an image using different state parameters. If
roentgen b75cab
multiple images are to be displayed and there is not enough
roentgen b75cab
space for each of the decoded rasters, multiple state blocks
roentgen b75cab
can be managed and then calls can be made to
roentgen b75cab
TIFFRGBAImageGet as needed to display an image.

roentgen b75cab
roentgen b75cab

The generated raster is assumed to be an array of

roentgen b75cab
width times height 32-bit entries, where
roentgen b75cab
width must be less than or equal to the width of the
roentgen b75cab
image (height may be any non-zero size). If the
roentgen b75cab
raster dimensions are smaller than the image, the image data
roentgen b75cab
is cropped to the raster bounds. If the raster height is
roentgen b75cab
greater than that of the image, then the image data are
roentgen b75cab
placed in the lower part of the raster. (Note that the
roentgen b75cab
raster is assume to be organized such that the pixel at
roentgen b75cab
location (x,y) is
roentgen b75cab
raster[y*width+x]; with the
roentgen b75cab
raster origin in the lower-left hand corner.)

roentgen b75cab
roentgen b75cab

Raster pixels are 8-bit packed red, green, blue, alpha

roentgen b75cab
samples. The macros TIFFGetR, TIFFGetG,
roentgen b75cab
TIFFGetB, and TIFFGetA should be used to
roentgen b75cab
access individual samples. Images without Associated Alpha
roentgen b75cab
matting information have a constant Alpha of 1.0 (255).

roentgen b75cab
roentgen b75cab

TIFFRGBAImageGet converts non-8-bit images by

roentgen b75cab
scaling sample values. Palette, grayscale, bilevel,
roentgen b75cab
<small>CMYK</small> , and YCbCr images are converted to
roentgen b75cab
<small>RGB</small> transparently. Raster pixels are returned
roentgen b75cab
uncorrected by any colorimetry information present in the
roentgen b75cab
directory.

roentgen b75cab
roentgen b75cab

The parameter stopOnError specifies how to act if

roentgen b75cab
an error is encountered while reading the image. If
roentgen b75cab
stopOnError is non-zero, then an error will terminate
roentgen b75cab
the operation; otherwise TIFFRGBAImageGet will
roentgen b75cab
continue processing data until all the possible data in the
roentgen b75cab
image have been requested.

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

ALTERNATE RASTER FORMATS

roentgen b75cab
roentgen b75cab
roentgen b75cab
       cols="2" cellspacing="0" cellpadding="0">
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

To use the core support for reading and processing

roentgen b75cab
<small>TIFF</small> images, but write the resulting raster
roentgen b75cab
data in a different format one need only override the
roentgen b75cab
‘‘put methods’’ used to store
roentgen b75cab
raster data. These methods are are defined in the
roentgen b75cab
TIFFRGBAImage structure and initially setup by
roentgen b75cab
TIFFRGBAImageBegin to point to routines that pack
roentgen b75cab
raster data in the default <small>ABGR</small> pixel format.
roentgen b75cab
Two different routines are used according to the physical
roentgen b75cab
organization of the image data in the file:
roentgen b75cab
PlanarConfiguration=1 (packed samples), and
roentgen b75cab
PlanarConfiguration=2 (separated samples). Note that
roentgen b75cab
this mechanism can be used to transform the data before
roentgen b75cab
storing it in the raster. For example one can convert data
roentgen b75cab
to colormap indices for display on a colormap display.

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

SIMULTANEOUS RASTER STORE AND DISPLAY

roentgen b75cab
roentgen b75cab
roentgen b75cab
       cols="2" cellspacing="0" cellpadding="0">
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

It is simple to display an image as it is being read into

roentgen b75cab
memory by overriding the put methods as described above for
roentgen b75cab
supporting alternate raster formats. Simply keep a reference
roentgen b75cab
to the default put methods setup by
roentgen b75cab
TIFFRGBAImageBegin and then invoke them before or
roentgen b75cab
after each display operation. For example, the
roentgen b75cab
tiffgt(1) utility uses the following put method to
roentgen b75cab
update the display as the raster is being filled:

roentgen b75cab
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
roentgen b75cab
roentgen b75cab

(the original routine provided by the library is saved in

roentgen b75cab
the variable putContig.)

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

SUPPORTING ADDITIONAL TIFF FORMATS

roentgen b75cab
roentgen b75cab
roentgen b75cab
       cols="2" cellspacing="0" cellpadding="0">
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

The TIFFRGBAImage routines support the most

roentgen b75cab
commonly encountered flavors of <small>TIFF.</small> It is
roentgen b75cab
possible to extend this support by overriding the
roentgen b75cab
‘‘get method’’ invoked by
roentgen b75cab
TIFFRGBAImageGet to read <small>TIFF</small> image
roentgen b75cab
data. Details of doing this are a bit involved, it is best
roentgen b75cab
to make a copy of an existing get method and modify it to
roentgen b75cab
suit the needs of an application.

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

NOTES

roentgen b75cab
roentgen b75cab
roentgen b75cab
       cols="2" cellspacing="0" cellpadding="0">
roentgen b75cab
roentgen b75cab
roentgen b75cab
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
SamplesPerPixel minus ExtraSamples).

roentgen b75cab
roentgen b75cab

Palette image colormaps that appear to be incorrectly

roentgen b75cab
written as 8-bit values are automatically scaled to
roentgen b75cab
16-bits.

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

RETURN VALUES

roentgen b75cab
roentgen b75cab
roentgen b75cab
       cols="2" cellspacing="0" cellpadding="0">
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

All routines return 1 if the operation was successful.

roentgen b75cab
Otherwise, 0 is returned if an error was encountered and
roentgen b75cab
stopOnError is zero.

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

DIAGNOSTICS

roentgen b75cab
roentgen b75cab
roentgen b75cab
       cols="2" cellspacing="0" cellpadding="0">
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

All error messages are directed to the

roentgen b75cab
TIFFError(3TIFF) routine.

roentgen b75cab
roentgen b75cab

Sorry, can not handle %d-bit pictures. The image

roentgen b75cab
had BitsPerSample other than 1, 2, 4, 8, or 16.

roentgen b75cab
roentgen b75cab

Sorry, can not handle %d-channel images. The image

roentgen b75cab
had SamplesPerPixel other than 1, 3, or 4.

roentgen b75cab
roentgen b75cab

Missing needed "PhotometricInterpretation"

roentgen b75cab
tag. The image did not have a tag that describes how to
roentgen b75cab
display the data.

roentgen b75cab
roentgen b75cab

No "PhotometricInterpretation" tag, assuming

roentgen b75cab
RGB. The image was missing a tag that describes how to
roentgen b75cab
display it, but because it has 3 or 4 samples/pixel, it is
roentgen b75cab
assumed to be <small>RGB.</small>

roentgen b75cab
roentgen b75cab

No "PhotometricInterpretation" tag, assuming

roentgen b75cab
min-is-black. The image was missing a tag that describes
roentgen b75cab
how to display it, but because it has 1 sample/pixel, it is
roentgen b75cab
assumed to be a grayscale or bilevel image.

roentgen b75cab
roentgen b75cab

No space for photometric conversion table. There

roentgen b75cab
was insufficient memory for a table used to convert image
roentgen b75cab
samples to 8-bit <small>RGB.</small>

roentgen b75cab
roentgen b75cab

Missing required "Colormap" tag. A

roentgen b75cab
Palette image did not have a required Colormap
roentgen b75cab
tag.

roentgen b75cab
roentgen b75cab

No space for tile buffer. There was insufficient

roentgen b75cab
memory to allocate an i/o buffer.

roentgen b75cab
roentgen b75cab

No space for strip buffer. There was insufficient

roentgen b75cab
memory to allocate an i/o buffer.

roentgen b75cab
roentgen b75cab

Can not handle format. The image has a format

roentgen b75cab
(combination of BitsPerSample,
roentgen b75cab
SamplesPerPixel, and
roentgen b75cab
PhotometricInterpretation) that can not be
roentgen b75cab
handled.

roentgen b75cab
roentgen b75cab

No space for B&W mapping table. There was

roentgen b75cab
insufficient memory to allocate a table used to map
roentgen b75cab
grayscale data to <small>RGB.</small>

roentgen b75cab
roentgen b75cab

No space for Palette mapping table. There was

roentgen b75cab
insufficient memory to allocate a table used to map data to
roentgen b75cab
8-bit <small>RGB.</small>

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

SEE ALSO

roentgen b75cab
roentgen b75cab
roentgen b75cab
       cols="2" cellspacing="0" cellpadding="0">
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

TIFFOpen(3TIFF), TIFFReadRGBAImage(3TIFF),

roentgen b75cab
TIFFReadRGBAImageOriented(3TIFF),
roentgen b75cab
TIFFReadRGBAStrip(3TIFF),
roentgen b75cab
TIFFReadRGBATile(3TIFF), libtiff(3TIFF)

roentgen b75cab
roentgen b75cab

Libtiff library home page:

roentgen b75cab
http://www.remotesensing.org/libtiff/

roentgen b75cab
roentgen b75cab
roentgen b75cab

roentgen b75cab
roentgen b75cab