How do you return x and y values from rgb?

Non-platform specific questions.

How do you return x and y values from rgb?

Postby Bee-Ant » 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...
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...
Attachments
test.png
test.png (355 Bytes) Viewed 675 times
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: How do you return x and y values from rgb?

Postby DST » Thu Jun 24, 2010 7:05 pm

i think you need to use the fcommands to open the file, and read the data, but you have to know what you're looking at, and write something to interpret the data from there. Also, compressed images are probably exceedingly difficult due to the lookup indexes they use,

probably bmp is the easiest to do.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: How do you return x and y values from rgb?

Postby Bee-Ant » Thu Jun 24, 2010 7:56 pm

DST wrote:i think you need to use the fcommands to open the file, and read the data

Bee-Ant wrote:I want to read this from an actor's animation, not from an external picture file...
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: How do you return x and y values from rgb?

Postby DST » Thu Jun 24, 2010 8:05 pm

Well, you can draw_from to get the animation onto a canvas but....

Fuzzy wrote:... but as it stands, there is no readpixel() function in GE...


from viewtopic.php?f=3&t=1230&
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: How do you return x and y values from rgb?

Postby Bee-Ant » Thu Jun 24, 2010 8:20 pm


:cry: :cry:
It seems I need to define each sprite black dot coordinates manually...
:cry: :cry:

But I'm so sure there would be some trick.
Not using canvas nor readpixel() thing, but completely different method...
Maybe using Units[][] :P
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron