Return-Path: <tiff-bounces@lists.maptools.org>
Received: from inas017.isp.belgacom.be (localhost [127.0.0.1])
        by inav009.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AV-3.00) with ESMTP id k72Hwg4u020738
        for <joris.at.lebbeke@skynet.be>; Wed, 2 Aug 2006 19:58:43 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from inmx016.isp.belgacom.be (inmx016.isp.belgacom.be [195.238.4.219])
        by inas017.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AS-2.03) with ESMTP id k72HwWeX025337
        for <joris.at.lebbeke@skynet.be>; Wed, 2 Aug 2006 19:58:40 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (r153.dmsolutions.ca [209.217.116.153] (may be forged))
        by inmx016.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-2.32) with ESMTP id k72HwT7W025614
        for <joris.at.lebbeke@skynet.be>; Wed, 2 Aug 2006 19:58:30 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (duke.maptools.org [127.0.0.1])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id k72Haptu003288;
	Wed, 2 Aug 2006 13:37:24 -0400
Received: from scmze001.ssan.egs-seg.gc.ca (scmze001.ssan.egs-seg.gc.ca
	[205.194.19.85])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id k72Ham1M003285
	for <tiff@lists.maptools.org>; Wed, 2 Aug 2006 13:36:48 -0400
Received: from bulwark1.ic.gc.ca ([192.197.178.1])
	by scmze001.ssan.egs-seg.gc.ca with ESMTP; 02 Aug 2006 13:27:13 -0400
Received: from msg-gate1.ic.gc.ca ([142.53.11.41]) by bulwark1.ic.gc.ca
	via smtpd (for scmze001.ssan.egs-seg.gc.ca [205.194.19.85]) with ESMTP;
	Wed, 2 Aug 2006 13:27:13 -0400
Received: from parapet11.ic.gc.ca (parapet11.ic.gc.ca [142.53.11.253])
	by msg-gate1.ic.gc.ca (Switch-3.1.8/Switch-3.1.7) with ESMTP id
	k72HRDZs014161
	for <tiff@lists.maptools.org>; Wed, 2 Aug 2006 13:27:13 -0400 (EDT)
Received: from msg-con2.icent.ic.gc.ca by parapet11.ic.gc.ca
	via smtpd (for msg-gate1.ic.gc.ca [142.53.11.41]) with ESMTP;
	Wed, 2 Aug 2006 13:27:13 -0400
Received: from msg-con1.icent.ic.gc.ca ([142.53.28.148]) by
	msg-con2.icent.ic.gc.ca with Microsoft SMTPSVC(6.0.3790.211); 
	Wed, 2 Aug 2006 13:27:13 -0400
Received: from msg-mb2.icent.ic.gc.ca ([142.53.28.151]) by
	msg-con1.icent.ic.gc.ca with Microsoft SMTPSVC(6.0.3790.211); 
	Wed, 2 Aug 2006 13:27:13 -0400
X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0
Content-class: urn:content-classes:message
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Subject: RE: [Tiff] How to save in tiff format file?
Date: Wed, 2 Aug 2006 13:27:12 -0400
Message-ID: <F78E6BBD22A6FC4489EBE250454079080559254E@msg-mb2.icent.ic.gc.ca>
In-Reply-To: <20060802020937.42718.qmail@web50714.mail.yahoo.com>
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
Thread-Topic: [Tiff] How to save in tiff format file?
Thread-Index: Aca12LW561Z8cS/tTyG0T/A9jlU55QAbShRg
From: "Pallek, Bernie: #CIPO - OPIC" <Pallek.Bernie@ic.gc.ca>
To: "Tiff \(E-mail\)" <tiff@lists.maptools.org>
X-OriginalArrivalTime: 02 Aug 2006 17:27:13.0390 (UTC)
	FILETIME=[E48470E0:01C6B658]
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by duke.maptools.org id
	k72Ham1M003285
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.4
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>
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org
X-UIDL: 000000000023ceae.00001923
X-MSP-STORE: Wed, 02 Aug 2006 19:58:50 +0200
Status:   

Toh wrote:
> for (int i = 0; i < Gheight; i++)
>    for(int j = 0; j < Gwidth; j++)
>         sImg[i * Gwidth + j] = (unsigned char)(j * i);

Perhaps try something a little more "visually obvious", like:

memset(sImg, 0, Gheight * Gwidth); // clear to black (photometric == min-is-black)
int iMax = min(Gheight, Gwidth);
for (int i = 0; i < iMax; ++i)
	sImg[i * Gwidth + i] = 255; // diagonal line of white

Now, if the line is distorted, the "way" in which it is distorted may help you figure out where the problem lies.  For example, with the original indexing error ("TIFFWriteScanline(dif, &array[k] , k);"), instead of the start of each scanline, a pointer to the next pixel of the first scanline is passed.  This results in a vertical line if you've set up your array as I described.

You could also try gradients (e.g. each pixel in a line containing the same pixel colour, but each line using an incrementing colour), corners, etc.

If you've reached the point where theoretically everything is correct (i.e. you've stepped through the code in your imagination, picturing each stage, etc), and it's *still* misbehaving, send me as much of the complete routine as you are able, and I'll take a look at it when I get a chance.  Or maybe you have some co-workers or nearby friends who could look at it; often a fresh pair of eyes is all that's needed to catch a minor mistake with major effects.

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