I wanted to remove the AWT dependancy from Snowman Village, but it uses ImageIO for saving the screenshots. Kevglass handily pointed me towards this png encoder, which has minimal dependancies. It wasn't too much trouble to modify it to remove the BufferedImage use, so the version below will happily save png images without any annoying AWT dependancy. I also added an option to encode the image flipped vertically, so you can just hand it data straight from an OpenGL pixel grab.

You may also want the handy Screenshot class, which makes taking screenshots of LWJGL apps a breeze.

I've had to attach the source as a txt file because the stupid forum won't allow .java files to be attached, and otherwise it exceedes the post size limit. PngEncoder - accepts an int[] containing 0xAARRGGBB pixels, and encodes them into a png

The original code was LGPL, but frankly I don't know how that applies when someone releases something as a single-file source-only distribution. Either way, the code above is free for any kind of use or modification. Enjoy.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org