Can someone tell me what the format
field of the SDL_PixelFormat
is for? What does it contain? The documentation of the SDL2 library does not give enough detail.
Here are the bytes of two instances of such an object. The format
field covers the first 4 bytes.
04 18 16 16 00 00 00 00
00 00 00 00 00 00 00 00
20 04 00 00 00 00 FF 00
00 FF 00 00 FF 00 00 00
00 00 00 00 00 00 00 08
10 08 00 00 01 00 00 00
50 47 D6 B4 88 59 00 00
04 20 36 16 00 00 00 00
00 00 00 00 00 00 00 00
20 04 00 00 00 00 FF 00
00 FF 00 00 FF 00 00 00
00 00 00 FF 00 00 00 00
10 08 00 18 01 00 00 00
00 00 00 00 00 00 00 00
The first string of bytes comes from a window surface retrieved with SDL_GetWindowSurface
, and the other one comes from an image surface created with SDL_LoadBMP
.
The format
field stores the pixel format type, see: SDL_PixelFormatEnum.
For example, the SDL_AllocFormat function creates a SDL_PixelFormat corresponding to a pixel format and stores the given parameter in the specific field. Besides that, sets also all the other fields to the corresponding values.