[vtkusers] Re: Is there anyone who knows how to load a image fileasbackground in a RenderWindow?
Goodwin Lawlor
goodwin.lawlor at ucd.ie
Fri Nov 19 02:41:51 EST 2004
Hi York,
Just to let you know, this code below:
vtkImageData *imageData = vtkImageData::New();
imageData = reader->GetOutput();
will cause a memory leak. I think you want:
vtkImageData *imageData = reader->GetOutput();
hth
Goodwin
"york" <yorktim at bit.edu.cn> wrote in message
news:20041119050546.65164338D2 at public.kitware.com...
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
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at:
<http://www.vtk.org/Wiki/VTK_FAQ>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list