4#include "SDL3pp_error.h"
5#include "SDL3pp_render.h"
6#include "SDL3pp_surface.h"
7#include "SDL3pp_version.h"
8#include "SDL3pp_video.h"
10#if !defined(SDL3PP_DISABLE_IMAGE) && !defined(SDL3PP_ENABLE_IMAGE) && \
11 __has_include(<SDL3_image/SDL_image.h>)
12#define SDL3PP_ENABLE_IMAGE
15#if defined(SDL3PP_ENABLE_IMAGE) || defined(SDL3PP_DOC)
17#include <SDL3_image/SDL_image.h>
46#define SDL_IMAGE_MAJOR_VERSION
48#define SDL_IMAGE_MINOR_VERSION
50#define SDL_IMAGE_MICRO_VERSION
57#define SDL_IMAGE_VERSION \
59 SDL_IMAGE_MAJOR_VERSION, SDL_IMAGE_MINOR_VERSION, SDL_IMAGE_MICRO_VERSION)
64#define SDL_IMAGE_VERSION_ATLEAST(X, Y, Z) \
65 ((SDL_IMAGE_MAJOR_VERSION >= X) && \
66 (SDL_IMAGE_MAJOR_VERSION > X || SDL_IMAGE_MINOR_VERSION >= Y) && \
67 (SDL_IMAGE_MAJOR_VERSION > X || SDL_IMAGE_MINOR_VERSION > Y || \
68 SDL_IMAGE_MICRO_VERSION >= Z))
133 return Surface{IMG_LoadTyped_IO(src.
get(),
false, type)};
217 return Surface{IMG_Load_IO(src.
get(),
false)};
244 return Texture{IMG_LoadTexture(renderer.
get(), file)};
281 return Texture{IMG_LoadTexture_IO(renderer.
get(), src.
get(),
false)};
329 IMG_LoadTextureTyped_IO(renderer.
get(), src.
get(),
false, type)};
1794 return Surface{IMG_LoadSizedSVG_IO(src.
get(), width, height)};
1816 return Surface{IMG_ReadXPMFromArray(xpm)};
1838 return Surface{IMG_ReadXPMFromArrayToRGB888(xpm)};
1972 :
Resource(IMG_LoadAnimation(file))
1987 :
Resource(IMG_LoadAnimation_IO(src.
get(), false))
2009 :
Resource(IMG_LoadAnimationTyped_IO(src.
get(), false, type))
2099 void reset(IMG_Animation* newResource = {})
2101 IMG_FreeAnimation(
release(newResource));
2120 constexpr explicit Animation(IMG_Animation* resource = {}) {}
2122 constexpr Animation(
const Animation& other) =
delete;
2209#pragma endregion impl
2223 : Resource(
CheckError(SDL_LoadBMP_IO(src.get(), false)))
A SDL managed resource.
Definition SDL3pp_resource.h:17
constexpr IMG_Animation * release(IMG_Animation * newResource={})
Return contained resource and empties or replace value.
Definition SDL3pp_resource.h:60
constexpr Resource(T resource={})
Constructs the underlying resource.
Definition SDL3pp_resource.h:22
constexpr T get() const
Return contained resource;.
Definition SDL3pp_resource.h:57
Helpers to use C++ strings parameters.
Definition SDL3pp_strings.h:43
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:206
Texture LoadTextureBMP(RendererBase &renderer, IOStreamBase &src)
Load a BMP texture from a seekable SDL data stream.
Definition SDL3pp_render.h:3598
Surface ReadXPMFromArrayToRGB888(char **xpm)
Load an XPM image from a memory array.
Definition SDL3pp_image.h:1836
Surface LoadXCF(IOStreamBase &src)
Load a XCF image directly.
Definition SDL3pp_image.h:1657
Surface LoadJXL(IOStreamBase &src)
Load a JXL image directly.
Definition SDL3pp_image.h:1324
Surface LoadTGA(IOStreamBase &src)
Load a TGA image directly.
Definition SDL3pp_image.h:1583
Surface ReadXPMFromArray(char **xpm)
Load an XPM image from a memory array.
Definition SDL3pp_image.h:1814
bool isXV(IOStreamBase &src)
Detect XV image data on a readable/seekable IOStreamBase.
Definition SDL3pp_image.h:1062
Surface LoadWEBP(IOStreamBase &src)
Load a WEBP image directly.
Definition SDL3pp_image.h:1768
int IMG_Version()
This function gets the version of the dynamically linked SDL_image library.
Definition SDL3pp_image.h:79
bool isLBM(IOStreamBase &src)
Detect LBM image data on a readable/seekable IOStreamBase.
Definition SDL3pp_image.h:675
bool isPNM(IOStreamBase &src)
Detect PNM image data on a readable/seekable IOStreamBase.
Definition SDL3pp_image.h:804
Surface LoadCUR(IOStreamBase &src)
Load a CUR image directly.
Definition SDL3pp_image.h:1213
Surface LoadTIF(IOStreamBase &src)
Load a TIFF image directly.
Definition SDL3pp_image.h:1620
Surface LoadSizedSVG(IOStreamBase &src, int width, int height)
Load an SVG image, scaled to a specific size.
Definition SDL3pp_image.h:1792
Animation LoadGIFAnimation(IOStreamBase &src)
Load a GIF animation directly.
Definition SDL3pp_image.h:2160
bool isWEBP(IOStreamBase &src)
Detect WEBP image data on a readable/seekable IOStreamBase.
Definition SDL3pp_image.h:1105
bool isXPM(IOStreamBase &src)
Detect XPM image data on a readable/seekable IOStreamBase.
Definition SDL3pp_image.h:1019
Surface LoadLBM(IOStreamBase &src)
Load a LBM image directly.
Definition SDL3pp_image.h:1361
bool isCUR(IOStreamBase &src)
Detect CUR image data on a readable/seekable IOStreamBase.
Definition SDL3pp_image.h:460
bool isPNG(IOStreamBase &src)
Detect PNG image data on a readable/seekable IOStreamBase.
Definition SDL3pp_image.h:761
Surface LoadAVIF(IOStreamBase &src)
Load a AVIF image directly.
Definition SDL3pp_image.h:1139
Surface LoadSVG(IOStreamBase &src)
Load a SVG image directly.
Definition SDL3pp_image.h:1509
Surface LoadXV(IOStreamBase &src)
Load a XV image directly.
Definition SDL3pp_image.h:1731
void SavePNG(SurfaceBase &surface, StringParam file)
Save an SurfaceBase into a PNG image file.
Definition SDL3pp_image.h:1890
Surface LoadGIF(IOStreamBase &src)
Load a GIF image directly.
Definition SDL3pp_image.h:1250
Surface LoadPNG(IOStreamBase &src)
Load a PNG image directly.
Definition SDL3pp_image.h:1435
Animation LoadWEBPAnimation(IOStreamBase &src)
Load a WEBP animation directly.
Definition SDL3pp_image.h:2180
Texture LoadTexture(RendererBase &renderer, StringParam file)
Load an image from a filesystem path into a GPU texture.
Definition SDL3pp_image.h:242
bool isBMP(IOStreamBase &src)
Detect BMP image data on a readable/seekable IOStreamBase.
Definition SDL3pp_image.h:503
void SaveAVIF(SurfaceBase &surface, StringParam file, int quality)
Save an SurfaceBase into a AVIF image file.
Definition SDL3pp_image.h:1854
Surface LoadICO(IOStreamBase &src)
Load a ICO image directly.
Definition SDL3pp_image.h:1176
bool isAVIF(IOStreamBase &src)
Detect AVIF image data on a readable/seekable IOStreamBase.
Definition SDL3pp_image.h:374
bool isJPG(IOStreamBase &src)
Detect JPG image data on a readable/seekable IOStreamBase.
Definition SDL3pp_image.h:589
Surface LoadPCX(IOStreamBase &src)
Load a PCX image directly.
Definition SDL3pp_image.h:1398
bool isPCX(IOStreamBase &src)
Detect PCX image data on a readable/seekable IOStreamBase.
Definition SDL3pp_image.h:718
Surface LoadXPM(IOStreamBase &src)
Load a XPM image directly.
Definition SDL3pp_image.h:1694
Surface LoadSurface(IOStreamBase &src, StringParam type)
Load an image from an SDL data source into a software surface.
Definition SDL3pp_image.h:131
bool isGIF(IOStreamBase &src)
Detect GIF image data on a readable/seekable IOStreamBase.
Definition SDL3pp_image.h:546
Surface LoadPNM(IOStreamBase &src)
Load a PNM image directly.
Definition SDL3pp_image.h:1472
bool isQOI(IOStreamBase &src)
Detect QOI image data on a readable/seekable IOStreamBase.
Definition SDL3pp_image.h:890
bool isXCF(IOStreamBase &src)
Detect XCF image data on a readable/seekable IOStreamBase.
Definition SDL3pp_image.h:976
void SaveJPG(SurfaceBase &surface, StringParam file, int quality)
Save an SurfaceBase into a JPEG image file.
Definition SDL3pp_image.h:1924
bool isJXL(IOStreamBase &src)
Detect JXL image data on a readable/seekable IOStreamBase.
Definition SDL3pp_image.h:632
Surface LoadQOI(IOStreamBase &src)
Load a QOI image directly.
Definition SDL3pp_image.h:1546
bool isSVG(IOStreamBase &src)
Detect SVG image data on a readable/seekable IOStreamBase.
Definition SDL3pp_image.h:847
Surface LoadJPG(IOStreamBase &src)
Load a JPG image directly.
Definition SDL3pp_image.h:1287
bool isTIF(IOStreamBase &src)
Detect TIFF image data on a readable/seekable IOStreamBase.
Definition SDL3pp_image.h:933
bool isICO(IOStreamBase &src)
Detect ICO image data on a readable/seekable IOStreamBase.
Definition SDL3pp_image.h:417
the main namespace where all SDL3pp public functions and types live
Definition SDL3pp_assert.h:7
Animated image support.
Definition SDL3pp_image.h:1958
SurfaceRef GetFrame(int index) const
Return the frame image under given index.
Definition SDL3pp_image.h:2038
int GetHeight() const
Get the height in pixels.
Definition SDL3pp_image.h:2021
int GetDelay(int index) const
Return the frame delay under given index.
Definition SDL3pp_image.h:2045
AnimationBase(IOStreamBase &src, StringParam type)
Load an animation from an SDL datasource.
Definition SDL3pp_image.h:2008
int GetWidth() const
Get the width in pixels.
Definition SDL3pp_image.h:2016
AnimationBase(StringParam file)
Load an animation from a file.
Definition SDL3pp_image.h:1971
int GetCount() const
Return the number of frames.
Definition SDL3pp_image.h:2031
Point GetSize() const
Get the size in pixels.
Definition SDL3pp_image.h:2026
AnimationBase(IOStreamBase &src)
Load an animation from an IOStreamBase.
Definition SDL3pp_image.h:1986
Handle to a non owned animation.
Definition SDL3pp_image.h:2057
void reset(IMG_Animation *newResource={})
Dispose of an AnimationBase and free its resources.
Definition SDL3pp_image.h:2099
constexpr AnimationRef(AnimationRef &&other)
Move constructor.
Definition SDL3pp_image.h:2071
constexpr AnimationRef(const AnimationRef &other)
Copy constructor.
Definition SDL3pp_image.h:2063
AnimationRef & operator=(AnimationRef other)
Assignment operator.
Definition SDL3pp_image.h:2084
constexpr ~AnimationRef()=default
Default constructor.
Handle to an owned animation.
Definition SDL3pp_image.h:2114
~Animation()
Frees up resource when object goes out of scope.
Definition SDL3pp_image.h:2132
constexpr Animation(Animation &&other)=default
Move constructor.
constexpr Animation(IMG_Animation *resource={})
Constructs from the underlying resource.
Definition SDL3pp_image.h:2120
Animation & operator=(Animation other)
Assignment operator.
Definition SDL3pp_image.h:2137
The read/write operation structure.
Definition SDL3pp_iostream.h:107
Handle to an owned iOStream.
Definition SDL3pp_iostream.h:1613
The structure that defines a point (using integers)
Definition SDL3pp_rect.h:41
A structure representing rendering state.
Definition SDL3pp_render.h:157
A collection of pixels used in software blitting.
Definition SDL3pp_surface.h:138
SurfaceBase(StringParam file)
Load an image from a filesystem path into a software surface.
Definition SDL3pp_image.h:2189
Handle to a non owned surface.
Definition SDL3pp_surface.h:1814
Handle to an owned surface.
Definition SDL3pp_surface.h:1873
TextureBase(RendererBase &renderer, StringParam file)
Load an image from a filesystem path into a software surface.
Definition SDL3pp_image.h:2199
Handle to an owned texture.
Definition SDL3pp_render.h:2922