SDL_SaveBMP(3)

πŸ’Ύ SDL_SaveBMP(3) β€” SDL3 FUNCTIONS

okay bestie, welcome to the SDL3 corner of the man pages, this one's all about SDL_SaveBMP. yes it's literally in the name. we're saving a surface. to a file. in BMP format. slay. πŸŽ€


✨ NAME ✨

SDL_SaveBMP β€” save a surface to a file in BMP format. that's the whole vibe. no cap. πŸ¦‹


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_surface.h>

bool SDL_SaveBMP(SDL_Surface *surface, const char *file);

look at that signature. two args. one bool back. immaculate. πŸ’…


πŸ‘‘ DESCRIPTION πŸ‘‘

okay so here's the tea on how this thing actually behaves, because BMP is not a one-size-fits-all situation and you need to know which lane your surface is in:

  • Surfaces rockin' a 24-bit, 32-bit, or paletted 8-bit format? they get saved into the BMP directly. no middleman, no conversion, straight to file. periodt. πŸ’–
  • Other RGB formats at 8-bit or higher get converted to a 24-bit surface first. unless β€” and this is the juicy part β€” they have an alpha mask or a colorkey, in which case they get converted to a 32-bit surface before saving. so your transparency doesn't just evaporate, bestie, it gets upgraded. ✨
  • YUV? not supported. paletted 1-bit and 4-bit formats? also not supported. like, at all. it's giving "we don't do that here." πŸ’€

πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • surface β€” the SDL_Surface structure holding the image you wanna save. this is your main character. 🌟
  • file β€” a file to save to. yep. that's the destination. give it a path and let it cook. πŸ“

🌈 RETURN VALUE 🌈

returns true on success or false on failure β€” classic binary slay. and if it fails? call SDL_GetError() for more info, because she will tell you what went wrong. don't just sit there guessing, bestie. 😭


🧚 THREAD SAFETY 🧚

this function can be called on different threads with different surfaces. so yes, you can absolutely have multiple threads each doing their own little save, as long as nobody's sharing a surface. go off. 🫢


⭐ AVAILABILITY ⭐

available since SDL 3.2.0. if you're on anything older, this is not the function you're looking for. πŸ™ˆ


πŸ”₯ SEE ALSO πŸ”₯

iykyk. go read those next, they're the whole friend group. πŸ’œ


lowkey reminder: those unsupported formats (YUV, paletted 1-bit, paletted 4-bit) aren't a "maybe" β€” they're just not supported. no amount of manifesting will change that. 🌸

that's the page, babe. brought to you by Simple Directmedia Layer, running SDL 3.4.18 β€” mwah, ily, go save something pretty. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from