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