2012.09.03 15:25 "[Tiff] Help Reading TIFF", by Steve Miller

2012.09.03 15:53 "Re: [Tiff] Help Reading TIFF", by David Burken

Hi Steve,

Try like this:

    unsigned short  bitsPerSample;

    if( !TIFFGetField(tiffPtr, TIFFTAG_BITSPERSAMPLE, &(bitsPerSample)) )
       bitsPerSample = 8;


On 09/03/2012 11:25 AM, Steve Miller wrote:

// TIFF.cpp: Defines the entry point for the console application.
















#pragmacomment(lib, "libtiff")

int_tmain(int argc, _TCHAR* argv[])


       TIFF *fpTIFFImage;

       unsigned int height;

       unsigned int width;

       unsigned int BitsPerSample;

       unsigned int *Image = 0;

       unsigned int *stopOnError= 0;

if(fpTIFFImage = TIFFOpen("C:\\Users\\Steve\\Gettysburg020512\\39077g25.tif", "r"))


              //height = TIFFGetField(fpTIFFImage, TIFFTAG_IMAGELENGTH);

              //width = TIFFGetField(fpTIFFImage, TIFFTAG_IMAGEWIDTH);

              height = 5529;

              width = 7079;

              BitsPerSample = TIFFGetField(fpTIFFImage,

              *Image = (unsigned
int)_TIFFmalloc(height*width*BitsPerSample*sizeof(unsigned int));

              TIFFReadRGBAImage(fpTIFFImage, width, height, Image, 0);


       return 0;


I am having trouble getting the TIFFGetField results I think I should. It
is returning a 1 and I know from ASTIFFTAG Viewer I should be getting height
of 5529 and length of 7079.

Any help would be appreciated.