Cannot create ImageIcon

Trying to emulate exactly what the tests are doing, but it won't use my textures.


ProceduralTextureGenerator pt = new ProceduralTextureGenerator(heightMap);
pt.addTexture(new ImageIcon(BZ2.class.getClassLoader().getResource("dune1.bmp")), -128, 0, 128);



Results in:

java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:999)
at java.awt.image.BufferedImage.<init>(BufferedImage.java:312)
at com.jmex.terrain.util.ProceduralTextureGenerator.addTexture(ProceduralTextureGenerator.java:222)
at com.games4j.bz2.BZ2.simpleInitGame(BZ2.java:131)
at com.jme.app.BaseSimpleGame.initGame(BaseSimpleGame.java:503)
at com.jme.app.BaseGame.start(BaseGame.java:69)
at com.games4j.bz2.BZ2.main(BZ2.java:54)


I've tried multiple textures, bmp, tga, jpg, and not just the same image.

Any ideas? God I feel like this is something really stupid.

Have you tried debugging to see where the width and height are coming from exactly?

I did.



Width and Height are set to -1. The path to the image is correct, so I don't know why it's not loading… or not reading.



I tried using other jpeg textures, but same.



Now I tried saving the BMP texture as a JPG texture from Photoshop and it worked!



Very strange :confused: