Received: from [192.48.153.1] by phillip.thumbsplus.com (NTMail 3.03.0013/7.aaxh) with ESMTP id pcrews for <pcrews@cerious.com>; Mon, 9 Feb 1998 12:18:38 -0400
Received: from cthulhu.engr.sgi.com (cthulhu.engr.sgi.com [192.26.80.2]) by sgi.sgi.com (950413.SGI.8.6.12/970507) via ESMTP id JAA07688; Mon, 9 Feb 1998 09:08:24 -0800
	env-from (owner-tiff@sgi.engr.sgi.com)
Received: (from majordomo-owner@localhost) by cthulhu.engr.sgi.com (950413.SGI.8.6.12/960327.SGI.AUTOCF) id HAA01684 for tiff-list; Mon, 9 Feb 1998 07:07:33 -0800
Received: from sgi.sgi.com (sgi.engr.sgi.com [192.26.80.37]) by cthulhu.engr.sgi.com (950413.SGI.8.6.12/960327.SGI.AUTOCF) via ESMTP id HAA01680 for <tiff-relay@cthulhu.engr.sgi.com>; Mon, 9 Feb 1998 07:07:31 -0800
Received: from pop.mcs.dundee.ac.uk (pop.mcs.dundee.ac.uk [134.36.32.11]) by sgi.sgi.com (950413.SGI.8.6.12/970507) via ESMTP id HAA24162
	for <tiff@sgi.com>; Mon, 9 Feb 1998 07:07:04 -0800
	env-from (amochan@mcs.dundee.ac.uk)
Received: from .dundee.ac.uk (dialin2.dundee.ac.uk [134.36.2.202])
	by pop.mcs.dundee.ac.uk (8.8.8/8.8.8/(NRD 8/1/98)) with SMTP id PAA23573;
	Mon, 9 Feb 1998 15:09:20 GMT
Message-ID: <34DF8C08.4127@mcs.dundee.ac.uk>
Date: Mon, 09 Feb 1998 15:06:48 -0800
From: Tony Mochan <amochan@mcs.dundee.ac.uk>
Reply-To: tony@mochan.demon.co.uk
Organization: University of Dundee
X-Mailer: Mozilla 3.0 (Win16; I)
MIME-Version: 1.0
To: tiff@sgi.com
CC: tony@mochan.demon.co.uk
Subject: Problem with Libtiff
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Sender: owner-tiff@fddi-sgi.sgi.com
Precedence: bulk

Hi there,

I have been trying to use libtiff to write a small program to view a
TIFF file and calculate various things using the colour of pixels.

I have been successful in viewing images that have up to 16384 pixels
(4000 Hex), but beyond that value, the image mearly repeats itself, thus
chopping off the rest of the pixels.

I'm not sure if it is when loading it in, allocating the memory or
displaying it that I'm going wrong.

Any help would be appreciated.

Code extracts follow : (raster, width and height are class variables)

/********************** OnFileOpen Function
*****************************/

// Open the TIFF file            
    		TIFF* tif=TIFFOpen(fname,"r");

    if (tif) {                    

// Get the Width and Height of the Image
	TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
	TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);
	    
// Allocate the memory for the raster
	raster = (uint32*) _TIFFmalloc(width * height * sizeof(uint32));
                         
	if (raster != NULL) {
// Read in the Image Raster
		if (TIFFReadRGBAImage(tif, width, height, raster, 1)) {
	
			// Redraw the Window			
			RedrawWindow(); 
	    }
	}
	TIFFClose(tif);
	} // End of if(tif)


/********************** OnDraw Function *****************************/

   if (raster!=NULL)             
    {                                        
		// Centre the Image
		StartPosY = (WinHeight-(int)height)/2;
		if (StartPosY<0)
			StartPosY=0;
		StartPosX = (WinWidth-(int)width)/2;
		if (StartPosX<0)
			StartPosX=0;
        
        // Draw the Image (Pixel by Pixel)
		for (uint32 y=StartPosY;y<(height+StartPosY);y++)
			for (uint32 x=StartPosX;x<(width+StartPosX);x++)
    		{
				rpixel = TIFFGetR(raster[((y-StartPosY)*width)+(x-StartPosX)]);
				gpixel = TIFFGetG(raster[((y-StartPosY)*width)+(x-StartPosX)]);
				bpixel = TIFFGetB(raster[((y-StartPosY)*width)+(x-StartPosX)]);
	    		pDC->SetPixel((int)x, (int)(WinHeight-y),
RGB(rpixel,gpixel,bpixel));
    		}
	}

Also, is there a maximum limit to the size of a TIFF file that can be
read, or does this just depend on the computer???

Thanks.

--
Tony Mochan                             amochan@mcs.dundee.ac.uk
Software Developer
Department of Orthopaedic & Trauma Surgery (University of Dundee)
Dundee Royal Infirmary
Scotland, U.K.
