[vtkusers] Problems to save snapshots of a vtk window
Valérie Duay
valerie.duay at epfl.ch
Tue Feb 21 15:51:48 EST 2006
Hi,
I use a vtk window to visualize the iterations (image + contours) of my
itk filter. This window works well. Now I would like to save a snapshot
of this window at each iteration. I try to do this with
vtkWindowToImageFilter but I get many problems.
1. It can save only the first iteration and not the following ones. If I
use winToIm->Modified(), the program crashes at the first iteration.
2. It can save the first iteration only if I have an image or contours
in the window but not both. Otherwise the program crashes at the first
iteration.
//I define that outside the function SaveWindow()
vtkWindowToImageFilter *winToIm = vtkWindowToImageFilter::New();
winToIm->SetInput(renWin);
vtkJPEGWriter *jpgWriter = vtkJPEGWriter::New();
//The function SaveWindow is called at each iteration
void SaveWindow()
{
//winToIm->Modified(); =>Bug
jpgWriter->SetInput( winToIm->GetOutput() );
jpgWriter->SetQuality( 100 );
jpgWriter->SetFileName( "image.jpg" );
jpgWriter->ProgressiveOff();
jpgWriter->Write();
}
//I have the following code to visualize the image and contour together
on the same window
ren->AddActor(imageActor);
ren->AddProp(targetContourActor);
renWin->AddRenderer(ren);
renWin->SetSize(DisplayWinSize,DisplayWinSize);
renWin->Modified();
renWin->Render();
How should I do that?
Thanks in advance for your help,
Valerie
More information about the vtkusers
mailing list