IMG_SavePNG_IO(3)

πŸ’– IMG_SavePNG_IO(3) πŸ’–

okay so hi bestie, welcome to IMG_SavePNG_IO(3) from SDL_image3 FUNCTIONS β€” yes, the manual name is folded in right here, we're not doing that copy-paste header line. This is the β€œsave your SDL_Surface as PNG data through an SDL_IOStream” moment, and it's lowkey iconic. πŸŽ€

🌸 NAME 🌸

IMG_SavePNG_IO β€” save an SDL_Surface into PNG image data, via an SDL_IOStream. That's the whole vibe. ✨

✨ SYNOPSIS ✨

#include <SDL3_image/SDL_image.h>

bool IMG_SavePNG_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so the main character here is simple: if you just want to save to a filename, you can use IMG_SavePNG() instead. Like, don't do extra work for no reason, bestie. πŸ’…

Now the important caveat: if closeio is true, dst will be closed before returning, whether this function succeeds or not. Whether. It. Succeeds. Or. Not. So yes, that stream is getting closed either way β€” no cap. Set it to false if you need to keep that SDL_IOStream open, okay? 🫢

πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • surface β€” the SDL_Surface to save. That's the image data you're trying to get out into PNG land. πŸ–ΌοΈ
  • dst β€” the SDL_IOStream to save the image data to. It's the destination stream, the little data pipe, the place the PNG bytes are headed. 🚰
  • closeio β€” true to close/free the SDL_IOStream before returning, false to leave it open. So it's literally the β€œdo we shut the door behind us?” switch. πŸšͺ

🌈 RETURN VALUE 🌈

Returns true on success or false on failure; call SDL_GetError() for more information. So if things go sideways, don't just stare at it β€” hit up SDL_GetError() for the tea. β˜•

πŸ’œ AVAILABILITY πŸ’œ

This function is available since SDL_image 3.0.0. Periodt. If you're on something older, this is not the function you're looking for, bestie. πŸ•°οΈ

πŸ‘‘ SEE ALSO πŸ‘‘

  • IMG_SavePNG(3) β€” the filename-saving cousin, for when you don't need to hand it an SDL_IOStream. iykyk. πŸ’«

okay that's the page, bestie. This is from SDL_image, version SDL_image 3.4.4 β€” and the original footer didn't give us a date, so no fake date energy here, just the source, the version, and a cute little wave. bye! πŸŽ€βœ¨πŸ’–

πŸ“¦ where this page comes from