You are not logged in.
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)
Offline
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
Yes very good, big thanks
Last edited by Cid2mizard (2009-02-06 11:25:02)
Offline
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..
Last edited by spiffen (2009-02-06 14:32:21)
Offline
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
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
It's good for grrlib 3.0.1 ?
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.
Offline
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
Offline
yes it's me i have forget ">>8) & 0XFF;" for my u32 color ^^
Offline