kusano 7d535a
.\" $Id: TIFFReadRGBATile.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 TIFFReadRGBATile 3TIFF "December 10, 1998" "libtiff"
kusano 7d535a
.SH NAME
kusano 7d535a
TIFFReadRGBATile \- read and decode an image tile into a fixed-format raster
kusano 7d535a
.SH SYNOPSIS
kusano 7d535a
.B "#include <tiffio.h>"</tiffio.h>
kusano 7d535a
.sp
kusano 7d535a
.B "#define TIFFGetR(abgr)	((abgr) & 0xff)"
kusano 7d535a
.br
kusano 7d535a
.B "#define TIFFGetG(abgr)	(((abgr) >> 8) & 0xff)"
kusano 7d535a
.br
kusano 7d535a
.B "#define TIFFGetB(abgr)	(((abgr) >> 16) & 0xff)"
kusano 7d535a
.br
kusano 7d535a
.B "#define TIFFGetA(abgr)	(((abgr) >> 24) & 0xff)"
kusano 7d535a
.sp
kusano 7d535a
.BI "int TIFFReadRGBATile(TIFF *" tif ", uint32 " x ", uint32 " y ", uint32 *" raster ")"
kusano 7d535a
.SH DESCRIPTION
kusano 7d535a
.IR TIFFReadRGBATile
kusano 7d535a
reads a single tile of a tile-based image into memory, storing the result in
kusano 7d535a
the user supplied RGBA
kusano 7d535a
.IR raster .
kusano 7d535a
The raster is assumed to be an array of width times length 32-bit entries,
kusano 7d535a
where width is the width of a tile (TIFFTAG_TILEWIDTH) and length is the
kusano 7d535a
height of a tile (TIFFTAG_TILELENGTH). 
kusano 7d535a
kusano 7d535a
.PP
kusano 7d535a
The 
kusano 7d535a
.IR x
kusano 7d535a
and 
kusano 7d535a
.IR y
kusano 7d535a
values are the offsets from the top left corner to the top left corner of the
kusano 7d535a
tile to be read.  They must be an exact multiple of the tile width and length. 
kusano 7d535a
kusano 7d535a
.PP
kusano 7d535a
Note that the raster is assume to be organized such that the pixel at location
kusano 7d535a
(\fIx\fP,\fIy\fP) is \fIraster\fP[\fIy\fP*\fIwidth\fP+\fIx\fP]; with the
kusano 7d535a
raster origin in the 
kusano 7d535a
.I lower-left hand corner
kusano 7d535a
of the tile. That is bottom to top organization.  Edge tiles which partly fall
kusano 7d535a
off the image will be filled out with appropriate zeroed areas.
kusano 7d535a
kusano 7d535a
.PP
kusano 7d535a
Raster pixels are 8-bit packed red, green, blue, alpha samples. 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. Images without Associated Alpha
kusano 7d535a
matting information have a constant Alpha of 1.0 (255).
kusano 7d535a
.PP
kusano 7d535a
See the 
kusano 7d535a
.IR TIFFRGBAImage (3TIFF) 
kusano 7d535a
page for more details on how various image types are converted to RGBA values.
kusano 7d535a
.SH NOTES
kusano 7d535a
Samples must be either 1, 2, 4, 8, or 16 bits. Colorimetric samples/pixel must
kusano 7d535a
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 as 8-bit values
kusano 7d535a
are automatically scaled to 16-bits.
kusano 7d535a
.PP
kusano 7d535a
.I TIFFReadRGBATile
kusano 7d535a
is just a wrapper around the more general
kusano 7d535a
.IR TIFFRGBAImage (3TIFF)
kusano 7d535a
facilities.  It's main advantage over the similar 
kusano 7d535a
.IR TIFFReadRGBAImage() 
kusano 7d535a
function is that for large images a single buffer capable of holding the whole
kusano 7d535a
image doesn't need to be allocated, only enough for one tile.  The 
kusano 7d535a
.IR TIFFReadRGBAStrip() 
kusano 7d535a
function does a similar operation for stripped images.
kusano 7d535a
.SH "RETURN VALUES"
kusano 7d535a
1 is returned if the image was successfully read and converted.
kusano 7d535a
Otherwise, 0 is returned if an error was encountered.
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 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, but because it
kusano 7d535a
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
kusano 7d535a
.I TIFFReadRGBAImage
kusano 7d535a
can not handle.
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 data to 8-bit
kusano 7d535a
.SM RGB.
kusano 7d535a
.SH "SEE ALSO"
kusano 7d535a
.BR TIFFOpen (3TIFF),
kusano 7d535a
.BR TIFFRGBAImage (3TIFF),
kusano 7d535a
.BR TIFFReadRGBAImage (3TIFF),
kusano 7d535a
.BR TIFFReadRGBAStrip (3TIFF),
kusano 7d535a
.BR libtiff (3TIFF)
kusano 7d535a
.PP
kusano 7d535a
Libtiff library home page:
kusano 7d535a
.BR http://www.remotesensing.org/libtiff/