Slick TextureData

Started by sirK, August 16, 2012, 22:24:32

Previous topic - Next topic

sirK

Hello,

I have tried to find information on this topic, but have nothing found that can directly help me.
I am playing around with RGBA manipulation of textures. Or lets say I try. I just can't seem to figure out how to use the Data that is provided by getTextureData().
I do something like:
tex = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/test_small.png"));
byte[] texData = tex.getTextureData();


But when printing this array I cannot seem to understand the pattern behind it to unlock the information that I'm searching for (mainly the alpha channel of every pixel).
There are many negative numbers, so I fear there may be somthing wrong, since I expected to find values between 0 and 256.

Maybe one of you can help me with this problem.

Thanks,
sirK

Fool Running

That is actually correct. Java bytes seem to be converted as signed bytes instead of unsigned bytes. The negative values you are seeing are actually the byte values from 128-255.
See http://www.crazysquirrel.com/computing/java/basics/how-to-convert-bytes.jspx if you need to manipulate them as integers.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

sirK

Ah ok, I see. Right, have forgotten about the signed byte thing in Java. Haven't programmed a while in java, so I obviously got confused there.
Well, thanks for the quick response. That helps a lot.