AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
June 1998

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



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 17:04 "Re: TIFFGetField syntax and use", by Bill Davis
1998.06.10 16:21 "Re: TIFFGetField syntax and use", by George Sazaklis

1998.06.10 16:21 "Re: TIFFGetField syntax and use", by George Sazaklis

Hi, Steve, 

The correct way to use TIFFGetField is to pass
pointers to the actual variables as function parameters. 

This is because C only supports call by value so when
you want to get a result back, you need to 
use a pointer. 

So the right way to do it is:

#include <tiffio.h>

main ()
{
	uint16 photo, bitspersample; /* uint16 is unsigned int with 2 bytes */

	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);
}

Also you should check the return value of TIFFGetField
for the case where the requested tag does not exist in the 
TIFF file. 

See the manual page for TIFFGetField 
for a list of tags and the corresponding type. 

Good luck!
George Sazaklis