10139N/A<!
DOCTYPE REFENTRY PUBLIC "-//Sun Microsystems//DTD DocBook V3.0-Based SolBook Subset V2.0//EN" [
10139N/A<!--ArborText, Inc., 1988-1999, v.4002-->
10139N/A<!
ENTITY exde-
tt "EXTENDED DESCRIPTION">
10139N/A<!
ENTITY suncopy "Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.">
10139N/A<
refentry id="TIFFRGBAImage-3tiff">
10139N/A<
refmeta><
refentrytitle>TIFFRGBAImage</
refentrytitle><
manvolnum>3tiff</
manvolnum>
10139N/A<
refmiscinfo class="date">05 Apr 2004</
refmiscinfo>
10139N/A<
refmiscinfo class="sectdesc">&man3;</
refmiscinfo>
10139N/A<
refmiscinfo class="software">&release;</
refmiscinfo>
10139N/A<
refmiscinfo class="arch">generic</
refmiscinfo>
10139N/A<
refmiscinfo class="copyright">&suncopy;</
refmiscinfo>
10139N/A<
indexterm><
primary>TIFFRGBAImage</
primary></
indexterm><
indexterm><
primary>
10139N/Aread and decode an image into a raster</
primary></
indexterm>
10139N/A<
refnamediv id="TIFFRGBAImage-3tiff-name"><
refdescriptor>TIFFRGBAImage</
refdescriptor>
10139N/A<
refname>TIFFRGBAImageBegin</
refname><
refname>TIFFRGBAImageEnd</
refname><
refname>
10139N/ATIFFRGBAImageGet</
refname><
refname>TIFFRGBAImageOK</
refname><
refname>TIFFRGBAImageOriented<?
Pub Caret>
10139N/A</
refname><
refpurpose>read and decode an image into a raster</
refpurpose>
10139N/A<
refsect1 id="TIFFRGBAImage-3tiff-synp"><
title>&synp-tt;</
title>
10139N/Atypedef unsigned char TIFFRGBValue;
10139N/Atypedef struct _TIFFRGBAImage TIFFRGBAImage;
10139N/Aint TIFFRGBAImageOK(TIFF* tif, char emsg[1024]);
10139N/Aint TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stopOnError, char emsg[1024]);
10139N/Aint TIFFRGBAImageGet(TIFFRGBAImage* img, uint32* raster, uint32 width, uint32 height);
10139N/Avoid TIFFRGBAImageEnd(TIFFRGBAImage* img);</
programlisting>
10139N/A<
refsect1 id="TIFFRGBAImage-3tiff-desc"><
title>&desc-tt;</
title>
10139N/A<
para>The routines described here provide a high-level interface through which
10139N/ATIFF images may be read into memory. Images may be strip- or tile-based and
10139N/Aand so on. Decoding state is encapsulated in a <
literal>TIFFRGBAImage</
literal>
10139N/Astructure, which makes it possible to capture state for multiple images and
10139N/Aquickly switch between them. The target raster format can be customized to
10139N/Athe needs of a particular application by installing custom routines that manipulate
10139N/Aimage data according to application requirements.</
para>
10139N/A<
para>The default usage of these routines is as follows:</
para>
10139N/A<
listitem><
para>Use <
literal>TIFFRGBAImageOK</
literal> to check whether an
10139N/Aimage can be processed.</
para></
listitem>
10139N/A<
listitem><
para>Use <
literal>TIFFRGBAImageBegin</
literal> to construct a decoder
10139N/A<
listitem><
para>Use <
literal>TIFFRGBAImageGet</
literal> to read and decode
10139N/Aan image into a target raster.</
para></
listitem>
10139N/A<
listitem><
para>Use <
literal>TIFFRGBAImageEnd</
literal> to release resources.
10139N/A<
para><
literal>TIFFRGBAImageGet</
literal> can be called multiple times to
10139N/Adecode an image using different state parameters. If multiple images are
10139N/Ato be displayed and there is not enough space for each of the decoded rasters,
10139N/Amultiple state blocks can be managed and then calls can be made to <
literal>
10139N/ATIFFRGBAImageGet</
literal> as needed to display an image.</
para>
10139N/A<
para>The generated raster is assumed to be an array of <
replaceable>width
10139N/A</
replaceable> times <
replaceable>height</
replaceable> 32-bit entries, where <
replaceable>
10139N/Awidth</
replaceable> must be less than or equal to the width of the image,
10139N/Aand <
replaceable>height</
replaceable> may be any non-zero size. If the raster
10139N/Adimensions are smaller than the image, the image data is cropped to the raster
10139N/Abounds. If the raster height is greater than that of the image, then the image
10139N/Adata is placed in the lower part of the raster. Note that the raster is assumed
10139N/Ato be organized such that the pixel at location (<
replaceable>x,y</
replaceable>)
10139N/Ais <
replaceable>raster[y*width+x]</
replaceable>, with the raster origin in
10139N/A<
refsect1 id="TIFFRGBAImage-3tiff-exde"><
title>&exde-tt;</
title>
10139N/A<
para>Raster pixels are 8-bit packed red, green, blue, alpha samples. The
10139N/Amacros <
literal>TIFFGetR</
literal>, <
literal>TIFFGetG</
literal>, <
literal>
10139N/ATIFFGetB</
literal>, and <
literal>TIFFGetA</
literal> should be used to access
10139N/Aindividual samples. Images without Associated Alpha matting information have
10139N/Aa constant Alpha of 1.0 (255).</
para>
10139N/A<
para><
literal>TIFFRGBAImageGet</
literal> converts non-8-bit images by scaling
10139N/Asample values. Palette, grayscale, bilevel, CMYK, and YCbCr images are converted
10139N/Ato RGB transparently. Raster pixels are returned uncorrected by any colorimetry
10139N/Ainformation present in the directory.</
para>
10139N/A<
para>The parameter <
literal>stopOnError</
literal> specifies how to act if
10139N/Aan error is encountered while reading the image. If <
literal>stopOnError</
literal>
10139N/Ais non-zero, then an error terminates the operation. Otherwise, <
literal>
10139N/ATIFFRGBAImageGet</
literal> continues to process data until all of the possible
10139N/Adata in the image has been requested.</
para>
10139N/A<
refsect2 id="TIFFRGBAImage-3tiff-exde-raster">
10139N/A<
title>Alternate Raster Formats</
title>
10139N/A<
para>To use the core support for reading and processing TIFF images, but
10139N/Awrite the resulting raster data in a different format, you need only override
10139N/Athe “put methods” used to store raster data. These methods are
10139N/Adefined in the <
literal>TIFFRGBAImage</
literal> structure and initially set
10139N/Aup by <
literal>TIFFRGBAImageBegin</
literal> to point to routines that pack
10139N/Araster data in the default ABGR pixel format. </
para>
10139N/A<
para>Two different routines are used according to the physical organization
10139N/Aof the image data in the file:</
para>
10139N/A<
listitem><
para>PlanarConfiguration=1 (packed samples)</
para></
listitem>
10139N/A<
listitem><
para>PlanarConfiguration=2 (separated samples). </
para></
listitem>
10139N/A<
para>Note that this mechanism can be used to transform the data before storing
10139N/Athe data in the raster. For example, you can convert data to colormap indices
10139N/Afor display on a colormap display.</
para>
10139N/A<
refsect2 id="TIFFRGBAImage-3tiff-exde-display">
10139N/A<
title>Simultaneous Raster Store and Display</
title>
10139N/A<
para>An image can be displayed as the image is being into memory by overriding
10139N/Athe put methods as described above to support alternate raster formats. Simply
10139N/Akeep a reference to the default put methods set up by <
literal>TIFFRGBAImageBegin
10139N/A</
literal> and then invoke these methods before or after each display operation.
10139N/AFor example, the <
command>tiffgt(1)</
command> utility uses the following put
10139N/Amethod to update the display as the raster is being filled:</
para>
10139N/AputContigAndDraw(TIFFRGBAImage* img, uint32* raster,
10139N/A uint32 x, uint32 y, uint32 w, uint32 h,
10139N/A (*putContig)(img, raster, x, y, w, h, fromskew, toskew, cp);
10139N/A if (img->orientation == ORIENTATION_TOPLEFT)
10139N/A lrectwrite(0, y-(h-1), w-1, y, raster-x-(h-1)*w);
10139N/A lrectwrite(0, y, w-1, y+h-1, raster);
10139N/A<
para>The original routine provided by the library is saved in the variable <
literal>
10139N/A<
refsect2 id="TIFFRGBAImage-3tiff-exde-tiff">
10139N/A<
title>Supporting Additional TIFF Formats</
title>
10139N/A<
para>The <
literal>TIFFRGBAImage</
literal> routines support the most commonly
10139N/Aencountered flavors of TIFF. You can extend this support by overriding the “get
10139N/Amethod” invoked by <
literal>TIFFRGBAImageGet</
literal> to read TIFF
10139N/Aimage data. Details of how to do this can be quite involved, it is best to
10139N/Amake a copy of an existing get method and modify to suit the needs of an application.
10139N/A<
refsect2 id="TIFFRGBAImage-3tiff-exde-diags">
10139N/A<
para>All error messages are directed to the <
literal>TIFFError(3tiff)</
literal>
10139N/A<
variablelist termlength="wholeline">
10139N/A<
varlistentry><
term>Sorry, can not handle %d-bit pictures.</
term><
listitem>
10139N/A<
para>The image has a <
literal>BitsPerSample</
literal> value other than 1,
10139N/A<
varlistentry><
term>Sorry, can not handle %d-channel images.</
term><
listitem>
10139N/A<
para>The image has a <
literal>SamplesPerPixel</
literal> value other than
10139N/A<
varlistentry><
term>Missing needed "PhotometricInterpretation" tag.</
term>
10139N/A<
listitem><
para>The image does not have a tag that describes how to display
10139N/A<
varlistentry><
term>No "PhotometricInterpretation" tag, assuming RGB.</
term>
10139N/A<
listitem><
para>The image does not have a tag that describes how to display
10139N/A<
varlistentry><
term>No "PhotometricInterpretation" tag, assuming min-is-black.
10139N/A</
term><
listitem><
para>The image does not have a tag that describes how to
10139N/Adisplay the data, but is assumed to be a grayscale or bilevel image because
10139N/A<
varlistentry><
term>No space for photometric conversion table.</
term><
listitem>
10139N/A<
para>There is insufficient memory for a table needed to convert image samples
10139N/A<
varlistentry><
term>Missing required "Colormap" tag.</
term><
listitem><
para>
10139N/AA Palette image does not have a required <
literal>Colormap</
literal> tag.
10139N/A<
varlistentry><
term>No space for tile buffer.</
term><
listitem><
para>There
10139N/Ais insufficient memory to allocate an i/o buffer.</
para>
10139N/A<
varlistentry><
term>No space for strip buffer.</
term><
listitem><
para>There
10139N/Ais insufficient memory to allocate an i/o buffer.</
para>
10139N/A<
varlistentry><
term>Can not handle format.</
term><
listitem><
para>The image
10139N/Ahas a format (combination of <
literal>BitsPerSample</
literal>, <
literal>SamplesPerPixel
10139N/A</
literal>, and <
literal>PhotometricInterpretation</
literal>) that <
literal>
10139N/ATIFFReadRGBAImage</
literal> cannot process.</
para>
10139N/A<
varlistentry><
term>No space for B&W mapping table.</
term><
listitem><
para>
10139N/AThere is insufficient memory to allocate a table needed to map grayscale data
10139N/A<
varlistentry><
term>No space for Palette mapping table.</
term><
listitem><
para>
10139N/AThere is insufficient memory to allocate a table needed to map data to 8-bit
10139N/A<
refsect1 id="TIFFRGBAImage-3tiff-rtrn"><
title>&rtrn-tt;</
title>
10139N/A<
para>All routines return 1 if the operation was successful. Otherwise, 0
10139N/Ais returned if an error was encountered and <
literal>stopOnError</
literal>
10139N/A<
refsect1 id="TIFFRGBAImage-3tiff-attr"><
title>&attr-tt;</
title>
10139N/A<
para>See <
olink targetdocent="REFMAN5" localinfo="attributes-5"><
citerefentry>
10139N/A<
refentrytitle>attributes</
refentrytitle><
manvolnum>5</
manvolnum></
citerefentry></
olink>
10139N/Afor descriptions of the following attributes:</
para>
10139N/A<
tgroup cols="2" colsep="1" rowsep="1"><
colspec colname="COLSPEC0" colwidth="1*">
10139N/A<
colspec colname="COLSPEC1" colwidth="1*">
10139N/A<
row><
entry align="center" valign="middle">ATTRIBUTE TYPE</
entry><
entry align="center" 10139N/Avalign="middle">ATTRIBUTE VALUE</
entry></
row>
10139N/A<
row><
entry><
para>Availability</
para></
entry><
entry><
para>SUNWTiff</
para></
entry>
10139N/A<
row><
entry colname="COLSPEC0"><
para>Interface stability</
para></
entry><
entry 13623N/Acolname="COLSPEC1"><
para>Uncommitted</
para></
entry></
row>
10139N/A<
refsect1 id="TIFFRGBAImage-3tiff-also"><
title>&also-tt;</
title>
10139N/A<!--Reference to another man page--> 10139N/A<!--Reference to a Help manual--> 10139N/A<
para><
citerefentry><
refentrytitle>libtiff</
refentrytitle><
manvolnum>3</
manvolnum>
10139N/A</
citerefentry>, <
citerefentry><
refentrytitle>TIFFOpen</
refentrytitle><
manvolnum>
10139N/A3tiff</
manvolnum></
citerefentry>, <
citerefentry><
refentrytitle>TIFFReadRGBAImage
10139N/A</
refentrytitle><
manvolnum>3tiff</
manvolnum></
citerefentry>, <
citerefentry>
10139N/A<
refentrytitle>TIFFReadRGBAStrip</
refentrytitle><
manvolnum>3tiff</
manvolnum>
10139N/A</
citerefentry>, <
citerefentry><
refentrytitle>TIFFReadRGBATile</
refentrytitle>
10139N/A<
manvolnum>3tiff</
manvolnum></
citerefentry></
para>
10139N/A<
refsect1 id="TIFFRGBAImage-3tiff-note"><
title>¬e-tt;</
title>
10139N/Amust be either 1, 3, or 4 (that is, <
literal>SamplesPerPixel</
literal> minus <
literal>
10139N/A<
para>Palette image colormaps that appear to be incorrectly written as 8-bit
10139N/Avalues are automatically scaled to 16-bits.</
para>
10139N/A<
para>Orientations other than bottom-left or top-left are not processed correctly.
10139N/A<
para>This man page was originally written by Sam Leffler. Updated by Breda
10139N/AMcColgan, Sun Microsystems Inc., 2004.</
para>