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 β€” the SDL_Surface you're saving. your actual image, your main character. πŸ‘‘
  • dst β€” the SDL_IOStream you're writing the image data to. the destination, the stage, the venue.
  • closeio β€” true to close/free the SDL_IOStream before returning, false to leave it open. your call, but remember the warning above β€” true closes 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