[vtkusers] Re: Is there anyone who knows how to load a image file asbackground in a RenderWindow?
york
yorktim at bit.edu.cn
Fri Nov 19 00:06:01 EST 2004
Hi Good Win,
I have resolved the problem by your advise and translate
the code http://www.bioengineering-research.com/vtk/BackgroundImage.tcl
to VC++.Net
Thanks!
Here are the relevant parts of my code:
vtk3DSImporter* importer = vtk3DSImporter::New();
importer->ComputeNormalsOn();
importer->SetFileName("747.3DS");
importer->Read();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin = importer->GetRenderWindow();
renWin->SetNumberOfLayers(2);
vtkRenderer *ren = vtkRenderer::New();
ren->InteractiveOn();
vtkBMPReader *reader = vtkBMPReader::New();
reader->SetFileName("test24BIT.bmp");
reader->Update();
vtkImageData *imageData = vtkImageData::New();
imageData = reader->GetOutput();
int a[3];
int numCols;
int numRows;
int z;
imageData->GetDimensions(a);
numCols = a[0];
numRows = a[1];
z = a[2];
// scan [[reader GetOutput] GetDimensions] "%d %d %d" numCols numRows z
vtkImageActor *actor = vtkImageActor::New();
actor->SetInput(reader->GetOutput());
vtkRenderer *ren1 = vtkRenderer::New();
ren1->AddActor(actor);
ren1->InteractiveOff();
ren1->GetActiveCamera()->ParallelProjectionOn();
ren1->GetActiveCamera()->SetParallelScale(numRows/2);
renWin->SetSize(numCols,numRows);
renWin->AddRenderer(ren1);
ren1->SetLayer(1);
ren->SetLayer(0);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
iren->Initialize();
iren->Start();
york
yorktim at bit.edu.cn
2004-11-19
More information about the vtkusers
mailing list