SDL_LoadSurface_IO(3)

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

πŸ’– SDL_LoadSurface_IO(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, and today's main character is SDL_LoadSurface_IO πŸ’…


✨ NAME ✨

SDL_LoadSurface_IO β€” load a BMP or PNG image from a seekable SDL data stream πŸ–ΌοΈ

like, literally just "gimme the picture, and gimme it from a stream" 🫢


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_surface.h>

SDL_Surface * SDL_LoadSurface_IO(SDL_IOStream *src, bool closeio);

πŸ¦‹ DESCRIPTION πŸ¦‹

so you call this and it hands you back a whole new surface. cute, right? ✨

but listen β€” the new surface should be freed with SDL_DestroySurface(). Not doing so will result in a memory leak. and no, leaking is not a personality trait, bestie 😭 free your surfaces, it's giving responsible queen behavior πŸ‘‘


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • src β€” the data stream for the surface. that's the vibe source. the tea. the actual bytes 🌈
  • closeio β€” if true, it calls SDL_CloseIO() on src before returning, even in the case of an error. so like, if you're passing true, just know it's closing the door behind you no matter what happens on the way out πŸ™ˆ

⭐ RETURN VALUE ⭐

Returns a pointer to a new SDL_Surface structure, or NULL on failure β€” and if it flops, call SDL_GetError() for more information πŸ’€ no cap, that's where the actual reason lives.


🧚 THREAD SAFETY 🧚

It is safe to call this function from any thread. multi-threaded and unbothered πŸ’…βœ¨


πŸ‘‘ AVAILABILITY πŸ‘‘

This function is available since SDL 3.4.0. so if you're on something older... not me finding out the hard way 😭


πŸ’œ SEE ALSO πŸ’œ


that's the whole page, periodt πŸŽ€ go forth and load your surfaces, you absolute icon 🫢🌈

Simple Directmedia Layer Β· SDL 3.4.18 Β· SDL_LoadSurface_IO(3) β€” mwah, thanks for reading, ily, bye bestie πŸ’–πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from