[vtkusers] problem saving series of images

John Hunter jdhunter at ace.bsd.uchicago.edu
Fri Oct 10 10:50:53 EDT 2003


>>>>> "John" == John Hunter <jdhunter at ace.bsd.uchicago.edu> writes:

    John> In the current incarnation, however, the last frame is saved
    John> in every image.

Herb Mullens contacted me offlist and pointed me to
vtkWindowToImageFilter, which was designed to solve this problem --
http://www.vtk.org/doc/nightly/html/classvtkWindowToImageFilter.html.
Below post the modified code that works for future googlers.

def save_image(fname):
    renWin = renderer.GetRenderWindow()
    w2i = vtk.vtkWindowToImageFilter()
    writer = vtk.vtkPNGWriter()
    w2i.SetInput(renWin)
    w2i.Update()
    writer.SetInput(w2i.GetOutput())
    writer.SetFileName(fname)
    renWin.Render()
    writer.Write()

Thanks,
John Hunter



More information about the vtkusers mailing list