2002.09.04 13:15 "Trouble setting BitsPerSample to 8", by Brian Stains

2002.09.04 13:15 "Trouble setting BitsPerSample to 8", by Brian Stains

When I write an RGB TIFF using the following code, BitsPerSample in the resulting file is always 0,0,0. I must be missing something. Does anyone see my problem?

I can successfully write an image with BitsPerSample = 1, SamplesPerPixel = 1, PhotoMetric = MinIsBlack, and other fields as below. (Setting data is, of course, different in this case.) BitsPerSample in the resulting file is correctly set to 1.

Thanks,
Brian Stains

I'm working on WindowsNT.

TIFF* tifOut = TIFFOpen("e:\\images\\tif\\newtif.tif","w");
TIFFSetField(tifOut,TIFFTAG_IMAGEWIDTH,w);
TIFFSetField(tifOut,TIFFTAG_IMAGELENGTH,h);
TIFFSetField(tifOut,TIFFTAG_BITSPERSAMPLE,8);
TIFFSetField(tifOut,TIFFTAG_COMPRESSION,COMPRESSION_NONE);
TIFFSetField(tifOut,TIFFTAG_PHOTOMETRIC,PHOTOMETRIC_RGB);
TIFFSetField(tifOut,TIFFTAG_SAMPLESPERPIXEL, 3);
TIFFSetField(tifOut,TIFFTAG_PLANARCONFIG,PLANARCONFIG_CONTIG);

// write data with TIFFWriteScanline(...)
// I can see that the data is OK because the Wang Imaging app will display this TIF,
// in spite of the incorrect BitsPerSample in the output file.

TIFFClose(tifOut);