Pixel operation questions

Hi, I’m an almost complete newbie to C with a few questions about SDL’s
pixel operations. Please excuse me if these are mind-numbingly obvious
to experienced programmers. ^^;;

First, in the example-

fmt=surface->format;
SDL_LockSurface(surface);
pixel=((Uint32)surface->pixels);
SDL_UnlockSurface(surface);

how exactly do you specify which pixel you want to grab?

Second, can you map a pixel directly to the buffer using more then 8bpp?
It’s not too clear…

Thanks, Temp

Hi, I’m an almost complete newbie to C with a few questions about SDL’s
pixel operations. Please excuse me if these are mind-numbingly obvious
to experienced programmers. ^^;;

First, in the example-

fmt=surface->format;
SDL_LockSurface(surface);
pixel=((Uint32)surface->pixels);
SDL_UnlockSurface(surface);

Essentially this comes down to locating the pixel in the array of bytes
pointed to by surface->pixels, and copying the relevant bytes to your
pixel variable… I could regergitate cope that has been written before,
but here is a link that I hope you will find more usefull:

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

The code assumes that the surface is already locked, but other than that
it should make sense.

-LorenOn Sun, 2002-09-22 at 20:01, La Temperanza wrote:

how exactly do you specify which pixel you want to grab?

Second, can you map a pixel directly to the buffer using more then 8bpp?
It’s not too clear…

Thanks, Temp