[vtkusers] printig a VTK window in wxWindows
Prabhu Ramachandran
prabhu at aero.iitm.ernet.in
Thu Sep 20 01:28:40 EDT 2001
hi,
>>>>> "choni" == choni <choni at adinet.com.uy> writes:
choni> Has anybody tried to print a vtk image from a wxWindows
choni> window? Any help regarding this subject will be
choni> appreciated.
If by print you mean dump screen to an image, yes, this can be easily
done. I have done this for wxPython an the code should be somewhat
similar for wxWindows.
Use one of the following (this is all python code so you will need to
translate it a little to c++).
# save as PPM
renwin.SetFileName(filename)
renwin.SaveImageAsPPM()
# save as BMP
w2if = vtkWindowToImageFilter()
w2if.SetInput(renwin)
ex = vtkBMPWriter()
ex.SetFileName(filename)
ex.SetInput(w2if.GetOutput())
ex.Write()
You could use a whole bunch of writers instead of the vtkBMPWriter -
vtkTIFFWriter, vtkPNGWriter (new in VTK 4 CVS tree), vtkJPEGWriter
(also new in VTK 4.0 CVS tree), etc.
There is one thing you need to remember, you have to raise the VTK
window that is rendering the scene to the top - I do this by obtaining
the top level window and then invoking Raise() on it followed by a
wxYield() and then do a renwin.Render(). On UNIX if you dont raise
the window to the top with other windows obscuring it, the image you
get will be exactly what you see with all the other windows obscuring
the view.
I hope this makes sense.
prabhu
More information about the vtkusers
mailing list