<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
<br><br><div><div id="SkyDrivePlaceholder"></div>> From: cloos@jhcloos.com<br>> To: cairo@cairographics.org<br>> CC: nadeemafana@live.com<br>> Subject: Re: [cairo] TIFF files<br>> Date: Fri, 16 Mar 2012 11:11:59 -0400<br>> <br>> >>>>> "NA" == Nadeem Afana <nadeemafana@live.com> writes:<br>> <br>> NA> How can I generate TIFF files using Cairo and C/C++ in Linux?<br>> <br>> LibTiff.<br>> <br>> Libtiff is well documented (start with >>man libtiff<<. Each of the<br>> functions listed under LIST OF ROUTINES has its own man page) and comes<br>> with some example apps which help document the api.<br>> <br>> As an example, I added this to a test app to write out said app's<br>> internal CIELAB+Alpha buffer (if cairo had support for colour spaces I<br>> would have used it to write a pdf...):<br>> <br>> if (labtif) {<br>>         TIFFDefaultStripSize (labtif, height);<br>> TIFFSetField (labtif, TIFFTAG_IMAGEWIDTH, width);<br>> TIFFSetField (labtif, TIFFTAG_IMAGELENGTH, height);<br>> TIFFSetField (labtif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);<br>> TIFFSetField (labtif, TIFFTAG_SAMPLESPERPIXEL, 4);<br>> TIFFSetField (labtif, TIFFTAG_BITSPERSAMPLE, TIFFDataWidth(TIFF_DOUBLE) * 8);<br>> TIFFSetField (labtif, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB);<br>> TIFFSetField (labtif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);<br>> TIFFSetField (labtif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_CIELAB);<br>>         TIFFSetField (labtif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP);<br>>         TIFFSetField (labtif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);<br>>         TIFFSetField (labtif, TIFFTAG_ROWSPERSTRIP, height );<br>>         if (dpi > 0.) {<br>>                 TIFFSetField (labtif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);<br>>                 TIFFSetField (labtif, TIFFTAG_XRESOLUTION, dpi );<br>>                 TIFFSetField (labtif, TIFFTAG_YRESOLUTION, dpi );<br>>         }<br>>         TIFFWriteRawStrip (labtif, 0, labbuf, len * 4 * sizeof(double));<br>>         TIFFClose (labtif);<br>> }<br>> <br>> (labtiff is opened with:<br>> <br>>         labtif = TIFFOpen(optarg, "w");<br>> <br>> inside of a getopt_long(3) block)<br>> <br>> For a more portable app you'd want either to base fillorder on the<br>> hosts's endianness or ensure the buffer has matching order. You also<br>> may want to use some form of compression, etc.<br>> <br>> There are a bunch of fields to set, but the api is straitforward.<br>> <br>> -JimC<br>> -- <br>> James Cloos <cloos@jhcloos.com> OpenPGP: 1024D/ED7DAEA6<br></div>                                            </div></body>
</html>