Return-Path: <awaresystems.be+caf_=filtered=awaresystems.be@gmail.com>
X-Original-To: filtered@awaresystems.be
Delivered-To: filtered@awaresystems.be
Received: from mx-j.b-one.net (mx-j.one.com [91.198.169.57])
	by mail9.b-one.net (Postfix) with ESMTP id 65CB1400160
	for <filtered@awaresystems.be>; Thu, 15 Sep 2011 03:41:31 +0200 (CEST)
Received: by mx-j.b-one.net (Postfix, from userid 106)
	id 5843E1BC091; Thu, 15 Sep 2011 03:41:02 +0200 (CEST)
X-Virus-Scanned: by one.com
Received-SPF: pass (mx-j: domain of
 awaresystems.be+caf_=filtered=awaresystems.be@gmail.com designates
 74.125.82.52 as permitted sender)
X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4
Received: from mail-ww0-f52.google.com (mail-ww0-f52.google.com
 [74.125.82.52]) by mx-j.b-one.net (Postfix) with ESMTP id D72B41BC086 for
 <filtered@awaresystems.be>; Thu, 15 Sep 2011 03:41:01 +0200 (CEST)
Received: by wwj40 with SMTP id 40so2453634wwj.33 for
 <filtered@awaresystems.be>; Wed, 14 Sep 2011 18:41:01 -0700 (PDT)
Received: by 10.216.171.200 with SMTP id r50mr444489wel.90.1316050861315;
 Wed, 14 Sep 2011 18:41:01 -0700 (PDT)
X-Forwarded-To: filtered@awaresystems.be
X-Forwarded-For: awaresystems.be@gmail.com filtered@awaresystems.be
Delivered-To: awaresystems.be@gmail.com
Received: by 10.216.8.131 with SMTP id 3cs79905wer; Wed, 14 Sep 2011 18:41:00
 -0700 (PDT)
Received: by 10.216.137.76 with SMTP id x54mr2985258wei.44.1316050858864;
 Wed, 14 Sep 2011 18:40:58 -0700 (PDT)
Received-SPF: softfail (google.com: best guess record for domain of
 transitioning tiff-bounces@lists.maptools.org does not designate
 91.198.169.249 as permitted sender) client-ip=91.198.169.249;
Received: by 10.241.226.136 with POP3 id 8mf950700wyg.33; Wed, 14 Sep 2011
 18:40:58 -0700 (PDT)
X-Gmail-Fetch-Info: info@awaresystems.be 1 pop.awaresystems.be 110
 info@awaresystems.be
X-Original-To: info@awaresystems.be
Delivered-To: info@awaresystems.be
Received: from mx-r.b-one.net (mx-r.one.com [91.198.169.249]) by
 mail9.b-one.net (Postfix) with ESMTP id F21BB400160 for
 <info@awaresystems.be>; Thu, 15 Sep 2011 03:25:04 +0200 (CEST)
Received: by mx-r.b-one.net (Postfix, from userid 106) id E717550DC464; Thu,
 15 Sep 2011 03:24:52 +0200 (CEST)
X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4
Received: from lists.maptools.org (lists.maptools.org [65.39.174.144]) by
 mx-r.b-one.net (Postfix) with ESMTP id 7F78550C947A for
 <info@awaresystems.be>; Thu, 15 Sep 2011 03:24:51 +0200 (CEST)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by
 lists.maptools.org (Postfix) with ESMTP id 7011E87540; Wed, 14 Sep 2011
 20:22:14 -0500 (EST)
Received: from out01.roch.ny.frontiernet.net (out01.roch.ny.frontiernet.net
 [66.133.183.226]) by lists.maptools.org (Postfix) with ESMTP id C4C5B8751D
 for <tiff@lists.maptools.org>; Wed, 14 Sep 2011 20:20:01 -0500 (EST)
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result:
 ArMGAEVScU5BJSp1/2dsb2JhbABCmRKOPIMKQD0WGAMCAQIBWAgBAb1QhnEEjEeMFIwm
X-IronPort-AV: E=Sophos;i="4.68,384,1312156800"; d="scan'208";a="164620303"
Received: from relay04.roch.ny.frontiernet.net ([66.133.182.167]) by
 out01.roch.ny.frontiernet.net with ESMTP; 15 Sep 2011 01:20:01 +0000
X-Previous-IP: 65.37.42.117
Received: from [192.168.2.101]
 (65-37-42-117.dsl1-fairport.roch.ny.frontiernet.net [65.37.42.117]) by
 relay04.roch.ny.frontiernet.net (Postfix) with ESMTPA id BB2EB17CDB for
 <tiff@lists.maptools.org>; Thu, 15 Sep 2011 01:19:59 +0000 (UTC)
Message-ID: <4E7152B4.3080608@intielectronics.com>
Date: Wed, 14 Sep 2011 21:19:48 -0400
From: DonM <dm413-tiff@intielectronics.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20110902
 Thunderbird/6.0.2
MIME-Version: 1.0
To: tiff@lists.maptools.org
Subject: [Tiff] TIFFOpen fails on file with large image size.
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
 <mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/mailman/private/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
 <mailto:tiff-request@lists.maptools.org?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org

I am writing files using TiffWriteEncodedStrip where I write the entire image as one strip. I want to do this because it is significantly faster than writing images with multiple strips -- about 4X in my testing. I am capturing frames from a camera at 40 fps now and faster in the future so write performance is an issue.

I am able to write such files, and I can open them in a viewer (Irfanview). However, when I try to open these files myself, my application crashes in TIFFOpen. The call stack at the time of the crash seems to be corrupted. The last valid entry looks to be TiffReadDirectory, but from there it goes a little haywire. The actual crash is an assert in _fstat64.

If I change the writing to write two strips instead of 1, I have no problem opening and reading the file, but the write is about 4 times slower.

My images are 800 x 800 x 2 bytes (16 bit monochrome). I am running under Win7, VC++ 2008,32 bit, non-unicode. I have tested with both libtiff 4.0 and 3.9.5, and had the same results.

My write code looks like this:

	int width = 800;
	int height = 800;
	int depth=2;
	TIFF* tif = TIFFOpen("testimage.tiff", "w");
	if (tif)
	{
		for (int i=0; i<framecount; i++)
		{
			TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
			TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
			TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8*depth);
			TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
			TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
			TIFFSetField(tif, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);
			TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
			TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
			TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, height);
			n = TIFFWriteEncodedStrip(tif, 0, pBuffer, width*height*depth);
			n = TIFFWriteDirectory(tif);
		}		
		TIFFClose(tif);
	}

I tried changing to 8 bit depth, and still had the problem. I have also tried smaller image sizes, and still had the problem. So it doesn't appear to be an overall size issue, but rather only having one strip.

Any suggestions for what I could do to fix or work around this?

Thanks,
Don

_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
