[SDL] GPF on SDL_GetRGB

Sam Lantinga slouken at devolution.com
Tue Jan 25 09:43:53 PST 2005


> I'm faced with what must surely be a common problem - reading the color of a 
> pixel on an SDL surface. I've struggled with three methods (shown below) 
> gleamed from the SDL documentation and other sources on the web, but in all 
> cases the program GPF's on the SDL_GetRGBA call. 

Make sure surface->pixels isn't NULL, if it is, you need to lock the surface.
Make sure that x and y are not out of bounds.  They range from 0 to (w or h)-1

See ya,
	-Sam Lantinga, Software Engineer, Blizzard Entertainment




More information about the SDL mailing list