Return-Path: <tiff-bounces@lists.maptools.org>
Received: from inas016.isp.belgacom.be (localhost [127.0.0.1])
        by inav019.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AV-3.00) with ESMTP id k6LCvKv2023741
        for <joris.at.lebbeke@skynet.be>; Fri, 21 Jul 2006 14:57:20 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from inmx016.isp.belgacom.be (inmx016.isp.belgacom.be [195.238.4.219])
        by inas016.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AS-2.03) with ESMTP id k6LCvAOe012635
        for <joris.at.lebbeke@skynet.be>; Fri, 21 Jul 2006 14:57:11 +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 k6LCv8wU029287
        for <joris.at.lebbeke@skynet.be>; Fri, 21 Jul 2006 14:57:08 +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 k6LCeOw6029249;
	Fri, 21 Jul 2006 08:40:30 -0400
Received: from web50709.mail.yahoo.com (web50709.mail.yahoo.com
	[206.190.38.250])
	by duke.maptools.org (8.12.11/8.12.10) with SMTP id k6LCeMUL029245
	for <tiff@lists.maptools.org>; Fri, 21 Jul 2006 08:40:22 -0400
Received: (qmail 74268 invoked by uid 60001); 21 Jul 2006 12:40:22 -0000
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.sg;
	h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding;
	b=wbF4LuTpSY4YMnSRq2MakpwmAV3Nx0GOPg4NWZYtzjIZMDCgyQzupAmnYk5O0LDGZgHpH3xKSdZsvfKdvpYdwi0DlWB52dsKR2NCVA1kPYl7l1YG8vTFxGL+JkHz9vnyy110gm8VJrmH9QChakjnUn43LV9uvMAVz9+88ZKlSzc=
	; 
Message-ID: <20060721124022.74266.qmail@web50709.mail.yahoo.com>
Received: from [202.156.6.68] by web50709.mail.yahoo.com via HTTP;
	Fri, 21 Jul 2006 20:40:22 CST
Date: Fri, 21 Jul 2006 20:40:22 +0800 (CST)
From: Toh kc <kach_82@yahoo.com.sg>
To: tiff@lists.maptools.org
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Subject: [Tiff] How to save in tiff format file?
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.000018ab
X-MSP-STORE: Fri, 21 Jul 2006 14:57:21 +0200
Status:   

Hi all,

I need u guys' help, I am a newbie in this area. I
want to save an image as tiff file. I have able to
save the file 
successfully. However, the saved tiff file is only
part of the image intended to save. This is my code
below. I think the error
lies in the intialisation of the array. So may I know
what would be the actual correct intialisation of it? 
Looking forward for u guys' reply. Thank you.



#define XSIZE 256
#define YSIZE 256
CString name1;
CString name2;
unsigned char array[XSIZE * YSIZE];

    for (int i = 0; i < YSIZE; i++)
            for(int j = 0; j < XSIZE; j++)
                    array[i * XSIZE + j] = (unsigned
char)(j * i);


	CFileDialog dlg(FALSE,"tif","*.tif",
		OFN_HIDEREADONLY | OFN_FILEMUSTEXIST |
OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | 
	    OFN_OVERWRITEPROMPT,
		"TIFF Files (*.tif)|*.tif|"
		"All Files (*.*)|*.*||", 
		NULL);

    char title[]= {"Save Tif Image"};
	dlg.m_ofn.lpstrTitle= title;  

    if( dlg.DoModal() == IDOK )
	{
        name1 = dlg.GetFileName();//must be filename
nt pathname==> crash
		name2.Format("image\\%s.tif",name1);//format the
file	

		TIFF* dif = TIFFOpen(name2, "w");
		TIFFSetField(dif,TIFFTAG_IMAGEWIDTH, Gwidth);//get
the imagewidth from the read file
		TIFFSetField(dif, TIFFTAG_PLANARCONFIG,1);
		TIFFSetField(dif, TIFFTAG_PHOTOMETRIC, 1);
		TIFFSetField(dif, TIFFTAG_BITSPERSAMPLE, 8);
		TIFFSetField(dif, TIFFTAG_COMPRESSION, 1);

		for (int k = 0; k < Gheight; k++)//same size of the

original image(Gheight)
		{
			TIFFWriteScanline(dif, &array[k] , k);
		}

		TIFFClose(dif);
	}
	else
		return;	 


		
__________________________________ 
The World Cup Is Now On Your Favorite Front Page 
http://www.yahoo.com.sg
_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
