palette Pointer to the palette, or NULL if the !BitsPerPixel?__
!BitsPerPixel? The number of bits used to represent each pixel in a surface. Usually 8, 16, 24 or 32.
The number of bytes used to represent each pixel in a surface. Usually one to four.
[RGBA?mask Binary mask used to retrieve individual color values
[RGBA?shift Binary left shift of each color component in the pixel value
colorkey Pixel value of transparent pixels
If you wish to do pixel level modifications on a surface, then understanding how SDL stores its color information is essential.
8-bit pixel formats are the easiest to understand. Since its an 8-bit format, we have 8 !BitsPerPixel? and 1 !BytesPerPixel?. Since !BytesPerPixel? is 1, all pixels are represented by a Uint8 which contains an index into palette-colors. So, to determine the color of a pixel in a 8-bit surface: we read the color index from surface-pixels and we use that index to read the SDL_Color structure from surface-format-palette-colors. Like so:
SDL_Surface surface; SDL_!PixelFormat? *fmt; SDL_Color *color; Uint8 index; . . / Create surface */ . . fmt=surface-
Pixel formats above 8-bit are an entirely different experience. They are considered to be