[vtkusers] Need help getting vtkCanvas as Image via swing or AWT
Alan
alan at vuesonix.com
Tue Apr 22 16:40:48 EDT 2003
Hi,
I'm trying to capture the image output of the vtkCanvas component. I've
tried
// should capture image contents from swing based component
RepaintManager
rpMgr=RepaintManager.currentManager(panel.getvtkCanvas());
img=rpMgr.getOffscreenBuffer(panel, panel.getWidth(),
panel.getHeight());
and also
// should capture image contents from awt based component
Component c=panel.getvtkCanvas();
img=c.createImage(c.getWidth(), c.getHeight());
Graphics g=img.getGraphics();
c.printAll(g);
where
panel extends Jpanel and contains a vtkCanvas() object.
Although the image size is always correct, the image contents are always
empty. This despite the fact that VTK has displayed a pretty picture
onscreen, Java just doesn't seem to be able to access it at either the
Swing or AWT level.
Can anyone help me capture the output of vtkCanvas to an Image()? Is
there a reason that this can't be done?
Thanks for any insight on this puzzle.
--Alan
BTW, my workaround has been to capture the component via the Robot() class:
Robot r=new Robot();
Rectangle rect=panel.getBounds();
rect.translate(-panel.getInsets().left,-panel.getInsets().top);
img=r.createScreenCapture(rect);
This works acceptably, but only if the vtkCanvas is not covered by any
other windows.
More information about the vtkusers
mailing list