Hello, I was wondering if anyone knew how to take a GLJPanel canvas and export (write) to a .jpg file.
Hello,
I don’t know if this really works with the GLJPanel, but theoretically a snapshot of a Component in awt can be made with :
GraphicsConfiguration gc = canvas.getGraphicsConfiguration();
BufferedImage bimg = gc.createCompatibleImage(canvas.getWidth(), canvas.getHeight());
canvas.paint(bimg.getGraphics());
File imageFile = new File("snapshot.jpg");
try {
ImageIO.write(bimg, "jpg", imageFile);
} catch (IOException ie) {
System.err.println("can't write jpg file");
}
Oliver
with gljpanel it sould be better to use paintComponent instead of paint
and maybe its better to call this over the awt thread… but try this only of u get only garbage
Thanks, the paintComponent version worked.