I’m having some difficulty doing the Display.setIcon thing in lwjgl.
I’ve managed to get the icon to display on the game window, but the one on windows 8’s taskbar looks a bit funky… It cuts up the image in four quarters and displays it in a funny way. I’ll make an attempt to visualize:
bbbb
bbbb
becomes:
bbbb
eeeeee
eeeeee
where e stands for empty…
My code is as follows:
public ByteBuffer loadIcon(String filename, int width, int height) throws IOException {
BufferedImage image = ImageIO.read(new File(filename)); // load image
// convert image to byte array
byte[] imageBytes = new byte[width * height * 4];
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
int pixel = image.getRGB(j, i);
for (int k = 0; k < 3; k++) // red, green, blue
imageBytes[(i*16+j)*4 + k] = (byte)(((pixel>>(2-k)*8))&255);
imageBytes[(i*16+j)*4 + 3] = (byte)(((pixel>>(3)*8))&255); // alpha
}
}
return ByteBuffer.wrap(imageBytes);
}
and
try {
ByteBuffer[] icons = new ByteBuffer[2];
icons[0] = loadIcon("res/components/icon16x16.png", 16, 16);
icons[1] = loadIcon("res/components/icon32x32.png", 32, 32);
Display.setIcon(icons);
} catch (IOException ex) {
ex.printStackTrace();
}
any ideas? Has anyone successfully managed to set icons for a java application using LWJGL and windows 8?
I’m thinking that maybe my dimensions are wrong. The icons on the taskbar looks a bit oblong. though I have no idea of what dimensions to try.