//
// Generated by Brutal.Sdl.Generate; do not edit by hand.
#nullable enable
namespace Brutal.SdlApi.Image
{
public static unsafe partial class SdlImage
{
///
/// This function gets the version of the dynamically linked SDL_image library.
///
/// SDL_image version.
///
/// This function is available since SDL_image 3.0.0.
///
public static int Version() => PInvoke.Version();
///
/// Ergonomic wrapper over IMG_Load. Throws instead of returning a null pointer on failure.
///
/// a path on the filesystem to load an image from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* Load(string file)
{
SdlSurface* result = PInvoke.Load(file);
if (result == null)
{
throw SdlException.FromError("IMG_Load failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_Load_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream that data will be read from.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadIO(nint src, bool closeio)
{
SdlSurface* result = PInvoke.LoadIO(src, closeio ? (byte)1 : (byte)0);
if (result == null)
{
throw SdlException.FromError("IMG_Load_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadTyped_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream that data will be read from.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
///
/// a filename extension that represent this data ("BMP", "GIF",
/// "PNG", etc).
///
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadTypedIO(nint src, bool closeio, string type)
{
SdlSurface* result = PInvoke.LoadTypedIO(src, closeio ? (byte)1 : (byte)0, type);
if (result == null)
{
throw SdlException.FromError("IMG_LoadTyped_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadTexture. Throws instead of returning a null handle on failure.
///
/// the SDL_Renderer to use to create the texture.
/// a path on the filesystem to load an image from.
/// The created handle (never a null handle).
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlTexture LoadTexture(SdlRenderer renderer, string file)
{
SdlTexture result = PInvoke.LoadTexture(renderer, file);
if (result.IsNull())
{
throw SdlException.FromError("IMG_LoadTexture failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadTexture_IO. Throws instead of returning a null handle on failure.
///
/// the SDL_Renderer to use to create the texture.
/// an SDL_IOStream that data will be read from.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
/// The created handle (never a null handle).
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlTexture LoadTextureIO(SdlRenderer renderer, nint src, bool closeio)
{
SdlTexture result = PInvoke.LoadTextureIO(renderer, src, closeio ? (byte)1 : (byte)0);
if (result.IsNull())
{
throw SdlException.FromError("IMG_LoadTexture_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadTextureTyped_IO. Throws instead of returning a null handle on
/// failure.
///
/// the SDL_Renderer to use to create the texture.
/// an SDL_IOStream that data will be read from.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
///
/// a filename extension that represent this data ("BMP", "GIF",
/// "PNG", etc).
///
/// The created handle (never a null handle).
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlTexture LoadTextureTypedIO(SdlRenderer renderer, nint src, bool closeio, string type)
{
SdlTexture result = PInvoke.LoadTextureTypedIO(renderer, src, closeio ? (byte)1 : (byte)0, type);
if (result.IsNull())
{
throw SdlException.FromError("IMG_LoadTextureTyped_IO failed");
}
return result;
}
///
/// Load an image from a filesystem path into a GPU texture.
///
/// the SDL_GPUDevice to use to create the GPU texture.
///
/// the SDL_GPUCopyPass to use to upload the loaded image to
/// the GPU texture.
///
/// a path on the filesystem to load an image from.
///
/// a pointer filled in with the width of the GPU texture. may be
/// NULL.
///
///
/// a pointer filled in with the width of the GPU texture. may be
/// NULL.
///
/// a new GPU texture, or NULL on error.
///
///
/// An SDL_GPUTexture represents an image in GPU memory, usable by SDL's GPU
/// API. Regardless of the source format of the image, this function will
/// create a GPU texture with the format SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM
/// with no mip levels. It can be bound as a sampled texture from a graphics or
/// compute pipeline and as a a readonly storage texture in a compute pipeline.
///
///
/// 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_LoadGPUTexture_IO().
///
///
/// When done with the returned texture, the app should dispose of it with a
/// call to SDL_ReleaseGPUTexture().
///
///
///
/// This function is available since SDL_image 3.4.0.
///
///
///
public static nint LoadGPUTexture(
SdlGpuDevice device,
nint copy_pass,
string file,
out int width,
out int height
)
{
width = default;
height = default;
fixed (int* widthPtr = &width)
{
fixed (int* heightPtr = &height)
{
return PInvoke.LoadGPUTexture(device, copy_pass, file, widthPtr, heightPtr);
}
}
}
///
/// Load an image from an SDL data source into a GPU texture.
///
/// the SDL_GPUDevice to use to create the GPU texture.
///
/// the SDL_GPUCopyPass to use to upload the loaded image to
/// the GPU texture.
///
/// an SDL_IOStream that data will be read from.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
///
/// a pointer filled in with the width of the GPU texture. may be
/// NULL.
///
///
/// a pointer filled in with the width of the GPU texture. may be
/// NULL.
///
/// a new GPU texture, or NULL on error.
///
///
/// An SDL_GPUTexture represents an image in GPU memory, usable by SDL's GPU
/// API. Regardless of the source format of the image, this function will
/// create a GPU texture with the format SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM
/// with no mip levels. It can be bound as a sampled texture from a graphics or
/// compute pipeline and as a a readonly storage texture in a compute pipeline.
///
///
/// 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_LoadGPUTexture(device, copy_pass, "filename.jpg",
/// width, height) will call this function and manage those details for you,
/// determining the file type from the filename's extension.
///
///
/// There is also IMG_LoadGPUTextureTyped_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.
///
///
/// When done with the returned texture, the app should dispose of it with a
/// call to SDL_ReleaseGPUTexture().
///
///
///
/// This function is available since SDL_image 3.4.0.
///
///
///
public static nint LoadGPUTextureIO(
SdlGpuDevice device,
nint copy_pass,
nint src,
bool closeio,
out int width,
out int height
)
{
width = default;
height = default;
fixed (int* widthPtr = &width)
{
fixed (int* heightPtr = &height)
{
return PInvoke.LoadGPUTextureIO(
device,
copy_pass,
src,
closeio ? (byte)1 : (byte)0,
widthPtr,
heightPtr
);
}
}
}
///
/// Load an image from an SDL data source into a GPU texture.
///
/// the SDL_GPUDevice to use to create the GPU texture.
///
/// the SDL_GPUCopyPass to use to upload the loaded image to
/// the GPU texture.
///
/// an SDL_IOStream that data will be read from.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
///
/// a filename extension that represent this data ("BMP", "GIF",
/// "PNG", etc).
///
///
/// a pointer filled in with the width of the GPU texture. may be
/// NULL.
///
///
/// a pointer filled in with the width of the GPU texture. may be
/// NULL.
///
/// a new GPU texture, or NULL on error.
///
///
/// An SDL_GPUTexture represents an image in GPU memory, usable by SDL's GPU
/// API. Regardless of the source format of the image, this function will
/// create a GPU texture with the format SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM
/// with no mip levels. It can be bound as a sampled texture from a graphics or
/// compute pipeline and as a a readonly storage texture in a compute pipeline.
///
///
/// 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.
///
///
/// 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 NULL, 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 SDL_IOStream: `IMG_LoadGPUTexture(device, copy_pass, "filename.jpg",
/// width, height) will call this function and manage those details for you,
/// determining the file type from the filename's extension.
///
///
/// There is also IMG_LoadGPUTexture_IO(), 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 NULL for type.
///
///
/// When done with the returned texture, the app should dispose of it with a
/// call to SDL_ReleaseGPUTexture().
///
///
///
/// This function is available since SDL_image 3.4.0.
///
///
///
public static nint LoadGPUTextureTypedIO(
SdlGpuDevice device,
nint copy_pass,
nint src,
bool closeio,
string type,
out int width,
out int height
)
{
width = default;
height = default;
fixed (int* widthPtr = &width)
{
fixed (int* heightPtr = &height)
{
return PInvoke.LoadGPUTextureTypedIO(
device,
copy_pass,
src,
closeio ? (byte)1 : (byte)0,
type,
widthPtr,
heightPtr
);
}
}
}
///
/// Ergonomic wrapper over IMG_GetClipboardImage. Throws instead of returning a null pointer on
/// failure.
///
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* GetClipboardImage()
{
SdlSurface* result = PInvoke.GetClipboardImage();
if (result == null)
{
throw SdlException.FromError("IMG_GetClipboardImage failed");
}
return result;
}
///
/// Detect ANI animated cursor data on a readable/seekable SDL_IOStream.
///
/// a seekable/readable SDL_IOStream to provide image data.
/// true if this is ANI animated cursor data, false otherwise.
///
///
/// This function attempts to determine if a file is a given filetype, reading
/// the least amount possible from the SDL_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.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool IsANI(nint src) => PInvoke.IsANI(src) != 0;
///
/// Detect AVIF image data on a readable/seekable SDL_IOStream.
///
/// a seekable/readable SDL_IOStream to provide image data.
/// true if this is AVIF data, false otherwise.
///
///
/// This function attempts to determine if a file is a given filetype, reading
/// the least amount possible from the SDL_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.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool IsAVIF(nint src) => PInvoke.IsAVIF(src) != 0;
///
/// Detect CUR image data on a readable/seekable SDL_IOStream.
///
/// a seekable/readable SDL_IOStream to provide image data.
/// true if this is CUR data, false otherwise.
///
///
/// This function attempts to determine if a file is a given filetype, reading
/// the least amount possible from the SDL_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.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool IsCUR(nint src) => PInvoke.IsCUR(src) != 0;
///
/// Detect BMP image data on a readable/seekable SDL_IOStream.
///
/// a seekable/readable SDL_IOStream to provide image data.
/// true if this is BMP data, false otherwise.
///
///
/// This function attempts to determine if a file is a given filetype, reading
/// the least amount possible from the SDL_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.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool IsBMP(nint src) => PInvoke.IsBMP(src) != 0;
///
/// Detect GIF image data on a readable/seekable SDL_IOStream.
///
/// a seekable/readable SDL_IOStream to provide image data.
/// true if this is GIF data, false otherwise.
///
///
/// This function attempts to determine if a file is a given filetype, reading
/// the least amount possible from the SDL_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.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool IsGIF(nint src) => PInvoke.IsGIF(src) != 0;
///
/// Detect ICO image data on a readable/seekable SDL_IOStream.
///
/// a seekable/readable SDL_IOStream to provide image data.
/// true if this is ICO data, false otherwise.
///
///
/// This function attempts to determine if a file is a given filetype, reading
/// the least amount possible from the SDL_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.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool IsICO(nint src) => PInvoke.IsICO(src) != 0;
///
/// Detect JPG image data on a readable/seekable SDL_IOStream.
///
/// a seekable/readable SDL_IOStream to provide image data.
/// true if this is JPG data, false otherwise.
///
///
/// This function attempts to determine if a file is a given filetype, reading
/// the least amount possible from the SDL_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.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool IsJPG(nint src) => PInvoke.IsJPG(src) != 0;
///
/// Detect JXL image data on a readable/seekable SDL_IOStream.
///
/// a seekable/readable SDL_IOStream to provide image data.
/// true if this is JXL data, false otherwise.
///
///
/// This function attempts to determine if a file is a given filetype, reading
/// the least amount possible from the SDL_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.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool IsJXL(nint src) => PInvoke.IsJXL(src) != 0;
///
/// Detect LBM image data on a readable/seekable SDL_IOStream.
///
/// a seekable/readable SDL_IOStream to provide image data.
/// true if this is LBM data, false otherwise.
///
///
/// This function attempts to determine if a file is a given filetype, reading
/// the least amount possible from the SDL_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.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool IsLBM(nint src) => PInvoke.IsLBM(src) != 0;
///
/// Detect PCX image data on a readable/seekable SDL_IOStream.
///
/// a seekable/readable SDL_IOStream to provide image data.
/// true if this is PCX data, false otherwise.
///
///
/// This function attempts to determine if a file is a given filetype, reading
/// the least amount possible from the SDL_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.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool IsPCX(nint src) => PInvoke.IsPCX(src) != 0;
///
/// Detect PNG image data on a readable/seekable SDL_IOStream.
///
/// a seekable/readable SDL_IOStream to provide image data.
/// true if this is PNG data, false otherwise.
///
///
/// This function attempts to determine if a file is a given filetype, reading
/// the least amount possible from the SDL_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.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool IsPNG(nint src) => PInvoke.IsPNG(src) != 0;
///
/// Detect PNM image data on a readable/seekable SDL_IOStream.
///
/// a seekable/readable SDL_IOStream to provide image data.
/// true if this is PNM data, false otherwise.
///
///
/// This function attempts to determine if a file is a given filetype, reading
/// the least amount possible from the SDL_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.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool IsPNM(nint src) => PInvoke.IsPNM(src) != 0;
///
/// Detect QOI image data on a readable/seekable SDL_IOStream.
///
/// a seekable/readable SDL_IOStream to provide image data.
/// true if this is QOI data, false otherwise.
///
///
/// This function attempts to determine if a file is a given filetype, reading
/// the least amount possible from the SDL_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.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool IsQOI(nint src) => PInvoke.IsQOI(src) != 0;
///
/// Detect SVG image data on a readable/seekable SDL_IOStream.
///
/// a seekable/readable SDL_IOStream to provide image data.
/// true if this is SVG data, false otherwise.
///
///
/// This function attempts to determine if a file is a given filetype, reading
/// the least amount possible from the SDL_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.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool IsSVG(nint src) => PInvoke.IsSVG(src) != 0;
///
/// Detect TIFF image data on a readable/seekable SDL_IOStream.
///
/// a seekable/readable SDL_IOStream to provide image data.
/// true if this is TIFF data, false otherwise.
///
///
/// This function attempts to determine if a file is a given filetype, reading
/// the least amount possible from the SDL_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.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool IsTIF(nint src) => PInvoke.IsTIF(src) != 0;
///
/// Detect WEBP image data on a readable/seekable SDL_IOStream.
///
/// a seekable/readable SDL_IOStream to provide image data.
/// true if this is WEBP data, false otherwise.
///
///
/// This function attempts to determine if a file is a given filetype, reading
/// the least amount possible from the SDL_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.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool IsWEBP(nint src) => PInvoke.IsWEBP(src) != 0;
///
/// Detect XCF image data on a readable/seekable SDL_IOStream.
///
/// a seekable/readable SDL_IOStream to provide image data.
/// true if this is XCF data, false otherwise.
///
///
/// This function attempts to determine if a file is a given filetype, reading
/// the least amount possible from the SDL_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.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool IsXCF(nint src) => PInvoke.IsXCF(src) != 0;
///
/// Detect XPM image data on a readable/seekable SDL_IOStream.
///
/// a seekable/readable SDL_IOStream to provide image data.
/// true if this is XPM data, false otherwise.
///
///
/// This function attempts to determine if a file is a given filetype, reading
/// the least amount possible from the SDL_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.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool IsXPM(nint src) => PInvoke.IsXPM(src) != 0;
///
/// Detect XV image data on a readable/seekable SDL_IOStream.
///
/// a seekable/readable SDL_IOStream to provide image data.
/// true if this is XV data, false otherwise.
///
///
/// This function attempts to determine if a file is a given filetype, reading
/// the least amount possible from the SDL_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.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool IsXV(nint src) => PInvoke.IsXV(src) != 0;
///
/// Ergonomic wrapper over IMG_LoadAVIF_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load image data from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadAVIFIO(nint src)
{
SdlSurface* result = PInvoke.LoadAVIFIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadAVIF_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadBMP_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load image data from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadBMPIO(nint src)
{
SdlSurface* result = PInvoke.LoadBMPIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadBMP_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadCUR_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load image data from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadCURIO(nint src)
{
SdlSurface* result = PInvoke.LoadCURIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadCUR_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadGIF_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load image data from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadGIFIO(nint src)
{
SdlSurface* result = PInvoke.LoadGIFIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadGIF_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadICO_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load image data from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadICOIO(nint src)
{
SdlSurface* result = PInvoke.LoadICOIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadICO_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadJPG_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load image data from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadJPGIO(nint src)
{
SdlSurface* result = PInvoke.LoadJPGIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadJPG_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadJXL_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load image data from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadJXLIO(nint src)
{
SdlSurface* result = PInvoke.LoadJXLIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadJXL_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadLBM_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load image data from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadLBMIO(nint src)
{
SdlSurface* result = PInvoke.LoadLBMIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadLBM_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadPCX_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load image data from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadPCXIO(nint src)
{
SdlSurface* result = PInvoke.LoadPCXIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadPCX_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadPNG_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load image data from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadPNGIO(nint src)
{
SdlSurface* result = PInvoke.LoadPNGIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadPNG_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadPNM_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load image data from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadPNMIO(nint src)
{
SdlSurface* result = PInvoke.LoadPNMIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadPNM_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadSVG_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load image data from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadSVGIO(nint src)
{
SdlSurface* result = PInvoke.LoadSVGIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadSVG_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadSizedSVG_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load SVG data from.
/// desired width of the generated surface, in pixels.
/// desired height of the generated surface, in pixels.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadSizedSVGIO(nint src, int width, int height)
{
SdlSurface* result = PInvoke.LoadSizedSVGIO(src, width, height);
if (result == null)
{
throw SdlException.FromError("IMG_LoadSizedSVG_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadQOI_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load image data from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadQOIIO(nint src)
{
SdlSurface* result = PInvoke.LoadQOIIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadQOI_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadTGA_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load image data from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadTGAIO(nint src)
{
SdlSurface* result = PInvoke.LoadTGAIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadTGA_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadTIF_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load image data from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadTIFIO(nint src)
{
SdlSurface* result = PInvoke.LoadTIFIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadTIF_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadWEBP_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load image data from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadWEBPIO(nint src)
{
SdlSurface* result = PInvoke.LoadWEBPIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadWEBP_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadXCF_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load image data from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadXCFIO(nint src)
{
SdlSurface* result = PInvoke.LoadXCFIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadXCF_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadXPM_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load image data from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadXPMIO(nint src)
{
SdlSurface* result = PInvoke.LoadXPMIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadXPM_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadXV_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream to load image data from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlSurface* LoadXVIO(nint src)
{
SdlSurface* result = PInvoke.LoadXVIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadXV_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_Save. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// path on the filesystem to write new file to.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void Save(SdlSurface* surface, string file)
{
if (PInvoke.Save(surface, file) == 0)
{
throw SdlException.FromError("IMG_Save failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveTyped_IO. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// the SDL_IOStream to save the image data to.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
///
/// a filename extension that represent this data ("BMP", "GIF",
/// "PNG", etc).
///
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveTypedIO(SdlSurface* surface, nint dst, bool closeio, string type)
{
if (PInvoke.SaveTypedIO(surface, dst, closeio ? (byte)1 : (byte)0, type) == 0)
{
throw SdlException.FromError("IMG_SaveTyped_IO failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveAVIF. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// path on the filesystem to write new file to.
///
/// the desired quality, ranging between 0 (lowest) and 100
/// (highest).
///
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveAVIF(SdlSurface* surface, string file, int quality)
{
if (PInvoke.SaveAVIF(surface, file, quality) == 0)
{
throw SdlException.FromError("IMG_SaveAVIF failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveAVIF_IO. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// the SDL_IOStream to save the image data to.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
///
/// the desired quality, ranging between 0 (lowest) and 100
/// (highest).
///
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveAVIFIO(SdlSurface* surface, nint dst, bool closeio, int quality)
{
if (PInvoke.SaveAVIFIO(surface, dst, closeio ? (byte)1 : (byte)0, quality) == 0)
{
throw SdlException.FromError("IMG_SaveAVIF_IO failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveBMP. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// path on the filesystem to write new file to.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveBMP(SdlSurface* surface, string file)
{
if (PInvoke.SaveBMP(surface, file) == 0)
{
throw SdlException.FromError("IMG_SaveBMP failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveBMP_IO. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// the SDL_IOStream to save the image data to.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveBMPIO(SdlSurface* surface, nint dst, bool closeio)
{
if (PInvoke.SaveBMPIO(surface, dst, closeio ? (byte)1 : (byte)0) == 0)
{
throw SdlException.FromError("IMG_SaveBMP_IO failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveCUR. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// path on the filesystem to write new file to.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveCUR(SdlSurface* surface, string file)
{
if (PInvoke.SaveCUR(surface, file) == 0)
{
throw SdlException.FromError("IMG_SaveCUR failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveCUR_IO. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// the SDL_IOStream to save the image data to.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveCURIO(SdlSurface* surface, nint dst, bool closeio)
{
if (PInvoke.SaveCURIO(surface, dst, closeio ? (byte)1 : (byte)0) == 0)
{
throw SdlException.FromError("IMG_SaveCUR_IO failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveGIF. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// path on the filesystem to write new file to.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveGIF(SdlSurface* surface, string file)
{
if (PInvoke.SaveGIF(surface, file) == 0)
{
throw SdlException.FromError("IMG_SaveGIF failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveGIF_IO. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// the SDL_IOStream to save the image data to.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveGIFIO(SdlSurface* surface, nint dst, bool closeio)
{
if (PInvoke.SaveGIFIO(surface, dst, closeio ? (byte)1 : (byte)0) == 0)
{
throw SdlException.FromError("IMG_SaveGIF_IO failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveICO. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// path on the filesystem to write new file to.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveICO(SdlSurface* surface, string file)
{
if (PInvoke.SaveICO(surface, file) == 0)
{
throw SdlException.FromError("IMG_SaveICO failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveICO_IO. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// the SDL_IOStream to save the image data to.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveICOIO(SdlSurface* surface, nint dst, bool closeio)
{
if (PInvoke.SaveICOIO(surface, dst, closeio ? (byte)1 : (byte)0) == 0)
{
throw SdlException.FromError("IMG_SaveICO_IO failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveJPG. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// path on the filesystem to write new file to.
///
/// [0; 33] is Lowest quality, [34; 66] is Middle quality, [67;
/// 100] is Highest quality.
///
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveJPG(SdlSurface* surface, string file, int quality)
{
if (PInvoke.SaveJPG(surface, file, quality) == 0)
{
throw SdlException.FromError("IMG_SaveJPG failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveJPG_IO. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// the SDL_IOStream to save the image data to.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
///
/// [0; 33] is Lowest quality, [34; 66] is Middle quality, [67;
/// 100] is Highest quality.
///
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveJPGIO(SdlSurface* surface, nint dst, bool closeio, int quality)
{
if (PInvoke.SaveJPGIO(surface, dst, closeio ? (byte)1 : (byte)0, quality) == 0)
{
throw SdlException.FromError("IMG_SaveJPG_IO failed");
}
}
///
/// Ergonomic wrapper over IMG_SavePNG. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// path on the filesystem to write new file to.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SavePNG(SdlSurface* surface, string file)
{
if (PInvoke.SavePNG(surface, file) == 0)
{
throw SdlException.FromError("IMG_SavePNG failed");
}
}
///
/// Ergonomic wrapper over IMG_SavePNG_IO. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// the SDL_IOStream to save the image data to.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SavePNGIO(SdlSurface* surface, nint dst, bool closeio)
{
if (PInvoke.SavePNGIO(surface, dst, closeio ? (byte)1 : (byte)0) == 0)
{
throw SdlException.FromError("IMG_SavePNG_IO failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveTGA. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// path on the filesystem to write new file to.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveTGA(SdlSurface* surface, string file)
{
if (PInvoke.SaveTGA(surface, file) == 0)
{
throw SdlException.FromError("IMG_SaveTGA failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveTGA_IO. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// the SDL_IOStream to save the image data to.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveTGAIO(SdlSurface* surface, nint dst, bool closeio)
{
if (PInvoke.SaveTGAIO(surface, dst, closeio ? (byte)1 : (byte)0) == 0)
{
throw SdlException.FromError("IMG_SaveTGA_IO failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveWEBP. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// path on the filesystem to write the new file to.
///
/// between 0 and 100. For lossy, 0 gives the smallest size and
/// 100 the largest. For lossless, this parameter is the amount
/// of effort put into the compression: 0 is the fastest but
/// gives larger files compared to the slowest, but best, 100.
///
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveWEBP(SdlSurface* surface, string file, float quality)
{
if (PInvoke.SaveWEBP(surface, file, quality) == 0)
{
throw SdlException.FromError("IMG_SaveWEBP failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveWEBP_IO. Throws instead of returning false on failure.
///
/// the SDL surface to save.
/// the SDL_IOStream to save the image data to.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
///
/// between 0 and 100. For lossy, 0 gives the smallest size and
/// 100 the largest. For lossless, this parameter is the amount
/// of effort put into the compression: 0 is the fastest but
/// gives larger files compared to the slowest, but best, 100.
///
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveWEBPIO(SdlSurface* surface, nint dst, bool closeio, float quality)
{
if (PInvoke.SaveWEBPIO(surface, dst, closeio ? (byte)1 : (byte)0, quality) == 0)
{
throw SdlException.FromError("IMG_SaveWEBP_IO failed");
}
}
///
/// Ergonomic wrapper over IMG_LoadAnimation. Throws instead of returning a null pointer on failure.
///
/// path on the filesystem containing an animated image.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static ImgAnimation* LoadAnimation(string file)
{
ImgAnimation* result = PInvoke.LoadAnimation(file);
if (result == null)
{
throw SdlException.FromError("IMG_LoadAnimation failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadAnimation_IO. Throws instead of returning a null pointer on failure.
///
/// an SDL_IOStream that data will be read from.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static ImgAnimation* LoadAnimationIO(nint src, bool closeio)
{
ImgAnimation* result = PInvoke.LoadAnimationIO(src, closeio ? (byte)1 : (byte)0);
if (result == null)
{
throw SdlException.FromError("IMG_LoadAnimation_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadAnimationTyped_IO. Throws instead of returning a null pointer on
/// failure.
///
/// an SDL_IOStream that data will be read from.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
/// a filename extension that represent this data ("GIF", etc).
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static ImgAnimation* LoadAnimationTypedIO(nint src, bool closeio, string type)
{
ImgAnimation* result = PInvoke.LoadAnimationTypedIO(src, closeio ? (byte)1 : (byte)0, type);
if (result == null)
{
throw SdlException.FromError("IMG_LoadAnimationTyped_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadANIAnimation_IO. Throws instead of returning a null pointer on
/// failure.
///
/// an SDL_IOStream from which data will be read.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static ImgAnimation* LoadANIAnimationIO(nint src)
{
ImgAnimation* result = PInvoke.LoadANIAnimationIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadANIAnimation_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadAPNGAnimation_IO. Throws instead of returning a null pointer on
/// failure.
///
/// an SDL_IOStream from which data will be read.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static ImgAnimation* LoadAPNGAnimationIO(nint src)
{
ImgAnimation* result = PInvoke.LoadAPNGAnimationIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadAPNGAnimation_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadAVIFAnimation_IO. Throws instead of returning a null pointer on
/// failure.
///
/// an SDL_IOStream that data will be read from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static ImgAnimation* LoadAVIFAnimationIO(nint src)
{
ImgAnimation* result = PInvoke.LoadAVIFAnimationIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadAVIFAnimation_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadGIFAnimation_IO. Throws instead of returning a null pointer on
/// failure.
///
/// an SDL_IOStream that data will be read from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static ImgAnimation* LoadGIFAnimationIO(nint src)
{
ImgAnimation* result = PInvoke.LoadGIFAnimationIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadGIFAnimation_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_LoadWEBPAnimation_IO. Throws instead of returning a null pointer on
/// failure.
///
/// an SDL_IOStream that data will be read from.
/// The created resource (never null); the caller owns it and is responsible for freeing it.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static ImgAnimation* LoadWEBPAnimationIO(nint src)
{
ImgAnimation* result = PInvoke.LoadWEBPAnimationIO(src);
if (result == null)
{
throw SdlException.FromError("IMG_LoadWEBPAnimation_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_SaveAnimation. Throws instead of returning false on failure.
///
/// the animation to save.
/// path on the filesystem containing an animated image.
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveAnimation(ImgAnimation* anim, string file)
{
if (PInvoke.SaveAnimation(anim, file) == 0)
{
throw SdlException.FromError("IMG_SaveAnimation failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveAnimationTyped_IO. Throws instead of returning false on failure.
///
/// the animation to save.
/// an SDL_IOStream that data will be written to.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
/// a filename extension that represent this data ("GIF", etc).
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveAnimationTypedIO(ImgAnimation* anim, nint dst, bool closeio, string type)
{
if (PInvoke.SaveAnimationTypedIO(anim, dst, closeio ? (byte)1 : (byte)0, type) == 0)
{
throw SdlException.FromError("IMG_SaveAnimationTyped_IO failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveANIAnimation_IO. Throws instead of returning false on failure.
///
/// the animation to save.
/// an SDL_IOStream from which data will be written to.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveANIAnimationIO(ImgAnimation* anim, nint dst, bool closeio)
{
if (PInvoke.SaveANIAnimationIO(anim, dst, closeio ? (byte)1 : (byte)0) == 0)
{
throw SdlException.FromError("IMG_SaveANIAnimation_IO failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveAPNGAnimation_IO. Throws instead of returning false on failure.
///
/// the animation to save.
/// an SDL_IOStream from which data will be written to.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveAPNGAnimationIO(ImgAnimation* anim, nint dst, bool closeio)
{
if (PInvoke.SaveAPNGAnimationIO(anim, dst, closeio ? (byte)1 : (byte)0) == 0)
{
throw SdlException.FromError("IMG_SaveAPNGAnimation_IO failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveAVIFAnimation_IO. Throws instead of returning false on failure.
///
/// the animation to save.
/// an SDL_IOStream from which data will be written to.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
///
/// the desired quality, ranging between 0 (lowest) and 100
/// (highest).
///
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveAVIFAnimationIO(ImgAnimation* anim, nint dst, bool closeio, int quality)
{
if (PInvoke.SaveAVIFAnimationIO(anim, dst, closeio ? (byte)1 : (byte)0, quality) == 0)
{
throw SdlException.FromError("IMG_SaveAVIFAnimation_IO failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveGIFAnimation_IO. Throws instead of returning false on failure.
///
/// the animation to save.
/// an SDL_IOStream from which data will be written to.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveGIFAnimationIO(ImgAnimation* anim, nint dst, bool closeio)
{
if (PInvoke.SaveGIFAnimationIO(anim, dst, closeio ? (byte)1 : (byte)0) == 0)
{
throw SdlException.FromError("IMG_SaveGIFAnimation_IO failed");
}
}
///
/// Ergonomic wrapper over IMG_SaveWEBPAnimation_IO. Throws instead of returning false on failure.
///
/// the animation to save.
/// an SDL_IOStream from which data will be written to.
///
/// true to close/free the SDL_IOStream before returning, false
/// to leave it open.
///
///
/// between 0 and 100. For lossy, 0 gives the smallest size and
/// 100 the largest. For lossless, this parameter is the amount
/// of effort put into the compression: 0 is the fastest but
/// gives larger files compared to the slowest, but best, 100.
///
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static void SaveWEBPAnimationIO(ImgAnimation* anim, nint dst, bool closeio, int quality)
{
if (PInvoke.SaveWEBPAnimationIO(anim, dst, closeio ? (byte)1 : (byte)0, quality) == 0)
{
throw SdlException.FromError("IMG_SaveWEBPAnimation_IO failed");
}
}
///
/// Ergonomic wrapper over IMG_CreateAnimatedCursor. Throws instead of returning a null handle on
/// failure.
///
/// an animation to use to create an animated cursor.
/// the x position of the cursor hot spot.
/// the y position of the cursor hot spot.
/// The created handle (never a null handle).
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static SdlCursor CreateAnimatedCursor(ImgAnimation* anim, int hot_x, int hot_y)
{
SdlCursor result = PInvoke.CreateAnimatedCursor(anim, hot_x, hot_y);
if (result.IsNull())
{
throw SdlException.FromError("IMG_CreateAnimatedCursor failed");
}
return result;
}
///
/// Dispose of an IMG_Animation and free its resources.
///
/// IMG_Animation to dispose of.
///
///
/// The provided anim pointer is not valid once this call returns.
///
///
///
/// This function is available since SDL_image 3.0.0.
///
///
///
///
///
///
///
///
///
public static void FreeAnimation(ImgAnimation* anim) => PInvoke.FreeAnimation(anim);
///
/// Ergonomic wrapper over IMG_CreateAnimationEncoder. Throws instead of returning a null handle on
/// failure.
///
/// the file where the animation will be saved.
/// The created handle (never a null handle).
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static ImgAnimationEncoder CreateAnimationEncoder(string file)
{
ImgAnimationEncoder result = PInvoke.CreateAnimationEncoder(file);
if (result.IsNull())
{
throw SdlException.FromError("IMG_CreateAnimationEncoder failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_CreateAnimationEncoder_IO. Throws instead of returning a null handle on
/// failure.
///
/// an SDL_IOStream that will be used to save the stream.
///
/// true to close the SDL_IOStream when done, false to leave it
/// open.
///
/// a filename extension that represent this data ("WEBP", etc).
/// The created handle (never a null handle).
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static ImgAnimationEncoder CreateAnimationEncoderIO(nint dst, bool closeio, string type)
{
ImgAnimationEncoder result = PInvoke.CreateAnimationEncoderIO(dst, closeio ? (byte)1 : (byte)0, type);
if (result.IsNull())
{
throw SdlException.FromError("IMG_CreateAnimationEncoder_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_CreateAnimationEncoderWithProperties. Throws instead of returning a null
/// handle on failure.
///
/// the properties of the animation encoder.
/// The created handle (never a null handle).
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static ImgAnimationEncoder CreateAnimationEncoderWithProperties(uint props)
{
ImgAnimationEncoder result = PInvoke.CreateAnimationEncoderWithProperties(props);
if (result.IsNull())
{
throw SdlException.FromError("IMG_CreateAnimationEncoderWithProperties failed");
}
return result;
}
///
/// Add a frame to an animation encoder.
///
/// the receiving images.
/// the surface to add as the next frame in the animation.
///
/// the duration of the frame, usually in milliseconds but can
/// be other units if the
/// IMG_PROP_ANIMATION_ENCODER_CREATE_TIMEBASE_DENOMINATOR_NUMBER
/// property is set when creating the encoder.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function is available since SDL_image 3.4.0.
///
///
///
///
///
public static bool AddAnimationEncoderFrame(ImgAnimationEncoder encoder, SdlSurface* surface, ulong duration) =>
PInvoke.AddAnimationEncoderFrame(encoder, surface, duration) != 0;
///
/// Close an animation encoder, finishing any encoding.
///
/// the encoder to close.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// Calling this function frees the animation encoder, and returns the final
/// status of the encoding process.
///
///
///
/// This function is available since SDL_image 3.4.0.
///
///
///
///
public static bool CloseAnimationEncoder(ImgAnimationEncoder encoder) =>
PInvoke.CloseAnimationEncoder(encoder) != 0;
///
/// Ergonomic wrapper over IMG_CreateAnimationDecoder. Throws instead of returning a null handle on
/// failure.
///
/// the file containing a series of images.
/// The created handle (never a null handle).
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static ImgAnimationDecoder CreateAnimationDecoder(string file)
{
ImgAnimationDecoder result = PInvoke.CreateAnimationDecoder(file);
if (result.IsNull())
{
throw SdlException.FromError("IMG_CreateAnimationDecoder failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_CreateAnimationDecoder_IO. Throws instead of returning a null handle on
/// failure.
///
/// an SDL_IOStream containing a series of images.
///
/// true to close the SDL_IOStream when done, false to leave it
/// open.
///
/// a filename extension that represent this data ("WEBP", etc).
/// The created handle (never a null handle).
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static ImgAnimationDecoder CreateAnimationDecoderIO(nint src, bool closeio, string type)
{
ImgAnimationDecoder result = PInvoke.CreateAnimationDecoderIO(src, closeio ? (byte)1 : (byte)0, type);
if (result.IsNull())
{
throw SdlException.FromError("IMG_CreateAnimationDecoder_IO failed");
}
return result;
}
///
/// Ergonomic wrapper over IMG_CreateAnimationDecoderWithProperties. Throws instead of returning a null
/// handle on failure.
///
/// the properties of the animation decoder.
/// The created handle (never a null handle).
/// The SDL call failed; the message carries the SDL_GetError
/// text.
public static ImgAnimationDecoder CreateAnimationDecoderWithProperties(uint props)
{
ImgAnimationDecoder result = PInvoke.CreateAnimationDecoderWithProperties(props);
if (result.IsNull())
{
throw SdlException.FromError("IMG_CreateAnimationDecoderWithProperties failed");
}
return result;
}
///
/// Get the properties of an animation decoder.
///
/// the animation decoder.
///
/// the properties ID of the animation decoder, or 0 if there are no
/// properties; call SDL_GetError() for more information.
///
///
///
/// This function returns the properties of the animation decoder, which holds
/// information about the underlying image such as description, copyright text
/// and loop count.
///
///
/// IMG_PROP_METADATA_LOOP_COUNT_NUMBER, if present, specifies the number of times to play the
/// animation, with 0 meaning loop continuously.
///
///
///
/// This function is available since SDL_image 3.4.0.
///
///
///
///
public static uint GetAnimationDecoderProperties(ImgAnimationDecoder decoder) =>
PInvoke.GetAnimationDecoderProperties(decoder);
///
/// Get the next frame in an animation decoder.
///
/// the animation decoder.
///
/// a pointer filled in with the SDL_Surface for the next frame in
/// the animation.
///
///
/// the duration of the frame, usually in milliseconds but can
/// be other units if the
/// IMG_PROP_ANIMATION_DECODER_CREATE_TIMEBASE_DENOMINATOR_NUMBER
/// property is set when creating the decoder.
///
///
/// true on success or false on failure and when no more frames are
/// available; call IMG_GetAnimationDecoderStatus() or SDL_GetError()
/// for more information.
///
///
///
/// This function decodes the next frame in the animation decoder, returning it
/// as an SDL_Surface. The returned surface should be freed with
/// SDL_FreeSurface() when no longer needed.
///
///
/// If the animation decoder has no more frames or an error occurred while
/// decoding the frame, this function returns false. In that case, please call
/// SDL_GetError() for more information. If SDL_GetError() returns an empty
/// string, that means there are no more available frames. If SDL_GetError()
/// returns a valid string, that means the decoding failed.
///
///
///
/// This function is available since SDL_image 3.4.0.
///
///
///
///
///
///
///
public static bool GetAnimationDecoderFrame(ImgAnimationDecoder decoder, SdlSurface** frame, out ulong duration)
{
duration = default;
fixed (ulong* durationPtr = &duration)
{
return PInvoke.GetAnimationDecoderFrame(decoder, frame, durationPtr) != 0;
}
}
///
/// Get the decoder status indicating the current state of the decoder.
///
/// the decoder to get the status of.
///
/// the status of the underlying decoder, or
/// IMG_DECODER_STATUS_INVALID if the given decoder is invalid.
///
///
/// This function is available since SDL_image 3.4.0.
///
///
public static ImgAnimationDecoderStatus GetAnimationDecoderStatus(ImgAnimationDecoder decoder) =>
PInvoke.GetAnimationDecoderStatus(decoder);
///
/// Reset an animation decoder.
///
/// the decoder to reset.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// Calling this function resets the animation decoder, allowing it to start
/// from the beginning again. This is useful if you want to decode the frame
/// sequence again without creating a new decoder.
///
///
///
/// This function is available since SDL_image 3.4.0.
///
///
///
///
///
///
public static bool ResetAnimationDecoder(ImgAnimationDecoder decoder) =>
PInvoke.ResetAnimationDecoder(decoder) != 0;
///
/// Close an animation decoder, finishing any decoding.
///
/// the decoder to close.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// Calling this function frees the animation decoder, and returns the final
/// status of the decoding process.
///
///
///
/// This function is available since SDL_image 3.4.0.
///
///
///
///
public static bool CloseAnimationDecoder(ImgAnimationDecoder decoder) =>
PInvoke.CloseAnimationDecoder(decoder) != 0;
}
}