AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

1998.06.10 15:00 "TIFFGetField syntax and use", by Steve Garcia
1998.06.10 15:54 "RE: TIFFGetField syntax and use", by Frank Kim
1998.06.10 16:09 "Re: TIFFGetField syntax and use", by Steven Michael Garcia
1998.06.10 16:21 "Re: TIFFGetField syntax and use", by George Sazaklis
1998.06.10 17:04 "RE: TIFFGetField syntax and use", by Bill Davis

1998.06.10 16:09 "Re: TIFFGetField syntax and use", by Steven Michael Garcia

try this:

#include <tiffio.h>
int photo, bitspersample;

main ()
{
        TIFF *tif = TIFFOpen("myfile.tif", "r");
        TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photo);
        TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitspersample);
        printf("Photo = %d, Bits/Sample = %d", photo, bitspersample);
        TIFFClose(tif);
}

by the way, i suggest moving to C++ instead of C. much better language.

then for printing you can do this:

cout << "Photo = " << photo << ", Bits/Sample = " << bitspersample << endl;

see how you don't have to worry about the type of the data you are printing. :-)

After reading more of the man pages, I tried what you suggested above, by sending the memory address. Yet when I print out the photo and bits/sample values, I get some awfully large numbers which I presume are memory address locations like:

Photo = 4259841
Bits/Sample = 4259848

The funny thing is I have used TIFFGetField for other tags, and it seems to work just fine. For instance I did

TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &length);
printf("Image Length = %d", length);

and I get a correct printout. I passed it the memory location and I was able to access the value at that memory location (I retrieved 261). So I'm wondering if there is something screwed up about the PHOTOMETRIC and BITSPERSAMPLE tags which may not exist with other tags.

Anyone else seen this problem? Is there a completely different way of accessing the data in those tags I mentioned above?

BTW, I plan on learning C++ soon...I know the advantages are numerous, I just wanted to learn C first (I think on recommendation). :-) Then I can learn great things like Java, etc.

Steve

    /\         /^\   
   /^^\       /^^^\ 
  /    \/^\  /     \    
 /      \  \/       \  Steven Garcia        Graduate School, Bioengineering 
/        \  \        \ steveg@engin.umich.edu              Univ. of Michigan