.\" 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_Load_RW: .\" https://wiki.libsdl.org/SDL_image/IMG_Load_RW .\" Generated with SDL/build-scripts/wikiheaders.pl .\" revision 3~git20240129~750f1c1+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_Load_RW .\" 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_Load_RW 3 "SDL_image 3.0.0" "SDL_image" "SDL_image3 FUNCTIONS" .SH NAME IMG_Load_RW \- 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_Load_RW(SDL_RWops *src, SDL_bool freesrc); .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 freesrc is SDL_TRUE, the RWops will be closed before returning, whether this function succeeds or not\[char46] SDL_image reads everything it needs from the RWops during this call in any case\[char46] There is a separate function to read files from disk without having to deal with SDL_RWops: .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_LoadTyped_RW (), which is equivalent to this function except a file extension (like "BMP", "JPG", etc) can be specified, in case SDL_image cannot autodetect the file format\[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_LoadTexture_RW () 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_RWops that data will be read from\[char46] .TP .I freesrc SDL_TRUE to close/free the SDL_RWops before returning, SDL_FALSE to leave it open\[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_LoadTyped_RW (3), .BR SDL_DestroySurface (3)