IMG_SaveJPG_IO(3)
π IMG_SaveJPG_IO(3)
okay so bestie, welcome to the SDL_image3 FUNCTIONS section, and specifically to IMG_SaveJPG_IO β the glow-up function that takes your SDL_Surface and yeets it straight into JPEG data through an SDL_IOStream. no filenames required, we're going β¨stream modeβ¨.
π NAME π
IMG_SaveJPG_IO β save an SDL_Surface into JPEG image data, via an SDL_IOStream. that's the whole vibe. iykyk.
πΈ SYNOPSIS πΈ
#include <SDL3_image/SDL_image.h>
bool IMG_SaveJPG_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio, int quality);
like, look at her. four args, a bool return, and she's iconic.
π¦ DESCRIPTION π¦
so real talk: if you literally just want to save to a filename and not deal with streams at all, you can use IMG_SaveJPG() instead. that's the shortcut queen. this function is the one you want when your destination is already an SDL_IOStream and you're doing something a little more custom.
and here's the part you do NOT want to skip, bestie: if closeio is true, then dst will be closed before returning β whether this function succeeds or not. no cap. success, failure, whatever happens, she's closing that stream. so don't touch dst afterwards, it's gone, it has left the chat. π
okay but fr fr, read that again. true means it gets closed no matter what happens in this function. plan accordingly.
π FUNCTION PARAMETERS π
surfaceβ theSDL_Surfaceyou're saving. your actual image, your main character. πdstβ theSDL_IOStreamyou're writing the image data to. the destination, the stage, the venue.closeioβtrueto close/free theSDL_IOStreambefore returning,falseto leave it open. your call, but remember the warning above βtruecloses it even on failure. πqualityβ the spicy one. here's the exact scale, don't make me repeat myself:[0; 33]is Lowest quality[34; 66]is Middle quality[67; 100]is Highest quality
β RETURN VALUE β
returns true on success or false on failure. and if it fails? call SDL_GetError() for more information β that's where the drama lives, she'll tell you what went wrong. π«Ά
π AVAILABILITY π
this function is available since SDL_image 3.0.0. so like, if you're on something older, no she's not there, upgrade bestie. β¨
π SEE ALSO π
IMG_SaveJPG(3)β the filename shortcut, she's right there if you need her.
and that's the whole page, bestie π this diva of a manual page lives in SDL_image 3.4.4, so jot that down β and the footer's whole personality is just that version number doing its little <rainbow>main character walk</rainbow> at the bottom of the terminal. mwah. π
π
π¦ where this page comes from
- ubuntu stonking: libsdl3-image-doc 3.4.4+ds-2 Β· zlib/libpng AND HPND-like AND zlib-like-permissive
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms