AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
July 2006

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2006.07.21 12:40 "How to save in tiff format file?", by Toh Kc
2006.07.21 17:16 "Re: How to save a tiff format file?", by Bernie Pallek
2006.07.25 11:45 "Re: How to save in tiff format file?", by Gerben Vos
2006.07.25 13:41 "Re: How to save in tiff format file?", by Bernie Pallek
2006.07.30 10:36 "Re: How to save in tiff format file?", by Toh Kc
2006.07.31 13:39 "Re: How to save in tiff format file?", by Bernie Pallek
2006.08.02 02:09 "Re: How to save in tiff format file?", by Toh Kc
2006.08.02 10:14 "Re: How to save in tiff format file?", by Gerben Vos
2006.08.02 17:27 "Re: How to save in tiff format file?", by Bernie Pallek

2006.07.21 12:40 "How to save in tiff format file?", by Toh Kc

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