How do I convert `SDL_PixelFormatEnum` to `SDL_PixelFormat`?

Hello!

My understanding is that SDL_PixelFormatEnum is an enumeration that partially indexes the space of possible values of SDL_PixelFormat. So, to every SDL_PixelFormatEnum corresponds an appropriate value of SDL_PixelFormat. Is there a standard way to «dereference» that «index», that is, a procedure SDL_PixelFormat dereference (SDL_PixelFormatEnum format)?

I want to compute the size of an image buffer given the dimensions and the pixel format enumeration value. I am working with another language (Haskell), so I cannot access CPP pragmas such as SDL_BYTESPERPIXEL. I can write my own logic in C but I was hoping that there is a standard solution.

Sounds like SDL_AllocFormat - SDL Wiki ?

1 Like