IMG_SaveTyped_IO(3)
β¨ IMG_SaveTyped_IO(3) β¨
okay bestie, gather round, because we're doing the SDL_image3 FUNCTIONS thing and this one is genuinely so fun π
πΈ NAME πΈ
IMG_SaveTyped_IO β save an SDL_Surface into formatted image data, via an SDL_IOStream. like, you got a surface, you got a stream, we're making pixels into a file-shaped thing. iconic behavior honestly π
β¨ SYNOPSIS β¨
#include <SDL3_image/SDL_image.h>
bool IMG_SaveTyped_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio, const char *type);
π DESCRIPTION π
So if you literally just wanna save to a filename and be done with it, you can use IMG_Save() instead. no shame in it, that one's for the low-effort girlies π«Ά
But listen β if closeio is true, then dst is gonna get closed before the function returns. and not "only if it worked" closed. whether this function succeeds or not. so like, no take-backsies, no second chances, that stream is GONE. plan accordingly bestie π
And for formats that accept a quality setting? a default quality of 90 gets used. that's the vibe, that's the number, no cap β¨
π FUNCTION PARAMETERS π
surfaceβ theSDL_Surfaceyou wanna save. your little pixel baby. πdstβ theSDL_IOStreamwhere the image data is gonna live. this is the destination, the final boss, the place we're yeeting bytes into.closeioβtrueif you want theSDL_IOStreamclosed/freed before returning,falseif you want it left open. pick wisely, this is a commitment πtypeβ a filename extension that represents this data, like"BMP","GIF","PNG", etc. that's how it knows what format to give you. the"etc"is doing a lot of heavy lifting there but we move π¦
π RETURN VALUE π
Returns true on success or false on failure β and if it's a false, bestie, please call SDL_GetError() for more information. don't just sit there guessing, the error message is RIGHT THERE π
β AVAILABILITY β
This function has been available since SDL_image 3.4.0. so if you're on something older, that's a no from the universe.
π SEE ALSO π
IMG_Save(3)IMG_SaveAVIF_IO(3)IMG_SaveBMP_IO(3)IMG_SaveCUR_IO(3)IMG_SaveGIF_IO(3)IMG_SaveICO_IO(3)IMG_SaveJPG_IO(3)IMG_SavePNG_IO(3)IMG_SaveTGA_IO(3)IMG_SaveWEBP_IO(3)
and that's the whole page, you ate it, you understood it, main character energy fr fr π
tiny reminder bestie: thatcloseio = truething closesdstno matter what happens. success, failure, chaos, whatever. it's giving "no refunds" π
SDL_image version 3.4.8 said it, IMG_SaveTyped_IO(3) said it, and now you know it too. mwah, go save some surfaces π«Άπβ¨
π¦ where this page comes from
- fedora 43: SDL3_image-devel 3.4.8-1.fc43 Β· Zlib AND (HPND-Pbmplus AND Zlib) AND MIT AND (MIT OR Unlicense) AND LicenseRef-Fedora-Public-Domain
- fedora 43: SDL3_image-devel 3.4.8-1.fc43 Β· Zlib AND (HPND-Pbmplus AND Zlib) AND MIT AND (MIT OR Unlicense) AND LicenseRef-Fedora-Public-Domain
- fedora 44: SDL3_image-devel 3.4.8-1.fc44 Β· Zlib AND (HPND-Pbmplus AND Zlib) AND MIT AND (MIT OR Unlicense) AND LicenseRef-Fedora-Public-Domain
- fedora 44: SDL3_image-devel 3.4.8-1.fc44 Β· Zlib AND (HPND-Pbmplus AND Zlib) AND MIT AND (MIT OR Unlicense) AND LicenseRef-Fedora-Public-Domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms