| AWARE [SYSTEMS] | Imaging expertise for the Delphi developer | |||||||
![]() |
TIFF and LibTiff Mailing List Archive | |||||||
LibTiff Mailing List
TIFF and LibTiff Mailing List Archive Contact
The TIFF Mailing List Homepage |
Thread2006.07.21 12:40 "How to save in tiff format file?", by Toh KcHi 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
|
|||||||