LWJGL
May 18, 2013, 03:52:33 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.9.0 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: Slick TextureData  (Read 738 times)
sirK
Newbie
*
Posts: 6


« on: August 16, 2012, 15:24:32 »

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:
Code:
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
Logged
Fool Running
Nerdus Imperius
*****
Posts: 740


« Reply #1 on: August 17, 2012, 05:37:56 »

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

Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option Grin
sirK
Newbie
*
Posts: 6


« Reply #2 on: August 17, 2012, 06:09:30 »

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.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!