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(
at java.awt.image.BufferedImage.<init>(
at com.jmex.terrain.util.ProceduralTextureGenerator.addTexture(
at com.games4j.bz2.BZ2.simpleInitGame(
at com.games4j.bz2.BZ2.main(

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: