[vtkusers] problems using vtkWindowToImageFilter and vtkJPEGWriter

Dan Frankel wasban at comcast.net
Tue May 3 01:39:22 EDT 2005


Hello, I am having trouble with vtkWindowToImageFilter or vtkRenderWindow,
and have hopes someone can shed light on my problem.

I am seeing garbled images produced by vtk image writers such as
vtkJPEGWriter, vtkPNMWriter, vtkTIFFWriter, etc.
The rendered image in the vtkRenderWindow looks fine on the screen, but when
I open the jpeg output file with an
imageviewer such as ImageMagic the resulting image is completely corrupted.
The garbled output file looks nothing
like the RenderWindow image but the output file does appear to change if the
RenderWindow size is modified with the
SetSize() method.  I've tried this in both C++ and Python with similar
results.  The code executes with no errors.  I'm
running vtk 4.2 on Linux Redhad 9.  Is there something I've got wrong with
my script?  Does anyone have any ideas of what
could be going on?   Here is what I'm doing:


import vtk

renWin = vtk.vtkRenderWindow()
ren = vtk.vtkRenderer()
renWin.AddRenderer(ren)
spherepolys = vtk.vtkSphereSource()
sphereMapper = vtk.vtkPolyDataMapper()
sphereMapper.SetInput(spherepolys.GetOutput())
sphereMapper.ScalarVisibilityOff()
sphereActor = vtk.vtkActor()
sphereActor.SetMapper(sphereMapper)

ren.AddActor(sphereActor)
ren.SetBackground(0,0,0)

winfil = vtk.vtkWindowToImageFilter()
jpgwrit = vtk.vtkJPEGWriter()
winfil.SetInput(renWin)
jpgwrit.SetInput(winfil.GetOutput())

renWin.Render()
winfil.Modified()
jpgwrit.SetFileName("testimg.jpg")
jpgwrit.Write()


Any ideas or suggestions are greatly welcome.

Thanks,

Dan





More information about the vtkusers mailing list