I created new project in libgdx without Android, specified for Eclipse. I added testcar.png to assests in core project, refreshed core and desktop projects,

new Texture(Gdx.files.absolute("C:\\TestGame\\desktop\\bin\\testcar.png"));
new Texture(Gdx.files.internal("testcar.png"));


Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException:

Couldn't load file: C:/TestGame/desktop/bin/testcar.png at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:148) at com.badlogic.gdx.graphics.TextureData$Factory.loadFromFile(TextureData.java:98) at com.badlogic.gdx.graphics.Texture.(Texture.java:100) at com.badlogic.gdx.graphics.Texture.(Texture.java:92) at com.mygdx.screens.MainMenuScreen.show(MainMenuScreen.java:33)

but both those constructors work with jpg or gif(same folder as png) without any problem.

What i do wrong ? Is it bug?


Strange bug, after slight editing of image, and saving image as png again, exception dissapper. During debug of application i saw TExture constructor call PixMap constructor and send FileHandle of file as argument, constructor read bytes from image (dont know correctly or with errors) then those bytes go to Gdx2DPixmap(bytes, 0, bytes.length, 0) and that constructor throws java.io.IOException: Error loading pixmap: decoder init failed for stream. That exception looks like as result of failed attempt to call native mehod load() in Gdx2DPixmap. So changing image somehow, was random but solution-creating idea.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.