[vtkusers] vtkImageData from pixel data
Suganthi
suganthi at softteam.com
Mon Apr 25 03:17:44 EDT 2005
Hello vtkUsers,
We are trying to obtain the vtkImageData from the byte* (24bit pixel data).
When we create a bmp file we get crash in writing a BMPFile in the method
"void vtkBMPWriter::WriteFile(ofstream *file, vtkImageData *data,int
extent[6]) "
kindly tell us what is wrong with this code, And we want to know what are
the header parameters to be set for the vtkImageData.
void CMainFrame::ImageData(byte* src)
{
vtkImageData *outData = vtkImageData::New();
byte arry[320*240*3];
memcpy(arry,src,320*240*3);
vtkImageImport *import = vtkImageImport::New();
import->SetDataExtent(0,319,0,239,0,0);
import->SetWholeExtent(0,319,0,239,0,0);
import->SetDataScalarType(VTK_UNSIGNED_CHAR);
import->SetImportVoidPointer((void*)src);
import->UpdateWholeExtent();
outData = import->GetOutput();
outData->SetNumberOfScalarComponents( 1 );
int iNo = outData->GetNumberOfScalarComponents();
WriteBMP(outData);
return;
}
void Definitions::WriteBMP(vtkImageData *source)
{
vtkBMPWriter write =vtkBMPWriter::New();
write->SetFilePrefix("C:/tested/tested");
write->SetFilePattern("%s%d.bmp");
write->SetInput(source);
write->Write();
}
regards
SoftUsers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050425/87c3c08f/attachment.htm>
More information about the vtkusers
mailing list