Slick2D Unexpected Error

早过忘川 提交于 2020-01-16 19:15:28

问题


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


回答1:


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.




回答2:


org.newdawn.slick.opengl.PNGImageData failed to read the data

Unsupported format for this image

The error message says what's wrong. Either your image is corrupted, or not supported, or not saved properly. What kind of image are you using?




回答3:


@Anubian is correct that your PNG must be corrupt. Try remaking it or use another software to create it. See where Slick2D threw the exception here. I tried to use Wolfgang Fellger's PNG Analyzer and I couldn't even open your image.



来源:https://stackoverflow.com/questions/23997911/slick2d-unexpected-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!