Received: from [192.48.153.1] by phillip.thumbsplus.com (NTMail 3.03.0017/7.aaxh) with ESMTP id pcrews for <pcrews@cerious.com>; Wed, 10 Jun 1998 13:42:47 -0400
Received: from cthulhu.engr.sgi.com (cthulhu.engr.sgi.com [192.26.80.2]) by sgi.sgi.com (980309.SGI.8.8.8-aspam-6.2/980304.SGI-aspam: SGI does not authorize the use of its proprietary systems or networks for unsolicited or bulk email from the Internet.) via ESMTP id KAA02736; Wed, 10 Jun 1998 10:28:59 -0700 (PDT)
	mail_from (owner-tiff@sgi.engr.sgi.com)
Received: (from majordomo-owner@localhost)
	by cthulhu.engr.sgi.com (980427.SGI.8.8.8/970903.SGI.AUTOCF)
	id KAA28261
	for tiff-list;
	Wed, 10 Jun 1998 10:05:00 -0700 (PDT)
	mail_from (owner-tiff@sgi.sgi.com)
Received: from sgi.sgi.com (sgi.engr.sgi.com [192.26.80.37])
	by cthulhu.engr.sgi.com (980427.SGI.8.8.8/970903.SGI.AUTOCF)
	via ESMTP id KAA76739
	for <tiff-relay@cthulhu.engr.sgi.com>;
	Wed, 10 Jun 1998 10:04:57 -0700 (PDT)
	mail_from (owner-tiff@sgi.sgi.com)
Received: from suw3svr01.hisd.harris.com (suw3svr01.hisd.harris.com [158.147.19.67]) by sgi.sgi.com (980309.SGI.8.8.8-aspam-6.2/980304.SGI-aspam: SGI does not authorize the use of its proprietary systems or networks for unsolicited or bulk email from the Internet.) via ESMTP id KAA19588
	for <tiff@sgi.com>; Wed, 10 Jun 1998 10:04:54 -0700 (PDT)
	mail_from (wdavis@hisd.harris.com)
Received: from suw3stt06 (suw3stt06 [158.147.19.124])
          by suw3svr01.hisd.harris.com (8.8.4/8.8.4/jjs) with SMTP
	  id NAA13271; Wed, 10 Jun 1998 13:04:18 -0400 (EDT)
From: Bill Davis <wdavis@hisd.harris.com>
Received: by suw3stt06 (SMI-8.6) id NAA11524; Wed, 10 Jun 1998 13:04:18 -0400
Date: Wed, 10 Jun 1998 13:04:18 -0400
Message-Id: <199806101704.NAA11524@suw3stt06>
To: steveg@engin.umich.edu, tiff@sgi.com, Frank.Kim@NetCentric.com
Subject: RE: TIFFGetField syntax and use
X-Sun-Charset: US-ASCII
Sender: owner-tiff@fddi-sgi.sgi.com
Precedence: bulk


> From Frank.Kim@NetCentric.com Wed Jun 10 12:40:18 1998
> From: Frank Kim <Frank.Kim@NetCentric.com>
> To: "'Steve Garcia'" <steveg@engin.umich.edu>, tiff@sgi.com
> Subject: RE: TIFFGetField syntax and use
> Date: Wed, 10 Jun 1998 11:54:11 -0400
> MIME-Version: 1.0
> X-Mailer: Internet Mail Service (5.0.1460.8)
> Sender: owner-tiff@fddi-sgi.sgi.com
> 
> try this:
> 
> #include <tiffio.h>
> int photo, bitspersample;

Change the line above to:
  short photo, bitspersample;

> main ()
> {
> 	TIFF *tif = TIFFOpen("myfile.tif", "r");
> 	TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photo);

Note the change to add the & on the variable.  You are passing
an address and it is important to pass the address of something
that is the proper size.  An int and short will not be the same
size on every compiler.  A 16 bit compiler usually has int=16 and
short=16 but a 32 bit compiler usually has int=32 and short=16.
Pointing at an int will work if:
 1) the int has been initialized to zero
 2) the value being read is not negative
 3) the byte order on the machine is the right one to have
    a pointer to an int point at the low order two bytes
    of the int so it is also a pointer to a short
So, don't use an int where a short is called for by the spec.
The spec I referenced said short.  Someone correct me if that
has changed.

Bill Davis

> 	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.
> :-)
> 
> 
> -----Original Message-----
> From: Steve Garcia [mailto:steveg@engin.umich.edu]
> Sent: Wednesday, June 10, 1998 11:00 AM
> To: tiff@sgi.com
> Subject: TIFFGetField syntax and use
> 
> 
> I want to retrieve the value of the tag's PHOTOMETRIC and BITSPERSAMPLE.
> I'm presuming that it is easiest to use the TIFFGetField function to do
> this,
> but I'm not having any real success.  I'm using tiff-v3.4.
> 
> I'm not sure I understand the syntax of the function properly.  My code 
> (truncated for e-mail purposes) is as follows:
> 
> #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);
> }
> 
> Now I know I'm getting the memory address when I print out the "photo"
> and "bitspersample", yet I can't seem to retrieve the actual value that the
> Tags contain.  
> 
> Any suggestions?  First major C program I'm trying to write (still a novice
> at this) but I really like this programming stuff.  Thanks for any 
> suggestions!
> 
> Steve
> 		
>     /\         /^\    Steven Garcia	    Graduate School, Bioengineering
>    /^^\       /^^^\   steveg@engin.umich.edu              Univ. of Michigan
>   /    \/^\  /     \      
>  /      \  \/       \                          
> /  	 \  \	     \	   	         "I AM the last one!" - Dragonheart 
> 
