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β theSDL_Surfacestructure 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
- 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