Hello Guest

TWL's PNGDecoder now available as standalone JAR

  • 0 Replies
  • 7295 Views
TWL's PNGDecoder now available as standalone JAR
« on: May 15, 2010, 21:09:29 »
The PNGDecoder from the TWL - Themable Widget Library is now available as a separate JAR.

JAR: PNGDecoder.jar
Source: PNGDecoder.java

Example usage:
Code: [Select]
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.
« Last Edit: May 17, 2010, 20:02:09 by Matthias »