# UnsupportedOperationException: Unsupported format for this image

So.. I'm learning lwjgl currently and I stumbled on this weird error caused by slick-util which seems to be incorrectly displayed.

ERROR :

java.lang.UnsupportedOperationException: Unsupported format for this image
at org.newdawn.slick.opengl.PNGDecoder.decode(PNGDecoder.java:272)
java:200)
at com.saumi.assets.Assets.<init>(Assets.java:23)
at com.saumi.main.Main.init(Main.java:27)
at com.saumi.main.Main.<init>(Main.java:45)
at com.saumi.main.Main.main(Main.java:71)


The problem is that even though it says unable to read png data, the picture that the error points to is loaded properly and even displayed onto the screen!

EDIT :

public static Texture loadTexture(String path , String fileType){
Texture tex = null;

try {
} catch (IOException e) {
e.printStackTrace();
}

return tex;
}


My Assets code which loads the textures :

public class Assets {

public static Texture playBtn , tutBtn , quitBtn;

public static Texture background;

public static Texture player , missile;

public Assets(){

}

}


The Error points to the Background Image , and the order in which it is loaded does not matter, it always points to that image.

• Welcome to GDSE. Your error is formatted as code, so that's fine. It might help us to see a minimal, complete, and verifiable example (MCVE) of the problematic code. – Pikalek Jan 4 '18 at 3:30
• Are you trying to read png data from more than one file or source? – Jay Jan 4 '18 at 4:40
• I've edited the post to show my code, and i am loading the image from a file in my res folder. – Saumi Jan 4 '18 at 4:58
• Try substituting one of the other image filenames for Background.png. If that works, then you've narrowed the problem to the image file itself. If that doesn't work, then it suggests something else is wrong. – Pikalek Jan 4 '18 at 21:38

There are a few solutions to this. Try them until you find one that works for you!

## Re-saving the image (Maybe Windows only)

1. Open the image in your image editing program / re-create the image from scratch.
2. Copy the entire image to your clipboard from your image editing software (don't save it).
3. Paste the image into MS Paint (might work with other programs. Tested only with MS Paint) and save the image as a .png.

## Change bit-depth to 32 bit (credit to Lemonzap)

2. Gimp: Should automatically have 32-bit depth if your Image > Mode is RGB.
3. Photoshop: In the menu Image > Module choose 32 Bits/Channel or set it when you create the image (Image from Zidane)