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>
64#define SDL_IMAGE_MAJOR_VERSION
66#define SDL_IMAGE_MINOR_VERSION
68#define SDL_IMAGE_MICRO_VERSION
75#define SDL_IMAGE_VERSION \
77 SDL_IMAGE_MAJOR_VERSION, SDL_IMAGE_MINOR_VERSION, SDL_IMAGE_MICRO_VERSION)
82#define SDL_IMAGE_VERSION_ATLEAST(X, Y, Z) \
83 ((SDL_IMAGE_MAJOR_VERSION >= X) && \
84 (SDL_IMAGE_MAJOR_VERSION > X || SDL_IMAGE_MINOR_VERSION >= Y) && \
85 (SDL_IMAGE_MAJOR_VERSION > X || SDL_IMAGE_MINOR_VERSION > Y || \
86 SDL_IMAGE_MICRO_VERSION >= Z))
150 return Surface{IMG_LoadTyped_IO(src.
get(),
false, type)};
232 return Surface{IMG_Load_IO(src.
get(),
false)};
259 return Texture{IMG_LoadTexture(renderer.
get(), file)};
296 return Texture{IMG_LoadTexture_IO(renderer.
get(), src.
get(),
false)};
345 IMG_LoadTextureTyped_IO(renderer.
get(), src.
get(),
false, type)};
1847 return Surface{IMG_LoadSizedSVG_IO(src.
get(), width, height)};
1866 return Surface{IMG_ReadXPMFromArray(xpm)};
1887 return Surface{IMG_ReadXPMFromArrayToRGB888(xpm)};
2055 static void reset(IMG_Animation* resource) { IMG_FreeAnimation(resource); }
2082 return Animation(IMG_LoadAnimation(file));
2098 return Animation(IMG_LoadAnimation_IO(src,
false));
2121 return Animation(IMG_LoadAnimationTyped_IO(src,
false, type));
2188 return Animation{IMG_LoadGIFAnimation_IO(src)};
2210 return Animation{IMG_LoadWEBPAnimation_IO(src)};
2219 return Surface(IMG_Load(file));
2224 return Surface(IMG_Load_IO(src.
get(),
false));
2229 return Texture(IMG_LoadTexture(renderer.
get(), file));
2234 return Texture(IMG_LoadTexture_IO(renderer.
get(), src.
get(),
false));
2237#pragma endregion impl
2247 return Surface(SDL_LoadBMP(file));
2252 return Surface(SDL_LoadBMP_IO(src.get(),
false));
2255inline Texture
Texture::Load(RendererRef renderer, StringParam file)
2260inline Texture
Texture::Load(RendererRef renderer, IOStreamRef src)
RESOURCE release()
Returns reference and reset this.
Definition SDL3pp_resource.h:178
Implement shared ownership for a resource.
Definition SDL3pp_resource.h:283
Implement unique ownership for a resource.
Definition SDL3pp_resource.h:226
constexpr ResourceUnique(std::nullptr_t=nullptr)
Default constructor.
Definition SDL3pp_resource.h:231
void reset()
Resets the value, destroying the resource if not nullptr.
Definition SDL3pp_resource.h:265
A dumb pointer to resource.
Definition SDL3pp_resource.h:197
constexpr ResourceUnsafe()=default
Default constructor.
Implement weak ownership for a resource.
Definition SDL3pp_resource.h:328
A SDL managed resource.
Definition SDL3pp_resource.h:29
constexpr Resource(T resource={})
Constructs from the underlying resource.
Definition SDL3pp_resource.h:37
constexpr T get() const
Return contained resource;.
Definition SDL3pp_resource.h:76
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(RendererRef &renderer, IOStreamRef &src)
Load a BMP texture from a seekable SDL data stream.
Definition SDL3pp_render.h:3630
Surface ReadXPMFromArrayToRGB888(char **xpm)
Load an XPM image from a memory array.
Definition SDL3pp_image.h:1885
Surface LoadTGA(IOStreamRef src)
Load a TGA image directly.
Definition SDL3pp_image.h:1636
Surface LoadPNG(IOStreamRef src)
Load a PNG image directly.
Definition SDL3pp_image.h:1488
bool isPNG(IOStreamRef src)
Detect PNG image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:777
Surface ReadXPMFromArray(char **xpm)
Load an XPM image from a memory array.
Definition SDL3pp_image.h:1864
Surface LoadXPM(IOStreamRef src)
Load a XPM image directly.
Definition SDL3pp_image.h:1747
bool isTIF(IOStreamRef src)
Detect TIFF image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:949
int IMG_Version()
This function gets the version of the dynamically linked SDL_image library.
Definition SDL3pp_image.h:97
bool isWEBP(IOStreamRef src)
Detect WEBP image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1121
Surface LoadQOI(IOStreamRef src)
Load a QOI image directly.
Definition SDL3pp_image.h:1599
bool isXPM(IOStreamRef src)
Detect XPM image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1035
bool isPCX(IOStreamRef src)
Detect PCX image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:734
Surface LoadGIF(IOStreamRef src)
Load a GIF image directly.
Definition SDL3pp_image.h:1303
AnimationShared share()
Move this animation into a AnimationShared.
Definition SDL3pp_image.h:2142
bool isJXL(IOStreamRef src)
Detect JXL image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:648
bool isLBM(IOStreamRef src)
Detect LBM image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:691
bool isICO(IOStreamRef src)
Detect ICO image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:433
bool isPNM(IOStreamRef src)
Detect PNM image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:820
void SaveAVIF(SurfaceRef surface, StringParam file, int quality)
Save an Surface into a AVIF image file.
Definition SDL3pp_image.h:1903
Surface LoadSizedSVG(IOStreamRef src, int width, int height)
Load an SVG image, scaled to a specific size.
Definition SDL3pp_image.h:1845
void SaveJPG(SurfaceRef surface, StringParam file, int quality)
Save an Surface into a JPEG image file.
Definition SDL3pp_image.h:1973
bool isJPG(IOStreamRef src)
Detect JPG image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:605
Surface LoadPCX(IOStreamRef src)
Load a PCX image directly.
Definition SDL3pp_image.h:1451
bool isXCF(IOStreamRef src)
Detect XCF image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:992
Surface LoadPNM(IOStreamRef src)
Load a PNM image directly.
Definition SDL3pp_image.h:1525
Surface LoadSVG(IOStreamRef src)
Load a SVG image directly.
Definition SDL3pp_image.h:1562
Surface LoadTIF(IOStreamRef src)
Load a TIFF image directly.
Definition SDL3pp_image.h:1673
Animation LoadGIFAnimation(IOStreamRef src)
Load a GIF animation directly.
Definition SDL3pp_image.h:2186
Surface LoadCUR(IOStreamRef src)
Load a CUR image directly.
Definition SDL3pp_image.h:1229
Surface LoadJPG(IOStreamRef src)
Load a JPG image directly.
Definition SDL3pp_image.h:1340
bool isSVG(IOStreamRef src)
Detect SVG image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:863
ResourceShared< Animation > AnimationShared
Handle to a shared animation.
Definition SDL3pp_image.h:45
Surface LoadXCF(IOStreamRef src)
Load a XCF image directly.
Definition SDL3pp_image.h:1710
void SavePNG(SurfaceRef surface, StringParam file)
Save an Surface into a PNG image file.
Definition SDL3pp_image.h:1939
Surface LoadSurface(IOStreamRef src, StringParam type)
Load an image from an SDL data source into a software surface.
Definition SDL3pp_image.h:148
bool isBMP(IOStreamRef src)
Detect BMP image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:519
Surface LoadWEBP(IOStreamRef src)
Load a WEBP image directly.
Definition SDL3pp_image.h:1821
Surface LoadAVIF(IOStreamRef src)
Load a AVIF image directly.
Definition SDL3pp_image.h:1155
Surface LoadICO(IOStreamRef src)
Load a ICO image directly.
Definition SDL3pp_image.h:1192
bool isXV(IOStreamRef src)
Detect XV image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1078
Texture LoadTexture(RendererRef renderer, StringParam file)
Load an image from a filesystem path into a GPU texture.
Definition SDL3pp_image.h:257
bool isQOI(IOStreamRef src)
Detect QOI image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:906
Surface LoadJXL(IOStreamRef src)
Load a JXL image directly.
Definition SDL3pp_image.h:1377
Surface LoadLBM(IOStreamRef src)
Load a LBM image directly.
Definition SDL3pp_image.h:1414
bool isAVIF(IOStreamRef src)
Detect AVIF image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:390
Surface LoadXV(IOStreamRef src)
Load a XV image directly.
Definition SDL3pp_image.h:1784
bool isGIF(IOStreamRef src)
Detect GIF image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:562
bool isCUR(IOStreamRef src)
Detect CUR image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:476
Surface LoadBMP(IOStreamRef src)
Load a BMP image directly.
Definition SDL3pp_image.h:1266
Animation LoadWEBPAnimation(IOStreamRef src)
Load a WEBP animation directly.
Definition SDL3pp_image.h:2208
the main namespace where all SDL3pp public functions and types live
Definition SDL3pp_assert.h:7
Animated image support.
Definition SDL3pp_image.h:2006
int GetDelay(int index) const
Return the frame delay under given index.
Definition SDL3pp_image.h:2041
int GetCount() const
Return the number of frames.
Definition SDL3pp_image.h:2027
SurfaceRef GetFrame(int index) const
Return the frame image under given index.
Definition SDL3pp_image.h:2034
int GetWidth() const
Get the width in pixels.
Definition SDL3pp_image.h:2012
static void reset(IMG_Animation *resource)
Dispose of an AnimationRef and free its resources.
Definition SDL3pp_image.h:2055
Point GetSize() const
Get the size in pixels.
Definition SDL3pp_image.h:2022
int GetHeight() const
Get the height in pixels.
Definition SDL3pp_image.h:2017
Unsafe Handle to animation.
Definition SDL3pp_image.h:2157
constexpr AnimationUnsafe(Animation &&other)
Constructs AnimationUnsafe from Animation.
Definition SDL3pp_image.h:2163
Handle to an owned animation.
Definition SDL3pp_image.h:2066
static Animation Load(StringParam file)
Load an animation from a file.
Definition SDL3pp_image.h:2080
void Free()
Dispose of an AnimationRef and free its resources.
Definition SDL3pp_image.h:2133
static Animation Load(IOStreamRef src)
Load an animation from an IOStreamRef.
Definition SDL3pp_image.h:2096
static Animation LoadTyped(IOStreamRef src, StringParam type)
Load an animation from an SDL datasource.
Definition SDL3pp_image.h:2119
The read/write operation structure.
Definition SDL3pp_iostream.h:123
The structure that defines a point (using integers).
Definition SDL3pp_rect.h:46
A structure representing rendering state.
Definition SDL3pp_render.h:182
A collection of pixels used in software blitting.
Definition SDL3pp_surface.h:153
Handle to an owned surface.
Definition SDL3pp_surface.h:1824
static Surface Load(StringParam file)
Load an image from a filesystem path into a software surface.
Definition SDL3pp_image.h:2217
Handle to an owned texture.
Definition SDL3pp_render.h:2685
static Texture Load(RendererRef renderer, StringParam file)
Load an image from a filesystem path into a software surface.
Definition SDL3pp_image.h:2227