SDL_getRGB

Hi,

i really don?t understand how SDL_getRGB works:
void SDL_GetRGB(Uint32 pixel, SDL_PixelFormat * fmt, Uint8 r, Uig,
Uint8 *b
);

r , g, b and Pixelformat is clear to me ,but what about __Uint32 pixel ?
does this mean every pixel on my surface has a number ? isn?t a pixel
defined by it?s x and y value ?
sorry if my question is stupid,i just want to klick on my surface and
get the exact rgb-values.

here?s what i did:

SDL_Color col;
Uint8 r, g, b, a;
SDL_PixelFormat *fmt;
fmt=surface->format;
SDL_GetRGB( n , fmt, &r, &g, &b);
col.r = r;
cout << "This should be the red value: " << col.r << “\n”;

where n are different values i tried but had no luck…now please
someone show me how to get this value for a given pixel,let?s say 100,100.

thx, jurri

The Uin32 pixel is the pixel. You need to pull it from your
surface’s “pixels” element! :^)

I think you need to look at the “getpixel()” example code, here:

http://sdldoc.csn.ul.ie/guidevideo.php

Enjoy!

-bill!On Fri, Jul 11, 2003 at 02:25:45AM +0200, jurri wrote:

Hi,

i really don?t understand how SDL_getRGB works:
void SDL_GetRGB(Uint32 pixel, SDL_PixelFormat * fmt, Uint8 r, Uig,
Uint8 *b
);

r , g, b and Pixelformat is clear to me ,but what about __Uint32 pixel ?
does this mean every pixel on my surface has a number ? isn?t a pixel
defined by it?s x and y value ?


bill at newbreedsoftware.com Got kids? Get Tux Paint!
http://newbreedsoftware.com/bill/ http://newbreedsoftware.com/tuxpaint/

Hi,

Am Freitag, 11 Juli 2003 schrieben Sie:

r , g, b and Pixelformat is clear to me ,but what about __Uint32
pixel ?
does this mean every pixel on my surface has a number ?

actually yes. and actually in the memory of your pc it is not addressed
by the x and y values.
computer memory is allways addresses in a linear way. the pixel information
actually is not more than an array. therefore every pixel has ONE
address. the x and y values are just the way to represent that value
that tells you where which pixel will be on the screen. actually
you can calculate the pixel-address like this.
xPos + yPos * surface->width = pixel

i hope i didn’t mess up the calculation, as i don’t have a chance
to look at the SDL-Source (and way of storing) right now.