SDL3pp
A slim C++ wrapper for SDL3
|
Header file for SDL_image library. More...
Classes | |
struct | SDL::AnimationRef |
Animated image support. More... | |
struct | SDL::Animation |
Handle to an owned animation. More... | |
struct | SDL::AnimationUnsafe |
Unsafe Handle to animation. More... | |
Macros | |
#define | SDL_IMAGE_VERSION |
This is the version number macro for the current SDL_image version. | |
#define | SDL_IMAGE_VERSION_ATLEAST(X, Y, Z) |
This macro will evaluate to true if compiled with SDL_image at least X.Y.Z. | |
Typedefs | |
using | SDL::AnimationShared = ResourceShared< Animation > |
Handle to a shared animation. | |
using | SDL::AnimationWeak = ResourceWeak< Animation > |
Weak handle to a shared animation. | |
Functions | |
int | SDL::IMG_Version () |
This function gets the version of the dynamically linked SDL_image library. | |
Surface | SDL::LoadSurface (IOStreamRef src, StringParam type) |
Load an image from an SDL data source into a software surface. | |
Surface | SDL::LoadSurface (StringParam file) |
Load an image from a filesystem path into a software surface. | |
Surface | SDL::LoadSurface (IOStreamRef src) |
Load an image from an SDL data source into a software surface. | |
Texture | SDL::LoadTexture (RendererRef renderer, StringParam file) |
Load an image from a filesystem path into a GPU texture. | |
Texture | SDL::LoadTexture (RendererRef renderer, IOStreamRef src) |
Load an image from an SDL data source into a GPU texture. | |
Texture | SDL::LoadTexture (RendererRef renderer, IOStreamRef src, StringParam type) |
Load an image from an SDL data source into a GPU texture. | |
bool | SDL::isAVIF (IOStreamRef src) |
Detect AVIF image data on a readable/seekable IOStream. | |
bool | SDL::isICO (IOStreamRef src) |
Detect ICO image data on a readable/seekable IOStream. | |
bool | SDL::isCUR (IOStreamRef src) |
Detect CUR image data on a readable/seekable IOStream. | |
bool | SDL::isBMP (IOStreamRef src) |
Detect BMP image data on a readable/seekable IOStream. | |
bool | SDL::isGIF (IOStreamRef src) |
Detect GIF image data on a readable/seekable IOStream. | |
bool | SDL::isJPG (IOStreamRef src) |
Detect JPG image data on a readable/seekable IOStream. | |
bool | SDL::isJXL (IOStreamRef src) |
Detect JXL image data on a readable/seekable IOStream. | |
bool | SDL::isLBM (IOStreamRef src) |
Detect LBM image data on a readable/seekable IOStream. | |
bool | SDL::isPCX (IOStreamRef src) |
Detect PCX image data on a readable/seekable IOStream. | |
bool | SDL::isPNG (IOStreamRef src) |
Detect PNG image data on a readable/seekable IOStream. | |
bool | SDL::isPNM (IOStreamRef src) |
Detect PNM image data on a readable/seekable IOStream. | |
bool | SDL::isSVG (IOStreamRef src) |
Detect SVG image data on a readable/seekable IOStream. | |
bool | SDL::isQOI (IOStreamRef src) |
Detect QOI image data on a readable/seekable IOStream. | |
bool | SDL::isTIF (IOStreamRef src) |
Detect TIFF image data on a readable/seekable IOStream. | |
bool | SDL::isXCF (IOStreamRef src) |
Detect XCF image data on a readable/seekable IOStream. | |
bool | SDL::isXPM (IOStreamRef src) |
Detect XPM image data on a readable/seekable IOStream. | |
bool | SDL::isXV (IOStreamRef src) |
Detect XV image data on a readable/seekable IOStream. | |
bool | SDL::isWEBP (IOStreamRef src) |
Detect WEBP image data on a readable/seekable IOStream. | |
Surface | SDL::LoadAVIF (IOStreamRef src) |
Load a AVIF image directly. | |
Surface | SDL::LoadICO (IOStreamRef src) |
Load a ICO image directly. | |
Surface | SDL::LoadCUR (IOStreamRef src) |
Load a CUR image directly. | |
Surface | SDL::LoadBMP (IOStreamRef src) |
Load a BMP image directly. | |
Surface | SDL::LoadGIF (IOStreamRef src) |
Load a GIF image directly. | |
Surface | SDL::LoadJPG (IOStreamRef src) |
Load a JPG image directly. | |
Surface | SDL::LoadJXL (IOStreamRef src) |
Load a JXL image directly. | |
Surface | SDL::LoadLBM (IOStreamRef src) |
Load a LBM image directly. | |
Surface | SDL::LoadPCX (IOStreamRef src) |
Load a PCX image directly. | |
Surface | SDL::LoadPNG (IOStreamRef src) |
Load a PNG image directly. | |
Surface | SDL::LoadPNM (IOStreamRef src) |
Load a PNM image directly. | |
Surface | SDL::LoadSVG (IOStreamRef src) |
Load a SVG image directly. | |
Surface | SDL::LoadQOI (IOStreamRef src) |
Load a QOI image directly. | |
Surface | SDL::LoadTGA (IOStreamRef src) |
Load a TGA image directly. | |
Surface | SDL::LoadTIF (IOStreamRef src) |
Load a TIFF image directly. | |
Surface | SDL::LoadXCF (IOStreamRef src) |
Load a XCF image directly. | |
Surface | SDL::LoadXPM (IOStreamRef src) |
Load a XPM image directly. | |
Surface | SDL::LoadXV (IOStreamRef src) |
Load a XV image directly. | |
Surface | SDL::LoadWEBP (IOStreamRef src) |
Load a WEBP image directly. | |
Surface | SDL::LoadSizedSVG (IOStreamRef src, int width, int height) |
Load an SVG image, scaled to a specific size. | |
Surface | SDL::ReadXPMFromArray (char **xpm) |
Load an XPM image from a memory array. | |
Surface | SDL::ReadXPMFromArrayToRGB888 (char **xpm) |
Load an XPM image from a memory array. | |
void | SDL::SaveAVIF (SurfaceRef surface, StringParam file, int quality) |
Save an Surface into a AVIF image file. | |
void | SDL::SaveAVIF (SurfaceRef surface, IOStreamRef dst, int quality) |
Save an Surface into AVIF image data, via an IOStream. | |
void | SDL::SavePNG (SurfaceRef surface, StringParam file) |
Save an Surface into a PNG image file. | |
void | SDL::SavePNG (SurfaceRef surface, IOStreamRef dst) |
Save an Surface into PNG image data, via an IOStream. | |
void | SDL::SaveJPG (SurfaceRef surface, StringParam file, int quality) |
Save an Surface into a JPEG image file. | |
void | SDL::SaveJPG (SurfaceRef surface, IOStreamRef dst, int quality) |
Save an Surface into JPEG image data, via an IOStream. | |
Animation | SDL::LoadGIFAnimation (IOStreamRef src) |
Load a GIF animation directly. | |
Animation | SDL::LoadWEBPAnimation (IOStreamRef src) |
Load a WEBP animation directly. | |
AnimationShared | SDL::Animation::share () |
Move this animation into a AnimationShared. | |
A simple library to load images of various formats as SDL surfaces
#define SDL_IMAGE_VERSION |
#define SDL_IMAGE_VERSION_ATLEAST | ( | X, | |
Y, | |||
Z | |||
) |
using SDL::AnimationShared = typedef ResourceShared<Animation> |
using SDL::AnimationWeak = typedef ResourceWeak<Animation> |
|
inline |
|
inline |
This function attempts to determine if a file is a given filetype, reading the least amount possible from the IOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic i/o errors.
This function will always attempt to seek src
back to where it started when this function was called, but it will not report any errors in doing so, but assuming seeking works, this means you can immediately use this with a different IMG_isTYPE function, or load the image without further seeking.
You do not need to call this function to load data; SDL_image can work to determine file type in many cases in its standard load functions.
src | a seekable/readable IOStream to provide image data. |
|
inline |
This function attempts to determine if a file is a given filetype, reading the least amount possible from the IOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic i/o errors.
This function will always attempt to seek src
back to where it started when this function was called, but it will not report any errors in doing so, but assuming seeking works, this means you can immediately use this with a different IMG_isTYPE function, or load the image without further seeking.
You do not need to call this function to load data; SDL_image can work to determine file type in many cases in its standard load functions.
src | a seekable/readable IOStream to provide image data. |
|
inline |
This function attempts to determine if a file is a given filetype, reading the least amount possible from the IOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic i/o errors.
This function will always attempt to seek src
back to where it started when this function was called, but it will not report any errors in doing so, but assuming seeking works, this means you can immediately use this with a different IMG_isTYPE function, or load the image without further seeking.
You do not need to call this function to load data; SDL_image can work to determine file type in many cases in its standard load functions.
src | a seekable/readable IOStream to provide image data. |
|
inline |
This function attempts to determine if a file is a given filetype, reading the least amount possible from the IOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic i/o errors.
This function will always attempt to seek src
back to where it started when this function was called, but it will not report any errors in doing so, but assuming seeking works, this means you can immediately use this with a different IMG_isTYPE function, or load the image without further seeking.
You do not need to call this function to load data; SDL_image can work to determine file type in many cases in its standard load functions.
src | a seekable/readable IOStream to provide image data. |
|
inline |
This function attempts to determine if a file is a given filetype, reading the least amount possible from the IOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic i/o errors.
This function will always attempt to seek src
back to where it started when this function was called, but it will not report any errors in doing so, but assuming seeking works, this means you can immediately use this with a different IMG_isTYPE function, or load the image without further seeking.
You do not need to call this function to load data; SDL_image can work to determine file type in many cases in its standard load functions.
src | a seekable/readable IOStream to provide image data. |
|
inline |
This function attempts to determine if a file is a given filetype, reading the least amount possible from the IOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic i/o errors.
This function will always attempt to seek src
back to where it started when this function was called, but it will not report any errors in doing so, but assuming seeking works, this means you can immediately use this with a different IMG_isTYPE function, or load the image without further seeking.
You do not need to call this function to load data; SDL_image can work to determine file type in many cases in its standard load functions.
src | a seekable/readable IOStream to provide image data. |
|
inline |
This function attempts to determine if a file is a given filetype, reading the least amount possible from the IOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic i/o errors.
This function will always attempt to seek src
back to where it started when this function was called, but it will not report any errors in doing so, but assuming seeking works, this means you can immediately use this with a different IMG_isTYPE function, or load the image without further seeking.
You do not need to call this function to load data; SDL_image can work to determine file type in many cases in its standard load functions.
src | a seekable/readable IOStream to provide image data. |
|
inline |
This function attempts to determine if a file is a given filetype, reading the least amount possible from the IOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic i/o errors.
This function will always attempt to seek src
back to where it started when this function was called, but it will not report any errors in doing so, but assuming seeking works, this means you can immediately use this with a different IMG_isTYPE function, or load the image without further seeking.
You do not need to call this function to load data; SDL_image can work to determine file type in many cases in its standard load functions.
src | a seekable/readable IOStream to provide image data. |
|
inline |
This function attempts to determine if a file is a given filetype, reading the least amount possible from the IOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic i/o errors.
This function will always attempt to seek src
back to where it started when this function was called, but it will not report any errors in doing so, but assuming seeking works, this means you can immediately use this with a different IMG_isTYPE function, or load the image without further seeking.
You do not need to call this function to load data; SDL_image can work to determine file type in many cases in its standard load functions.
src | a seekable/readable IOStream to provide image data. |
|
inline |
This function attempts to determine if a file is a given filetype, reading the least amount possible from the IOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic i/o errors.
This function will always attempt to seek src
back to where it started when this function was called, but it will not report any errors in doing so, but assuming seeking works, this means you can immediately use this with a different IMG_isTYPE function, or load the image without further seeking.
You do not need to call this function to load data; SDL_image can work to determine file type in many cases in its standard load functions.
src | a seekable/readable IOStream to provide image data. |
|
inline |
This function attempts to determine if a file is a given filetype, reading the least amount possible from the IOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic i/o errors.
This function will always attempt to seek src
back to where it started when this function was called, but it will not report any errors in doing so, but assuming seeking works, this means you can immediately use this with a different IMG_isTYPE function, or load the image without further seeking.
You do not need to call this function to load data; SDL_image can work to determine file type in many cases in its standard load functions.
src | a seekable/readable IOStream to provide image data. |
|
inline |
This function attempts to determine if a file is a given filetype, reading the least amount possible from the IOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic i/o errors.
This function will always attempt to seek src
back to where it started when this function was called, but it will not report any errors in doing so, but assuming seeking works, this means you can immediately use this with a different IMG_isTYPE function, or load the image without further seeking.
You do not need to call this function to load data; SDL_image can work to determine file type in many cases in its standard load functions.
src | a seekable/readable IOStream to provide image data. |
|
inline |
This function attempts to determine if a file is a given filetype, reading the least amount possible from the IOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic i/o errors.
This function will always attempt to seek src
back to where it started when this function was called, but it will not report any errors in doing so, but assuming seeking works, this means you can immediately use this with a different IMG_isTYPE function, or load the image without further seeking.
You do not need to call this function to load data; SDL_image can work to determine file type in many cases in its standard load functions.
src | a seekable/readable IOStream to provide image data. |
|
inline |
This function attempts to determine if a file is a given filetype, reading the least amount possible from the IOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic i/o errors.
This function will always attempt to seek src
back to where it started when this function was called, but it will not report any errors in doing so, but assuming seeking works, this means you can immediately use this with a different IMG_isTYPE function, or load the image without further seeking.
You do not need to call this function to load data; SDL_image can work to determine file type in many cases in its standard load functions.
src | a seekable/readable IOStream to provide image data. |
|
inline |
This function attempts to determine if a file is a given filetype, reading the least amount possible from the IOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic i/o errors.
This function will always attempt to seek src
back to where it started when this function was called, but it will not report any errors in doing so, but assuming seeking works, this means you can immediately use this with a different IMG_isTYPE function, or load the image without further seeking.
You do not need to call this function to load data; SDL_image can work to determine file type in many cases in its standard load functions.
src | a seekable/readable IOStream to provide image data. |
|
inline |
This function attempts to determine if a file is a given filetype, reading the least amount possible from the IOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic i/o errors.
This function will always attempt to seek src
back to where it started when this function was called, but it will not report any errors in doing so, but assuming seeking works, this means you can immediately use this with a different IMG_isTYPE function, or load the image without further seeking.
You do not need to call this function to load data; SDL_image can work to determine file type in many cases in its standard load functions.
src | a seekable/readable IOStream to provide image data. |
|
inline |
This function attempts to determine if a file is a given filetype, reading the least amount possible from the IOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic i/o errors.
This function will always attempt to seek src
back to where it started when this function was called, but it will not report any errors in doing so, but assuming seeking works, this means you can immediately use this with a different IMG_isTYPE function, or load the image without further seeking.
You do not need to call this function to load data; SDL_image can work to determine file type in many cases in its standard load functions.
src | a seekable/readable IOStream to provide image data. |
|
inline |
This function attempts to determine if a file is a given filetype, reading the least amount possible from the IOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic i/o errors.
This function will always attempt to seek src
back to where it started when this function was called, but it will not report any errors in doing so, but assuming seeking works, this means you can immediately use this with a different IMG_isTYPE function, or load the image without further seeking.
You do not need to call this function to load data; SDL_image can work to determine file type in many cases in its standard load functions.
src | a seekable/readable IOStream to provide image data. |
|
inline |
If you know you definitely have a AVIF image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream to load image data from. |
|
inline |
If you know you definitely have a BMP image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream to load image data from. |
|
inline |
If you know you definitely have a CUR image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream to load image data from. |
|
inline |
If you know you definitely have a GIF image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream to load image data from. |
|
inline |
If you know you definitely have a GIF image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream that data will be read from. |
|
inline |
If you know you definitely have a ICO image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream to load image data from. |
|
inline |
If you know you definitely have a JPG image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream to load image data from. |
|
inline |
If you know you definitely have a JXL image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream to load image data from. |
|
inline |
If you know you definitely have a LBM image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream to load image data from. |
|
inline |
If you know you definitely have a PCX image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream to load image data from. |
|
inline |
If you know you definitely have a PNG image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream to load image data from. |
|
inline |
If you know you definitely have a PNM image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream to load image data from. |
|
inline |
If you know you definitely have a QOI image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream to load image data from. |
|
inline |
Since SVG files are resolution-independent, you specify the size you would like the output image to be and it will be generated at those dimensions.
Either width or height may be 0 and the image will be auto-sized to preserve aspect ratio.
When done with the returned surface, the app should dispose of it with a call to Surface.Destroy().
src | an IOStream to load SVG data from. |
width | desired width of the generated surface, in pixels. |
height | desired height of the generated surface, in pixels. |
|
inline |
An Surface is a buffer of pixels in memory accessible by the CPU. Use this if you plan to hand the data to something else or manipulate it further in code.
There are no guarantees about what format the new 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). You can inspect an Surface for its specifics, and use SurfaceRef.Convert to then migrate to any supported format.
If the image format supports a transparent pixel, SDL will set the colorkey for the surface. You can enable RLE acceleration on the surface afterwards by calling: SurfaceRef.SetColorKey(image, SDL_RLEACCEL, image->format->colorkey);
There is a separate function to read files from disk without having to deal with IOStream: LoadSurface("filename.jpg")
will call this function and manage those details for you, determining the file type from the filename's extension.
There is also LoadSurface(), 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 are using SDL's 2D rendering API, there is an equivalent call to load images directly into an Texture for use by the GPU without using a software surface: call LoadTexture() instead.
src | an IOStream that data will be read from. |
|
inline |
An Surface is a buffer of pixels in memory accessible by the CPU. Use this if you plan to hand the data to something else or manipulate it further in code.
There are no guarantees about what format the new 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). You can inspect an Surface for its specifics, and use SurfaceRef.Convert to then migrate to any supported format.
If the image format supports a transparent pixel, SDL will set the colorkey for the surface. You can enable RLE acceleration on the surface afterwards by calling: SurfaceRef.SetColorKey(image, SDL_RLEACCEL, image->format->colorkey);
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. If type
is nullptr, SDL_image will rely solely on its ability to guess the format.
There is a separate function to read files from disk without having to deal with IOStream: LoadSurface("filename.jpg")
will call this function and manage those details for you, determining the file type from the filename's extension.
There is also LoadSurface(), 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 nullptr for type.
If you are using SDL's 2D rendering API, there is an equivalent call to load images directly into an Texture for use by the GPU without using a software surface: call LoadTexture() instead.
src | an IOStream that data will be read from. |
type | a filename extension that represent this data ("BMP", "GIF", "PNG", etc). |
|
inline |
An Surface is a buffer of pixels in memory accessible by the CPU. Use this if you plan to hand the data to something else or manipulate it further in code.
There are no guarantees about what format the new 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). You can inspect an Surface for its specifics, and use SurfaceRef.Convert to then migrate to any supported format.
If the image format supports a transparent pixel, SDL will set the colorkey for the surface. You can enable RLE acceleration on the surface afterwards by calling: SurfaceRef.SetColorKey(image, SDL_RLEACCEL, image->format->colorkey);
There is a separate function to read files from an IOStream, if you need an i/o abstraction to provide data from anywhere instead of a simple filesystem read; that function is LoadSurface(SDL_IOStream).
If you are using SDL's 2D rendering API, there is an equivalent call to load images directly into an Texture for use by the GPU without using a software surface: call LoadTexture() instead.
file | a path on the filesystem to load an image from. |
|
inline |
If you know you definitely have a SVG image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream to load image data from. |
|
inline |
An 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 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 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 disk without having to deal with IOStream: 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 LoadTexture(), 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 Surface (a buffer of pixels in CPU memory), call LoadSurface() instead.
renderer | the Renderer to use to create the GPU texture. |
src | an IOStream that data will be read from. |
|
inline |
An 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 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 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).
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. If type
is nullptr, SDL_image will rely solely on its ability to guess the format.
There is a separate function to read files from disk without having to deal with IOStream: LoadTexture("filename.jpg")
will call this function and manage those details for you, determining the file type from the filename's extension.
There is also LoadTexture(), 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 nullptr for type.
If you would rather decode an image to an Surface (a buffer of pixels in CPU memory), call LoadSurface() instead.
renderer | the Renderer to use to create the GPU texture. |
src | an IOStream that data will be read from. |
type | a filename extension that represent this data ("BMP", "GIF", "PNG", etc). |
|
inline |
An 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 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 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 you would rather decode an image to an Surface (a buffer of pixels in CPU memory), call LoadSurface() instead.
renderer | the Renderer to use to create the GPU texture. |
file | a path on the filesystem to load an image from. |
|
inline |
If you know you definitely have a TGA image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream to load image data from. |
|
inline |
If you know you definitely have a TIFF image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream to load image data from. |
|
inline |
If you know you definitely have a WEBP image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream to load image data from. |
|
inline |
If you know you definitely have a WEBP image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream that data will be read from. |
|
inline |
If you know you definitely have a XCF image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream to load image data from. |
|
inline |
If you know you definitely have a XPM image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream to load image data from. |
|
inline |
If you know you definitely have a XV image, you can call this function, which will skip SDL_image's file format detection routines. Generally it's better to use the abstract interfaces; also, there is only an IOStream interface available here.
src | an IOStream to load image data from. |
|
inline |
The returned surface will be an 8bpp indexed surface, if possible, otherwise it will be 32bpp. If you always want 32-bit data, use ReadXPMFromArrayToRGB888() instead.
xpm | a null-terminated array of strings that comprise XPM data. |
|
inline |
The returned surface will always be a 32-bit RGB surface. If you want 8-bit indexed colors (and the XPM data allows it), use ReadXPMFromArray() instead.
When done with the returned surface, the app should dispose of it with a call to Surface.Destroy().
xpm | a null-terminated array of strings that comprise XPM data. |
|
inline |
If you just want to save to a filename, you can use SaveAVIF() instead.
surface | the SDL surface to save. |
dst | the IOStream to save the image data to. |
quality | the desired quality, ranging between 0 (lowest) and 100 (highest). |
Error | on failure. |
|
inline |
If the file already exists, it will be overwritten.
surface | the SDL surface to save. |
file | path on the filesystem to write new file to. |
quality | the desired quality, ranging between 0 (lowest) and 100 (highest). |
Error | on failure. |
|
inline |
If you just want to save to a filename, you can use SaveJPG() instead.
surface | the SDL surface to save. |
dst | the IOStream to save the image data to. |
quality | [0; 33] is Lowest quality, [34; 66] is Middle quality, [67; 100] is Highest quality. |
Error | on failure. |
|
inline |
If the file already exists, it will be overwritten.
surface | the SDL surface to save. |
file | path on the filesystem to write new file to. |
quality | [0; 33] is Lowest quality, [34; 66] is Middle quality, [67; 100] is Highest quality. |
Error | on failure. |
|
inline |
|
inline |