You are not logged in.

#1 2009-01-28 01:12:57

Cid2mizard
Member

Get pixel color

I'm interresting to get a fonction which return the pixel color, it's very good for a pixel detection or collision.

may be :
int GRRLIB_GetPixelColor(GRRLIB_texImg tex, int x, int y)
{
    u32 color;
    //....
    return (color);
}

Thanks

Last edited by Cid2mizard (2009-01-28 01:22:06)


www.nintendomax.com - 100% Hack  0% Warez

Offline

 

#2 2009-01-28 08:41:42

NoNameNo
Administrator

Re: Get pixel color

you mean the color detection in a texture buffer ?? or you would say in the entire video buffer ??
i think the video buffer will be more usefull, i will code is soon.

Offline

 

#3 2009-01-28 10:08:59

Cid2mizard
Member

Re: Get pixel color

my favorite is texture buffer ^^  wink


www.nintendomax.com - 100% Hack  0% Warez

Offline

 

#4 2009-02-05 22:51:39

NoNameNo
Administrator

Re: Get pixel color

i finally coded it wink have a look at the SVN wink

Offline

 

#5 2009-02-06 02:04:41

Cid2mizard
Member

Re: Get pixel color

Yes very good, big thanks wink

Last edited by Cid2mizard (2009-02-06 11:25:02)


www.nintendomax.com - 100% Hack  0% Warez

Offline

 

#6 2009-02-06 14:21:43

spiffen
Member

Re: Get pixel color

While you're at it, could you write a PutPixel function as well, that ofcourse works on textures too (not sure if there is any difference)..

EDIT:
Sorry for that.. Checked SVN, and ofcourse you added that function as well.. big_smile

Last edited by spiffen (2009-02-06 14:32:21)

Offline

 

#7 2009-02-06 17:55:40

NoNameNo
Administrator

Re: Get pixel color

take care with the GRRLIB_SetPixelTotexImg, since i Call DCFlushRange each time you call GRRLIB_SetPixelTotexImg, this function is very very slow, you'd better pre-calcul all your needs then run your code, avoid pre-calc during your app.

Offline

 

#8 2009-02-06 22:07:49

Crayon
Bad Mother Fucker

Re: Get pixel color

NoNameNo wrote:

take care with the GRRLIB_SetPixelTotexImg, since i Call DCFlushRange each time you call GRRLIB_SetPixelTotexImg, this function is very very slow, you'd better pre-calcul all your needs then run your code, avoid pre-calc during your app.

With revision 29, this is not true anymore, use GRRLIB_SetPixelTotexImg as much as you want and at the end just call GRRLIB_FlushTex. Look at the template for an example:
http://code.google.com/p/grrlib/source/ … rce/main.c

Offline

 

#9 2009-02-07 01:18:57

Cid2mizard
Member

Re: Get pixel color

It's good for grrlib 3.0.1 ?

Code:

u32 GRRLIB_GetPixelFromtexImg(int x, int y, int w, u8 * GRRLIB_LoadTexture)
{
    u8 *truc = (u8*)GRRLIB_LoadTexture;
    u8 r, g, b, a;
    u32 offset;

    offset = (((y >> 2)<<4)*w) + ((x >> 2)<<6) + (((y%4 << 2) + x%4 ) << 1); // Fuckin equation found by NoNameNo ;)

    a=*(truc+offset);
    r=*(truc+offset+1);
    g=*(truc+offset+32);
    b=*(truc+offset+33);

    return((r<<24) | (g<<16) | (b<<8) | a);
}

Because color is u32 and the return is -1 for white, 0 for black and -256 for no color pixel.


www.nintendomax.com - 100% Hack  0% Warez

Offline

 

#10 2009-02-08 00:46:11

NoNameNo
Administrator

Re: Get pixel color

i think you are wrong, since the returned value is a U32 meaning unsigned 32 bit long, you cant get negative result. check your print code wink

Offline

 

#11 2009-02-08 01:25:59

Cid2mizard
Member

Re: Get pixel color

yes it's me i have forget ">>8) & 0XFF;" for my u32 color ^^


www.nintendomax.com - 100% Hack  0% Warez

Offline

 

Board footer

Powered by FluxBB