[SDL] pixel operation questions

Loren Osborn linux_dr at yahoo.com
Mon Sep 23 00:27:01 PDT 2002


On Sun, 2002-09-22 at 20:01, La Temperanza wrote:
> 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.

-Loren
> 
> 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






More information about the SDL mailing list