Slick Util TextureLoader problem - not directly giving an image to it

Hi there guys!

Hopefully there’s someone around to help me :wink:

I’m playing with LWJGL an Slick and I want to load an Image, manipulate it’s colors and pass it into a texture.

Right now I’ve written a class to load the image, grab the pixels, manipulate the R-, G- and B values and put all that stuff into a byte[].
Since the glDrawPixels()-method really is kind of slow I wanted to create a texture to map onto my objects.

My approach:

Stream the byte[] into the TextureLoader from slick-util.jar

Since my source-image is a gif, I’m using:


//target is my array of manipulated pixel-bytes (or whatever I should call it)
ByteArrayInputStream ba = new ByteArrayInputStream(target);
texture = TextureLoader.getTexture("GIF", ba);

I think, the problem is, that I’m not passing a real Image into it.

Here’s the thrown exception:


Wed Dec 02 14:16:06 CET 2009 INFO:Use Java PNG Loader = true
java.lang.NullPointerException
	at org.newdawn.slick.opengl.ImageIOImageData.imageToByteBuffer(ImageIOImageData.java:132)
	at org.newdawn.slick.opengl.ImageIOImageData.loadImage(ImageIOImageData.java:118)
	at org.newdawn.slick.opengl.ImageIOImageData.loadImage(ImageIOImageData.java:106)
	at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:276)
	at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:231)
	at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:184)
	at org.newdawn.slick.opengl.TextureLoader.getTexture(TextureLoader.java:64)
	at org.newdawn.slick.opengl.TextureLoader.getTexture(TextureLoader.java:24)
	at utils.ColorChanger.setTexture(ColorChanger.java:57)
	at utils.ColorChanger.<init>(ColorChanger.java:42)
	at core.Main.init(Main.java:109)
	at core.Main.<init>(Main.java:54)
	at core.Main.main(Main.java:71)

Any suggestions?

Best greetz
Sven

Alright…
Back from lwjgl-IRC-chan, kevglass told me, I should use the InternalTextureLoader for this.

But I’m still running into problems.

My usage is now:


ByteArrayInputStream ba = new ByteArrayInputStream(target);
ImageIOImageData iod = new ImageIOImageData();
iod.loadImage(ba);
texture = InternalTextureLoader.get().getTexture(iod, GL11.GL_LINEAR);

It’s still throwing a NullPointerException, now at the iod.loadImage(ba);

Even debugging won’t show me, where the NullPointer exactly comes from.

Help!!! xD