LibGDX cannot load a specific image

I downloaded all my images in the past, and I use OpenGL ES 2.0 so that the images do not need the power of two (I have several downloaded successfully, but it is not).

This code is as follows:

Line 96: splashSheet = new Texture(Gdx.files.internal("test.png")); 

This is my error message:

  Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: test.png at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:111) Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: test.png at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140) at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64) at com.badlogic.gdx.graphics.Texture.load(Texture.java:175) at com.badlogic.gdx.graphics.Texture.create(Texture.java:159) at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:133) at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:122) at com.panini.game.GameScreen.show(GameScreen.java:96) at com.badlogic.gdx.Game.setScreen(Game.java:59) at com.panini.game.Splash.render(Splash.java:29) at com.badlogic.gdx.Game.render(Game.java:46) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:190) at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:108) Caused by: java.io.IOException: couldn't load pixmap at com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.<init>(Gdx2DPixmap.java:57) at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:138) ... 11 more 

Here is what makes this problem interesting. I can download this file , but I can not download this . The first is basically just a cropped screen shot that I want to use. The second image I provided (which does not work) is the original. It is called splashSprites.png, but I tried renaming it to test.png and referring to it correctly, but it still does not work, so I know that this is definitely not a naming problem. If I put both files in a resource directory or bin with the names test1.png and test2.png respectively, then the code will work if I ask to download test1.png, but not if I ask to download test2.png, so it’s not, m also puts files in the wrong place. These two seemed to be the most likely candidates, but I excluded them.

I tried other things, such as re-exporting the first image, etc., but it never worked (which took a screenshot, so here I am). I suppose this may have something to do with alpha in one of the images (because it is really the only thing that is different from the two - one has alpha and the other does not), but this is unlikely since I was able to load some other textures that had alpha. I'm really at a standstill.

Thanks in advance.

+7
source share
2 answers

I have found the answer. Apparently, LibGDX does not support 16-bit png (is that right?), Because after converting my sprite to 8-bit depth using Preview on OS X, I found that the problem disappeared.

Thanks to PT for recommendations on updating LibGDX because I received the following error message:

 Caused by: java.io.IOException: couldn't load pixmap 8bit only 
+7
source

Run pngcrush on the image to get it into the more common PNG format.

Is this screenshot generated using the forum screenshot code for the libGDX forum? I used this too and had problems with the huge PNG sizes, and I believe that I had problems downloading and editing. Anyway pngcrush fixed the problem for me.

The pngcheck tool may be able to highlight what is different between the two images you have.

Getting into the libGDX source, I see this recent (11 days ago) change in the libGDX image downloader: https://github.com/libgdx/libgdx/commit/4fac29aef94e3afafdd47d71e60faf256fa171b0 (it looks like IOException should contain more information about what really went not so), so you can try working with libGDX night cats?

+4
source

All Articles