Uh... Is there a way to load an image instead of loading a byte buffer?
Use TWL's PNGDecoder (also available as separate JAR - see link in signature):
Display.setIcon(new ByteBuffer[] {
loadIcon(getClass().getResource("icon16.png")),
loadIcon(getClass().getResource("icon32.png")),
});
.........
private static ByteBuffer loadIcon(URL url) throws IOException {
InputStream is = url.openStream();
try {
PNGDecoder decoder = new PNGDecoder(is);
ByteBuffer bb = ByteBuffer.allocateDirect(decoder.getWidth()*decoder.getHeight()*4);
decoder.decode(bb, decoder.getWidth()*4, PNGDecoder.Format.RGBA);
bb.flip();
return bb;
} finally {
is.close();
}
}