2007.10.29 15:21 "[Tiff] rookie question", by Ron Croonenberg

2007.11.15 14:42 "Re: [Tiff] Simple code to write Tiff images from Raw data", by Ron Croonenberg

Hello Jason,

I am very new to using libTiff, I bearly know what I am doing really. The thing is that someone was really friendly and gave me a code snippet

  that I use to create tiff files.

Someone on the list suggested to create a tiffinfo report. (As soon as I figured out how to do that I'll post one)

this is what I have/use for creating tiffs:

TIFFSetField (tif, TIFFTAG_IMAGEWIDTH, horiz);

TIFFSetField (tif, TIFFTAG_IMAGELENGTH, vertic);

         TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
         TIFFSetField (tif, TIFFTAG_SAMPLESPERPIXEL,  3);
         TIFFSetField (tif, TIFFTAG_BITSPERSAMPLE,    8);
         TIFFSetField (tif, TIFFTAG_EXTRASAMPLES,     0, NULL);
         TIFFSetField (tif, TIFFTAG_ORIENTATION,      ORIENTATION_TOPLEFT);
         TIFFSetField (tif, TIFFTAG_PHOTOMETRIC,      PHOTOMETRIC_RGB);

TIFFSetField (tif, TIFFTAG_IMAGEDESCRIPTION, "Cluster computing");

         TIFFSetField (tif, TIFFTAG_COMPRESSION,      COMPRESSION_DEFLATE);
         TIFFSetField (tif, TIFFTAG_PREDICTOR,        1 /* experiment */);

         TIFFSetField (tif, TIFFTAG_ROWSPERSTRIP,     16);

thanks,

Ron

Jason Tillett wrote:
> Here is my simple code snippet.
> I have not had any compatibility problems
> but maybe I just got lucky so far...
>
> TIFF *out=TIFFOpen(fn,"w");
> int width=nx;int height=ny;int sampleperpixel=1; //RGBA=4 bw/gray=1
> TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width);
> TIFFSetField(out, TIFFTAG_IMAGELENGTH, height);
> TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
> TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
> TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8);
> TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, sampleperpixel);
> TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, ny);
> // Write the information to the tiff file
> if(TIFFWriteEncodedStrip(out, 0, a, width * height * sampleperpixel) == 0){
> fprintf(stderr, "Could not write image\n");
> }
> TIFFClose(out);
>

--

=================================================================
  Ron Croonenberg                   |
                                    | Phone: 1 765 658 4761
  Lab Instructor &                  | Fax:   1 765 658 4732
          Technology Coordinator    |
                                    |
  Department of Computer Science    | e-mail: ronc@DePauw.edu
  DePauw University                 |
  275 Julian Science & Math Center  |
  602 South College Ave.            |
  Greencastle, IN  46135            |
=================================================================