TSdlImage
A simple library to load images of various formats as SDL surfaces.
The following formats are supported:
- BMP (Windows Bitmap Files)
- ICO (Icon files)
- CUR (Cursor files)
- GIF (also supports GIF animations using TSdlAnimatedImage)
- JPEG
- LBM (Delux Paint bitmap)
- PCX (Picture Exchange bitmap)
- PNG (Portable Network Graphics)
- PNM (Portable Any Map)
- SVG (Scalable Vector Graphics. There is a version of LoadSvg where you can specify the dimensions to rasterize to)
- QOI (Quite OK Image format)
- TGA (Targa image format)
- XCF (GIMP bitmap)
- XPM (X Pixmap)
- XV (Kronos Visualization Image file)
Definition
Unit: Neslib.Sdl3.Image
Properties
Name | Description |
---|---|
Version | The version of the used SDL_image library. |
Methods
Name | Description |
---|---|
IsBmp | Detect BMP image data on a readable/seekable TSdlIOStream. |
IsCur | Detect CUR image data on a readable/seekable TSdlIOStream. |
IsGif | Detect GIF image data on a readable/seekable TSdlIOStream. |
IsIco | Detect ICO image data on a readable/seekable TSdlIOStream. |
IsJpg | Detect JPG image data on a readable/seekable TSdlIOStream. |
IsLbm | Detect LBM image data on a readable/seekable TSdlIOStream. |
IsPcx | Detect PCX image data on a readable/seekable TSdlIOStream. |
IsPng | Detect PNG image data on a readable/seekable TSdlIOStream. |
IsPnm | Detect PNM image data on a readable/seekable TSdlIOStream. |
IsQoi | Detect QOI image data on a readable/seekable TSdlIOStream. |
IsSvg | Detect SVG image data on a readable/seekable TSdlIOStream. |
IsXcf | Detect XCF image data on a readable/seekable TSdlIOStream. |
IsXpm | Detect XPM image data on a readable/seekable TSdlIOStream. |
IsXV | Detect XV image data on a readable/seekable TSdlIOStream. |
Load(TSdlIOStream, Boolean, String) | Load an image from an SDL data source into a software surface. |
Load(String) | Load an image from a filesystem path into a software surface. |
LoadBmp | Load a BMP image directly. |
LoadCur | Load a CUR image directly. |
LoadGif | Load a GIF image directly. |
LoadIco | Load a ICO image directly. |
LoadJpg | Load a JPG image directly. |
LoadLbm | Load a LBM image directly. |
LoadPcx | Load a PCX image directly. |
LoadPng | Load a PNG image directly. |
LoadPnm | Load a PNM image directly. |
LoadQoi | Load a QOI image directly. |
LoadSvg(TSdlIOStream, Integer, Integer) | Load an SVG image, scaled to a specific size. |
LoadSvg(TSdlIOStream) | Load a AVSVGIF image directly. |
LoadTexture(TSdlRenderer, TSdlIOStream, Boolean, String) | Load an image from an SDL data source into a GPU texture. |
LoadTexture(TSdlRenderer, String) | Load an image from a filesystem path into a GPU texture. |
LoadTga | Load a TGA image directly. |
LoadXcf | Load a XCF image directly. |
LoadXpm(TArray<AnsiString>) | Load an XPM image from a memory array. |
LoadXpm(TSdlIOStream) | Load a XPM image directly. |
LoadXpm32 | Load an XPM image from a memory array. |
LoadXV | Load a XV image directly. |
SaveJpg(TSdlSurface, TSdlIOStream, Boolean, Integer) | Save a TSdlSurface into JPEG image data, via an TSdlIOStream. |
SaveJpg(TSdlSurface, String, Integer) | Save a TSdlSurface into a JPEG image file. |
SavePng(TSdlSurface, TSdlIOStream, Boolean) | Save a TSdlSurface into PNG image data, via an TSdlIOStream. |
SavePng(TSdlSurface, String) | Save a TSdlSurface into a PNG image file. |
Property Descriptions
Version
The version of the used SDL_image library.
class property Version: Integer read GetVersion
Type: Integer
Method Descriptions
IsBmp(TSdlIOStream)
Detect BMP image data on a readable/seekable TSdlIOStream.
This method attempts to determine if a file is a given filetype, reading the least amount possible from the TSdlIOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic I/O errors.
This method will always attempt to seek ASrc
back to where it started when this method 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 Is* method, or load the image without further seeking.
You do not need to call this method to load data; SDL_image can work to determine file type in many cases in its standard load functions.
class function IsBmp(const ASrc: TSdlIOStream): Boolean; inline; static
Parameters
ASrc
: TSdlIOStream
: A seekable/readable TSdlIOStream to provide image data.
Returns
Boolean
: True if this is BMP data, False otherwise.
See Also
IsCur(TSdlIOStream)
Detect CUR image data on a readable/seekable TSdlIOStream.
This method attempts to determine if a file is a given filetype, reading the least amount possible from the TSdlIOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic I/O errors.
This method will always attempt to seek ASrc
back to where it started when this method 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 Is* method, or load the image without further seeking.
You do not need to call this method to load data; SDL_image can work to determine file type in many cases in its standard load functions.
class function IsCur(const ASrc: TSdlIOStream): Boolean; inline; static
Parameters
ASrc
: TSdlIOStream
: A seekable/readable TSdlIOStream to provide image data.
Returns
Boolean
: True if this is CUR data, False otherwise.
See Also
IsGif(TSdlIOStream)
Detect GIF image data on a readable/seekable TSdlIOStream.
This method attempts to determine if a file is a given filetype, reading the least amount possible from the TSdlIOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic I/O errors.
This method will always attempt to seek ASrc
back to where it started when this method 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 Is* method, or load the image without further seeking.
You do not need to call this method to load data; SDL_image can work to determine file type in many cases in its standard load functions.
class function IsGif(const ASrc: TSdlIOStream): Boolean; inline; static
Parameters
ASrc
: TSdlIOStream
: A seekable/readable TSdlIOStream to provide image data.
Returns
Boolean
: True if this is GIF data, False otherwise.
See Also
IsIco(TSdlIOStream)
Detect ICO image data on a readable/seekable TSdlIOStream.
This method attempts to determine if a file is a given filetype, reading the least amount possible from the TSdlIOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic I/O errors.
This method will always attempt to seek ASrc
back to where it started when this method 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 Is* method, or load the image without further seeking.
You do not need to call this method to load data; SDL_image can work to determine file type in many cases in its standard load functions.
class function IsIco(const ASrc: TSdlIOStream): Boolean; inline; static
Parameters
ASrc
: TSdlIOStream
: A seekable/readable TSdlIOStream to provide image data.
Returns
Boolean
: True if this is ICO data, False otherwise.
See Also
IsJpg(TSdlIOStream)
Detect JPG image data on a readable/seekable TSdlIOStream.
This method attempts to determine if a file is a given filetype, reading the least amount possible from the TSdlIOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic I/O errors.
This method will always attempt to seek ASrc
back to where it started when this method 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 Is* method, or load the image without further seeking.
You do not need to call this method to load data; SDL_image can work to determine file type in many cases in its standard load functions.
class function IsJpg(const ASrc: TSdlIOStream): Boolean; inline; static
Parameters
ASrc
: TSdlIOStream
: A seekable/readable TSdlIOStream to provide image data.
Returns
Boolean
: True if this is JPOG data, False otherwise.
See Also
IsLbm(TSdlIOStream)
Detect LBM image data on a readable/seekable TSdlIOStream.
This method attempts to determine if a file is a given filetype, reading the least amount possible from the TSdlIOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic I/O errors.
This method will always attempt to seek ASrc
back to where it started when this method 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 Is* method, or load the image without further seeking.
You do not need to call this method to load data; SDL_image can work to determine file type in many cases in its standard load functions.
class function IsLbm(const ASrc: TSdlIOStream): Boolean; inline; static
Parameters
ASrc
: TSdlIOStream
: A seekable/readable TSdlIOStream to provide image data.
Returns
Boolean
: True if this is LBM data, False otherwise.
See Also
IsPcx(TSdlIOStream)
Detect PCX image data on a readable/seekable TSdlIOStream.
This method attempts to determine if a file is a given filetype, reading the least amount possible from the TSdlIOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic I/O errors.
This method will always attempt to seek ASrc
back to where it started when this method 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 Is* method, or load the image without further seeking.
You do not need to call this method to load data; SDL_image can work to determine file type in many cases in its standard load functions.
class function IsPcx(const ASrc: TSdlIOStream): Boolean; inline; static
Parameters
ASrc
: TSdlIOStream
: A seekable/readable TSdlIOStream to provide image data.
Returns
Boolean
: True if this is PCX data, False otherwise.
See Also
IsPng(TSdlIOStream)
Detect PNG image data on a readable/seekable TSdlIOStream.
This method attempts to determine if a file is a given filetype, reading the least amount possible from the TSdlIOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic I/O errors.
This method will always attempt to seek ASrc
back to where it started when this method 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 Is* method, or load the image without further seeking.
You do not need to call this method to load data; SDL_image can work to determine file type in many cases in its standard load functions.
class function IsPng(const ASrc: TSdlIOStream): Boolean; inline; static
Parameters
ASrc
: TSdlIOStream
: A seekable/readable TSdlIOStream to provide image data.
Returns
Boolean
: True if this is PNG data, False otherwise.
See Also
IsPnm(TSdlIOStream)
Detect PNM image data on a readable/seekable TSdlIOStream.
This method attempts to determine if a file is a given filetype, reading the least amount possible from the TSdlIOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic I/O errors.
This method will always attempt to seek ASrc
back to where it started when this method 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 Is* method, or load the image without further seeking.
You do not need to call this method to load data; SDL_image can work to determine file type in many cases in its standard load functions.
class function IsPnm(const ASrc: TSdlIOStream): Boolean; inline; static
Parameters
ASrc
: TSdlIOStream
: A seekable/readable TSdlIOStream to provide image data.
Returns
Boolean
: True if this is PNM data, False otherwise.
See Also
IsQoi(TSdlIOStream)
Detect QOI image data on a readable/seekable TSdlIOStream.
This method attempts to determine if a file is a given filetype, reading the least amount possible from the TSdlIOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic I/O errors.
This method will always attempt to seek ASrc
back to where it started when this method 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 Is* method, or load the image without further seeking.
You do not need to call this method to load data; SDL_image can work to determine file type in many cases in its standard load functions.
class function IsQoi(const ASrc: TSdlIOStream): Boolean; inline; static
Parameters
ASrc
: TSdlIOStream
: A seekable/readable TSdlIOStream to provide image data.
Returns
Boolean
: True if this is QOI data, False otherwise.
See Also
IsSvg(TSdlIOStream)
Detect SVG image data on a readable/seekable TSdlIOStream.
This method attempts to determine if a file is a given filetype, reading the least amount possible from the TSdlIOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic I/O errors.
This method will always attempt to seek ASrc
back to where it started when this method 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 Is* method, or load the image without further seeking.
You do not need to call this method to load data; SDL_image can work to determine file type in many cases in its standard load functions.
class function IsSvg(const ASrc: TSdlIOStream): Boolean; inline; static
Parameters
ASrc
: TSdlIOStream
: A seekable/readable TSdlIOStream to provide image data.
Returns
Boolean
: True if this is SVG data, False otherwise.
See Also
IsXcf(TSdlIOStream)
Detect XCF image data on a readable/seekable TSdlIOStream.
This method attempts to determine if a file is a given filetype, reading the least amount possible from the TSdlIOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic I/O errors.
This method will always attempt to seek ASrc
back to where it started when this method 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 Is* method, or load the image without further seeking.
You do not need to call this method to load data; SDL_image can work to determine file type in many cases in its standard load functions.
class function IsXcf(const ASrc: TSdlIOStream): Boolean; inline; static
Parameters
ASrc
: TSdlIOStream
: A seekable/readable TSdlIOStream to provide image data.
Returns
Boolean
: True if this is XCF data, False otherwise.
See Also
IsXpm(TSdlIOStream)
Detect XPM image data on a readable/seekable TSdlIOStream.
This method attempts to determine if a file is a given filetype, reading the least amount possible from the TSdlIOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic I/O errors.
This method will always attempt to seek ASrc
back to where it started when this method 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 Is* method, or load the image without further seeking.
You do not need to call this method to load data; SDL_image can work to determine file type in many cases in its standard load functions.
class function IsXpm(const ASrc: TSdlIOStream): Boolean; inline; static
Parameters
ASrc
: TSdlIOStream
: A seekable/readable TSdlIOStream to provide image data.
Returns
Boolean
: True if this is XPM data, False otherwise.
See Also
IsXV(TSdlIOStream)
Detect XV image data on a readable/seekable TSdlIOStream.
This method attempts to determine if a file is a given filetype, reading the least amount possible from the TSdlIOStream (usually a few bytes).
There is no distinction made between "not the filetype in question" and basic I/O errors.
This method will always attempt to seek ASrc
back to where it started when this method 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 Is* method, or load the image without further seeking.
You do not need to call this method to load data; SDL_image can work to determine file type in many cases in its standard load functions.
class function IsXV(const ASrc: TSdlIOStream): Boolean; inline; static
Parameters
ASrc
: TSdlIOStream
: A seekable/readable TSdlIOStream to provide image data.
Returns
Boolean
: True if this is XV data, False otherwise.
See Also
Load(TSdlIOStream, Boolean, String)
Load an image from an SDL data source into a software surface.
A TSdlSurface 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 TSdlSurface 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 TSdlSurface for its specifics, and use TSdlSurface.Convert to then migrate to any supported format.
If the image format supports a transparent pixel, SDL will set the colorkey for the surface.
If ACloseIO
is True, ASrc
will be closed before returning, whether this method succeeds or not. SDL_image reads everything it needs from ASrc
during this call in any case.
Even though this method 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 AType
is empty, SDL_image will rely solely on its ability to guess the format.
There is another overloaded method to read files from disk without having to deal with TSdlIOStream. That verion call this method and manage those details for you, determining the file type from the filename's extension.
If you are using SDL's 2D rendering API, there is an equivalent call to load images directly into a TSdlTexture for use by the GPU without using a software surface: call LoadTexture instead.
When done with the returned surface, the app should dispose of it with a call to TSdlSurface.Free.
class function Load(const ASrc: TSdlIOStream; const ACloseIO: Boolean; const AType: String = ''): TSdlSurface; overload; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
ASrc
: TSdlIOStream
: A TSdlIOStream that data will be read from.
ACloseIO
: Boolean
: True to close/free the TSdlIOStream before returning, False to leave it open.
AType
: String = ''
: (Optional) filename extension that represent this data ("BMP", "GIF", "PNG", etc) or empty (default) to autodetect.
Returns
TSdlSurface
: A new SDL surface.
See Also
Load(String)
Load an image from a filesystem path into a software surface.
A TSdlSurface 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 TSdlSurface 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 TSdlSurface for its specifics, and use TSdlSurface.Convert to then migrate to any supported format.
If the image format supports a transparent pixel, SDL will set the colorkey for the surface.
There is an overloaded version to read files from an TSdlIOStream, if you need an I/O abstraction to provide data from anywhere instead of a simple filesystem read.
If you are using SDL's 2D rendering API, there is an equivalent call to load images directly into a TSdlTexture for use by the GPU without using a software surface: call LoadTexture instead.
When done with the returned surface, the app should dispose of it with a call to TSdlSurface.Free.
class function Load(const AFile: String): TSdlSurface; overload; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
AFile
: String
: A path on the filesystem to load an image from.
Returns
TSdlSurface
: A new SDL surface.
See Also
LoadBmp(TSdlIOStream)
Load a BMP image directly.
If you know you definitely have a BMP image, you can call this method, which will skip SDL_image's file format detection routines. Generally it's better to use Load or LoadTexture; also, there is only an TSdlIOStream interface available here.
class function LoadBmp(const ASrc: TSdlIOStream): TSdlSurface; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
ASrc
: TSdlIOStream
: An TSdlIOStream to load image data from.
Returns
TSdlSurface
: A new TSdlSurface.
See Also
- LoadIco
- LoadCur
- LoadGif
- LoadJpg
- LoadLbm
- LoadPcx
- LoadPng
- LoadPnm
- LoadSvg
- LoadQoi
- LoadTga
- LoadXcf
- LoadXpm
- LoadXV
LoadCur(TSdlIOStream)
Load a CUR image directly.
If you know you definitely have a CUR image, you can call this method, which will skip SDL_image's file format detection routines. Generally it's better to use Load or LoadTexture; also, there is only an TSdlIOStream interface available here.
class function LoadCur(const ASrc: TSdlIOStream): TSdlSurface; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
ASrc
: TSdlIOStream
: An TSdlIOStream to load image data from.
Returns
TSdlSurface
: A new TSdlSurface.
See Also
- LoadIco
- LoadBmp
- LoadGif
- LoadJpg
- LoadLbm
- LoadPcx
- LoadPng
- LoadPnm
- LoadSvg
- LoadQoi
- LoadTga
- LoadXcf
- LoadXpm
- LoadXV
LoadGif(TSdlIOStream)
Load a GIF image directly.
If you know you definitely have a GIF image, you can call this method, which will skip SDL_image's file format detection routines. Generally it's better to use Load or LoadTexture; also, there is only an TSdlIOStream interface available here.
class function LoadGif(const ASrc: TSdlIOStream): TSdlSurface; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
ASrc
: TSdlIOStream
: An TSdlIOStream to load image data from.
Returns
TSdlSurface
: A new TSdlSurface.
See Also
- LoadIco
- LoadCur
- LoadBmp
- LoadJpg
- LoadLbm
- LoadPcx
- LoadPng
- LoadPnm
- LoadSvg
- LoadQoi
- LoadTga
- LoadXcf
- LoadXpm
- LoadXV
LoadIco(TSdlIOStream)
Load a ICO image directly.
If you know you definitely have a ICO image, you can call this method, which will skip SDL_image's file format detection routines. Generally it's better to use Load or LoadTexture; also, there is only an TSdlIOStream interface available here.
class function LoadIco(const ASrc: TSdlIOStream): TSdlSurface; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
ASrc
: TSdlIOStream
: An TSdlIOStream to load image data from.
Returns
TSdlSurface
: A new TSdlSurface.
See Also
- LoadCur
- LoadBmp
- LoadGif
- LoadJpg
- LoadLbm
- LoadPcx
- LoadPng
- LoadPnm
- LoadSvg
- LoadQoi
- LoadTga
- LoadXcf
- LoadXpm
- LoadXV
LoadJpg(TSdlIOStream)
Load a JPG image directly.
If you know you definitely have a JPG image, you can call this method, which will skip SDL_image's file format detection routines. Generally it's better to use Load or LoadTexture; also, there is only an TSdlIOStream interface available here.
class function LoadJpg(const ASrc: TSdlIOStream): TSdlSurface; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
ASrc
: TSdlIOStream
: An TSdlIOStream to load image data from.
Returns
TSdlSurface
: A new TSdlSurface.
See Also
- LoadIco
- LoadCur
- LoadBmp
- LoadGif
- LoadLbm
- LoadPcx
- LoadPng
- LoadPnm
- LoadSvg
- LoadQoi
- LoadTga
- LoadXcf
- LoadXpm
- LoadXV
LoadLbm(TSdlIOStream)
Load a LBM image directly.
If you know you definitely have a LBM image, you can call this method, which will skip SDL_image's file format detection routines. Generally it's better to use Load or LoadTexture; also, there is only an TSdlIOStream interface available here.
class function LoadLbm(const ASrc: TSdlIOStream): TSdlSurface; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
ASrc
: TSdlIOStream
: An TSdlIOStream to load image data from.
Returns
TSdlSurface
: A new TSdlSurface.
See Also
- LoadIco
- LoadCur
- LoadBmp
- LoadGif
- LoadJpg
- LoadPcx
- LoadPng
- LoadPnm
- LoadSvg
- LoadQoi
- LoadTga
- LoadXcf
- LoadXpm
- LoadXV
LoadPcx(TSdlIOStream)
Load a PCX image directly.
If you know you definitely have a PCX image, you can call this method, which will skip SDL_image's file format detection routines. Generally it's better to use Load or LoadTexture; also, there is only an TSdlIOStream interface available here.
class function LoadPcx(const ASrc: TSdlIOStream): TSdlSurface; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
ASrc
: TSdlIOStream
: An TSdlIOStream to load image data from.
Returns
TSdlSurface
: A new TSdlSurface.
See Also
- LoadIco
- LoadCur
- LoadBmp
- LoadGif
- LoadJpg
- LoadLbm
- LoadPng
- LoadPnm
- LoadSvg
- LoadQoi
- LoadTga
- LoadXcf
- LoadXpm
- LoadXV
LoadPng(TSdlIOStream)
Load a PNG image directly.
If you know you definitely have a PNG image, you can call this method, which will skip SDL_image's file format detection routines. Generally it's better to use Load or LoadTexture; also, there is only an TSdlIOStream interface available here.
class function LoadPng(const ASrc: TSdlIOStream): TSdlSurface; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
ASrc
: TSdlIOStream
: An TSdlIOStream to load image data from.
Returns
TSdlSurface
: A new TSdlSurface.
See Also
- LoadIco
- LoadCur
- LoadBmp
- LoadGif
- LoadJpg
- LoadLbm
- LoadPcx
- LoadPnm
- LoadSvg
- LoadQoi
- LoadTga
- LoadXcf
- LoadXpm
- LoadXV
LoadPnm(TSdlIOStream)
Load a PNM image directly.
If you know you definitely have a PNM image, you can call this method, which will skip SDL_image's file format detection routines. Generally it's better to use Load or LoadTexture; also, there is only an TSdlIOStream interface available here.
class function LoadPnm(const ASrc: TSdlIOStream): TSdlSurface; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
ASrc
: TSdlIOStream
: An TSdlIOStream to load image data from.
Returns
TSdlSurface
: A new TSdlSurface.
See Also
- LoadIco
- LoadCur
- LoadBmp
- LoadGif
- LoadJpg
- LoadLbm
- LoadPcx
- LoadPng
- LoadSvg
- LoadQoi
- LoadTga
- LoadXcf
- LoadXpm
- LoadXV
LoadQoi(TSdlIOStream)
Load a QOI image directly.
If you know you definitely have a QOI image, you can call this method, which will skip SDL_image's file format detection routines. Generally it's better to use Load or LoadTexture; also, there is only an TSdlIOStream interface available here.
class function LoadQoi(const ASrc: TSdlIOStream): TSdlSurface; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
ASrc
: TSdlIOStream
: An TSdlIOStream to load image data from.
Returns
TSdlSurface
: A new TSdlSurface.
See Also
- LoadIco
- LoadCur
- LoadBmp
- LoadGif
- LoadJpg
- LoadLbm
- LoadPcx
- LoadPng
- LoadPnm
- LoadSvg
- LoadTga
- LoadXcf
- LoadXpm
- LoadXV
LoadSvg(TSdlIOStream, Integer, Integer)
Load an SVG image, scaled to a specific size.
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 TSdlSurface.Free.
class function LoadSvg(const ASrc: TSdlIOStream; const AWidth, AHeight: Integer): TSdlSurface; overload; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
ASrc
: TSdlIOStream
: A TSdlIOStream to load SVG data from.
AWidth
: Integer
: Desired width of the generated surface, in pixels.
AHeight
: Integer
: Desired height of the generated surface, in pixels.
Returns
TSdlSurface
: A new SDL surface.
LoadSvg(TSdlIOStream)
Load a AVSVGIF image directly.
If you know you definitely have a SVG image, you can call this method, which will skip SDL_image's file format detection routines. Generally it's better to use Load or LoadTexture; also, there is only an TSdlIOStream interface available here.
class function LoadSvg(const ASrc: TSdlIOStream): TSdlSurface; overload; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
ASrc
: TSdlIOStream
: An TSdlIOStream to load image data from.
Returns
TSdlSurface
: A new TSdlSurface.
See Also
- LoadIco
- LoadCur
- LoadBmp
- LoadGif
- LoadJpg
- LoadLbm
- LoadPcx
- LoadPng
- LoadPnm
- LoadQoi
- LoadTga
- LoadXcf
- LoadXpm
- LoadXV
LoadTexture(TSdlRenderer, TSdlIOStream, Boolean, String)
Load an image from an SDL data source into a GPU texture.
A TSdlTexture represents an image in GPU memory, usable by SDL's 2D Render API. This can be significantly more efficient than using a CPU-bound TSdlSurface 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 a TSdlTexture 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 ACloseIO
is True, ASrc
will be closed before returning, whether this method succeeds or not. SDL_image reads everything it needs from ASrc
during this call in any case.
Even though this method 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 AType
is empty, SDL_image will rely solely on its ability to guess the format.
There is another overloaded method to read files from disk without having to deal with TSdlIOStream. That verion call this method and manage those details for you, determining the file type from the filename's extension.
If you would rather decode an image to an TSdlSurface (a buffer of pixels in CPU memory), call Load instead.
When done with the returned texture, the app should dispose of it with a call to TSdlTexture.Free.
class function LoadTexture(const ARenderer: TSdlRenderer; const ASrc: TSdlIOStream; const ACloseIO: Boolean; const AType: String = ''): TSdlTexture; overload; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
ARenderer
: TSdlRenderer
: The TSdlRenderer to use to create the GPU texture.
ASrc
: TSdlIOStream
: A TSdlIOStream that data will be read from.
ACloseIO
: Boolean
: True to close/free the TSdlIOStream before returning, False to leave it open.
AType
: String = ''
: (Optional) filename extension that represent this data ("BMP", "GIF", "PNG", etc) or empty (default) to autodetect.
Returns
TSdlTexture
: A new texture.
See Also
LoadTexture(TSdlRenderer, String)
Load an image from a filesystem path into a GPU texture.
A TSdlTexture represents an image in GPU memory, usable by SDL's 2D Render API. This can be significantly more efficient than using a CPU-bound TSdlSurface 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 a TSdlTexture 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 an overloaded version to read files from an TSdlIOStream, if you need an I/O abstraction to provide data from anywhere instead of a simple filesystem read.
If you would rather decode an image to an TSdlSurface (a buffer of pixels in CPU memory), call Load instead.
When done with the returned texture, the app should dispose of it with a call to TSdlTexture.Free.
class function LoadTexture(const ARenderer: TSdlRenderer; const AFile: String): TSdlTexture; overload; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
ARenderer
: TSdlRenderer
: The TSdlRenderer to use to create the GPU texture.
AFile
: String
: A path on the filesystem to load an image from.
Returns
TSdlTexture
: A new texture.
See Also
LoadTga(TSdlIOStream)
Load a TGA image directly.
If you know you definitely have a TGA image, you can call this method, which will skip SDL_image's file format detection routines. Generally it's better to use Load or LoadTexture; also, there is only an TSdlIOStream interface available here.
class function LoadTga(const ASrc: TSdlIOStream): TSdlSurface; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
ASrc
: TSdlIOStream
: An TSdlIOStream to load image data from.
Returns
TSdlSurface
: A new TSdlSurface.
See Also
- LoadIco
- LoadCur
- LoadBmp
- LoadGif
- LoadJpg
- LoadLbm
- LoadPcx
- LoadPng
- LoadPnm
- LoadSvg
- LoadQoi
- LoadXcf
- LoadXpm
- LoadXV
LoadXcf(TSdlIOStream)
Load a XCF image directly.
If you know you definitely have a XCF image, you can call this method, which will skip SDL_image's file format detection routines. Generally it's better to use Load or LoadTexture; also, there is only an TSdlIOStream interface available here.
class function LoadXcf(const ASrc: TSdlIOStream): TSdlSurface; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
ASrc
: TSdlIOStream
: An TSdlIOStream to load image data from.
Returns
TSdlSurface
: A new TSdlSurface.
See Also
- LoadIco
- LoadCur
- LoadBmp
- LoadGif
- LoadJpg
- LoadLbm
- LoadPcx
- LoadPng
- LoadPnm
- LoadSvg
- LoadQoi
- LoadTga
- LoadXpm
- LoadXV
LoadXpm(TArray<AnsiString>)
Load an XPM image from a memory array.
The returned surface will be an 8bpp indexed surface, if possible, otherwise it will be 32bpp. If you always want 32-bit data, use LoadXpm32 instead.
When done with the returned surface, the app should dispose of it with a call to TSdlSurface.Free.
class function LoadXpm(const AXpm: TArray<AnsiString>): TSdlSurface; overload; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
AXpm
: TArray<AnsiString>
: An array of AnsiStrings that comprise XPM data.
Returns
TSdlSurface
: A new TSdlSurface.
See Also
LoadXpm(TSdlIOStream)
Load a XPM image directly.
If you know you definitely have a XPM image, you can call this method, which will skip SDL_image's file format detection routines. Generally it's better to use Load or LoadTexture; also, there is only an TSdlIOStream interface available here.
class function LoadXpm(const ASrc: TSdlIOStream): TSdlSurface; overload; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
ASrc
: TSdlIOStream
: An TSdlIOStream to load image data from.
Returns
TSdlSurface
: A new TSdlSurface.
See Also
- LoadIco
- LoadCur
- LoadBmp
- LoadGif
- LoadJpg
- LoadLbm
- LoadPcx
- LoadPng
- LoadPnm
- LoadSvg
- LoadQoi
- LoadTga
- LoadXcf
- LoadXV
LoadXpm32(TArray<AnsiString>)
Load an XPM image from a memory array.
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 LoadXpm instead.
When done with the returned surface, the app should dispose of it with a call to TSdlSurface.Free.
class function LoadXpm32(const AXpm: TArray<AnsiString>): TSdlSurface; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
AXpm
: TArray<AnsiString>
: An array of AnsiStrings that comprise XPM data.
Returns
TSdlSurface
: A new TSdlSurface.
See Also
LoadXV(TSdlIOStream)
Load a XV image directly.
If you know you definitely have a XV image, you can call this method, which will skip SDL_image's file format detection routines. Generally it's better to use Load or LoadTexture; also, there is only an TSdlIOStream interface available here.
class function LoadXV(const ASrc: TSdlIOStream): TSdlSurface; inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
ASrc
: TSdlIOStream
: An TSdlIOStream to load image data from.
Returns
TSdlSurface
: A new TSdlSurface.
See Also
- LoadIco
- LoadCur
- LoadBmp
- LoadGif
- LoadJpg
- LoadLbm
- LoadPcx
- LoadPng
- LoadPnm
- LoadSvg
- LoadQoi
- LoadTga
- LoadXcf
- LoadXpm
SaveJpg(TSdlSurface, TSdlIOStream, Boolean, Integer)
Save a TSdlSurface into JPEG image data, via an TSdlIOStream.
If you just want to save to a filename, you can use the other overloaded version instead.
If ACloseIO
is True, ADst
will be closed before returning, whether this function succeeds or not.
procedure SaveJpg(const ASurface: TSdlSurface; const ADst: TSdlIOStream; const ACloseIO: Boolean; const AQuality: Integer); overload
Exceptions
ESdlError
: Raised on failure.
Parameters
ASurface
: TSdlSurface
: The SDL surface to save.
ADst
: TSdlIOStream
: The TSdlIOStream to save the image data to.
ACloseIO
: Boolean
: True to close/free the TSdlIOStream before returning, False to leave it open.
AQuality
: Integer
: 0..33 is Lowest quality, 34..66 is Middle quality, 67.100 is Highest quality..
SaveJpg(TSdlSurface, String, Integer)
Save a TSdlSurface into a JPEG image file.
If the file already exists, it will be overwritten.
procedure SaveJpg(const ASurface: TSdlSurface; const AFile: String; const AQuality: Integer); overload
Exceptions
ESdlError
: Raised on failure.
Parameters
ASurface
: TSdlSurface
: The SDL surface to save.
AFile
: String
: Path on the filesystem to write new file to.
AQuality
: Integer
: 0..33 is Lowest quality, 34..66 is Middle quality, 67.100 is Highest quality..
SavePng(TSdlSurface, TSdlIOStream, Boolean)
Save a TSdlSurface into PNG image data, via an TSdlIOStream.
If you just want to save to a filename, you can use the other overloaded version instead.
If ACloseIO
is True, ADst
will be closed before returning, whether this function succeeds or not.
procedure SavePng(const ASurface: TSdlSurface; const ADst: TSdlIOStream; const ACloseIO: Boolean); overload
Parameters
ASurface
: TSdlSurface
: The SDL surface to save.
ADst
: TSdlIOStream
: The TSdlIOStream to save the image data to.
ACloseIO
: Boolean
: True to close/free the TSdlIOStream before returning, False to leave it open.
SavePng(TSdlSurface, String)
Save a TSdlSurface into a PNG image file.
If the file already exists, it will be overwritten.
procedure SavePng(const ASurface: TSdlSurface; const AFile: String); overload
Parameters
ASurface
: TSdlSurface
: The SDL surface to save.
AFile
: String
: Path on the filesystem to write new file to.