---
name: "IMG_LoadTexture"
section: "3"
platform: "linux"
package: "libsdl3-image-doc"
version: "3.2.4+ds-1+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/IMG_LoadTexture"
---

# IMG\_LoadTexture(3)

Load an image from a filesystem path into a GPU texture.

## NAME

IMG\_LoadTexture - Load an image from a filesystem path into a GPU texture.

## HEADER FILE

Defined in SDL3\_image/SDL\_image.h

## SYNOPSIS

```
#include "SDL3_image/SDL_image.h"
```

**SDL\_Texture \* IMG\_LoadTexture(SDL\_Renderer \*renderer, const char \*file);**

## 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).

There is a separate function to read files from an SDL\_IOStream, if you need an i/o abstraction to provide data from anywhere instead of a simple filesystem read; that function is

**IMG\_LoadTexture\_IO** ().

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.

- *file*

  a path on the filesystem to load an image from.

## RETURN VALUE

Returns a new texture, or NULL on error.

## AVAILABILITY

This function is available since SDL\_image 3.0.0.

## SEE ALSO

**•**(3), [**IMG\_LoadTextureTyped\_IO**(3)](/IMG_LoadTextureTyped_IO/3.md), **•**(3), [**IMG\_LoadTexture\_IO**(3)](/IMG_LoadTexture_IO/3.md)
