IMG_SaveWEBP_IO(3)
πΎ IMG_SaveWEBP_IO(3) β the SDL_image3 glow-up where you yeet a surface into WEBP data through an SDL_IOStream
okay bestie, gather round, because this one is lowkey the cooler, more flexible sibling of the save-to-a-filename function and it deserves its moment π
β¨ NAME β¨
IMG_SaveWEBP_IO β save an SDL_Surface into WEBP image data, via an SDL_IOStream. that's it, that's the whole job, and it ate π«Ά
π SYNOPSIS π
#include <SDL3_image/SDL_image.h>
bool IMG_SaveWEBP_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio, float quality);
πΈ DESCRIPTION πΈ
so like, if all you wanna do is save straight to a filename, you literally do not need this one β just use IMG_SaveWEBP() instead and go live your life, queen π
but if you're the kind of main character who's writing into a memory buffer, a custom stream, or literally anywhere that isn't a plain old file path, then IMG_SaveWEBP_IO is your girl. it takes your surface and pushes the WEBP data out through an SDL_IOStream that you provide. iconic.
one thing you need to know before you go: if closeio is true, then dst will be closed before returning β whether this function succeeds or not. no takebacksies, no exceptions, it's getting closed either way. so don't come crying to me if you were planning to reuse that stream afterward π
π¦ FUNCTION PARAMETERS π¦
surfaceβ theSDL_Surfaceyou wanna save. your canvas, your art, your moment β¨dstβ theSDL_IOStreamthe image data gets written to. this is the destination, the vibes-receptacle, the place where the bytes go πcloseioβ passtrueto close/free theSDL_IOStreambefore returning, orfalseto leave it open like a considerate friend who closes the door quietly on their way out πͺqualityβ a number between0and100. and the meaning flips depending on which mode you're in, so pay attention bestie:- for lossy,
0gives you the smallest file size and100gives you the largest ππ - for lossless, this parameter is actually about how much effort goes into the compression:
0is the fastest but produces larger files compared to the slowest-but-best100π’β‘οΈπ
- for lossy,
π RETURN VALUE π
returns true on success or false on failure. and if you get a false, do not just sit there guessing β call SDL_GetError() for more info, because she will tell you exactly what went wrong π
π AVAILABILITY π
this function has been available since SDL_image 3.4.0. so if you're on anything older, sorry babe, she's not there yet π
π₯ SEE ALSO π₯
IMG_SaveWEBP(3)β the filename-flavored version of this exact vibe. go check her out too π
no cap: closeio closing your stream on failure too is the kind of detail that ruins your whole afternoon if you forget it. remember it. tattoo it. periodt. π
and that's the whole page, bestie π this was written for SDL_image, version 3.4.8 β mwah, go save some WEBP files, you've got this ππ
π¦ 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