Can I save a screenshot from JOGL?

If I have a JOGL app and I want people to be able to save the 3D views as images (GIFs or JPGs or whatever)… would that be straightforward? Is it possible to get the current contents of a GLCanvas as an ImageBuffer or something like that?

You can grab the pixels with glReadPixels, put them to a BufferedImage and then save them with imageio.

Like So:

http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=jogl;action=display;num=1091095319;start=2#2

Brilliant - it works perfectly - thanks!

The first time I tried it I forgot to call the function from within the drawing thread and got blank output, but once I put it in the drawing thread it worked instantly.