Blame html/man/TIFFRGBAImage.3tiff.html

Packit 7838c8
Packit 7838c8
Packit 7838c8
<html>
Packit 7838c8
<head>
Packit 7838c8
<meta name="generator" content="groff -Thtml, see www.gnu.org">
Packit 7838c8
<meta name="Content-Style" content="text/css">
Packit 7838c8
<title>TIFFRGBAImage</title>
Packit 7838c8
</head>
Packit 7838c8
<body>
Packit 7838c8
Packit 7838c8

TIFFRGBAImage

Packit 7838c8
NAME
Packit 7838c8
SYNOPSIS
Packit 7838c8
DESCRIPTION
Packit 7838c8
ALTERNATE RASTER FORMATS
Packit 7838c8
SIMULTANEOUS RASTER STORE AND DISPLAY
Packit 7838c8
SUPPORTING ADDITIONAL TIFF FORMATS
Packit 7838c8
NOTES
Packit 7838c8
RETURN VALUES
Packit 7838c8
DIAGNOSTICS
Packit 7838c8
SEE ALSO
Packit 7838c8
Packit 7838c8

Packit 7838c8
Packit 7838c8

NAME

Packit 7838c8
Packit 7838c8
Packit 7838c8
       cols="2" cellspacing="0" cellpadding="0">
Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

TIFFRGBAImageOK, TIFFRGBAImageBegin, TIFFRGBAImageGet,

Packit 7838c8
TIFFRGBAImageEnd − read and decode an image into a
Packit 7838c8
raster

Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

SYNOPSIS

Packit 7838c8
Packit 7838c8
Packit 7838c8
       cols="2" cellspacing="0" cellpadding="0">
Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

#include <tiffio.h>

Packit 7838c8
Packit 7838c8

typedef unsigned char TIFFRGBValue; typedef struct

Packit 7838c8
_TIFFRGBAImage TIFFRGBAImage;

Packit 7838c8
Packit 7838c8

