Kovalan Muniandy wrote:
> Dear Reader,
>
> Steve Pietrowicz writes about capturing still images in JPEG format (Java 3D
> FAQ):
> http://tintoy.ncsa.uiuc.edu/~srp/java3d/howto.html#capture
>
> However, I get an exception when I do it. Could someone give me a hint?
> Thanks,
>
> Kovalan
> Ps. The exception:
>
> Exception occurred during Canvas3D callback:
> java.lang.NullPointerException
> at
> javax.media.j3d.GraphicsContext3D.readRaster(GraphicsContext3D.java:1
> 068)
> at TurnCamera$CapturingCanvas.postSwap(TurnCamera.java:128)
> at javax.media.j3d.Renderer.run(Renderer.java:715)
>
> >> The code:
>
> public class CapturingCanvas extends Canvas3D
> {
> public CapturingCanvas() {
> super( null );
> }
> public void postSwap() {
> GraphicsContext3D ctx = getGraphicsContext3D();
> Raster ras = new Raster();
You have to create a Raster object that already has an ImageComponent that is
the same width and height as
the canvas. Read the API doc for the Java3D Raster and ImageComponent classes.