PNG decoder
Fast Java PNG Decoder originally written by Matthias Mann for the TWL GUI System. Now available as a separate project too. Opposite to the Standard java ImageIO this lib is optimized for performance as well as for easy of use.
This library is intended to be used with OpenGL and it decodes into formats understood by OpenGL.
Size of textures 64x64.
Add Gradle dependency
implementation ("org.l33tlabs.twl", "pngdecoder", "1.0")
Then use like as below
// load png file from resources
PNGDecoder decoder = new PNGDecoder(ClassName.class.getResourceAsStream(fileName));
//create a byte buffer big enough to store RGBA values
ByteBuffer buffer = ByteBuffer.allocateDirect(4 * decoder.getWidth()
* decoder.getHeight());
//decode
decoder.decode(buffer, decoder.getWidth() * 4, PNGDecoder.Format.RGBA);
//flip the buffer so its ready to read
buffer.flip();
Library on mvn
There is also small slim library on GitHub of Matthias Mann, where you can find decoders for other image formats.