[vtkusers] how to transform char* data to bitmap from vtkRenderWindow ?
louiskoo
419655660 at qq.com
Wed Sep 11 08:43:48 EDT 2013
Below is my method:
vtkRenderWindow *renWin = vtkRenderWindow::New();
//renWin->GetRenderers()->GetFirstRenderer()->SetBackground(255 , 0 ,0);
renWin->AddRenderer( ren1 );
renWin->SetSize( 200, 200 );
unsigned char* data;
*
data = renWin->GetPixelData(0 ,0 , 200 ,200 ,1);
*
int size =200;
vtkImageData *imageData = vtkImageData::New();
imageData->SetNumberOfScalarComponents(3);
imageData->SetExtent(0 ,size-1 , 0 ,size-1 ,0 ,0);
imageData->SetOrigin(0 ,0,0);
//imageData->SetSpacing(2.0 , 1.0 , 0);
//imageData->GetPointData()->SetScalars(colors);
for(int x = 0; x<size;x++)
{
for(int y =0;y<size;y++)
{
<b> imageData->SetScalarComponentFromDouble(x ,y ,0 , 0,
(double)data[x * size + y]);*
}
}
imageData->AllocateScalars();
imageData->SetScalarTypeToUnsignedChar();
imageData->Update();
vtkBMPWriter *bmpWriter = vtkBMPWriter::New();
bmpWriter->SetFileName("d:\\44.bmp");
bmpWriter->SetInput(imageData);
bmpWriter->Write();
However,the bitmap from the method is not right.
Any one can give me some idea?
--
View this message in context: http://vtk.1045678.n5.nabble.com/how-to-transform-char-data-to-bitmap-from-vtkRenderWindow-tp5723395.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list