How can I find out what color a pixel is in a surface?
Well… Lock the surface (if necessary), use surface->pitch and
surface->format->BytesPerPixel to find out how to address the pixel,
and then get it from surface->pixels.
Now, what do you want to do with the value?
If you want to get at the R, G and B (and alpha, if present), you have
to look closer at the SDL_PixelFormat struct to find out how to
extract them.
Oh, and don’t forget that 8 bit surfaces work differently. Those use a
palette, which you will have to index with the pixel values if you
want the actual colors.
//David Olofson - Programmer, Composer, Open Source Advocate
.- The Return of Audiality! --------------------------------.
| Free/Open Source Audio Engine for use in Games or Studio. |
| RT and off-line synth. Scripting. Sample accurate timing. |
`-----------------------------------> http://audiality.org -’
— http://olofson.net — http://www.reologica.se —On Thursday 05 June 2003 21.19, quakeboy wrote:
How can I find out what color a pixel is in a surface?