[vtkusers] What's wrong with my codes? (convert image to BMP)
vince xu
vince_xu at hotmail.com
Wed Mar 5 03:03:04 EST 2003
I want to convert the files
quarter.1 --> quarter.1.bmp
quarter.2 --> quarter.2.bmp
quarter.3 --> quarter.3.bmp
......
and so on.(files quarter.1 quarter.2......are available in
VtkData\data\headsq which was unzipped from VTKDATA.zip)
Here is my code:
#include "vtkImageReader.h"
#include "vtkimagewriter.h"
#include "vtkbmpwriter.h"
void main()
{
vtkImageReader *reader;
vtkBMPWriter *writer;
char fname[100];
strcpy( fname,"Data/headsq/quarter" );
reader = vtkImageReader::New();
reader->SetDataByteOrderToBigEndian();
reader->SetDataExtent(0, 63, 0, 63, 1, 93);
reader->SetFilePrefix(fname);
reader->SetFilePattern("%s.%d");
reader->SetDataSpacing(3.2, 3.2, 1.5);
// reader->SetDataScalarTypeToUnsignedChar();
writer = vtkBMPWriter::New();
writer->SetFilePrefix(fname);
writer->SetFilePattern("%s.%d.BMP");
writer->SetInput(reader->GetOutput());
writer->Write();
reader->Delete();
writer->Delete();
}
The program was compiled and linked sucsessfully.
But When it runs,it says that BMPwriter only accepts unsigned char.
If I delete the "//" in the program,then I can get BMP files.
But the files are blurred.
Whats wrong with my codes? How could I get clear files?
(Images stored in quarter.* are clear)
Best Regards,
Vince
_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn
More information about the vtkusers
mailing list