Re: TIFF files
Nadeem Afana <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <[email protected]> |
> From: [email protected] > To: [email protected] > CC: [email protected] > Subject: Re: [cairo] TIFF files > Date: Fri, 16 Mar 2012 11:11:59 -0400 > > >>>>> "NA" == Nadeem Afana <[email protected]> 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 <[email protected]> OpenPGP: 1024D/ED7DAEA6 -- cairo mailing list [email protected] http://lists.cairographics.org/mailman/listinfo/cairo