int TIFFRGBAImageOK(TIFF *tif, char

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

Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

DESCRIPTION

Packit 7838c8
Packit 7838c8
Packit 7838c8
       cols="2" cellspacing="0" cellpadding="0">
Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

The routines described here provide a high-level

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

Packit 7838c8
Packit 7838c8

The default usage for these routines is: check if an

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

Packit 7838c8
Packit 7838c8

The generated raster is assumed to be an array of

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

Packit 7838c8
Packit 7838c8

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

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

Packit 7838c8
Packit 7838c8

TIFFRGBAImageGet converts non-8-bit images by

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

Packit 7838c8
Packit 7838c8

The parameter stopOnError specifies how to act if

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

Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

ALTERNATE RASTER FORMATS

Packit 7838c8
Packit 7838c8
Packit 7838c8
       cols="2" cellspacing="0" cellpadding="0">
Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

To use the core support for reading and processing

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

Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

SIMULTANEOUS RASTER STORE AND DISPLAY

Packit 7838c8
Packit 7838c8
Packit 7838c8
       cols="2" cellspacing="0" cellpadding="0">
Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

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

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

Packit 7838c8
Packit 7838c8
static void
Packit 7838c8
putContigAndDraw(TIFFRGBAImage* img, uint32* raster,
Packit 7838c8
    uint32 x, uint32 y, uint32 w, uint32 h,
Packit 7838c8
    int32 fromskew, int32 toskew,
Packit 7838c8
    unsigned char* cp)
Packit 7838c8
{
Packit 7838c8
    (*putContig)(img, raster, x, y, w, h, fromskew, toskew, cp);
Packit 7838c8
    if (x+w == width) {
Packit 7838c8
     w = width;
Packit 7838c8
     if (img->orientation == ORIENTATION_TOPLEFT)
Packit 7838c8
         lrectwrite(0, y-(h-1), w-1, y, raster-x-(h-1)*w);
Packit 7838c8
     else
Packit 7838c8
         lrectwrite(0, y, w-1, y+h-1, raster);
Packit 7838c8
    }
Packit 7838c8
}
Packit 7838c8
Packit 7838c8
Packit 7838c8

(the original routine provided by the library is saved in

Packit 7838c8
the variable putContig.)

Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

SUPPORTING ADDITIONAL TIFF FORMATS

Packit 7838c8
Packit 7838c8
Packit 7838c8
       cols="2" cellspacing="0" cellpadding="0">
Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

The TIFFRGBAImage routines support the most

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

Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

NOTES

Packit 7838c8
Packit 7838c8
Packit 7838c8
       cols="2" cellspacing="0" cellpadding="0">
Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

Samples must be either 1, 2, 4, 8, or 16 bits.

Packit 7838c8
Colorimetric samples/pixel must be either 1, 3, or 4 (i.e.
Packit 7838c8
SamplesPerPixel minus ExtraSamples).

Packit 7838c8
Packit 7838c8

Palette image colormaps that appear to be incorrectly

Packit 7838c8
written as 8-bit values are automatically scaled to
Packit 7838c8
16-bits.

Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

RETURN VALUES

Packit 7838c8
Packit 7838c8
Packit 7838c8
       cols="2" cellspacing="0" cellpadding="0">
Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

All routines return 1 if the operation was successful.

Packit 7838c8
Otherwise, 0 is returned if an error was encountered and
Packit 7838c8
stopOnError is zero.

Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

DIAGNOSTICS

Packit 7838c8
Packit 7838c8
Packit 7838c8
       cols="2" cellspacing="0" cellpadding="0">
Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

All error messages are directed to the

Packit 7838c8
TIFFError(3TIFF) routine.

Packit 7838c8
Packit 7838c8

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

Packit 7838c8
had BitsPerSample other than 1, 2, 4, 8, or 16.

Packit 7838c8
Packit 7838c8

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

Packit 7838c8
had SamplesPerPixel other than 1, 3, or 4.

Packit 7838c8
Packit 7838c8

Missing needed "PhotometricInterpretation"

Packit 7838c8
tag. The image did not have a tag that describes how to
Packit 7838c8
display the data.

Packit 7838c8
Packit 7838c8

No "PhotometricInterpretation" tag, assuming

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

Packit 7838c8
Packit 7838c8

No "PhotometricInterpretation" tag, assuming

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

Packit 7838c8
Packit 7838c8

No space for photometric conversion table. There

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

Packit 7838c8
Packit 7838c8

Missing required "Colormap" tag. A

Packit 7838c8
Palette image did not have a required Colormap
Packit 7838c8
tag.

Packit 7838c8
Packit 7838c8

No space for tile buffer. There was insufficient

Packit 7838c8
memory to allocate an i/o buffer.

Packit 7838c8
Packit 7838c8

No space for strip buffer. There was insufficient

Packit 7838c8
memory to allocate an i/o buffer.

Packit 7838c8
Packit 7838c8

Can not handle format. The image has a format

Packit 7838c8
(combination of BitsPerSample,
Packit 7838c8
SamplesPerPixel, and
Packit 7838c8
PhotometricInterpretation) that can not be
Packit 7838c8
handled.

Packit 7838c8
Packit 7838c8

No space for B&W mapping table. There was

Packit 7838c8
insufficient memory to allocate a table used to map
Packit 7838c8
grayscale data to <small>RGB.</small>

Packit 7838c8
Packit 7838c8

No space for Palette mapping table. There was

Packit 7838c8
insufficient memory to allocate a table used to map data to
Packit 7838c8
8-bit <small>RGB.</small>

Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

SEE ALSO

Packit 7838c8
Packit 7838c8
Packit 7838c8
       cols="2" cellspacing="0" cellpadding="0">
Packit 7838c8
Packit 7838c8
Packit 7838c8
Packit 7838c8

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

Packit 7838c8
TIFFReadRGBAImageOriented(3TIFF),
Packit 7838c8
TIFFReadRGBAStrip(3TIFF),
Packit 7838c8
TIFFReadRGBATile(3TIFF), libtiff(3TIFF)

Packit 7838c8
Packit 7838c8

Libtiff library home page:

Packit 7838c8
http://www.simplesystems.org/libtiff/

Packit 7838c8
Packit 7838c8
Packit 7838c8

Packit 7838c8
</body>
Packit 7838c8
</html>