libsdl-org / SDL_image

Image decoding for many popular formats for Simple Directmedia Layer.
zlib License
513 stars 174 forks source link
sdl-image sdl2

SDL_image 3.0

The latest version of this library is available from GitHub: https://github.com/libsdl-org/SDL_image/releases

This is a simple library to load images of various formats as SDL surfaces. It can load BMP, GIF, JPEG, LBM, PCX, PNG, PNM (PPM/PGM/PBM), QOI, TGA, XCF, XPM, and simple SVG format images. It can also load AVIF, JPEG-XL, TIFF, and WebP images, depending on build options (see the note below for details.)

API:

include <SDL3_image/SDL_image.h>

SDL_Surface *IMG_Load(const char *file);

or SDL_Surface IMG_Load_IO(SDL_IOStream src, SDL_bool closeio); or SDL_Surface IMG_LoadTyped_IO(SDL_IOStream src, SDL_bool closeio, char *type);

where type is a string specifying the format (i.e. "PNG" or "pcx"). Note that IMG_Load_IO cannot load TGA images.

To create a surface from an XPM image included in C source, use:

SDL_Surface *IMG_ReadXPMFromArray(char **xpm);

An example program 'showimage' is included, with source in examples/showimage.c

Documentation is also available online at https://wiki.libsdl.org/SDL_image

This library is under the zlib License, see the file "LICENSE.txt" for details.

Note: Support for AVIF, JPEG-XL, TIFF, and WebP are not included by default because of the size of the decode libraries, but you can get them by running external/download.sh