Search code examples
javaslick2d

Slick2D Unexpected Error


I have been making a game with Slick2D and I recently started having to use the console for debugging, and I noticed that I have been getting these errors:

Mon Jun 02 16:13:35 BST 2014 WARN:class org.newdawn.slick.opengl.PNGImageData failed to read the data
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:187)
    at org.newdawn.slick.Image.<init>(Image.java:192)
    at org.newdawn.slick.Image.<init>(Image.java:166)
    at org.newdawn.slick.Image.<init>(Image.java:154)
    at org.newdawn.slick.Image.<init>(Image.java:132)
    at luke_r.java.project_alpha.SplashScreenInitiator.init(SplashScreenInitiator.java:27)
    at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
    at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:393)
    at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:317)
    at luke_r.java.project_alpha.Core.main(Core.java:21)
Mon Jun 02 16:13:35 BST 2014 INFO:Initialising sounds..
Mon Jun 02 16:13:35 BST 2014 INFO:- Sound works
Mon Jun 02 16:13:35 BST 2014 INFO:- 64 OpenAL source available
Mon Jun 02 16:13:35 BST 2014 INFO:- Sounds source generated
Mon Jun 02 16:13:35 BST 2014 WARN:class org.newdawn.slick.opengl.PNGImageData failed to read the data
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:187)
    at org.newdawn.slick.Image.<init>(Image.java:192)
    at org.newdawn.slick.Image.<init>(Image.java:166)
    at org.newdawn.slick.Image.<init>(Image.java:154)
    at org.newdawn.slick.Image.<init>(Image.java:132)
    at luke_r.java.project_alpha.ImageManager.load(ImageManager.java:14)
    at luke_r.java.project_alpha.SplashScreenInitiator.init(SplashScreenInitiator.java:30)
    at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
    at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:393)
    at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:317)
    at luke_r.java.project_alpha.Core.main(Core.java:21)

I have absolutely no idea (after lots of research) what could be causing this. Please could some explain?

EDIT: Here is the line it doesn't like for the first error: splash = new Image("res/img/splash.png"); Here is the line it doesn't like for the second error: sandMap = new Image("res/img/map/sandmap.png");

EDIT 2: Sandmap.png Splash.png


Solution

  • If you're still having trouble with this then I may have a solution. I use paint.net and ran into the same problem. When you save your image from paint.net a save configuration window will pop up after you choose your save destination. For me I had to change the Bit-Depth from 8-bit to 32-bit. Auto-detect will sometimes work but only if it auto detects it as 32-bit. I have not tested 24-bit, it may work as well. Hope this helps.