IMG_SaveTyped_IO(3)

πŸ“¦
version 3.4.8 Β· 5 versions
, in fedora 43, fedora 44

✨ 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 β€” the SDL_Surface you wanna save. your little pixel baby. πŸ‘‘
  • dst β€” the SDL_IOStream where the image data is gonna live. this is the destination, the final boss, the place we're yeeting bytes into.
  • closeio β€” true if you want the SDL_IOStream closed/freed before returning, false if 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 πŸŽ€


and that's the whole page, you ate it, you understood it, main character energy fr fr 🌟

tiny reminder bestie: that closeio = true thing closes dst no 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