logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

IMG_LoadTexture_IO - Load an image from an SDL data source into a GPU texture.

Availability

       This function is available since SDL_image 3.0.0.

Description

       An  SDL_Texture  represents  an  image  in  GPU  memory,  usable  by  SDL's  2D  Render  API. This can be
       significantly more efficient than using a CPU-bound SDL_Surface if you don't need to manipulate the image
       directly after loading it.

       If the loaded image has transparency or a colorkey, a texture with an  alpha  channel  will  be  created.
       Otherwise,  SDL_image  will  attempt  to  create  an  SDL_Texture in the most format that most reasonably
       represents the image data (but in many cases, this will just end up being 32-bit RGB or 32-bit RGBA).

       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.

       There is a separate function  to  read  files  from  disk  without  having  to  deal  with  SDL_IOStream:
       IMG_LoadTexture(renderer,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_LoadTextureTyped_IO (), 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.

       If  you  would rather decode an image to an SDL_Surface (a buffer of pixels in CPU memory), call IMG_Load
       () instead.

       When done with the returned texture, the app should dispose of it with a call to SDL_DestroyTexture().

Function Parameters

renderer
              the SDL_Renderer to use to create the GPU texture.

       src    an SDL_IOStream that data will be read from.

       closeio
              true to close/free the SDL_IOStream before returning, false to leave it open.

Header File

       Defined in SDL3_image/SDL_image.h

Name

       IMG_LoadTexture_IO - Load an image from an SDL data source into a GPU texture.

Return Value

       Returns a new texture, or NULL on error.

See Also

(3), IMG_LoadTexture(3), (3), IMG_LoadTextureTyped_IO(3), SDL_DestroyTexture(3)

SDL_image                                        SDL_image 3.2.4                           IMG_LoadTexture_IO(3)

Synopsis

#include"SDL3_image/SDL_image.h"SDL_Texture*IMG_LoadTexture_IO(SDL_Renderer*renderer,SDL_IOStream*src,boolcloseio);

See Also