.\" This manpage content is licensed under Creative Commons .\" Attribution 4.0 International (CC BY 4.0) .\" https://creativecommons.org/licenses/by/4.0/ .\" This manpage was generated from SDL_image's wiki page for IMG_LoadTyped_IO: .\" https://wiki.libsdl.org/SDL_image/IMG_LoadTyped_IO .\" Generated with SDL/build-scripts/wikiheaders.pl .\" revision 3~git20240319~18b2816+ds-1 .\" Please report issues in this manpage's content at: .\" https://github.com/libsdl-org/sdlwiki/issues/new .\" Please report issues in the generation of this manpage from the wiki at: .\" https://github.com/libsdl-org/SDL/issues/new?title=Misgenerated%20manpage%20for%20IMG_LoadTyped_IO .\" SDL_image can be found at https://libsdl.org/projects/SDL_image .de URL \$2 \(laURL: \$1 \(ra\$3 .. .if \n[.g] .mso www.tmac .TH IMG_LoadTyped_IO 3 "SDL_image 3.0.0" "SDL_image" "SDL_image3 FUNCTIONS" .SH NAME IMG_LoadTyped_IO \- Load an image from an SDL data source into a software surface\[char46] .SH SYNOPSIS .nf .B #include \(dqSDL3_image/SDL_image.h\(dq .PP .BI "SDL_Surface * IMG_LoadTyped_IO(SDL_IOStream *src, SDL_bool closeio, const char *type); .fi .SH DESCRIPTION An SDL_Surface is a buffer of pixels in memory accessible by the CPU\[char46] Use this if you plan to hand the data to something else or manipulate it further in code\[char46] 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)\[char46] You can inspect an SDL_Surface for its specifics, and use SDL_ConvertSurface to then migrate to any supported format\[char46] If the image format supports a transparent pixel, SDL will set the colorkey for the surface\[char46] You can enable RLE acceleration on the surface afterwards by calling: SDL_SetSurfaceColorKey(image, SDL_RLEACCEL, image->format->colorkey); If .BR closeio is SDL_TRUE, .BR src will be closed before returning, whether this function succeeds or not\[char46] SDL_image reads everything it needs from .BR src during this call in any case\[char46] 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\[char46] If .BR type is NULL, SDL_image will rely solely on its ability to guess the format\[char46] There is a separate function to read files from disk without having to deal with SDL_IOStream: .BR IMG_Load("filename\[char46]jpg") will call this function and manage those details for you, determining the file type from the filename's extension\[char46] There is also .BR 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\[char46] 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 .BR IMG_LoadTextureTyped_IO () instead\[char46] When done with the returned surface, the app should dispose of it with a call to SDL_DestroySurface()\[char46] .SH FUNCTION PARAMETERS .TP .I src an SDL_IOStream that data will be read from\[char46] .TP .I closeio SDL_TRUE to close/free the SDL_IOStream before returning, SDL_FALSE to leave it open\[char46] .TP .I type a filename extension that represent this data ("BMP", "GIF", "PNG", etc)\[char46] .SH RETURN VALUE Returns a new SDL surface, or NULL on error\[char46] .SH AVAILABILITY This function is available since SDL_image 3\[char46]0\[char46]0\[char46] .SH SEE ALSO .BR IMG_Load (3), .BR IMG_Load_IO (3), .BR SDL_DestroySurface (3)