SDL_SaveBMP_IO(3)
π SDL_SaveBMP_IO π
okay bestie, so this is a page from the SDL3 FUNCTIONS manual, and today's main character is SDL_SaveBMP_IO β the girl who takes your surface and yeets it into a BMP. let's get into it π
β¨ NAME β¨
SDL_SaveBMP_IO β save a surface to a seekable SDL data stream, in BMP format. that's it, that's the whole vibe π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_surface.h>
bool SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio);
π DESCRIPTION π
okay so here's the tea on how the saving actually goes down π«
Surfaces with a 24-bit, 32-bit, and paletted 8-bit format get saved into the BMP directly. no conversion, no detour, straight through. slay β¨
Other RGB formats with 8-bit or higher get converted first:
- to a 24-bit surface, or
- if they have an alpha mask or a colorkey, to a 32-bit surface
...and then they get saved. it's giving "we'll fix your outfit before the photo, don't worry" π
and now the part nobody wants to hear π
YUV formats, and paletted 1-bit and 4-bit formats, are not supported. periodt. they do not pass the vibe check and they do not get saved.
π¦ FUNCTION PARAMETERS π¦
surfaceβ theSDL_Surfacestructure holding the image you want to save. this is your girl, your canvas, your moment πdstβ a data stream to save to. the destination, the place where the BMP is gonna live π‘closeioβ iftrue, it callsSDL_CloseIO()ondstbefore returning, even in the case of an error. so like, yes, it will still close it even if everything went sideways. no cap, that's the deal π
π RETURN VALUE π
Returns true on success or false on failure β and bestie, if it fails, please call SDL_GetError() for more information. the function will not tell you what went wrong, you gotta go ask π€
β THREAD SAFETY β
This function can be called on different threads with different surfaces. so as long as each thread has its own surface, you're good β go be multithreaded, you icon π§
π AVAILABILITY π
This function is available since SDL 3.2.0. if you're on something older, this is not for you, sorry not sorry π
π SEE ALSO π
iykyk β load it back, or save it the non-IO way πΈ
and that's the whole page, bestie!! π«Ά this little manual moment came to you from Simple Directmedia Layer, running SDL 3.4.18, and yeah the page header said SDL_SaveBMP_IO(3) the whole time, we just folded that in up top like a cute little hair clip πβ¨ go save some BMPs, you're doing amazing π
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms