Save png without using AWT?

Does anyone know a way of saving a png image without using awt? ImageIO unfortunately depends on several awt classes. I expect DevIL could, but since thats rumoured to be dissappearing from LWJGL in the future I’d rather not use it. All the other 3rd party libraries I’ve found seem to have an unsuitable license (commercial or GPL) or have an awt dependancy.

Am I stuck with having to write a png saver by hand? :frowning:

does it have to be png? you can easily make or find a library which saves in raw or bmp format.

zipped TGA is equal in size to PNG…

So output as TGA then use ZipOutputStream

DP

Basically this is for the screenshot function in Snowman Village, so zipping a tga isn’t practical as the user isn’t going to like that much. At the moment writing something to create an uncompressed TGA looks easiest, but it’d be nice to have a proper compressed image rather than something huge.

I’m just curious, why avoid couple of AWT classes?

native compilation

As already mentioned, your best bet is either to write a custom writer yourself or to find one out there. I had a hard one finding one myself and gave up on the idea. If you do find a non-GPL, non-commercial one, let us all know. :slight_smile:

You might find this helpful;

http://www.j2meforums.com/wiki/index.php/PNG_class

It’s J2ME code but you can get the idea!

Actually… it seems quite easy to do. For screenshots you only need a tiny fraction of the spec… that is… 24bit truecolor (colortype 2), no filter and only 3 chunks (IHDR, IDAT and IEND) + fixed header (8 bytes). util.zip.Deflater takes care of the compression and it also generates the required CRCs on it’s way. So… hum… not exactly difficult. :slight_smile: