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
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.
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.