Hello Tim, > I recall reading something about capturing the contents of a Canvas3D in a > JPEG file so I went back and read the appropriate email and it mentioned a > JPEGImageEncoder. Now, I may just be being dense but what and where is > this? I had a look through the JDK1.2 API docs and coudln't find a > JPEGImageEncoder class, nor could I find it in the Java3D API docs. The JPEGImageEncoder class is part of the com.sun.image.codec.jpeg package, in the JDK1.2. Someone will correct me if I'm wrong, but since it's part of a com.* package, companies do not necessarily have to include it in their Java IDE (e.g. Symantec VisualCafe). This class does what its name says, that is it encodes a BufferedImage to an OutputStream. Using a JPEGEncodeParam object, you can specify the parameters of the encoding, such as compression. > Also, how would this be used to capture the contents? Would I need to > subclass the Canvas3D and override the postrender() function so that if a > certain bit is set it dumps out to a JPEG? What I needed is to capture the content of a Canvas3D and export it to a JPEG file. If you don't need to dump it to a file, then you can forget the JPEGImageEncoder class. How I managed to get this to work goes like this. You need to subclass the Canvas3D and add a method with those few lines: Dimension d = getSize(); BufferedImage bImage = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_ARGB); ImageComponent2D imgComp = new ImageComponent2D(ImageComponent2D.FORMAT_RGB, bImage); Raster snapshot = new Raster(new Point3f(), Raster.RASTER_COLOR, 0, 0, d.width, d.height, imgComp, null); // capture the canvas' content getGraphicsContext3D().readRaster(snapshot); // if you need the buffered image BufferedImage bi = snapshot.getImage().getImage(); Once you have that buffered image, you can export it to a file using the JPEGImageEncoder. Now, it seems there's a bug in the Windows version of Java3D 1.1.1... Normally, you could put all this code in a method (let's call it captureImage()) and call it from anywhere. This works on a Solaris box, but under Windows, it makes opengl32.dll crash. How you can go around this problem is by calling this method from an overriden postSwap() method: first call super.postSwap(), then check for a flag to see if you must call captureImage(). This is very troublesome, but it's the only way it works for me right now. If anybody has found another way to do it, please tell me. I hope this helps!
begin:vcard n:Bilodeau;Guillaume tel;work:(613) 991-5037 x-mozilla-html:FALSE org:National Research Council Canada;Visual Information Technology adr:;;;;;; version:2.1 email;internet:[EMAIL PROTECTED] title:Software Engineer x-mozilla-cpt:;-1 fn:Guillaume Bilodeau end:vcard