Blame html/man/TIFFRGBAImage.3tiff.html

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

TIFFRGBAImage

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

Packit Service 2594b8
Packit Service 2594b8

NAME

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
       cols="2" cellspacing="0" cellpadding="0">
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

TIFFRGBAImageOK, TIFFRGBAImageBegin, TIFFRGBAImageGet,

Packit Service 2594b8
TIFFRGBAImageEnd − read and decode an image into a
Packit Service 2594b8
raster

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

SYNOPSIS

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
       cols="2" cellspacing="0" cellpadding="0">
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

#include <tiffio.h>

Packit Service 2594b8
Packit Service 2594b8

typedef unsigned char TIFFRGBValue; typedef struct

Packit Service 2594b8
_TIFFRGBAImage TIFFRGBAImage;

Packit Service 2594b8
Packit Service 2594b8

int TIFFRGBAImageOK(TIFF *tif, char

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

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

DESCRIPTION

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
       cols="2" cellspacing="0" cellpadding="0">
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

The routines described here provide a high-level

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

Packit Service 2594b8
Packit Service 2594b8

The default usage for these routines is: check if an

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

Packit Service 2594b8
Packit Service 2594b8

The generated raster is assumed to be an array of

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

Packit Service 2594b8
Packit Service 2594b8

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

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

Packit Service 2594b8
Packit Service 2594b8

TIFFRGBAImageGet converts non-8-bit images by

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

Packit Service 2594b8
Packit Service 2594b8

The parameter stopOnError specifies how to act if

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

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

ALTERNATE RASTER FORMATS

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
       cols="2" cellspacing="0" cellpadding="0">
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

To use the core support for reading and processing

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

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

SIMULTANEOUS RASTER STORE AND DISPLAY

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
       cols="2" cellspacing="0" cellpadding="0">
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

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

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

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

(the original routine provided by the library is saved in

Packit Service 2594b8
the variable putContig.)

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

SUPPORTING ADDITIONAL TIFF FORMATS

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
       cols="2" cellspacing="0" cellpadding="0">
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

The TIFFRGBAImage routines support the most

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

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

NOTES

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
       cols="2" cellspacing="0" cellpadding="0">
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

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

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

Packit Service 2594b8
Packit Service 2594b8

Palette image colormaps that appear to be incorrectly

Packit Service 2594b8
written as 8-bit values are automatically scaled to
Packit Service 2594b8
16-bits.

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

RETURN VALUES

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
       cols="2" cellspacing="0" cellpadding="0">
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

All routines return 1 if the operation was successful.

Packit Service 2594b8
Otherwise, 0 is returned if an error was encountered and
Packit Service 2594b8
stopOnError is zero.

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

DIAGNOSTICS

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
       cols="2" cellspacing="0" cellpadding="0">
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

All error messages are directed to the

Packit Service 2594b8
TIFFError(3TIFF) routine.

Packit Service 2594b8
Packit Service 2594b8

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

Packit Service 2594b8
had BitsPerSample other than 1, 2, 4, 8, or 16.

Packit Service 2594b8
Packit Service 2594b8

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

Packit Service 2594b8
had SamplesPerPixel other than 1, 3, or 4.

Packit Service 2594b8
Packit Service 2594b8

Missing needed "PhotometricInterpretation"

Packit Service 2594b8
tag. The image did not have a tag that describes how to
Packit Service 2594b8
display the data.

Packit Service 2594b8
Packit Service 2594b8

No "PhotometricInterpretation" tag, assuming

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

Packit Service 2594b8
Packit Service 2594b8

No "PhotometricInterpretation" tag, assuming

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

Packit Service 2594b8
Packit Service 2594b8

No space for photometric conversion table. There

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

Packit Service 2594b8
Packit Service 2594b8

Missing required "Colormap" tag. A

Packit Service 2594b8
Palette image did not have a required Colormap
Packit Service 2594b8
tag.

Packit Service 2594b8
Packit Service 2594b8

No space for tile buffer. There was insufficient

Packit Service 2594b8
memory to allocate an i/o buffer.

Packit Service 2594b8
Packit Service 2594b8

No space for strip buffer. There was insufficient

Packit Service 2594b8
memory to allocate an i/o buffer.

Packit Service 2594b8
Packit Service 2594b8

Can not handle format. The image has a format

Packit Service 2594b8
(combination of BitsPerSample,
Packit Service 2594b8
SamplesPerPixel, and
Packit Service 2594b8
PhotometricInterpretation) that can not be
Packit Service 2594b8
handled.

Packit Service 2594b8
Packit Service 2594b8

No space for B&W mapping table. There was

Packit Service 2594b8
insufficient memory to allocate a table used to map
Packit Service 2594b8
grayscale data to <small>RGB.</small>

Packit Service 2594b8
Packit Service 2594b8

No space for Palette mapping table. There was

Packit Service 2594b8
insufficient memory to allocate a table used to map data to
Packit Service 2594b8
8-bit <small>RGB.</small>

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

SEE ALSO

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
       cols="2" cellspacing="0" cellpadding="0">
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

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

Packit Service 2594b8
TIFFReadRGBAImageOriented(3TIFF),
Packit Service 2594b8
TIFFReadRGBAStrip(3TIFF),
Packit Service 2594b8
TIFFReadRGBATile(3TIFF), libtiff(3TIFF)

Packit Service 2594b8
Packit Service 2594b8

Libtiff library home page:

Packit Service 2594b8
http://www.simplesystems.org/libtiff/

Packit Service 2594b8
Packit Service 2594b8
Packit Service 2594b8

Packit Service 2594b8
</body>
Packit Service 2594b8
</html>