SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
SDL3pp_image.h
1#ifndef SDL3PP_IMAGE_H_
2#define SDL3PP_IMAGE_H_
3
4#include "SDL3pp_error.h"
5#include "SDL3pp_gpu.h"
6#include "SDL3pp_mouse.h"
7#include "SDL3pp_render.h"
8#include "SDL3pp_surface.h"
9#include "SDL3pp_version.h"
10#include "SDL3pp_video.h"
11
12#if defined(SDL3PP_ENABLE_IMAGE) || defined(SDL3PP_DOC)
13
14#include <SDL3_image/SDL_image.h>
15
16namespace SDL {
17
28// Forward decl
29struct Animation;
30
32using AnimationRaw = IMG_Animation*;
33
34// Forward decl
35struct AnimationRef;
36
39{
41
44 : value(value)
45 {
46 }
47
49 constexpr AnimationParam(std::nullptr_t = nullptr)
50 : value(nullptr)
51 {
52 }
53
55 constexpr explicit operator bool() const { return !!value; }
56
58 constexpr auto operator<=>(const AnimationParam& other) const = default;
59
61 constexpr operator AnimationRaw() const { return value; }
62
64 constexpr auto operator->() { return value; }
65};
66
69{
71
74 : value(value)
75 {
76 }
77
81 {
82 }
83
85 constexpr AnimationConstParam(std::nullptr_t = nullptr)
86 : value(nullptr)
87 {
88 }
89
91 constexpr explicit operator bool() const { return !!value; }
92
94 constexpr auto operator<=>(const AnimationConstParam& other) const = default;
95
97 constexpr operator const AnimationRaw() const { return value; }
98
100 constexpr auto operator->() { return value; }
101};
102
103#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
104
105// Forward decl
106struct AnimationEncoder;
107
109using AnimationEncoderRaw = IMG_AnimationEncoder*;
110
111// Forward decl
113
116{
118
121 : value(value)
122 {
123 }
124
126 constexpr AnimationEncoderParam(std::nullptr_t = nullptr)
127 : value(nullptr)
128 {
129 }
130
132 constexpr explicit operator bool() const { return !!value; }
133
135 constexpr auto operator<=>(const AnimationEncoderParam& other) const =
136 default;
137
139 constexpr operator AnimationEncoderRaw() const { return value; }
140};
141
142// Forward decl
143struct AnimationDecoder;
144
146using AnimationDecoderRaw = IMG_AnimationDecoder*;
147
148// Forward decl
150
153{
155
158 : value(value)
159 {
160 }
161
163 constexpr AnimationDecoderParam(std::nullptr_t = nullptr)
164 : value(nullptr)
165 {
166 }
167
169 constexpr explicit operator bool() const { return !!value; }
170
172 constexpr auto operator<=>(const AnimationDecoderParam& other) const =
173 default;
174
176 constexpr operator AnimationDecoderRaw() const { return value; }
177};
178#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
179
180#ifdef SDL3PP_DOC
181
187#define SDL_IMAGE_MAJOR_VERSION
188
189#define SDL_IMAGE_MINOR_VERSION
190
191#define SDL_IMAGE_MICRO_VERSION
192
194
198#define SDL_IMAGE_VERSION \
199 SDL_VERSIONNUM( \
200 SDL_IMAGE_MAJOR_VERSION, SDL_IMAGE_MINOR_VERSION, SDL_IMAGE_MICRO_VERSION)
201
203#define SDL_IMAGE_VERSION_ATLEAST(X, Y, Z) \
204 ((SDL_IMAGE_MAJOR_VERSION >= X) && \
205 (SDL_IMAGE_MAJOR_VERSION > X || SDL_IMAGE_MINOR_VERSION >= Y) && \
206 (SDL_IMAGE_MAJOR_VERSION > X || SDL_IMAGE_MINOR_VERSION > Y || \
207 SDL_IMAGE_MICRO_VERSION >= Z))
208
209#endif // SDL3PP_DOC
210
211namespace IMG {
212
220inline int Version() { return IMG_Version(); }
221
222} // namespace IMG
223
258inline Surface LoadSurface(StringParam file) { return Surface{IMG_Load(file)}; }
259
305inline Surface LoadSurface(IOStreamParam src, bool closeio)
306{
307 return Surface{IMG_Load_IO(src, closeio)};
308}
309
311 : m_resource(IMG_Load(file))
312{
313}
314
315inline Surface::Surface(IOStreamParam src, bool closeio)
316 : m_resource(IMG_Load_IO(src, closeio))
317{
318}
319
374 StringParam type,
375 bool closeio = false)
376{
377 return Surface(IMG_LoadTyped_IO(src, closeio, type));
378}
379
409{
410 return Texture(IMG_LoadTexture(renderer, file));
411}
412
453 IOStreamParam src,
454 bool closeio = false)
455{
456 return Texture(IMG_LoadTexture_IO(renderer, src, closeio));
457}
458
460 : m_resource(IMG_LoadTexture(renderer, file))
461{
462}
463
464inline Texture::Texture(RendererParam renderer, IOStreamParam src, bool closeio)
465 : m_resource(IMG_LoadTexture_IO(renderer, src, closeio))
466{
467}
468
517 IOStreamParam src,
518 StringParam type,
519 bool closeio = false)
520{
521 return Texture(IMG_LoadTextureTyped_IO(renderer, src, closeio, type));
522}
523
524#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
525
558 GPUCopyPass copy_pass,
559 StringParam file,
560 int* width = nullptr,
561 int* height = nullptr)
562{
563 return IMG_LoadGPUTexture(device, copy_pass, file, width, height);
564}
565
609 GPUCopyPass copy_pass,
610 IOStreamParam src,
611 bool closeio = false,
612 int* width = nullptr,
613 int* height = nullptr)
614{
615 return IMG_LoadGPUTexture_IO(device, copy_pass, src, closeio, width, height);
616}
617
669 GPUCopyPass copy_pass,
670 IOStreamParam src,
671 StringParam type,
672 bool closeio = false,
673 int* width = nullptr,
674 int* height = nullptr)
675{
676 return IMG_LoadGPUTextureTyped_IO(
677 device, copy_pass, src, closeio, type, width, height);
678}
679
690inline Surface GetClipboardImage() { return Surface{IMG_GetClipboardImage()}; }
691
733inline bool isANI(IOStreamParam src) { return IMG_isANI(src); }
734
735#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
736
778inline bool isAVIF(IOStreamParam src) { return IMG_isAVIF(src); }
779
821inline bool isCUR(IOStreamParam src) { return IMG_isCUR(src); }
822
864inline bool isBMP(IOStreamParam src) { return IMG_isBMP(src); }
865
907inline bool isGIF(IOStreamParam src) { return IMG_isGIF(src); }
908
950inline bool isICO(IOStreamParam src) { return IMG_isICO(src); }
951
993inline bool isJPG(IOStreamParam src) { return IMG_isJPG(src); }
994
1036inline bool isJXL(IOStreamParam src) { return IMG_isJXL(src); }
1037
1079inline bool isLBM(IOStreamParam src) { return IMG_isLBM(src); }
1080
1122inline bool isPCX(IOStreamParam src) { return IMG_isPCX(src); }
1123
1165inline bool isPNG(IOStreamParam src) { return IMG_isPNG(src); }
1166
1208inline bool isPNM(IOStreamParam src) { return IMG_isPNM(src); }
1209
1251inline bool isQOI(IOStreamParam src) { return IMG_isQOI(src); }
1252
1294inline bool isSVG(IOStreamParam src) { return IMG_isSVG(src); }
1295
1337inline bool isTIF(IOStreamParam src) { return IMG_isTIF(src); }
1338
1380inline bool isWEBP(IOStreamParam src) { return IMG_isWEBP(src); }
1381
1423inline bool isXCF(IOStreamParam src) { return IMG_isXCF(src); }
1424
1466inline bool isXPM(IOStreamParam src) { return IMG_isXPM(src); }
1467
1509inline bool isXV(IOStreamParam src) { return IMG_isXV(src); }
1510
1544{
1545 return Surface(IMG_LoadAVIF_IO(src));
1546}
1547
1581{
1582 return Surface{IMG_LoadBMP_IO(src)};
1583}
1584
1618{
1619 return Surface{IMG_LoadCUR_IO(src)};
1620}
1621
1655{
1656 return Surface{IMG_LoadGIF_IO(src)};
1657}
1658
1692{
1693 return Surface{IMG_LoadICO_IO(src)};
1694}
1695
1729{
1730 return Surface{IMG_LoadJPG_IO(src)};
1731}
1732
1766{
1767 return Surface{IMG_LoadJXL_IO(src)};
1768}
1769
1803{
1804 return Surface{IMG_LoadLBM_IO(src)};
1805}
1806
1840{
1841 return Surface{IMG_LoadPCX_IO(src)};
1842}
1843
1877{
1878 return Surface{IMG_LoadPNG_IO(src)};
1879}
1880
1914{
1915 return Surface{IMG_LoadPNM_IO(src)};
1916}
1917
1952{
1953 return Surface{IMG_LoadSVG_IO(src)};
1954}
1955
1977{
1978 return Surface{IMG_LoadSizedSVG_IO(src, size.x, size.y)};
1979}
1980
2014{
2015 return Surface{IMG_LoadQOI_IO(src)};
2016}
2017
2051{
2052 return Surface{IMG_LoadTGA_IO(src)};
2053}
2054
2088{
2089 return Surface{IMG_LoadTIF_IO(src)};
2090}
2091
2125{
2126 return Surface{IMG_LoadWEBP_IO(src)};
2127}
2128
2162{
2163 return Surface{IMG_LoadXCF_IO(src)};
2164}
2165
2199{
2200 return Surface{IMG_LoadXPM_IO(src)};
2201}
2202
2235inline Surface LoadXV(IOStreamParam src) { return Surface{IMG_LoadXV_IO(src)}; }
2236
2251inline Surface ReadXPMFromArray(char** xpm)
2252{
2253 return Surface{IMG_ReadXPMFromArray(xpm)};
2254}
2255
2270{
2271 return Surface{IMG_ReadXPMFromArrayToRGB888(xpm)};
2272}
2273
2274#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2275
2300inline void Save(SurfaceParam surface, StringParam file)
2301{
2302 CheckError(IMG_Save(surface, file));
2303}
2304
2336inline void SaveTyped(SurfaceParam surface,
2337 IOStreamParam dst,
2338 StringParam type,
2339 bool closeio = false)
2340{
2341 CheckError(IMG_SaveTyped_IO(surface, dst, closeio, type));
2342}
2343
2344#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2345
2361inline void SaveAVIF(SurfaceParam surface, StringParam file, int quality)
2362{
2363 CheckError(IMG_SaveAVIF(surface, file, quality));
2364}
2365
2386inline void SaveAVIF(SurfaceParam surface,
2387 IOStreamParam dst,
2388 int quality,
2389 bool closeio = false)
2390{
2391 CheckError(IMG_SaveAVIF_IO(surface, dst, closeio, quality));
2392}
2393
2394#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2395
2409inline void SaveBMP(SurfaceParam surface, StringParam file)
2410{
2411 CheckError(IMG_SaveBMP(surface, file));
2412}
2413
2432inline void SaveBMP(SurfaceParam surface,
2433 IOStreamParam dst,
2434 bool closeio = false)
2435{
2436 CheckError(IMG_SaveBMP_IO(surface, dst, closeio));
2437}
2438
2452inline void SaveCUR(SurfaceParam surface, StringParam file)
2453{
2454 CheckError(IMG_SaveCUR(surface, file));
2455}
2456
2475inline void SaveCUR(SurfaceParam surface,
2476 IOStreamParam dst,
2477 bool closeio = false)
2478{
2479 CheckError(IMG_SaveCUR_IO(surface, dst, closeio));
2480}
2481
2495inline void SaveGIF(SurfaceParam surface, StringParam file)
2496{
2497 CheckError(IMG_SaveGIF(surface, file));
2498}
2499
2518inline void SaveGIF(SurfaceParam surface,
2519 IOStreamParam dst,
2520 bool closeio = false)
2521{
2522 CheckError(IMG_SaveGIF_IO(surface, dst, closeio));
2523}
2524
2538inline void SaveICO(SurfaceParam surface, StringParam file)
2539{
2540 CheckError(IMG_SaveICO(surface, file));
2541}
2542
2561inline void SaveICO(SurfaceParam surface,
2562 IOStreamParam dst,
2563 bool closeio = false)
2564{
2565 CheckError(IMG_SaveICO_IO(surface, dst, closeio));
2566}
2567
2568#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2569
2585inline void SaveJPG(SurfaceParam surface, StringParam file, int quality)
2586{
2587 CheckError(IMG_SaveJPG(surface, file, quality));
2588}
2589
2610inline void SaveJPG(SurfaceParam surface,
2611 IOStreamParam dst,
2612 int quality,
2613 bool closeio = false)
2614{
2615 CheckError(IMG_SaveJPG_IO(surface, dst, closeio, quality));
2616}
2617
2631inline void SavePNG(SurfaceParam surface, StringParam file)
2632{
2633 CheckError(IMG_SavePNG(surface, file));
2634}
2635
2654inline void SavePNG(SurfaceParam surface,
2655 IOStreamParam dst,
2656 bool closeio = false)
2657{
2658 CheckError(IMG_SavePNG_IO(surface, dst, closeio));
2659}
2660
2661#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2662
2676inline void SaveTGA(SurfaceParam surface, StringParam file)
2677{
2678 CheckError(IMG_SaveTGA(surface, file));
2679}
2680
2699inline void SaveTGA(SurfaceParam surface,
2700 IOStreamParam dst,
2701 bool closeio = false)
2702{
2703 CheckError(IMG_SaveTGA_IO(surface, dst, closeio));
2704}
2705
2723inline void SaveWEBP(SurfaceParam surface, StringParam file, float quality)
2724{
2725 CheckError(IMG_SaveWEBP(surface, file, quality));
2726}
2727
2750inline void SaveWEBP(SurfaceParam surface,
2751 IOStreamParam dst,
2752 float quality,
2753 bool closeio = false)
2754{
2755 CheckError(IMG_SaveWEBP_IO(surface, dst, closeio, quality));
2756}
2757
2758#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2766{
2767 AnimationRaw m_resource = nullptr;
2768
2769public:
2771 constexpr Animation(std::nullptr_t = nullptr) noexcept
2772 : m_resource(0)
2773 {
2774 }
2775
2783 constexpr explicit Animation(const AnimationRaw resource) noexcept
2784 : m_resource(resource)
2785 {
2786 }
2787
2788protected:
2790 constexpr Animation(const Animation& other) noexcept = default;
2791
2792public:
2794 constexpr Animation(Animation&& other) noexcept
2795 : Animation(other.release())
2796 {
2797 }
2798
2799 constexpr Animation(const AnimationRef& other) = delete;
2800
2801 constexpr Animation(AnimationRef&& other) = delete;
2802
2825 : m_resource(IMG_LoadAnimation(file))
2826 {
2827 }
2828
2856 Animation(IOStreamParam src, bool closeio = false)
2857 : m_resource(IMG_LoadAnimation_IO(src, closeio))
2858 {
2859 }
2860
2862 constexpr const AnimationRaw operator->() const noexcept
2863 {
2864 return m_resource;
2865 }
2866
2868 constexpr AnimationRaw operator->() noexcept { return m_resource; }
2869
2871 ~Animation() { IMG_FreeAnimation(m_resource); }
2872
2874 constexpr Animation& operator=(Animation&& other) noexcept
2875 {
2876 std::swap(m_resource, other.m_resource);
2877 return *this;
2878 }
2879
2880protected:
2882 constexpr Animation& operator=(const Animation& other) noexcept = default;
2883
2884public:
2886 constexpr AnimationRaw get() const noexcept { return m_resource; }
2887
2889 constexpr AnimationRaw release() noexcept
2890 {
2891 auto r = m_resource;
2892 m_resource = nullptr;
2893 return r;
2894 }
2895
2897 constexpr auto operator<=>(const Animation& other) const noexcept = default;
2898
2900 constexpr explicit operator bool() const noexcept { return !!m_resource; }
2901
2903 constexpr operator AnimationParam() const noexcept { return {m_resource}; }
2904
2921 void Free();
2922
2924 int GetWidth() const;
2925
2927 int GetHeight() const;
2928
2930 Point GetSize() const;
2931
2933 int GetCount() const;
2934
2940 Surface GetFrame(int index) const;
2941
2947 int GetDelay(int index) const;
2948
2949#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2950
2968 void Save(StringParam file);
2969
2996 void SaveTyped(IOStreamParam dst, StringParam type, bool closeio = false);
2997
3018 void SaveANI(IOStreamParam dst, bool closeio = false);
3019
3040 void SaveAPNG(IOStreamParam dst, bool closeio = false);
3041
3064 void SaveAVIF(IOStreamParam dst, int quality, bool closeio = false);
3065
3086 void SaveGIF(IOStreamParam dst, bool closeio = false);
3087
3112 void SaveWEBP(IOStreamParam dst, int quality, bool closeio = false);
3113
3127 Cursor CreateCursor(const PointRaw& hotspot);
3128
3129#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3130};
3131
3134{
3136
3144 AnimationRef(AnimationParam resource) noexcept
3145 : Animation(resource.value)
3146 {
3147 }
3148
3156 AnimationRef(AnimationRaw resource) noexcept
3157 : Animation(resource)
3158 {
3159 }
3160
3162 constexpr AnimationRef(const AnimationRef& other) noexcept = default;
3163
3166};
3167
3169inline int GetAnimationWidth(AnimationConstParam anim) { return anim->w; }
3170
3171inline int Animation::GetWidth() const
3172{
3173 return SDL::GetAnimationWidth(m_resource);
3174}
3175
3177inline int GetAnimationHeight(AnimationConstParam anim) { return anim->h; }
3178
3179inline int Animation::GetHeight() const
3180{
3181 return SDL::GetAnimationHeight(m_resource);
3182}
3183
3186{
3187 return {anim->w, anim->h};
3188}
3189
3191{
3192 return SDL::GetAnimationSize(m_resource);
3193}
3194
3196inline int GetAnimationCount(AnimationConstParam anim) { return anim->count; }
3197
3198inline int Animation::GetCount() const
3199{
3200 return SDL::GetAnimationCount(m_resource);
3201}
3202
3210{
3211 return Surface::Borrow(anim->frames[index]);
3212}
3213
3214inline Surface Animation::GetFrame(int index) const
3215{
3216 return SDL::GetAnimationFrame(m_resource, index);
3217}
3218
3225inline int GetAnimationDelay(AnimationConstParam anim, int index)
3226{
3227 return anim->delays[index];
3228}
3229
3230inline int Animation::GetDelay(int index) const
3231{
3232 return SDL::GetAnimationDelay(m_resource, index);
3233}
3234
3257{
3258 return Animation(std::move(file));
3259}
3260
3288inline Animation LoadAnimation(IOStreamParam src, bool closeio = false)
3289{
3290 return Animation(src, closeio);
3291}
3292
3328 StringParam type,
3329 bool closeio = false)
3330{
3331 return Animation(IMG_LoadAnimationTyped_IO(src, closeio, type));
3332}
3333
3334#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3335
3363{
3364 return Animation(IMG_LoadANIAnimation_IO(src));
3365}
3366
3394{
3395 return Animation(IMG_LoadAPNGAnimation_IO(src));
3396}
3397
3425{
3426 return Animation(IMG_LoadAVIFAnimation_IO(src));
3427}
3428
3429#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3430
3455{
3456 return Animation(IMG_LoadGIFAnimation_IO(src));
3457}
3458
3483{
3484 return Animation{IMG_LoadWEBPAnimation_IO(src)};
3485}
3486
3487#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3488
3508{
3509 CheckError(IMG_SaveAnimation(anim, file));
3510}
3511
3513{
3514 SDL::SaveAnimation(m_resource, std::move(file));
3515}
3516
3544 IOStreamParam dst,
3545 StringParam type,
3546 bool closeio = false)
3547{
3548 CheckError(IMG_SaveAnimationTyped_IO(anim, dst, closeio, type));
3549}
3550
3552 StringParam type,
3553 bool closeio)
3554{
3555 SDL::SaveAnimationTyped(m_resource, dst, std::move(type), closeio);
3556}
3557
3580 IOStreamParam dst,
3581 bool closeio = false)
3582{
3583 CheckError(IMG_SaveANIAnimation_IO(anim, dst, closeio));
3584}
3585
3586inline void Animation::SaveANI(IOStreamParam dst, bool closeio)
3587{
3588 SDL::SaveANIAnimation(m_resource, dst, closeio);
3589}
3590
3613 IOStreamParam dst,
3614 bool closeio = false)
3615{
3616 CheckError(IMG_SaveAPNGAnimation_IO(anim, dst, closeio));
3617}
3618
3619inline void Animation::SaveAPNG(IOStreamParam dst, bool closeio)
3620{
3621 SDL::SaveAPNGAnimation(m_resource, dst, closeio);
3622}
3623
3648 IOStreamParam dst,
3649 int quality,
3650 bool closeio = false)
3651{
3652 CheckError(IMG_SaveAVIFAnimation_IO(anim, dst, quality, closeio));
3653}
3654
3655inline void Animation::SaveAVIF(IOStreamParam dst, int quality, bool closeio)
3656{
3657 SDL::SaveAVIFAnimation(m_resource, dst, quality, closeio);
3658}
3659
3682 IOStreamParam dst,
3683 bool closeio = false)
3684{
3685 CheckError(IMG_SaveGIFAnimation_IO(anim, dst, closeio));
3686}
3687
3688inline void Animation::SaveGIF(IOStreamParam dst, bool closeio)
3689{
3690 SDL::SaveGIFAnimation(m_resource, dst, closeio);
3691}
3692
3719 IOStreamParam dst,
3720 int quality,
3721 bool closeio = false)
3722{
3723 CheckError(IMG_SaveWEBPAnimation_IO(anim, dst, quality, closeio));
3724}
3725
3726inline void Animation::SaveWEBP(IOStreamParam dst, int quality, bool closeio)
3727{
3728 SDL::SaveWEBPAnimation(m_resource, dst, quality, closeio);
3729}
3730
3746{
3747 return Cursor{
3748 CheckError(IMG_CreateAnimatedCursor(anim, hotspot.x, hotspot.y))};
3749}
3750
3752{
3753 return SDL::CreateAnimatedCursor(m_resource, hotspot);
3754}
3755
3756#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3757
3775inline void FreeAnimation(AnimationRaw anim) { IMG_FreeAnimation(anim); }
3776
3778
3779#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3780
3787{
3788 AnimationEncoderRaw m_resource = nullptr;
3789
3790public:
3792 constexpr AnimationEncoder(std::nullptr_t = nullptr) noexcept
3793 : m_resource(0)
3794 {
3795 }
3796
3804 constexpr explicit AnimationEncoder(
3805 const AnimationEncoderRaw resource) noexcept
3806 : m_resource(resource)
3807 {
3808 }
3809
3810protected:
3812 constexpr AnimationEncoder(const AnimationEncoder& other) noexcept = default;
3813
3814public:
3816 constexpr AnimationEncoder(AnimationEncoder&& other) noexcept
3817 : AnimationEncoder(other.release())
3818 {
3819 }
3820
3821 constexpr AnimationEncoder(const AnimationEncoderRef& other) = delete;
3822
3823 constexpr AnimationEncoder(AnimationEncoderRef&& other) = delete;
3824
3851 : m_resource(IMG_CreateAnimationEncoder(file))
3852 {
3853 }
3854
3884 AnimationEncoder(IOStreamParam dst, StringParam type, bool closeio = false)
3885 : m_resource(IMG_CreateAnimationEncoder_IO(dst, closeio, type))
3886 {
3887 }
3888
3937 : m_resource(IMG_CreateAnimationEncoderWithProperties(props))
3938 {
3939 }
3940
3942 ~AnimationEncoder() { IMG_CloseAnimationEncoder(m_resource); }
3943
3945 constexpr AnimationEncoder& operator=(AnimationEncoder&& other) noexcept
3946 {
3947 std::swap(m_resource, other.m_resource);
3948 return *this;
3949 }
3950
3951protected:
3954 const AnimationEncoder& other) noexcept = default;
3955
3956public:
3958 constexpr AnimationEncoderRaw get() const noexcept { return m_resource; }
3959
3961 constexpr AnimationEncoderRaw release() noexcept
3962 {
3963 auto r = m_resource;
3964 m_resource = nullptr;
3965 return r;
3966 }
3967
3969 constexpr auto operator<=>(const AnimationEncoder& other) const noexcept =
3970 default;
3971
3973 constexpr explicit operator bool() const noexcept { return !!m_resource; }
3974
3976 constexpr operator AnimationEncoderParam() const noexcept
3977 {
3978 return {m_resource};
3979 }
3980
3995 void Close();
3996
4014 void AddFrame(SurfaceParam surface, Uint64 duration);
4015};
4016
4019{
4021
4030 : AnimationEncoder(resource.value)
4031 {
4032 }
4033
4042 : AnimationEncoder(resource)
4043 {
4044 }
4045
4047 constexpr AnimationEncoderRef(const AnimationEncoderRef& other) noexcept =
4048 default;
4049
4052};
4053
4080{
4081 return AnimationEncoder(std::move(file));
4082}
4083
4112 StringParam type,
4113 bool closeio = false)
4114{
4115 return AnimationEncoder(dst, std::move(type), closeio);
4116}
4117
4165 PropertiesParam props)
4166{
4167 return AnimationEncoder(props);
4168}
4169
4170namespace prop::AnimationEncoder {
4171
4172constexpr auto CREATE_FILENAME_STRING =
4173 IMG_PROP_ANIMATION_ENCODER_CREATE_FILENAME_STRING;
4174
4175constexpr auto CREATE_IOSTREAM_POINTER =
4176 IMG_PROP_ANIMATION_ENCODER_CREATE_IOSTREAM_POINTER;
4177
4178constexpr auto CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN =
4179 IMG_PROP_ANIMATION_ENCODER_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN;
4180
4181constexpr auto CREATE_TYPE_STRING =
4182 IMG_PROP_ANIMATION_ENCODER_CREATE_TYPE_STRING;
4183
4184constexpr auto CREATE_QUALITY_NUMBER =
4185 IMG_PROP_ANIMATION_ENCODER_CREATE_QUALITY_NUMBER;
4186
4187constexpr auto CREATE_TIMEBASE_NUMERATOR_NUMBER =
4188 IMG_PROP_ANIMATION_ENCODER_CREATE_TIMEBASE_NUMERATOR_NUMBER;
4189
4190constexpr auto CREATE_TIMEBASE_DENOMINATOR_NUMBER =
4191 IMG_PROP_ANIMATION_ENCODER_CREATE_TIMEBASE_DENOMINATOR_NUMBER;
4192
4193constexpr auto CREATE_AVIF_MAX_THREADS_NUMBER =
4194 IMG_PROP_ANIMATION_ENCODER_CREATE_AVIF_MAX_THREADS_NUMBER;
4195
4196constexpr auto CREATE_AVIF_KEYFRAME_INTERVAL_NUMBER =
4197 IMG_PROP_ANIMATION_ENCODER_CREATE_AVIF_KEYFRAME_INTERVAL_NUMBER;
4198
4199constexpr auto CREATE_GIF_USE_LUT_BOOLEAN =
4200 IMG_PROP_ANIMATION_ENCODER_CREATE_GIF_USE_LUT_BOOLEAN;
4201
4202} // namespace prop::AnimationEncoder
4203
4223 SurfaceParam surface,
4224 Uint64 duration)
4225{
4226 CheckError(IMG_AddAnimationEncoderFrame(encoder, surface, duration));
4227}
4228
4229inline void AnimationEncoder::AddFrame(SurfaceParam surface, Uint64 duration)
4230{
4231 SDL::AddAnimationEncoderFrame(m_resource, surface, duration);
4232}
4233
4250{
4251 CheckError(IMG_CloseAnimationEncoder(encoder));
4252}
4253
4255
4261using AnimationDecoderStatus = IMG_AnimationDecoderStatus;
4262
4264 IMG_DECODER_STATUS_INVALID;
4265
4267 IMG_DECODER_STATUS_OK;
4268
4271 IMG_DECODER_STATUS_FAILED;
4272
4274 IMG_DECODER_STATUS_COMPLETE;
4275
4282{
4283 AnimationDecoderRaw m_resource = nullptr;
4284
4285public:
4287 constexpr AnimationDecoder(std::nullptr_t = nullptr) noexcept
4288 : m_resource(0)
4289 {
4290 }
4291
4299 constexpr explicit AnimationDecoder(
4300 const AnimationDecoderRaw resource) noexcept
4301 : m_resource(resource)
4302 {
4303 }
4304
4305protected:
4307 constexpr AnimationDecoder(const AnimationDecoder& other) noexcept = default;
4308
4309public:
4311 constexpr AnimationDecoder(AnimationDecoder&& other) noexcept
4312 : AnimationDecoder(other.release())
4313 {
4314 }
4315
4316 constexpr AnimationDecoder(const AnimationDecoderRef& other) = delete;
4317
4318 constexpr AnimationDecoder(AnimationDecoderRef&& other) = delete;
4319
4347 : m_resource(IMG_CreateAnimationDecoder(file))
4348 {
4349 }
4350
4381 AnimationDecoder(IOStreamParam src, StringParam type, bool closeio = false)
4382 : m_resource(IMG_CreateAnimationDecoder_IO(src, closeio, type))
4383 {
4384 }
4385
4425 : m_resource(IMG_CreateAnimationDecoderWithProperties(props))
4426 {
4427 }
4428
4430 ~AnimationDecoder() { IMG_CloseAnimationDecoder(m_resource); }
4431
4433 constexpr AnimationDecoder& operator=(AnimationDecoder&& other) noexcept
4434 {
4435 std::swap(m_resource, other.m_resource);
4436 return *this;
4437 }
4438
4439protected:
4442 const AnimationDecoder& other) noexcept = default;
4443
4444public:
4446 constexpr AnimationDecoderRaw get() const noexcept { return m_resource; }
4447
4449 constexpr AnimationDecoderRaw release() noexcept
4450 {
4451 auto r = m_resource;
4452 m_resource = nullptr;
4453 return r;
4454 }
4455
4457 constexpr auto operator<=>(const AnimationDecoder& other) const noexcept =
4458 default;
4459
4461 constexpr explicit operator bool() const noexcept { return !!m_resource; }
4462
4464 constexpr operator AnimationDecoderParam() const noexcept
4465 {
4466 return {m_resource};
4467 }
4468
4483 void Close();
4484
4502
4526 Surface GetFrame(Uint64* duration);
4527
4539
4557 void Reset();
4558};
4559
4562{
4564
4573 : AnimationDecoder(resource.value)
4574 {
4575 }
4576
4585 : AnimationDecoder(resource)
4586 {
4587 }
4588
4590 constexpr AnimationDecoderRef(const AnimationDecoderRef& other) noexcept =
4591 default;
4592
4595};
4596
4624{
4625 return AnimationDecoder(std::move(file));
4626}
4627
4657 StringParam type,
4658 bool closeio = false)
4659{
4660 return AnimationDecoder(src, std::move(type), closeio);
4661}
4662
4702 PropertiesParam props)
4703{
4704 return AnimationDecoder(props);
4705}
4706
4707namespace prop::AnimationDecoder {
4708
4709constexpr auto CREATE_FILENAME_STRING =
4710 IMG_PROP_ANIMATION_DECODER_CREATE_FILENAME_STRING;
4711
4712constexpr auto CREATE_IOSTREAM_POINTER =
4713 IMG_PROP_ANIMATION_DECODER_CREATE_IOSTREAM_POINTER;
4714
4715constexpr auto CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN =
4716 IMG_PROP_ANIMATION_DECODER_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN;
4717
4718constexpr auto CREATE_TYPE_STRING =
4719 IMG_PROP_ANIMATION_DECODER_CREATE_TYPE_STRING;
4720
4721constexpr auto CREATE_TIMEBASE_NUMERATOR_NUMBER =
4722 IMG_PROP_ANIMATION_DECODER_CREATE_TIMEBASE_NUMERATOR_NUMBER;
4723
4724constexpr auto CREATE_TIMEBASE_DENOMINATOR_NUMBER =
4725 IMG_PROP_ANIMATION_DECODER_CREATE_TIMEBASE_DENOMINATOR_NUMBER;
4726
4727constexpr auto CREATE_AVIF_MAX_THREADS_NUMBER =
4728 IMG_PROP_ANIMATION_DECODER_CREATE_AVIF_MAX_THREADS_NUMBER;
4729
4730constexpr auto CREATE_AVIF_ALLOW_INCREMENTAL_BOOLEAN =
4731 IMG_PROP_ANIMATION_DECODER_CREATE_AVIF_ALLOW_INCREMENTAL_BOOLEAN;
4732
4733constexpr auto CREATE_AVIF_ALLOW_PROGRESSIVE_BOOLEAN =
4734 IMG_PROP_ANIMATION_DECODER_CREATE_AVIF_ALLOW_PROGRESSIVE_BOOLEAN;
4735
4736constexpr auto CREATE_GIF_TRANSPARENT_COLOR_INDEX_NUMBER =
4737 IMG_PROP_ANIMATION_DECODER_CREATE_GIF_TRANSPARENT_COLOR_INDEX_NUMBER;
4738
4739constexpr auto CREATE_GIF_NUM_COLORS_NUMBER =
4740 IMG_PROP_ANIMATION_DECODER_CREATE_GIF_NUM_COLORS_NUMBER;
4741
4742} // namespace prop::AnimationDecoder
4743
4762 AnimationDecoderParam decoder)
4763{
4764 return IMG_GetAnimationDecoderProperties(decoder);
4765}
4766
4768{
4769 return SDL::GetAnimationDecoderProperties(m_resource);
4770}
4771
4772namespace prop::Metadata {
4773
4774constexpr auto IGNORE_PROPS_BOOLEAN = IMG_PROP_METADATA_IGNORE_PROPS_BOOLEAN;
4775
4776constexpr auto DESCRIPTION_STRING = IMG_PROP_METADATA_DESCRIPTION_STRING;
4777
4778constexpr auto COPYRIGHT_STRING = IMG_PROP_METADATA_COPYRIGHT_STRING;
4779
4780constexpr auto TITLE_STRING = IMG_PROP_METADATA_TITLE_STRING;
4781
4782constexpr auto AUTHOR_STRING = IMG_PROP_METADATA_AUTHOR_STRING;
4783
4784constexpr auto CREATION_TIME_STRING = IMG_PROP_METADATA_CREATION_TIME_STRING;
4785
4786constexpr auto FRAME_COUNT_NUMBER = IMG_PROP_METADATA_FRAME_COUNT_NUMBER;
4787
4788constexpr auto LOOP_COUNT_NUMBER = IMG_PROP_METADATA_LOOP_COUNT_NUMBER;
4789
4790} // namespace prop::Metadata
4791
4816 Uint64* duration)
4817{
4818 SDL_Surface* frame = nullptr;
4819 CheckError(IMG_GetAnimationDecoderFrame(decoder, &frame, duration));
4820 return Surface::Borrow(frame);
4821}
4822
4824{
4825 return SDL::GetAnimationDecoderFrame(m_resource, duration);
4826}
4827
4840 AnimationDecoderParam decoder)
4841{
4842 return IMG_GetAnimationDecoderStatus(decoder);
4843}
4844
4846{
4847 return SDL::GetAnimationDecoderStatus(m_resource);
4848}
4849
4869{
4870 CheckError(IMG_ResetAnimationDecoder(decoder));
4871}
4872
4874{
4875 SDL::ResetAnimationDecoder(m_resource);
4876}
4877
4894{
4895 CheckError(IMG_CloseAnimationDecoder(decoder));
4896}
4897
4899
4900#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
4901
4903
4904} // namespace SDL
4905
4906#else // defined(SDL3PP_ENABLE_IMAGE) || defined(SDL3PP_DOC)
4907
4908namespace SDL {
4909
4910inline Surface::Surface(StringParam file)
4911 : Surface(LoadBMP(std::move(file)))
4912{
4913}
4914
4915inline Surface::Surface(IOStreamParam src, bool closeio)
4916 : Surface(LoadBMP(std::move(src), closeio))
4917{
4918}
4919
4920inline Texture::Texture(RendererParam renderer, StringParam file)
4921 : Texture(std::move(renderer), Surface(std::move(file)))
4922{
4923}
4924
4925inline Texture::Texture(RendererParam renderer, IOStreamParam src, bool closeio)
4926 : Texture(std::move(renderer), Surface(std::move(src), closeio))
4927{
4928}
4929
4930} // namespace SDL
4931
4932#endif // defined(SDL3PP_ENABLE_IMAGE) || defined(SDL3PP_DOC)
4933
4934#endif /* SDL3PP_IMAGE_H_ */
An object representing animation decoder.
Definition: SDL3pp_image.h:4282
constexpr AnimationDecoder & operator=(AnimationDecoder &&other) noexcept
Assignment operator.
Definition: SDL3pp_image.h:4433
constexpr auto operator<=>(const AnimationDecoder &other) const noexcept=default
Comparison.
constexpr AnimationDecoder(const AnimationDecoder &other) noexcept=default
Copy constructor.
constexpr AnimationDecoderRaw get() const noexcept
Retrieves underlying AnimationDecoderRaw.
Definition: SDL3pp_image.h:4446
constexpr AnimationDecoder(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_image.h:4287
constexpr AnimationDecoderRaw release() noexcept
Retrieves underlying AnimationDecoderRaw and clear this.
Definition: SDL3pp_image.h:4449
constexpr AnimationDecoder & operator=(const AnimationDecoder &other) noexcept=default
Assignment operator.
AnimationDecoder(StringParam file)
Create a decoder to read a series of images from a file.
Definition: SDL3pp_image.h:4346
~AnimationDecoder()
Destructor.
Definition: SDL3pp_image.h:4430
AnimationDecoder(IOStreamParam src, StringParam type, bool closeio=false)
Create a decoder to read a series of images from an IOStream.
Definition: SDL3pp_image.h:4381
AnimationDecoder(PropertiesParam props)
Create an animation decoder with the specified properties.
Definition: SDL3pp_image.h:4424
constexpr AnimationDecoder(const AnimationDecoderRaw resource) noexcept
Constructs from AnimationDecoderParam.
Definition: SDL3pp_image.h:4299
constexpr AnimationDecoder(AnimationDecoder &&other) noexcept
Move constructor.
Definition: SDL3pp_image.h:4311
An object representing the encoder context.
Definition: SDL3pp_image.h:3787
constexpr AnimationEncoder & operator=(AnimationEncoder &&other) noexcept
Assignment operator.
Definition: SDL3pp_image.h:3945
constexpr AnimationEncoderRaw release() noexcept
Retrieves underlying AnimationEncoderRaw and clear this.
Definition: SDL3pp_image.h:3961
constexpr AnimationEncoder(const AnimationEncoderRaw resource) noexcept
Constructs from AnimationEncoderParam.
Definition: SDL3pp_image.h:3804
constexpr AnimationEncoder(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_image.h:3792
AnimationEncoder(IOStreamParam dst, StringParam type, bool closeio=false)
Create an encoder to save a series of images to an IOStream.
Definition: SDL3pp_image.h:3884
~AnimationEncoder()
Destructor.
Definition: SDL3pp_image.h:3942
AnimationEncoder(PropertiesParam props)
Create an animation encoder with the specified properties.
Definition: SDL3pp_image.h:3936
constexpr auto operator<=>(const AnimationEncoder &other) const noexcept=default
Comparison.
constexpr AnimationEncoder(AnimationEncoder &&other) noexcept
Move constructor.
Definition: SDL3pp_image.h:3816
constexpr AnimationEncoder & operator=(const AnimationEncoder &other) noexcept=default
Assignment operator.
constexpr AnimationEncoderRaw get() const noexcept
Retrieves underlying AnimationEncoderRaw.
Definition: SDL3pp_image.h:3958
constexpr AnimationEncoder(const AnimationEncoder &other) noexcept=default
Copy constructor.
AnimationEncoder(StringParam file)
Create an encoder to save a series of images to a file.
Definition: SDL3pp_image.h:3850
Animated image support.
Definition: SDL3pp_image.h:2766
constexpr Animation(Animation &&other) noexcept
Move constructor.
Definition: SDL3pp_image.h:2794
constexpr AnimationRaw release() noexcept
Retrieves underlying AnimationRaw and clear this.
Definition: SDL3pp_image.h:2889
constexpr auto operator<=>(const Animation &other) const noexcept=default
Comparison.
~Animation()
Destructor.
Definition: SDL3pp_image.h:2871
constexpr Animation(const Animation &other) noexcept=default
Copy constructor.
constexpr Animation & operator=(const Animation &other) noexcept=default
Assignment operator.
Animation(IOStreamParam src, bool closeio=false)
Load an animation from an IOStream.
Definition: SDL3pp_image.h:2856
constexpr AnimationRaw get() const noexcept
Retrieves underlying AnimationRaw.
Definition: SDL3pp_image.h:2886
constexpr AnimationRaw operator->() noexcept
member access to underlying AnimationRaw.
Definition: SDL3pp_image.h:2868
constexpr Animation(const AnimationRaw resource) noexcept
Constructs from AnimationParam.
Definition: SDL3pp_image.h:2783
constexpr const AnimationRaw operator->() const noexcept
member access to underlying AnimationRaw.
Definition: SDL3pp_image.h:2862
constexpr Animation & operator=(Animation &&other) noexcept
Assignment operator.
Definition: SDL3pp_image.h:2874
constexpr Animation(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_image.h:2771
Animation(StringParam file)
Load an animation from a file.
Definition: SDL3pp_image.h:2824
The structure used to identify an SDL cursor.
Definition: SDL3pp_mouse.h:182
An opaque handle representing a copy pass.
Definition: SDL3pp_gpu.h:1790
An opaque handle representing a texture.
Definition: SDL3pp_gpu.h:705
Helpers to use C++ strings parameters.
Definition: SDL3pp_strings.h:43
A collection of pixels used in software blitting.
Definition: SDL3pp_surface.h:227
constexpr Surface(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_surface.h:232
static constexpr Surface Borrow(SurfaceParam resource)
Safely borrows the from SurfaceParam.
Definition: SDL3pp_surface.h:409
An efficient driver-specific representation of pixel data.
Definition: SDL3pp_render.h:2466
constexpr Texture(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_render.h:2471
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition: SDL3pp_error.h:197
SDL_Point PointRaw
Alias to raw representation for Point.
Definition: SDL3pp_rect.h:22
void SaveAPNGAnimation(AnimationParam anim, IOStreamParam dst, bool closeio=false)
Save an animation in APNG format to an IOStream.
Definition: SDL3pp_image.h:3612
Surface ReadXPMFromArrayToRGB888(char **xpm)
Load an XPM image from a memory array.
Definition: SDL3pp_image.h:2269
bool isTIF(IOStreamParam src)
Detect TIFF image data on a readable/seekable IOStream.
Definition: SDL3pp_image.h:1337
IMG_AnimationDecoderStatus AnimationDecoderStatus
An enum representing the status of an animation decoder.
Definition: SDL3pp_image.h:4261
int GetWidth() const
Get the width in pixels.
Definition: SDL3pp_image.h:3171
Surface ReadXPMFromArray(char **xpm)
Load an XPM image from a memory array.
Definition: SDL3pp_image.h:2251
void AddAnimationEncoderFrame(AnimationEncoderParam encoder, SurfaceParam surface, Uint64 duration)
Add a frame to an animation encoder.
Definition: SDL3pp_image.h:4222
IMG_AnimationDecoder * AnimationDecoderRaw
Alias to raw representation for AnimationDecoder.
Definition: SDL3pp_image.h:146
Surface LoadCUR(IOStreamParam src)
Load a CUR image directly.
Definition: SDL3pp_image.h:1617
void FreeAnimation(AnimationRaw anim)
Dispose of an Animation and free its resources.
Definition: SDL3pp_image.h:3775
Surface LoadSVG(IOStreamParam src)
Load a SVG image directly.
Definition: SDL3pp_image.h:1951
GPUTexture LoadGPUTextureTyped(GPUDeviceParam device, GPUCopyPass copy_pass, IOStreamParam src, StringParam type, bool closeio=false, int *width=nullptr, int *height=nullptr)
Load an image from an SDL data source into a GPU texture.
Definition: SDL3pp_image.h:668
void SaveAPNG(IOStreamParam dst, bool closeio=false)
Save an animation in APNG format to an IOStream.
Definition: SDL3pp_image.h:3619
int GetHeight() const
Get the height in pixels.
Definition: SDL3pp_image.h:3179
AnimationEncoder CreateAnimationEncoder(StringParam file)
Create an encoder to save a series of images to a file.
Definition: SDL3pp_image.h:4079
void SaveAVIF(IOStreamParam dst, int quality, bool closeio=false)
Save an animation in AVIF format to an IOStream.
Definition: SDL3pp_image.h:3655
bool isXCF(IOStreamParam src)
Detect XCF image data on a readable/seekable IOStream.
Definition: SDL3pp_image.h:1423
Surface LoadPCX(IOStreamParam src)
Load a PCX image directly.
Definition: SDL3pp_image.h:1839
Surface LoadLBM(IOStreamParam src)
Load a LBM image directly.
Definition: SDL3pp_image.h:1802
Animation LoadAVIFAnimation(IOStreamParam src)
Load an AVIF animation directly from an IOStream.
Definition: SDL3pp_image.h:3424
AnimationEncoder CreateAnimationEncoderWithProperties(PropertiesParam props)
Create an animation encoder with the specified properties.
Definition: SDL3pp_image.h:4164
IMG_AnimationEncoder * AnimationEncoderRaw
Alias to raw representation for AnimationEncoder.
Definition: SDL3pp_image.h:109
void Save(SurfaceParam surface, StringParam file)
Save an Surface into an image file.
Definition: SDL3pp_image.h:2300
bool isQOI(IOStreamParam src)
Detect QOI image data on a readable/seekable IOStream.
Definition: SDL3pp_image.h:1251
bool isJPG(IOStreamParam src)
Detect JPG image data on a readable/seekable IOStream.
Definition: SDL3pp_image.h:993
void SaveWEBP(IOStreamParam dst, int quality, bool closeio=false)
Save an animation in WEBP format to an IOStream.
Definition: SDL3pp_image.h:3726
Cursor CreateCursor(const PointRaw &hotspot)
Create an animated cursor from an animation.
Definition: SDL3pp_image.h:3751
Surface LoadXV(IOStreamParam src)
Load a XV image directly.
Definition: SDL3pp_image.h:2235
bool isXPM(IOStreamParam src)
Detect XPM image data on a readable/seekable IOStream.
Definition: SDL3pp_image.h:1466
AnimationDecoder CreateAnimationDecoderWithProperties(PropertiesParam props)
Create an animation decoder with the specified properties.
Definition: SDL3pp_image.h:4701
void SaveBMP(SurfaceParam surface, StringParam file)
Save an Surface into a BMP image file.
Definition: SDL3pp_image.h:2409
void SaveAnimationTyped(AnimationParam anim, IOStreamParam dst, StringParam type, bool closeio=false)
Save an animation to an IOStream.
Definition: SDL3pp_image.h:3543
bool isGIF(IOStreamParam src)
Detect GIF image data on a readable/seekable IOStream.
Definition: SDL3pp_image.h:907
int GetDelay(int index) const
Return the frame delay under given index.
Definition: SDL3pp_image.h:3230
void SaveWEBPAnimation(AnimationParam anim, IOStreamParam dst, int quality, bool closeio=false)
Save an animation in WEBP format to an IOStream.
Definition: SDL3pp_image.h:3718
Surface LoadBMP(IOStreamParam src)
Load a BMP image directly.
Definition: SDL3pp_image.h:1580
Animation LoadWEBPAnimation(IOStreamParam src)
Load a WEBP animation directly.
Definition: SDL3pp_image.h:3482
void SaveAnimation(AnimationParam anim, StringParam file)
Save an animation to a file.
Definition: SDL3pp_image.h:3507
void Close()
Close an animation encoder, finishing any encoding.
Definition: SDL3pp_image.h:4254
void SaveJPG(SurfaceParam surface, StringParam file, int quality)
Save an Surface into a JPEG image file.
Definition: SDL3pp_image.h:2585
Surface LoadWEBP(IOStreamParam src)
Load a WEBP image directly.
Definition: SDL3pp_image.h:2124
Surface LoadSurfaceTyped(IOStreamParam src, StringParam type, bool closeio=false)
Load an image from an SDL data source into a software surface.
Definition: SDL3pp_image.h:373
Surface LoadTIF(IOStreamParam src)
Load a TIFF image directly.
Definition: SDL3pp_image.h:2087
Surface GetFrame(Uint64 *duration)
Get the next frame in an animation decoder.
Definition: SDL3pp_image.h:4823
Surface LoadJPG(IOStreamParam src)
Load a JPG image directly.
Definition: SDL3pp_image.h:1728
Surface LoadPNM(IOStreamParam src)
Load a PNM image directly.
Definition: SDL3pp_image.h:1913
bool isPCX(IOStreamParam src)
Detect PCX image data on a readable/seekable IOStream.
Definition: SDL3pp_image.h:1122
Animation LoadAnimation(StringParam file)
Load an animation from a file.
Definition: SDL3pp_image.h:3256
void SaveGIF(SurfaceParam surface, StringParam file)
Save an Surface into a GIF image file.
Definition: SDL3pp_image.h:2495
void SaveICO(SurfaceParam surface, StringParam file)
Save an Surface into a ICO image file.
Definition: SDL3pp_image.h:2538
bool isICO(IOStreamParam src)
Detect ICO image data on a readable/seekable IOStream.
Definition: SDL3pp_image.h:950
Surface GetClipboardImage()
Get the image currently in the clipboard.
Definition: SDL3pp_image.h:690
AnimationDecoderStatus GetAnimationDecoderStatus(AnimationDecoderParam decoder)
Get the decoder status indicating the current state of the decoder.
Definition: SDL3pp_image.h:4839
Animation LoadAnimationTyped(IOStreamParam src, StringParam type, bool closeio=false)
Load an animation from an IOStream.
Definition: SDL3pp_image.h:3327
void CloseAnimationDecoder(AnimationDecoderRaw decoder)
Close an animation decoder, finishing any decoding.
Definition: SDL3pp_image.h:4893
Cursor CreateAnimatedCursor(AnimationParam anim, const PointRaw &hotspot)
Create an animated cursor from an animation.
Definition: SDL3pp_image.h:3745
int GetAnimationDelay(AnimationConstParam anim, int index)
Return the frame delay under given index.
Definition: SDL3pp_image.h:3225
void SaveGIF(IOStreamParam dst, bool closeio=false)
Save an animation in GIF format to an IOStream.
Definition: SDL3pp_image.h:3688
Surface LoadTGA(IOStreamParam src)
Load a TGA image directly.
Definition: SDL3pp_image.h:2050
void Free()
Dispose of an Animation and free its resources.
Definition: SDL3pp_image.h:3777
Texture LoadTextureTyped(RendererParam renderer, IOStreamParam src, StringParam type, bool closeio=false)
Load an image from an SDL data source into a texture.
Definition: SDL3pp_image.h:516
void SaveANI(IOStreamParam dst, bool closeio=false)
Save an animation in ANI format to an IOStream.
Definition: SDL3pp_image.h:3586
Animation LoadAPNGAnimation(IOStreamParam src)
Load an APNG animation directly from an IOStream.
Definition: SDL3pp_image.h:3393
bool isJXL(IOStreamParam src)
Detect JXL image data on a readable/seekable IOStream.
Definition: SDL3pp_image.h:1036
bool isWEBP(IOStreamParam src)
Detect WEBP image data on a readable/seekable IOStream.
Definition: SDL3pp_image.h:1380
bool isPNM(IOStreamParam src)
Detect PNM image data on a readable/seekable IOStream.
Definition: SDL3pp_image.h:1208
bool isSVG(IOStreamParam src)
Detect SVG image data on a readable/seekable IOStream.
Definition: SDL3pp_image.h:1294
Point GetAnimationSize(AnimationConstParam anim)
Get the size in pixels.
Definition: SDL3pp_image.h:3185
Surface LoadGIF(IOStreamParam src)
Load a GIF image directly.
Definition: SDL3pp_image.h:1654
Surface LoadJXL(IOStreamParam src)
Load a JXL image directly.
Definition: SDL3pp_image.h:1765
PropertiesRef GetAnimationDecoderProperties(AnimationDecoderParam decoder)
Get the properties of an animation decoder.
Definition: SDL3pp_image.h:4761
bool isAVIF(IOStreamParam src)
Detect AVIF image data on a readable/seekable IOStream.
Definition: SDL3pp_image.h:778
void SaveAVIF(SurfaceParam surface, StringParam file, int quality)
Save an Surface into a AVIF image file.
Definition: SDL3pp_image.h:2361
bool isLBM(IOStreamParam src)
Detect LBM image data on a readable/seekable IOStream.
Definition: SDL3pp_image.h:1079
void SaveGIFAnimation(AnimationParam anim, IOStreamParam dst, bool closeio=false)
Save an animation in GIF format to an IOStream.
Definition: SDL3pp_image.h:3681
void SaveTyped(IOStreamParam dst, StringParam type, bool closeio=false)
Save an animation to an IOStream.
Definition: SDL3pp_image.h:3551
Surface GetFrame(int index) const
Return the frame image under given index.
Definition: SDL3pp_image.h:3214
void Close()
Close an animation decoder, finishing any decoding.
Definition: SDL3pp_image.h:4898
Surface LoadICO(IOStreamParam src)
Load a ICO image directly.
Definition: SDL3pp_image.h:1691
void SaveCUR(SurfaceParam surface, StringParam file)
Save an Surface into a CUR image file.
Definition: SDL3pp_image.h:2452
bool isPNG(IOStreamParam src)
Detect PNG image data on a readable/seekable IOStream.
Definition: SDL3pp_image.h:1165
Surface LoadAVIF(IOStreamParam src)
Load a AVIF image directly.
Definition: SDL3pp_image.h:1543
Surface LoadXPM(IOStreamParam src)
Load a XPM image directly.
Definition: SDL3pp_image.h:2198
Surface LoadPNG(IOStreamParam src)
Load a PNG image directly.
Definition: SDL3pp_image.h:1876
void AddFrame(SurfaceParam surface, Uint64 duration)
Add a frame to an animation encoder.
Definition: SDL3pp_image.h:4229
constexpr AnimationDecoderStatus DECODER_STATUS_OK
The decoder is ready to decode the next frame.
Definition: SDL3pp_image.h:4266
void SaveWEBP(SurfaceParam surface, StringParam file, float quality)
Save an Surface into a WEBP image file.
Definition: SDL3pp_image.h:2723
constexpr AnimationDecoderStatus DECODER_STATUS_COMPLETE
No more frames available.
Definition: SDL3pp_image.h:4273
Surface LoadSizedSVG(IOStreamParam src, const PointRaw &size)
Load an SVG image, scaled to a specific size.
Definition: SDL3pp_image.h:1976
constexpr AnimationDecoderStatus DECODER_STATUS_FAILED
The decoder failed to decode a frame, call GetError() for more information.
Definition: SDL3pp_image.h:4270
Animation LoadGIFAnimation(IOStreamParam src)
Load a GIF animation directly.
Definition: SDL3pp_image.h:3454
void SaveTGA(SurfaceParam surface, StringParam file)
Save an Surface into a TGA image file.
Definition: SDL3pp_image.h:2676
int GetCount() const
Return the number of frames.
Definition: SDL3pp_image.h:3198
bool isXV(IOStreamParam src)
Detect XV image data on a readable/seekable IOStream.
Definition: SDL3pp_image.h:1509
void SaveTyped(SurfaceParam surface, IOStreamParam dst, StringParam type, bool closeio=false)
Save an Surface into formatted image data, via an IOStream.
Definition: SDL3pp_image.h:2336
void Reset()
Reset an animation decoder.
Definition: SDL3pp_image.h:4873
AnimationDecoderStatus GetStatus()
Get the decoder status indicating the current state of the decoder.
Definition: SDL3pp_image.h:4845
Surface GetAnimationFrame(AnimationConstParam anim, int index)
Return the frame image under given index.
Definition: SDL3pp_image.h:3209
bool isANI(IOStreamParam src)
Detect ANI animated cursor data on a readable/seekable IOStream.
Definition: SDL3pp_image.h:733
Surface LoadQOI(IOStreamParam src)
Load a QOI image directly.
Definition: SDL3pp_image.h:2013
void SaveAVIFAnimation(AnimationParam anim, IOStreamParam dst, int quality, bool closeio=false)
Save an animation in AVIF format to an IOStream.
Definition: SDL3pp_image.h:3647
Texture LoadTexture(RendererParam renderer, StringParam file)
Load an image from a filesystem path into a texture.
Definition: SDL3pp_image.h:408
int GetAnimationCount(AnimationConstParam anim)
Return the number of frames.
Definition: SDL3pp_image.h:3196
int GetAnimationWidth(AnimationConstParam anim)
Get the width in pixels.
Definition: SDL3pp_image.h:3169
Surface GetAnimationDecoderFrame(AnimationDecoderParam decoder, Uint64 *duration)
Get the next frame in an animation decoder.
Definition: SDL3pp_image.h:4815
GPUTexture LoadGPUTexture(GPUDeviceParam device, GPUCopyPass copy_pass, StringParam file, int *width=nullptr, int *height=nullptr)
Load an image from a filesystem path into a GPU texture.
Definition: SDL3pp_image.h:557
Surface LoadXCF(IOStreamParam src)
Load a XCF image directly.
Definition: SDL3pp_image.h:2161
constexpr AnimationDecoderStatus DECODER_STATUS_INVALID
The decoder is invalid.
Definition: SDL3pp_image.h:4263
IMG_Animation * AnimationRaw
Alias to raw representation for Animation.
Definition: SDL3pp_image.h:32
void ResetAnimationDecoder(AnimationDecoderParam decoder)
Reset an animation decoder.
Definition: SDL3pp_image.h:4868
int GetAnimationHeight(AnimationConstParam anim)
Get the height in pixels.
Definition: SDL3pp_image.h:3177
PropertiesRef GetProperties()
Get the properties of an animation decoder.
Definition: SDL3pp_image.h:4767
Surface LoadSurface(StringParam file)
Load an image from a filesystem path into a software surface.
Definition: SDL3pp_image.h:258
void SaveANIAnimation(AnimationParam anim, IOStreamParam dst, bool closeio=false)
Save an animation in ANI format to an IOStream.
Definition: SDL3pp_image.h:3579
Animation LoadANIAnimation(IOStreamParam src)
Load an ANI animation directly from an IOStream.
Definition: SDL3pp_image.h:3362
AnimationDecoder CreateAnimationDecoder(StringParam file)
Create a decoder to read a series of images from a file.
Definition: SDL3pp_image.h:4623
void SavePNG(SurfaceParam surface, StringParam file)
Save an Surface into a PNG image file.
Definition: SDL3pp_image.h:2631
bool isBMP(IOStreamParam src)
Detect BMP image data on a readable/seekable IOStream.
Definition: SDL3pp_image.h:864
void CloseAnimationEncoder(AnimationEncoderRaw encoder)
Close an animation encoder, finishing any encoding.
Definition: SDL3pp_image.h:4249
bool isCUR(IOStreamParam src)
Detect CUR image data on a readable/seekable IOStream.
Definition: SDL3pp_image.h:821
void Save(StringParam file)
Save an animation to a file.
Definition: SDL3pp_image.h:3512
Point GetSize() const
Get the size in pixels.
Definition: SDL3pp_image.h:3190
::Uint64 Uint64
An unsigned 64-bit integer type.
Definition: SDL3pp_stdinc.h:371
Main include header for the SDL3pp library.
Safely wrap Animation for non owning const parameters.
Definition: SDL3pp_image.h:69
constexpr auto operator->()
member access to underlying AnimationRaw.
Definition: SDL3pp_image.h:100
const AnimationRaw value
parameter's const AnimationRaw
Definition: SDL3pp_image.h:70
constexpr auto operator<=>(const AnimationConstParam &other) const =default
Comparison.
constexpr AnimationConstParam(const AnimationRaw value)
Constructs from const AnimationRaw.
Definition: SDL3pp_image.h:73
constexpr AnimationConstParam(AnimationParam value)
Constructs from AnimationParam.
Definition: SDL3pp_image.h:79
constexpr AnimationConstParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_image.h:85
Safely wrap AnimationDecoder for non owning parameters.
Definition: SDL3pp_image.h:153
constexpr AnimationDecoderParam(AnimationDecoderRaw value)
Constructs from AnimationDecoderRaw.
Definition: SDL3pp_image.h:157
constexpr AnimationDecoderParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_image.h:163
AnimationDecoderRaw value
parameter's AnimationDecoderRaw
Definition: SDL3pp_image.h:154
constexpr auto operator<=>(const AnimationDecoderParam &other) const =default
Comparison.
Semi-safe reference for AnimationDecoder.
Definition: SDL3pp_image.h:4562
~AnimationDecoderRef()
Destructor.
Definition: SDL3pp_image.h:4594
AnimationDecoderRef(AnimationDecoderRaw resource) noexcept
Constructs from AnimationDecoderParam.
Definition: SDL3pp_image.h:4584
constexpr AnimationDecoderRef(const AnimationDecoderRef &other) noexcept=default
Copy constructor.
AnimationDecoderRef(AnimationDecoderParam resource) noexcept
Constructs from AnimationDecoderParam.
Definition: SDL3pp_image.h:4572
Safely wrap AnimationEncoder for non owning parameters.
Definition: SDL3pp_image.h:116
AnimationEncoderRaw value
parameter's AnimationEncoderRaw
Definition: SDL3pp_image.h:117
constexpr AnimationEncoderParam(AnimationEncoderRaw value)
Constructs from AnimationEncoderRaw.
Definition: SDL3pp_image.h:120
constexpr AnimationEncoderParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_image.h:126
constexpr auto operator<=>(const AnimationEncoderParam &other) const =default
Comparison.
Semi-safe reference for AnimationEncoder.
Definition: SDL3pp_image.h:4019
AnimationEncoderRef(AnimationEncoderRaw resource) noexcept
Constructs from AnimationEncoderParam.
Definition: SDL3pp_image.h:4041
AnimationEncoderRef(AnimationEncoderParam resource) noexcept
Constructs from AnimationEncoderParam.
Definition: SDL3pp_image.h:4029
~AnimationEncoderRef()
Destructor.
Definition: SDL3pp_image.h:4051
constexpr AnimationEncoderRef(const AnimationEncoderRef &other) noexcept=default
Copy constructor.
Safely wrap Animation for non owning parameters.
Definition: SDL3pp_image.h:39
AnimationRaw value
parameter's AnimationRaw
Definition: SDL3pp_image.h:40
constexpr AnimationParam(AnimationRaw value)
Constructs from AnimationRaw.
Definition: SDL3pp_image.h:43
constexpr auto operator<=>(const AnimationParam &other) const =default
Comparison.
constexpr auto operator->()
member access to underlying AnimationRaw.
Definition: SDL3pp_image.h:64
constexpr AnimationParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_image.h:49
Semi-safe reference for Animation.
Definition: SDL3pp_image.h:3134
AnimationRef(AnimationParam resource) noexcept
Constructs from AnimationParam.
Definition: SDL3pp_image.h:3144
~AnimationRef()
Destructor.
Definition: SDL3pp_image.h:3165
AnimationRef(AnimationRaw resource) noexcept
Constructs from AnimationParam.
Definition: SDL3pp_image.h:3156
constexpr AnimationRef(const AnimationRef &other) noexcept=default
Copy constructor.
Safely wrap GPUDevice for non owning parameters.
Definition: SDL3pp_gpu.h:387
Safely wrap IOStream for non owning parameters.
Definition: SDL3pp_iostream.h:34
The structure that defines a point (using integers).
Definition: SDL3pp_rect.h:83
Safely wrap Properties for non owning parameters.
Definition: SDL3pp_properties.h:53
Semi-safe reference for Properties.
Definition: SDL3pp_properties.h:716
Safely wrap Renderer for non owning parameters.
Definition: SDL3pp_render.h:54
Safely wrap Surface for non owning parameters.
Definition: SDL3pp_surface.h:53