IMG_LoadTyped_IO(3)
NAME π
IMG_LoadTyped_IO β load an image from an SDL data source into a software surface, bestie π
This page is from the SDL_image3 FUNCTIONS manual, and it's giving "typed IO loader with main character energy" β¨
SYNOPSIS π
#include <SDL3_image/SDL_image.h>
SDL_Surface * IMG_LoadTyped_IO(SDL_IOStream *src, bool closeio, const char *type);
DESCRIPTION π¦
Okay so first thing: an SDL_Surface is a buffer of pixels in memory that the CPU can access π. Use this function if you're planning to hand that data off to something else or keep manipulating it further in code. Very "I have pixels and I'm not afraid to use them" energy π.
There are no guarantees about what format the new SDL_Surface data will be π. In many cases, SDL_image will attempt to supply a surface that exactly matches the provided image, but in others it might have to convert β either because the image is in a format that SDL doesn't directly support, or because it's compressed data that could reasonably uncompress to various formats and SDL_image had to pick one. You can inspect an SDL_Surface for its specifics, and use SDL_ConvertSurface to then migrate to any supported format. Slay π
.
If the image format supports a transparent pixel, SDL will set the colorkey for the surface. You can enable RLE acceleration on the surface afterwards by calling: SDL_SetSurfaceColorKey(image, SDL_RLEACCEL, image->format->colorkey); β¨
If closeio is true, src will be closed before returning β whether this function succeeds or not π«Ά. SDL_image reads everything it needs from src during this call in any case. No cap.
Even though this function accepts a file type, SDL_image may still try other decoders that are capable of detecting file type from the contents of the image data, but may rely on the caller-provided type string for formats that it cannot autodetect π. If type is NULL, SDL_image will rely solely on its ability to guess the format. iykyk.
There is a separate function to read files from disk without having to deal with SDL_IOStream: IMG_Load("filename.jpg") will call this function and manage those details for you, determining the file type from the filename's extension πΈ.
There is also IMG_Load_IO(), which is equivalent to this function except that it will rely on SDL_image to determine what type of data it is loading, much like passing a NULL for type π.
If you are using SDL's 2D rendering API, there is an equivalent call to load images directly into an SDL_Texture for use by the GPU without using a software surface: call IMG_LoadTextureTyped_IO() instead π₯.
When done with the returned surface, the app should dispose of it with a call to SDL_DestroySurface(). Clean up your room, bestie π§.
FUNCTION PARAMETERS π
srcβ anSDL_IOStreamthat data will be read from. That's the source, periodt π.closeioβtrueto close/free theSDL_IOStreambefore returning,falseto leave it open. Choose wisely π.typeβ a filename extension that represent this data ("BMP","GIF","PNG", etc). Yes, literally a little string like that π .
RETURN VALUE π
Returns a new SDL surface, or NULL on error π. That's the whole vibe check.
AVAILABILITY β
This function is available since SDL_image 3.0.0. Iconic behavior since day one π.
SEE ALSO π¦
Okay that's the whole page, bestie π«Ά. Cute little sign-off tea: this came from the SDL_image manual, version SDL_image 3.4.4; the footer didn't actually print a date, so the date slot is literally a mystery β no invented dates, periodt π
. The page title is IMG_LoadTyped_IO(3), and that's the vibe. π
π¦ 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