I am trying to capture an image from the screen. I have seen other threads discussing this Issue, and I have follow the advice but I still does not work. I am running the 1.3.2 pre8 build.
The code is as follows:
<br /> Screen3D on=canvas.getScreen3D();<br /> Dimension dim=canvas.getSize();<br /> OffScreenCanvas3D shot=new OffScreenCanvas3D(canvas.getGraphicsConfiguration(), true);<br /> canvas.getView().addCanvas3D(shot);<br /> Screen3D off=shot.getScreen3D();<br /> off.setSize(dim);<br /> off.setPhysicalScreenHeight(dim.height);<br /> off.setPhysicalScreenWidth(dim.width);<br /> shot.setOffScreenLocation(canvas.getLocationOnScreen());</p> <p>BufferedImage bi=shot.doRender(dim.width, dim.height);<br />
and the error I sometimes get but not always:
<br /> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.media.j3d.Canvas3D.renderOffScreenBuffer(Unknown Source)<br /> at viewport.tools.OffScreenCanvas3D.doRender(OffScreenCanvas3D.java:59)<br />
and when i got no error the image I get is just a part of the actual scene or sometimes nothing.
I also tried it with the 1.3.1 release and there I got always a nullpointer exception except when i switched into debugging mode and set a breakpoint before OffscreenCAnvas.doRender(), the it worked correctly.
Can anybody help me?