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)
at org.newdawn.slick.opengl.PNGImageData.loadImage(PNGImageData.java:97)
at org.newdawn.slick.opengl.CompositeImageData.loadImage (CompositeImageData.java:62)
at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:43)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:292)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:254)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.
java:200)
at org.newdawn.slick.opengl.TextureLoader.getTexture(TextureLoader.java:64)
at org.newdawn.slick.opengl.TextureLoader.getTexture(TextureLoader.java:24)
at com.saumi.utils.Renderer.loadTexture(Renderer.java:91)
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!
I don't know what is is supposed to mean, please help.
EDIT :
My texture loader code :
public static Texture loadTexture(String path , String fileType){
Texture tex = null;
InputStream in = ResourceLoader.getResourceAsStream(path);
try {
tex = TextureLoader.getTexture(fileType,in);
} 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(){
playBtn = Renderer.loadTexture("res/PlayBtn.png", "PNG");
tutBtn = Renderer.loadTexture("res/TutBtn.png", "PNG");
quitBtn = Renderer.loadTexture("res/QuitBtn.png", "PNG");
player = Renderer.loadTexture("res/KillSkull.png", "PNG");
missile = Renderer.loadTexture("res/Missile.png", "PNG");
background = Renderer.loadTexture("res/Background.png", "PNG");
}
}
The Error points to the Background Image , and the order in which it is loaded does not matter, it always points to that image.
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. \$\endgroup\$ – Pikalek Jan 4 '18 at 21:38