LWJGL
May 18, 2013, 22:42:28 *
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: ilCopyPixels? Strange values  (Read 3924 times)
Ramon
Newbie
*
Posts: 6


« on: January 31, 2007, 14:20:43 »

Hey,

I'm using ilCopyPixels to get all of the colors from a texture. And after puzzling a while, i found out, that ilCopyPixels gives me negative values( using IL_FLOAT). And that these negative values turned out to be the highlighted parts of the image. So 1+that_value, gives the correct value in a range of 0.0f-1.0f. I think this might be really obvious for some of you, but i don't understand why it gives me those negative values.. By the way, i used IL_FLOAT, because IL_BYTE, or IL_UNSIGNED_BYTE looked even worse  Grin. Anyway, here is most of the relevant code:
Code:
IL.ilLoadFromURL();
IL.ilConvertImage(IL.IL_RGBA, IL.IL_BYTE);
Data=BufferUtils.createByteBuffer(512*512*4*4); //texture is 512 by 512 pixels exact. and .png but i doubt it matters?
IL.ilCopyPixels(0,0,0,512,512,1,IL.IL_RGBA,IL.IL_FLOAT,Data);
//after that, just continues to load the texture normal, so it can be displayed as well
//some where else, i try to make something of the Data
for (int i=0;i<512;i++)
{
for (int j=0;j<512;j++)
{
float []c=new float[3];
c[0]=Data.getFloat((i+j*512)*4*4);
c[1]=Data.getFloat(((i+j*512)*4+1)*4);
c[2]=Data.getFloat(((i+j*512)*4+2)*4);
for (int k=0;k<3;k++)
if (c[k]<0.0f)
c[k]=1.0f+c[k];
//now here I can use c[0-2] with GL11.glColor3f(); to get proper colors, like in the texture
}
}
So what's up with the negative values? I suppose it has something to do with the way DevIL and/or OpenGL stores texture data..., but how is that?

Ramon

PS I know this is really not the best way to do this,, the loop is quite expensive Roll Eyes But it was just for seeing what the hell the DevIL gave me  Wink
Logged
Fool Running
Nerdus Imperius
*****
Posts: 740


« Reply #1 on: February 02, 2007, 10:11:12 »

I'm gonna guess (its really just a guess Wink ) that it has something to do with converting the image to bytes (IL.ilConvertImage(IL.IL_RGBA, IL.IL_BYTE)) and then reading them out as floats (IL.ilCopyPixels(0,0,0,512,512,1,IL.IL_RGBA,IL.IL_FLOAT,Data)). But I really have no idea Grin
Logged

Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option Grin
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!