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.