TWL's PNGDecoder now available as standalone JAR

Started by Matthias, May 15, 2010, 21:09:29

Previous topic - Next topic

Matthias

The PNGDecoder from the TWL - Themable Widget Library is now available as a separate JAR.

JAR: PNGDecoder.jar
Source: PNGDecoder.java

Example usage:
InputStream in = new FileInputStream("white_pixel.png");
PNGDecoder decoder = new PNGDecoder(in);

System.out.println("width="+decoder.getWidth());
System.out.println("height="+decoder.getHeight());

ByteBuffer buf = ByteBuffer.allocateDirect(4*decoder.getWidth()*decoder.getHeight());
decoder.decode(buf, decoder.getWidth()*4, Format.RGBA);
buf.flip();

while(buf.hasRemaining()) {
   System.out.printf("%02X\n", buf.get() & 255);
}


Have fun :)

EDIT: The PNGDecoder has been moved into the de.matthiasmann.twl.utils package. A class in the old package is still there and forwards all methods to the new PNGDecoder.