How do you return x and y values from rgb?
Posted: Fri May 21, 2010 8:26 am
Look at the picture bellow...
It's a 100x100 pixels png picture.
There's a black(r=0;g=0;b=0;) dot.
And the other color is white(r=255;g=255;b=255;)...
All I want is to read each pixel RGB value and store them into some array...something like this...
Afterward, detect the black color indexes...
So that I would get the X and Y coordinate from the black color of the actor...
Oh yah, I want to read this from an actor's animation, not from an external picture file...
My question is...Does anyone know what's the correct code or method to do this?
I have tried some method but can't figure it out...
It's a 100x100 pixels png picture.
There's a black(r=0;g=0;b=0;) dot.
And the other color is white(r=255;g=255;b=255;)...
All I want is to read each pixel RGB value and store them into some array...something like this...
- Code: Select all
int i,j;
for(i=0;i<100;i++)
{
for(j=0;j<100;j++)
{
R[i][j]=&r[i][j];
G[i][j]=&g[i][j];
B[i][j]=&b[i][j];
}
}
Afterward, detect the black color indexes...
- Code: Select all
int i,j;
for(i=0;i<100;i++)
{
for(j=0;j<100;j++)
{
if(R[i][j]==0&&G[i][j]==0&&B[i][j]==0)
{
BlackX=j;
BlackY=i;
}
}
}
So that I would get the X and Y coordinate from the black color of the actor...
Oh yah, I want to read this from an actor's animation, not from an external picture file...
My question is...Does anyone know what's the correct code or method to do this?
I have tried some method but can't figure it out...