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
27
28// Forward decl
29struct AnimationBase;
30
31// Forward decl
32struct Animation;
33
35using AnimationRaw = IMG_Animation*;
36
38using AnimationRawConst = const IMG_Animation*;
39
46
49
50#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
51
52// Forward decl
54
55// Forward decl
56struct AnimationEncoder;
57
59using AnimationEncoderRaw = IMG_AnimationEncoder*;
60
67
68// Forward decl
70
71// Forward decl
72struct AnimationDecoder;
73
75using AnimationDecoderRaw = IMG_AnimationDecoder*;
76
83
84#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
85
86#ifdef SDL3PP_DOC
87
93#define SDL_IMAGE_MAJOR_VERSION
94
95#define SDL_IMAGE_MINOR_VERSION
96
97#define SDL_IMAGE_MICRO_VERSION
98
100
104#define SDL_IMAGE_VERSION \
105 SDL_VERSIONNUM( \
106 SDL_IMAGE_MAJOR_VERSION, SDL_IMAGE_MINOR_VERSION, SDL_IMAGE_MICRO_VERSION)
107
109#define SDL_IMAGE_VERSION_ATLEAST(X, Y, Z) \
110 ((SDL_IMAGE_MAJOR_VERSION >= X) && \
111 (SDL_IMAGE_MAJOR_VERSION > X || SDL_IMAGE_MINOR_VERSION >= Y) && \
112 (SDL_IMAGE_MAJOR_VERSION > X || SDL_IMAGE_MINOR_VERSION > Y || \
113 SDL_IMAGE_MICRO_VERSION >= Z))
114
115#endif // SDL3PP_DOC
116
117namespace IMG {
118
126inline int Version() { return IMG_Version(); }
127
128} // namespace IMG
129
164inline Surface LoadSurface(StringParam file) { return Surface{IMG_Load(file)}; }
165
167 : Surface(IMG_Load(file))
168{
169}
170
171inline Surface::Surface(IOStreamRef src, bool closeio)
172 : Surface(IMG_Load_IO(src, closeio))
173{
174}
175
221inline Surface LoadSurface_IO(IOStreamRef src, bool closeio = false)
222{
223 return Surface{IMG_Load_IO(src, closeio)};
224}
225
280 StringParam type,
281 bool closeio = false)
282{
283 return Surface(IMG_LoadTyped_IO(src, closeio, type));
284}
285
315{
316 return Texture(IMG_LoadTexture(renderer, file));
317}
318
320 : Texture(IMG_LoadTexture(renderer, file))
321{
322}
323
324inline Texture::Texture(RendererRef renderer, IOStreamRef src, bool closeio)
325 : Texture(IMG_LoadTexture_IO(renderer, src, closeio))
326{
327}
328
369 IOStreamRef src,
370 bool closeio = false)
371{
372 return Texture(IMG_LoadTexture_IO(renderer, src, closeio));
373}
374
423 IOStreamRef src,
424 StringParam type,
425 bool closeio = false)
426{
427 return Texture(IMG_LoadTextureTyped_IO(renderer, src, closeio, type));
428}
429
430#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
431
464 GPUCopyPass copy_pass,
465 StringParam file,
466 int* width = nullptr,
467 int* height = nullptr)
468{
469 return IMG_LoadGPUTexture(device, copy_pass, file, width, height);
470}
471
514inline GPUTexture LoadGPUTexture_IO(GPUDeviceRef device,
515 GPUCopyPass copy_pass,
516 IOStreamRef src,
517 bool closeio = false,
518 int* width = nullptr,
519 int* height = nullptr)
520{
521 return IMG_LoadGPUTexture_IO(device, copy_pass, src, closeio, width, height);
522}
523
574inline GPUTexture LoadGPUTextureTyped_IO(GPUDeviceRef device,
575 GPUCopyPass copy_pass,
576 IOStreamRef src,
577 StringParam type,
578 bool closeio = false,
579 int* width = nullptr,
580 int* height = nullptr)
581{
582 return IMG_LoadGPUTextureTyped_IO(
583 device, copy_pass, src, closeio, type, width, height);
584}
585
593inline Surface GetClipboardImage() { return Surface{IMG_GetClipboardImage()}; }
594
636inline bool isANI(IOStreamRef src) { return IMG_isANI(src); }
637
638#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
639
681inline bool isAVIF(IOStreamRef src) { return IMG_isAVIF(src); }
682
724inline bool isCUR(IOStreamRef src) { return IMG_isCUR(src); }
725
767inline bool isBMP(IOStreamRef src) { return IMG_isBMP(src); }
768
810inline bool isGIF(IOStreamRef src) { return IMG_isGIF(src); }
811
853inline bool isICO(IOStreamRef src) { return IMG_isICO(src); }
854
896inline bool isJPG(IOStreamRef src) { return IMG_isJPG(src); }
897
939inline bool isJXL(IOStreamRef src) { return IMG_isJXL(src); }
940
982inline bool isLBM(IOStreamRef src) { return IMG_isLBM(src); }
983
1025inline bool isPCX(IOStreamRef src) { return IMG_isPCX(src); }
1026
1068inline bool isPNG(IOStreamRef src) { return IMG_isPNG(src); }
1069
1111inline bool isPNM(IOStreamRef src) { return IMG_isPNM(src); }
1112
1154inline bool isQOI(IOStreamRef src) { return IMG_isQOI(src); }
1155
1197inline bool isSVG(IOStreamRef src) { return IMG_isSVG(src); }
1198
1240inline bool isTIF(IOStreamRef src) { return IMG_isTIF(src); }
1241
1283inline bool isWEBP(IOStreamRef src) { return IMG_isWEBP(src); }
1284
1326inline bool isXCF(IOStreamRef src) { return IMG_isXCF(src); }
1327
1369inline bool isXPM(IOStreamRef src) { return IMG_isXPM(src); }
1370
1412inline bool isXV(IOStreamRef src) { return IMG_isXV(src); }
1413
1447{
1448 return Surface(IMG_LoadAVIF_IO(src));
1449}
1450
1484{
1485 return Surface{IMG_LoadCUR_IO(src)};
1486}
1487
1521{
1522 return Surface{IMG_LoadGIF_IO(src)};
1523}
1524
1558{
1559 return Surface{IMG_LoadICO_IO(src)};
1560}
1561
1595{
1596 return Surface{IMG_LoadJPG_IO(src)};
1597}
1598
1632{
1633 return Surface{IMG_LoadJXL_IO(src)};
1634}
1635
1669{
1670 return Surface{IMG_LoadLBM_IO(src)};
1671}
1672
1706{
1707 return Surface{IMG_LoadPCX_IO(src)};
1708}
1709
1743{
1744 return Surface{IMG_LoadPNG_IO(src)};
1745}
1746
1781inline Surface LoadPNG_IO(IOStreamRef src, bool closeio)
1782{
1783 if (!closeio) return Surface{LoadPNG_IO(src)};
1784 Surface temp{LoadPNG_IO(src)};
1785 src.Close();
1786 return temp;
1787}
1788
1821{
1822 return LoadPNG_IO(IOFromFile(file, "rb"));
1823}
1824
1858{
1859 return Surface{IMG_LoadPNM_IO(src)};
1860}
1861
1896{
1897 return Surface{IMG_LoadSVG_IO(src)};
1898}
1899
1918{
1919 return Surface{IMG_LoadSizedSVG_IO(src, size.x, size.y)};
1920}
1921
1955{
1956 return Surface{IMG_LoadQOI_IO(src)};
1957}
1958
1992{
1993 return Surface{IMG_LoadTGA_IO(src)};
1994}
1995
2029{
2030 return Surface{IMG_LoadTIF_IO(src)};
2031}
2032
2066{
2067 return Surface{IMG_LoadWEBP_IO(src)};
2068}
2069
2103{
2104 return Surface{IMG_LoadXCF_IO(src)};
2105}
2106
2140{
2141 return Surface{IMG_LoadXPM_IO(src)};
2142}
2143
2177{
2178 return Surface{IMG_LoadXV_IO(src)};
2179}
2180
2195inline Surface ReadXPMFromArray(char** xpm)
2196{
2197 return Surface{IMG_ReadXPMFromArray(xpm)};
2198}
2199
2214{
2215 return Surface{IMG_ReadXPMFromArrayToRGB888(xpm)};
2216}
2217
2218#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2219
2244inline void Save(SurfaceConstRef surface, StringParam file)
2245{
2246 CheckError(IMG_Save(surface, file));
2247}
2248
2249inline void SurfaceBase::Save(StringParam filename) const
2250{
2251 SDL::Save(get(), filename);
2252}
2253
2285inline void SaveTyped_IO(SurfaceConstRef surface,
2286 IOStreamRef dst,
2287 StringParam type,
2288 bool closeio = false)
2289{
2290 CheckError(IMG_SaveTyped_IO(surface, dst, closeio, type));
2291}
2292
2294 StringParam type,
2295 bool closeio) const
2296{
2297 SDL::SaveTyped_IO(get(), dst, type, closeio);
2298}
2299
2300#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2301
2317inline void SaveAVIF(SurfaceRef surface, StringParam file, int quality)
2318{
2319 CheckError(IMG_SaveAVIF(surface, file, quality));
2320}
2321
2342inline void SaveAVIF_IO(SurfaceRef surface,
2343 IOStreamRef dst,
2344 int quality,
2345 bool closeio = false)
2346{
2347 CheckError(IMG_SaveAVIF_IO(surface, dst, closeio, quality));
2348}
2349
2350#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2351
2365inline void SaveCUR(SurfaceRef surface, StringParam file)
2366{
2367 CheckError(IMG_SaveCUR(surface, file));
2368}
2369
2388inline void SaveCUR_IO(SurfaceRef surface,
2389 IOStreamRef dst,
2390 bool closeio = false)
2391{
2392 CheckError(IMG_SaveCUR_IO(surface, dst, closeio));
2393}
2394
2408inline void SaveGIF(SurfaceRef surface, StringParam file)
2409{
2410 CheckError(IMG_SaveGIF(surface, file));
2411}
2412
2431inline void SaveGIF_IO(SurfaceRef surface,
2432 IOStreamRef dst,
2433 bool closeio = false)
2434{
2435 CheckError(IMG_SaveGIF_IO(surface, dst, closeio));
2436}
2437
2451inline void SaveICO(SurfaceRef surface, StringParam file)
2452{
2453 CheckError(IMG_SaveICO(surface, file));
2454}
2455
2474inline void SaveICO_IO(SurfaceRef surface,
2475 IOStreamRef dst,
2476 bool closeio = false)
2477{
2478 CheckError(IMG_SaveICO_IO(surface, dst, closeio));
2479}
2480
2481#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2482
2498inline void SaveJPG(SurfaceRef surface, StringParam file, int quality)
2499{
2500 CheckError(IMG_SaveJPG(surface, file, quality));
2501}
2502
2523inline void SaveJPG_IO(SurfaceRef surface,
2524 IOStreamRef dst,
2525 int quality,
2526 bool closeio = false)
2527{
2528 CheckError(IMG_SaveJPG_IO(surface, dst, closeio, quality));
2529}
2530
2544inline void SavePNG(SurfaceRef surface, StringParam file)
2545{
2546 CheckError(IMG_SavePNG(surface, file));
2547}
2548
2549inline void SurfaceBase::SavePNG(StringParam file) const
2550{
2551 SDL::SavePNG(get(), file);
2552}
2553
2572inline void SavePNG_IO(SurfaceRef surface,
2573 IOStreamRef dst,
2574 bool closeio = false)
2575{
2576 CheckError(IMG_SavePNG_IO(surface, dst, closeio));
2577}
2578
2579inline void SurfaceBase::SavePNG_IO(IOStreamRef dst, bool closeio) const
2580{
2581 SDL::SavePNG_IO(get(), dst, closeio);
2582}
2583
2584#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2585
2599inline void SaveTGA(SurfaceRef surface, StringParam file)
2600{
2601 CheckError(IMG_SaveTGA(surface, file));
2602}
2603
2622inline void SaveTGA_IO(SurfaceRef surface,
2623 IOStreamRef dst,
2624 bool closeio = false)
2625{
2626 CheckError(IMG_SaveTGA_IO(surface, dst, closeio));
2627}
2628
2646inline void SaveWEBP(SurfaceRef surface, StringParam file, float quality)
2647{
2648 CheckError(IMG_SaveWEBP(surface, file, quality));
2649}
2650
2673inline void SaveWEBP_IO(SurfaceRef surface,
2674 IOStreamRef dst,
2675 float quality,
2676 bool closeio = false)
2677{
2678 CheckError(IMG_SaveWEBP_IO(surface, dst, closeio, quality));
2679}
2680
2681#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2682
2688struct AnimationBase : ResourceBaseT<AnimationRaw, AnimationRawConst>
2689{
2691
2693 constexpr operator AnimationConstRef() const noexcept { return get(); }
2694
2711 void Free();
2712
2714 int GetWidth() const;
2715
2717 int GetHeight() const;
2718
2720 Point GetSize() const;
2721
2723 int GetCount() const;
2724
2730 Surface GetFrame(int index) const;
2731
2737 int GetDelay(int index) const;
2738
2739#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2740
2758 void Save(StringParam file);
2759
2786 void SaveTyped_IO(IOStreamRef dst, StringParam type, bool closeio = false);
2787
2808 void SaveANI_IO(IOStreamRef dst, bool closeio = false);
2809
2830 void SaveAPNG_IO(IOStreamRef dst, bool closeio = false);
2831
2854 void SaveAVIF_IO(IOStreamRef dst, int quality, bool closeio = false);
2855
2876 void SaveGIF_IO(IOStreamRef dst, bool closeio = false);
2877
2902 void SaveWEBP_IO(IOStreamRef dst, int quality, bool closeio = false);
2903
2917 Cursor CreateCursor(const PointRaw& hotspot);
2918
2919#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2920};
2921
2928{
2929 using AnimationBase::AnimationBase;
2930
2938 constexpr explicit Animation(AnimationRaw resource) noexcept
2939 : AnimationBase(resource)
2940 {
2941 }
2942
2944 constexpr Animation(Animation&& other) noexcept
2945 : Animation(other.release())
2946 {
2947 }
2948
2967 Animation(StringParam file);
2968
2993 Animation(IOStreamRef src, bool closeio = false);
2994
2996 ~Animation() { IMG_FreeAnimation(get()); }
2997
2999 constexpr Animation& operator=(Animation&& other) noexcept
3000 {
3001 swap(*this, other);
3002 return *this;
3003 }
3004};
3005
3007inline int GetAnimationWidth(AnimationConstRef anim) { return anim->w; }
3008
3009inline int AnimationBase::GetWidth() const
3010{
3011 return SDL::GetAnimationWidth(get());
3012}
3013
3015inline int GetAnimationHeight(AnimationConstRef anim) { return anim->h; }
3016
3018{
3019 return SDL::GetAnimationHeight(get());
3020}
3021
3024{
3025 return {anim->w, anim->h};
3026}
3027
3029{
3030 return SDL::GetAnimationSize(get());
3031}
3032
3034inline int GetAnimationCount(AnimationConstRef anim) { return anim->count; }
3035
3036inline int AnimationBase::GetCount() const
3037{
3038 return SDL::GetAnimationCount(get());
3039}
3040
3048{
3049 return Surface::borrow(anim->frames[index]);
3050}
3051
3052inline Surface AnimationBase::GetFrame(int index) const
3053{
3054 return SDL::GetAnimationFrame(get(), index);
3055}
3056
3063inline int GetAnimationDelay(AnimationConstRef anim, int index)
3064{
3065 return anim->delays[index];
3066}
3067
3068inline int AnimationBase::GetDelay(int index) const
3069{
3070 return SDL::GetAnimationDelay(get(), index);
3071}
3072
3091inline Animation LoadAnimation(StringParam file) { return Animation(file); }
3092
3094 : Animation(IMG_LoadAnimation(file))
3095{
3096}
3097
3098inline Animation::Animation(IOStreamRef src, bool closeio)
3099 : Animation(IMG_LoadAnimation_IO(src, closeio))
3100{
3101}
3102
3127inline Animation LoadAnimation_IO(IOStreamRef src, bool closeio = false)
3128{
3129 return Animation(src, closeio);
3130}
3131
3164 StringParam type,
3165 bool closeio = false)
3166{
3167 return Animation(IMG_LoadAnimationTyped_IO(src, closeio, type));
3168}
3169
3170#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3171
3196{
3197 return Animation(IMG_LoadANIAnimation_IO(src));
3198}
3199
3224{
3225 return Animation(IMG_LoadAPNGAnimation_IO(src));
3226}
3227
3252{
3253 return Animation(IMG_LoadAVIFAnimation_IO(src));
3254}
3255
3256#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3257
3282{
3283 return Animation(IMG_LoadGIFAnimation_IO(src));
3284}
3285
3310{
3311 return Animation{IMG_LoadWEBPAnimation_IO(src)};
3312}
3313
3314#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3315
3335{
3336 CheckError(IMG_SaveAnimation(anim, file));
3337}
3338
3340{
3341 SDL::SaveAnimation(get(), file);
3342}
3343
3371 IOStreamRef dst,
3372 StringParam type,
3373 bool closeio = false)
3374{
3375 CheckError(IMG_SaveAnimationTyped_IO(anim, dst, closeio, type));
3376}
3377
3379 StringParam type,
3380 bool closeio)
3381{
3382 SDL::SaveAnimationTyped_IO(get(), dst, type, closeio);
3383}
3384
3407 IOStreamRef dst,
3408 bool closeio = false)
3409{
3410 CheckError(IMG_SaveANIAnimation_IO(anim, dst, closeio));
3411}
3412
3413inline void AnimationBase::SaveANI_IO(IOStreamRef dst, bool closeio)
3414{
3415 SDL::SaveANIAnimation_IO(get(), dst, closeio);
3416}
3417
3440 IOStreamRef dst,
3441 bool closeio = false)
3442{
3443 CheckError(IMG_SaveAPNGAnimation_IO(anim, dst, closeio));
3444}
3445
3446inline void AnimationBase::SaveAPNG_IO(IOStreamRef dst, bool closeio)
3447{
3448 SDL::SaveAPNGAnimation_IO(get(), dst, closeio);
3449}
3450
3475 IOStreamRef dst,
3476 int quality,
3477 bool closeio = false)
3478{
3479 CheckError(IMG_SaveAVIFAnimation_IO(anim, dst, closeio, quality));
3480}
3481
3483 int quality,
3484 bool closeio)
3485{
3486 SDL::SaveAVIFAnimation_IO(get(), dst, quality, closeio);
3487}
3488
3511 IOStreamRef dst,
3512 bool closeio = false)
3513{
3514 CheckError(IMG_SaveGIFAnimation_IO(anim, dst, closeio));
3515}
3516
3517inline void AnimationBase::SaveGIF_IO(IOStreamRef dst, bool closeio)
3518{
3519 SDL::SaveGIFAnimation_IO(get(), dst, closeio);
3520}
3521
3548 IOStreamRef dst,
3549 int quality,
3550 bool closeio = false)
3551{
3552 CheckError(IMG_SaveWEBPAnimation_IO(anim, dst, closeio, quality));
3553}
3554
3556 int quality,
3557 bool closeio)
3558{
3559 SDL::SaveWEBPAnimation_IO(get(), dst, quality, closeio);
3560}
3561
3577{
3578 return Cursor(
3579 CheckError(IMG_CreateAnimatedCursor(anim, hotspot.x, hotspot.y)));
3580}
3581
3583{
3584 return SDL::CreateAnimatedCursor(get(), hotspot);
3585}
3586
3587#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3588
3607inline void FreeAnimation(AnimationRaw anim) { IMG_FreeAnimation(anim); }
3608
3610
3611#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3612
3618struct AnimationEncoderBase : ResourceBaseT<AnimationEncoderRaw>
3619{
3621
3636 void Close();
3637
3655 void AddFrame(SurfaceRef surface, Uint64 duration);
3656};
3657
3664{
3665 using AnimationEncoderBase::AnimationEncoderBase;
3666
3674 constexpr explicit AnimationEncoder(AnimationEncoderRaw resource) noexcept
3675 : AnimationEncoderBase(resource)
3676 {
3677 }
3678
3680 constexpr AnimationEncoder(AnimationEncoder&& other) noexcept
3681 : AnimationEncoder(other.release())
3682 {
3683 }
3684
3711
3741 AnimationEncoder(IOStreamRef dst, StringParam type, bool closeio = false);
3742
3791
3793 ~AnimationEncoder() { IMG_CloseAnimationEncoder(get()); }
3794
3796 constexpr AnimationEncoder& operator=(AnimationEncoder&& other) noexcept
3797 {
3798 swap(*this, other);
3799 return *this;
3800 }
3801};
3802
3829{
3830 return AnimationEncoder(file);
3831}
3832
3834 : AnimationEncoder(CheckError(IMG_CreateAnimationEncoder(file)))
3835{
3836}
3837
3839 StringParam type,
3840 bool closeio)
3842 CheckError(IMG_CreateAnimationEncoder_IO(dst, closeio, type)))
3843{
3844}
3845
3848 CheckError(IMG_CreateAnimationEncoderWithProperties(props)))
3849{
3850}
3851
3880 StringParam type,
3881 bool closeio = false)
3882{
3883 return AnimationEncoder(dst, type, closeio);
3884}
3885
3937
3944
3945constexpr auto FILENAME_STRING =
3946 IMG_PROP_ANIMATION_ENCODER_CREATE_FILENAME_STRING;
3947
3948constexpr auto IOSTREAM_POINTER =
3949 IMG_PROP_ANIMATION_ENCODER_CREATE_IOSTREAM_POINTER;
3950
3952 IMG_PROP_ANIMATION_ENCODER_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN;
3955
3956constexpr auto TYPE_STRING =
3957 IMG_PROP_ANIMATION_ENCODER_CREATE_TYPE_STRING;
3958
3959constexpr auto QUALITY_NUMBER =
3960 IMG_PROP_ANIMATION_ENCODER_CREATE_QUALITY_NUMBER;
3961
3963 IMG_PROP_ANIMATION_ENCODER_CREATE_TIMEBASE_NUMERATOR_NUMBER;
3966
3968 IMG_PROP_ANIMATION_ENCODER_CREATE_TIMEBASE_DENOMINATOR_NUMBER;
3971
3973 IMG_PROP_ANIMATION_ENCODER_CREATE_AVIF_MAX_THREADS_NUMBER;
3976
3978 IMG_PROP_ANIMATION_ENCODER_CREATE_AVIF_KEYFRAME_INTERVAL_NUMBER;
3982
3983constexpr auto GIF_USE_LUT_BOOLEAN =
3984 IMG_PROP_ANIMATION_ENCODER_CREATE_GIF_USE_LUT_BOOLEAN;
3986
3987} // namespace prop::AnimationEncoder::Create
3988
4008 SurfaceRef surface,
4009 Uint64 duration)
4010{
4011 CheckError(IMG_AddAnimationEncoderFrame(encoder, surface, duration));
4012}
4013
4015{
4016 SDL::AddAnimationEncoderFrame(get(), surface, duration);
4017}
4018
4035{
4036 CheckError(IMG_CloseAnimationEncoder(encoder));
4037}
4038
4040
4046using AnimationDecoderStatus = IMG_AnimationDecoderStatus;
4047
4049 IMG_DECODER_STATUS_INVALID;
4050
4052 IMG_DECODER_STATUS_OK;
4053
4056 IMG_DECODER_STATUS_FAILED;
4057
4059 IMG_DECODER_STATUS_COMPLETE;
4060
4066struct AnimationDecoderBase : ResourceBaseT<AnimationDecoderRaw>
4067{
4069
4084 void Close();
4085
4107
4131 Surface GetFrame(Uint64* duration);
4132
4144
4162 void Reset();
4163};
4164
4171{
4172 using AnimationDecoderBase::AnimationDecoderBase;
4173
4181 constexpr explicit AnimationDecoder(AnimationDecoderRaw resource) noexcept
4182 : AnimationDecoderBase(resource)
4183 {
4184 }
4185
4187 constexpr AnimationDecoder(AnimationDecoder&& other) noexcept
4188 : AnimationDecoder(other.release())
4189 {
4190 }
4191
4219
4250 AnimationDecoder(IOStreamRef src, StringParam type, bool closeio = false);
4251
4291
4293 ~AnimationDecoder() { IMG_CloseAnimationDecoder(get()); }
4294
4296 constexpr AnimationDecoder& operator=(AnimationDecoder&& other) noexcept
4297 {
4298 swap(*this, other);
4299 return *this;
4300 }
4301};
4302
4330{
4331 return AnimationDecoder(file);
4332}
4333
4335 : AnimationDecoder(CheckError(IMG_CreateAnimationDecoder(file)))
4336{
4337}
4338
4340 StringParam type,
4341 bool closeio)
4343 CheckError(IMG_CreateAnimationDecoder_IO(src, closeio, type)))
4344{
4345}
4346
4349 CheckError(IMG_CreateAnimationDecoderWithProperties(props)))
4350{
4351}
4352
4382 StringParam type,
4383 bool closeio = false)
4384{
4385 return AnimationDecoder(src, type, closeio);
4386}
4387
4431
4438
4439constexpr auto FILENAME_STRING =
4440 IMG_PROP_ANIMATION_DECODER_CREATE_FILENAME_STRING;
4441
4442constexpr auto IOSTREAM_POINTER =
4443 IMG_PROP_ANIMATION_DECODER_CREATE_IOSTREAM_POINTER;
4444
4446 IMG_PROP_ANIMATION_DECODER_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN;
4449
4450constexpr auto TYPE_STRING =
4451 IMG_PROP_ANIMATION_DECODER_CREATE_TYPE_STRING;
4452
4454 IMG_PROP_ANIMATION_DECODER_CREATE_TIMEBASE_NUMERATOR_NUMBER;
4457
4459 IMG_PROP_ANIMATION_DECODER_CREATE_TIMEBASE_DENOMINATOR_NUMBER;
4462
4464 IMG_PROP_ANIMATION_DECODER_CREATE_AVIF_MAX_THREADS_NUMBER;
4467
4469 IMG_PROP_ANIMATION_DECODER_CREATE_AVIF_ALLOW_INCREMENTAL_BOOLEAN;
4473
4475 IMG_PROP_ANIMATION_DECODER_CREATE_AVIF_ALLOW_PROGRESSIVE_BOOLEAN;
4479
4481 IMG_PROP_ANIMATION_DECODER_CREATE_GIF_TRANSPARENT_COLOR_INDEX_NUMBER;
4487
4489 IMG_PROP_ANIMATION_DECODER_CREATE_GIF_NUM_COLORS_NUMBER;
4491
4492} // namespace prop::AnimationDecoder::Create
4493
4515{
4516 return IMG_GetAnimationDecoderProperties(decoder);
4517}
4518
4523
4531
4532constexpr auto IGNORE_PROPS_BOOLEAN =
4533 IMG_PROP_METADATA_IGNORE_PROPS_BOOLEAN;
4534
4535constexpr auto DESCRIPTION_STRING =
4536 IMG_PROP_METADATA_DESCRIPTION_STRING;
4537
4538constexpr auto COPYRIGHT_STRING =
4539 IMG_PROP_METADATA_COPYRIGHT_STRING;
4540
4541constexpr auto TITLE_STRING =
4542 IMG_PROP_METADATA_TITLE_STRING;
4543
4544constexpr auto AUTHOR_STRING =
4545 IMG_PROP_METADATA_AUTHOR_STRING;
4546
4547constexpr auto CREATION_TIME_STRING =
4548 IMG_PROP_METADATA_CREATION_TIME_STRING;
4549
4550constexpr auto FRAME_COUNT_NUMBER =
4551 IMG_PROP_METADATA_FRAME_COUNT_NUMBER;
4552
4553constexpr auto LOOP_COUNT_NUMBER =
4554 IMG_PROP_METADATA_LOOP_COUNT_NUMBER;
4555
4556} // namespace prop::AnimationDecoder::Metadata
4557
4582 Uint64* duration)
4583{
4584 SDL_Surface* frame = nullptr;
4585 CheckError(IMG_GetAnimationDecoderFrame(decoder, &frame, duration));
4586 return Surface::borrow(frame);
4587}
4588
4590{
4591 return SDL::GetAnimationDecoderFrame(get(), duration);
4592}
4593
4606 AnimationDecoderRef decoder)
4607{
4608 return IMG_GetAnimationDecoderStatus(decoder);
4609}
4610
4615
4635{
4636 CheckError(IMG_ResetAnimationDecoder(decoder));
4637}
4638
4640
4657{
4658 CheckError(IMG_CloseAnimationDecoder(decoder));
4659}
4660
4662
4663#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
4664
4666
4667} // namespace SDL
4668
4669#else // defined(SDL3PP_ENABLE_IMAGE) || defined(SDL3PP_DOC)
4670
4671namespace SDL {
4672
4673inline Surface::Surface(StringParam file)
4674 : Surface(LoadBMP(file))
4675{
4676}
4677
4678inline Surface::Surface(IOStreamRef src, bool closeio)
4679 : Surface(LoadBMP_IO(src, closeio))
4680{
4681}
4682
4683inline Texture::Texture(RendererRef renderer, StringParam file)
4684 : Texture(renderer, Surface(file))
4685{
4686}
4687
4688inline Texture::Texture(RendererRef renderer, IOStreamRef src, bool closeio)
4689 : Texture(renderer, Surface(src, closeio))
4690{
4691}
4692
4693} // namespace SDL
4694
4695#endif // defined(SDL3PP_ENABLE_IMAGE) || defined(SDL3PP_DOC)
4696
4697#endif /* SDL3PP_IMAGE_H_ */
An opaque handle representing a copy pass.
Definition SDL3pp_gpu.h:1744
An opaque handle representing a texture.
Definition SDL3pp_gpu.h:675
constexpr RawPointer release() noexcept
Definition SDL3pp_resource.h:57
friend constexpr void swap(ResourceBaseT &lhs, ResourceBaseT &rhs) noexcept
Definition SDL3pp_resource.h:65
constexpr RawPointer get() const noexcept
Definition SDL3pp_resource.h:54
constexpr ResourceBaseT()=default
Default constructor, creates null/invalid resource.
Const reference wrapper for a given resource,.
Definition SDL3pp_resource.h:115
Helpers to use C++ strings parameters.
Definition SDL3pp_strings.h:58
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:199
ResourceRefT< GPUDeviceBase > GPUDeviceRef
Reference for GPUDevice.
Definition SDL3pp_gpu.h:387
ResourceRefT< IOStreamBase > IOStreamRef
Reference for IOStream.
Definition SDL3pp_iostream.h:37
IOStream IOFromFile(StringParam file, StringParam mode)
Use this function to create a new IOStream structure for reading from and/or writing to a named file.
Definition SDL3pp_iostream.h:1683
void Close()
Close and free an allocated IOStream structure.
Definition SDL3pp_iostream.h:1946
ResourceRefT< PropertiesBase > PropertiesRef
Reference for Properties.
Definition SDL3pp_properties.h:55
SDL_Point PointRaw
Alias to raw representation for Point.
Definition SDL3pp_rect.h:22
Surface LoadICO_IO(IOStreamRef src)
Load a ICO image directly.
Definition SDL3pp_image.h:1557
void SaveAPNG_IO(IOStreamRef dst, bool closeio=false)
Save an animation in APNG format to an IOStream.
Definition SDL3pp_image.h:3446
Surface LoadJXL_IO(IOStreamRef src)
Load a JXL image directly.
Definition SDL3pp_image.h:1631
Surface ReadXPMFromArrayToRGB888(char **xpm)
Load an XPM image from a memory array.
Definition SDL3pp_image.h:2213
AnimationEncoder CreateAnimationEncoderWithProperties(PropertiesRef props)
Create an animation encoder with the specified properties.
Definition SDL3pp_image.h:3932
Animation LoadWEBPAnimation_IO(IOStreamRef src)
Load a WEBP animation directly.
Definition SDL3pp_image.h:3309
bool isPNG(IOStreamRef src)
Detect PNG image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1068
Surface LoadPNG_IO(IOStreamRef src)
Load a PNG image directly.
Definition SDL3pp_image.h:1742
AnimationDecoder CreateAnimationDecoderWithProperties(PropertiesRef props)
Create an animation decoder with the specified properties.
Definition SDL3pp_image.h:4426
Surface ReadXPMFromArray(char **xpm)
Load an XPM image from a memory array.
Definition SDL3pp_image.h:2195
int GetAnimationHeight(AnimationConstRef anim)
Get the height in pixels.
Definition SDL3pp_image.h:3015
Animation LoadAPNGAnimation_IO(IOStreamRef src)
Load an APNG animation directly from an IOStream.
Definition SDL3pp_image.h:3223
void SaveAnimation(AnimationRef anim, StringParam file)
Save an animation to a file.
Definition SDL3pp_image.h:3334
Animation LoadAnimation_IO(IOStreamRef src, bool closeio=false)
Load an animation from an IOStream.
Definition SDL3pp_image.h:3127
void FreeAnimation(AnimationRaw anim)
Dispose of an Animation and free its resources.
Definition SDL3pp_image.h:3607
void SaveCUR(SurfaceRef surface, StringParam file)
Save an Surface into a CUR image file.
Definition SDL3pp_image.h:2365
Surface LoadWEBP_IO(IOStreamRef src)
Load a WEBP image directly.
Definition SDL3pp_image.h:2065
bool isTIF(IOStreamRef src)
Detect TIFF image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1240
AnimationEncoder CreateAnimationEncoder(StringParam file)
Create an encoder to save a series of images to a file.
Definition SDL3pp_image.h:3828
void SaveAVIFAnimation_IO(AnimationRef anim, IOStreamRef dst, int quality, bool closeio=false)
Save an animation in AVIF format to an IOStream.
Definition SDL3pp_image.h:3474
Surface LoadPNG(StringParam file)
Load a PNG image from a file.
Definition SDL3pp_image.h:1820
Cursor CreateCursor(const PointRaw &hotspot)
Create an animated cursor from an animation.
Definition SDL3pp_image.h:3582
Texture LoadTexture_IO(RendererRef renderer, IOStreamRef src, bool closeio=false)
Load an image from an SDL data source into a texture.
Definition SDL3pp_image.h:368
void SaveTyped_IO(SurfaceConstRef surface, IOStreamRef dst, StringParam type, bool closeio=false)
Save an Surface into formatted image data, via an IOStream.
Definition SDL3pp_image.h:2285
void Reset()
Reset an animation decoder.
Definition SDL3pp_image.h:4639
ResourceConstRef< AnimationRaw, AnimationRawConst > AnimationConstRef
Safely wrap Animation for non owning const parameters.
Definition SDL3pp_image.h:48
void SaveWEBP(SurfaceRef surface, StringParam file, float quality)
Save an Surface into a WEBP image file.
Definition SDL3pp_image.h:2646
bool isWEBP(IOStreamRef src)
Detect WEBP image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1283
Surface LoadGIF_IO(IOStreamRef src)
Load a GIF image directly.
Definition SDL3pp_image.h:1520
int GetHeight() const
Get the height in pixels.
Definition SDL3pp_image.h:3017
Surface LoadXPM_IO(IOStreamRef src)
Load a XPM image directly.
Definition SDL3pp_image.h:2139
Surface LoadTIF_IO(IOStreamRef src)
Load a TIFF image directly.
Definition SDL3pp_image.h:2028
bool isXPM(IOStreamRef src)
Detect XPM image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1369
void SaveWEBP_IO(SurfaceRef surface, IOStreamRef dst, float quality, bool closeio=false)
Save an Surface into WEBP image data, via an IOStream.
Definition SDL3pp_image.h:2673
bool isPCX(IOStreamRef src)
Detect PCX image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1025
Surface GetAnimationFrame(AnimationConstRef anim, int index)
Return the frame image under given index.
Definition SDL3pp_image.h:3047
bool isJXL(IOStreamRef src)
Detect JXL image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:939
Point GetAnimationSize(AnimationConstRef anim)
Get the size in pixels.
Definition SDL3pp_image.h:3023
bool isLBM(IOStreamRef src)
Detect LBM image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:982
void SavePNG(StringParam file) const
Save a surface to a file in PNG format.
Definition SDL3pp_image.h:2549
bool isICO(IOStreamRef src)
Detect ICO image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:853
void AddAnimationEncoderFrame(AnimationEncoderRef encoder, SurfaceRef surface, Uint64 duration)
Add a frame to an animation encoder.
Definition SDL3pp_image.h:4007
Surface GetAnimationDecoderFrame(AnimationDecoderRef decoder, Uint64 *duration)
Get the next frame in an animation decoder.
Definition SDL3pp_image.h:4581
bool isPNM(IOStreamRef src)
Detect PNM image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1111
void SaveAVIF_IO(SurfaceRef surface, IOStreamRef dst, int quality, bool closeio=false)
Save an Surface into AVIF image data, via an IOStream.
Definition SDL3pp_image.h:2342
IMG_AnimationDecoderStatus AnimationDecoderStatus
An enum representing the status of an animation decoder.
Definition SDL3pp_image.h:4046
int GetAnimationDelay(AnimationConstRef anim, int index)
Return the frame delay under given index.
Definition SDL3pp_image.h:3063
Surface LoadTGA_IO(IOStreamRef src)
Load a TGA image directly.
Definition SDL3pp_image.h:1991
void SaveAVIF(SurfaceRef surface, StringParam file, int quality)
Save an Surface into a AVIF image file.
Definition SDL3pp_image.h:2317
int GetDelay(int index) const
Return the frame delay under given index.
Definition SDL3pp_image.h:3068
ResourceRefT< AnimationDecoderBase > AnimationDecoderRef
Reference for AnimationDecoder.
Definition SDL3pp_image.h:82
Animation LoadAnimation(StringParam file)
Load an animation from a file.
Definition SDL3pp_image.h:3091
void Save(SurfaceConstRef surface, StringParam file)
Save an Surface into an image file.
Definition SDL3pp_image.h:2244
Surface LoadXCF_IO(IOStreamRef src)
Load a XCF image directly.
Definition SDL3pp_image.h:2102
void SaveJPG_IO(SurfaceRef surface, IOStreamRef dst, int quality, bool closeio=false)
Save an Surface into JPEG image data, via an IOStream.
Definition SDL3pp_image.h:2523
void SaveTGA_IO(SurfaceRef surface, IOStreamRef dst, bool closeio=false)
Save an Surface into TGA image data, via an IOStream.
Definition SDL3pp_image.h:2622
int GetAnimationCount(AnimationConstRef anim)
Return the number of frames.
Definition SDL3pp_image.h:3034
Surface GetClipboardImage()
Load an image from an SDL data source into a GPU texture.
Definition SDL3pp_image.h:593
void SaveJPG(SurfaceRef surface, StringParam file, int quality)
Save an Surface into a JPEG image file.
Definition SDL3pp_image.h:2498
bool isJPG(IOStreamRef src)
Detect JPG image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:896
Cursor CreateAnimatedCursor(AnimationRef anim, const PointRaw &hotspot)
Create an animated cursor from an animation.
Definition SDL3pp_image.h:3576
void SaveICO_IO(SurfaceRef surface, IOStreamRef dst, bool closeio=false)
Save an Surface into ICO image data, via an IOStream.
Definition SDL3pp_image.h:2474
void CloseAnimationDecoder(AnimationDecoderRaw decoder)
Close an animation decoder, finishing any decoding.
Definition SDL3pp_image.h:4656
void Save(StringParam filename) const
Save an Surface into an image file.
Definition SDL3pp_image.h:2249
AnimationEncoder CreateAnimationEncoder_IO(IOStreamRef dst, StringParam type, bool closeio=false)
Create an encoder to save a series of images to an IOStream.
Definition SDL3pp_image.h:3879
IMG_Animation * AnimationRaw
Alias to raw representation for Animation.
Definition SDL3pp_image.h:35
Surface LoadLBM_IO(IOStreamRef src)
Load a LBM image directly.
Definition SDL3pp_image.h:1668
IMG_AnimationDecoder * AnimationDecoderRaw
Alias to raw representation for AnimationDecoder.
Definition SDL3pp_image.h:75
Surface LoadCUR_IO(IOStreamRef src)
Load a CUR image directly.
Definition SDL3pp_image.h:1483
bool isXCF(IOStreamRef src)
Detect XCF image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1326
void Close()
Close an animation decoder, finishing any decoding.
Definition SDL3pp_image.h:4661
void ResetAnimationDecoder(AnimationDecoderRef decoder)
Reset an animation decoder.
Definition SDL3pp_image.h:4634
void SavePNG_IO(SurfaceRef surface, IOStreamRef dst, bool closeio=false)
Save an Surface into PNG image data, via an IOStream.
Definition SDL3pp_image.h:2572
void SaveGIF(SurfaceRef surface, StringParam file)
Save an Surface into a GIF image file.
Definition SDL3pp_image.h:2408
AnimationDecoderStatus GetStatus()
Get the decoder status indicating the current state of the decoder.
Definition SDL3pp_image.h:4611
void SaveICO(SurfaceRef surface, StringParam file)
Save an Surface into a ICO image file.
Definition SDL3pp_image.h:2451
bool isANI(IOStreamRef src)
Detect ANI animated cursor data on a readable/seekable IOStream.
Definition SDL3pp_image.h:636
void SaveTGA(SurfaceRef surface, StringParam file)
Save an Surface into a TGA image file.
Definition SDL3pp_image.h:2599
ResourceRefT< AnimationEncoderBase > AnimationEncoderRef
Reference for AnimationEncoder.
Definition SDL3pp_image.h:66
bool isSVG(IOStreamRef src)
Detect SVG image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1197
PropertiesRef GetAnimationDecoderProperties(AnimationDecoderRef decoder)
Get the properties of an animation decoder.
Definition SDL3pp_image.h:4514
Surface LoadXV_IO(IOStreamRef src)
Load a XV image directly.
Definition SDL3pp_image.h:2176
Surface GetFrame(Uint64 *duration)
Get the next frame in an animation decoder.
Definition SDL3pp_image.h:4589
void SaveAVIF_IO(IOStreamRef dst, int quality, bool closeio=false)
Save an animation in AVIF format to an IOStream.
Definition SDL3pp_image.h:3482
void AddFrame(SurfaceRef surface, Uint64 duration)
Add a frame to an animation encoder.
Definition SDL3pp_image.h:4014
Surface LoadSVG_IO(IOStreamRef src)
Load a SVG image directly.
Definition SDL3pp_image.h:1895
void SaveGIF_IO(IOStreamRef dst, bool closeio=false)
Save an animation in GIF format to an IOStream.
Definition SDL3pp_image.h:3517
int GetWidth() const
Get the width in pixels.
Definition SDL3pp_image.h:3009
void SavePNG(SurfaceRef surface, StringParam file)
Save an Surface into a PNG image file.
Definition SDL3pp_image.h:2544
void Free()
Dispose of an Animation and free its resources.
Definition SDL3pp_image.h:3609
bool isBMP(IOStreamRef src)
Detect BMP image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:767
void SaveWEBPAnimation_IO(AnimationRef anim, IOStreamRef dst, int quality, bool closeio=false)
Save an animation in WEBP format to an IOStream.
Definition SDL3pp_image.h:3547
Surface LoadPCX_IO(IOStreamRef src)
Load a PCX image directly.
Definition SDL3pp_image.h:1705
const IMG_Animation * AnimationRawConst
Alias to const raw representation for Animation.
Definition SDL3pp_image.h:38
void SaveCUR_IO(SurfaceRef surface, IOStreamRef dst, bool closeio=false)
Save an Surface into CUR image data, via an IOStream.
Definition SDL3pp_image.h:2388
Surface LoadSurfaceTyped_IO(IOStreamRef src, StringParam type, bool closeio=false)
Load an image from an SDL data source into a software surface.
Definition SDL3pp_image.h:279
Surface LoadPNM_IO(IOStreamRef src)
Load a PNM image directly.
Definition SDL3pp_image.h:1857
void Close()
Close an animation encoder, finishing any encoding.
Definition SDL3pp_image.h:4039
AnimationDecoderStatus GetAnimationDecoderStatus(AnimationDecoderRef decoder)
Get the decoder status indicating the current state of the decoder.
Definition SDL3pp_image.h:4605
void SaveANIAnimation_IO(AnimationRef anim, IOStreamRef dst, bool closeio=false)
Save an animation in ANI format to an IOStream.
Definition SDL3pp_image.h:3406
void SaveAnimationTyped_IO(AnimationRef anim, IOStreamRef dst, StringParam type, bool closeio=false)
Save an animation to an IOStream.
Definition SDL3pp_image.h:3370
ResourceRefT< AnimationBase > AnimationRef
Reference for Animation.
Definition SDL3pp_image.h:45
Surface LoadAVIF_IO(IOStreamRef src)
Load a AVIF image directly.
Definition SDL3pp_image.h:1446
constexpr AnimationDecoderStatus DECODER_STATUS_OK
The decoder is ready to decode the next frame.
Definition SDL3pp_image.h:4051
bool isXV(IOStreamRef src)
Detect XV image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1412
Texture LoadTexture(RendererRef renderer, StringParam file)
Load an image from a filesystem path into a texture.
Definition SDL3pp_image.h:314
void SaveGIF_IO(SurfaceRef surface, IOStreamRef dst, bool closeio=false)
Save an Surface into GIF image data, via an IOStream.
Definition SDL3pp_image.h:2431
Surface LoadSurface_IO(IOStreamRef src, bool closeio=false)
Load an image from an SDL data source into a software surface.
Definition SDL3pp_image.h:221
int GetAnimationWidth(AnimationConstRef anim)
Get the width in pixels.
Definition SDL3pp_image.h:3007
constexpr AnimationDecoderStatus DECODER_STATUS_COMPLETE
No more frames available.
Definition SDL3pp_image.h:4058
bool isQOI(IOStreamRef src)
Detect QOI image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1154
constexpr AnimationDecoderStatus DECODER_STATUS_FAILED
The decoder failed to decode a frame, call GetError() for more information.
Definition SDL3pp_image.h:4055
Animation LoadANIAnimation_IO(IOStreamRef src)
Load an ANI animation directly from an IOStream.
Definition SDL3pp_image.h:3195
AnimationDecoder CreateAnimationDecoder_IO(IOStreamRef src, StringParam type, bool closeio=false)
Create a decoder to read a series of images from an IOStream.
Definition SDL3pp_image.h:4381
Animation LoadAVIFAnimation_IO(IOStreamRef src)
Load an AVIF animation directly from an IOStream.
Definition SDL3pp_image.h:3251
void SaveTyped_IO(IOStreamRef dst, StringParam type, bool closeio=false) const
Save an Surface into formatted image data, via an IOStream.
Definition SDL3pp_image.h:2293
void SaveWEBP_IO(IOStreamRef dst, int quality, bool closeio=false)
Save an animation in WEBP format to an IOStream.
Definition SDL3pp_image.h:3555
void SaveANI_IO(IOStreamRef dst, bool closeio=false)
Save an animation in ANI format to an IOStream.
Definition SDL3pp_image.h:3413
Animation LoadAnimationTyped_IO(IOStreamRef src, StringParam type, bool closeio=false)
Load an animation from an IOStream.
Definition SDL3pp_image.h:3163
Texture LoadTextureTyped_IO(RendererRef renderer, IOStreamRef src, StringParam type, bool closeio=false)
Load an image from an SDL data source into a texture.
Definition SDL3pp_image.h:422
bool isAVIF(IOStreamRef src)
Detect AVIF image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:681
void SavePNG_IO(IOStreamRef dst, bool closeio=false) const
Save a surface to a seekable SDL data stream in PNG format.
Definition SDL3pp_image.h:2579
Surface LoadQOI_IO(IOStreamRef src)
Load a QOI image directly.
Definition SDL3pp_image.h:1954
PropertiesRef GetProperties()
Get the properties of an animation decoder.
Definition SDL3pp_image.h:4519
Surface LoadSizedSVG_IO(IOStreamRef src, const PointRaw &size)
Load an SVG image, scaled to a specific size.
Definition SDL3pp_image.h:1917
Surface LoadJPG_IO(IOStreamRef src)
Load a JPG image directly.
Definition SDL3pp_image.h:1594
bool isGIF(IOStreamRef src)
Detect GIF image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:810
void SaveGIFAnimation_IO(AnimationRef anim, IOStreamRef dst, bool closeio=false)
Save an animation in GIF format to an IOStream.
Definition SDL3pp_image.h:3510
constexpr AnimationDecoderStatus DECODER_STATUS_INVALID
The decoder is invalid.
Definition SDL3pp_image.h:4048
void SaveAPNGAnimation_IO(AnimationRef anim, IOStreamRef dst, bool closeio=false)
Save an animation in APNG format to an IOStream.
Definition SDL3pp_image.h:3439
bool isCUR(IOStreamRef src)
Detect CUR image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:724
Surface GetFrame(int index) const
Return the frame image under given index.
Definition SDL3pp_image.h:3052
int GetCount() const
Return the number of frames.
Definition SDL3pp_image.h:3036
void SaveTyped_IO(IOStreamRef dst, StringParam type, bool closeio=false)
Save an animation to an IOStream.
Definition SDL3pp_image.h:3378
Surface LoadSurface(StringParam file)
Load an image from a filesystem path into a software surface.
Definition SDL3pp_image.h:164
Point GetSize() const
Get the size in pixels.
Definition SDL3pp_image.h:3028
AnimationDecoder CreateAnimationDecoder(StringParam file)
Create a decoder to read a series of images from a file.
Definition SDL3pp_image.h:4329
Animation LoadGIFAnimation_IO(IOStreamRef src)
Load a GIF animation directly.
Definition SDL3pp_image.h:3281
void CloseAnimationEncoder(AnimationEncoderRaw encoder)
Close an animation encoder, finishing any encoding.
Definition SDL3pp_image.h:4034
GPUTexture LoadGPUTexture(GPUDeviceRef 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:463
IMG_AnimationEncoder * AnimationEncoderRaw
Alias to raw representation for AnimationEncoder.
Definition SDL3pp_image.h:59
void Save(StringParam file)
Save an animation to a file.
Definition SDL3pp_image.h:3339
::Uint64 Uint64
An unsigned 64-bit integer type.
Definition SDL3pp_stdinc.h:326
Surface LoadBMP_IO(IOStreamRef src, bool closeio=false)
Load a BMP image from a seekable SDL data stream.
Definition SDL3pp_surface.h:2714
Surface LoadBMP(StringParam file)
Load a BMP image from a file.
Definition SDL3pp_surface.h:2737
ResourceRefT< SurfaceBase > SurfaceRef
Reference for Surface.
Definition SDL3pp_surface.h:57
ResourceConstRef< SurfaceRaw, SurfaceRawConst > SurfaceConstRef
Safely wrap Surface for non owning const parameters.
Definition SDL3pp_surface.h:60
ResourceRefT< RendererBase > RendererRef
Reference for Renderer.
Definition SDL3pp_video.h:86
Supported properties for creating an animation decoder.
Definition SDL3pp_image.h:4437
constexpr auto AVIF_ALLOW_INCREMENTAL_BOOLEAN
Enable avif allow incremental.
Definition SDL3pp_image.h:4468
constexpr auto GIF_TRANSPARENT_COLOR_INDEX_NUMBER
Number for gif transparent color index.
Definition SDL3pp_image.h:4480
constexpr auto TYPE_STRING
String for type.
Definition SDL3pp_image.h:4450
constexpr auto TIMEBASE_NUMERATOR_NUMBER
Number for timebase numerator.
Definition SDL3pp_image.h:4453
constexpr auto IOSTREAM_POINTER
Pointer to iostream.
Definition SDL3pp_image.h:4442
constexpr auto AVIF_MAX_THREADS_NUMBER
Number for avif max threads.
Definition SDL3pp_image.h:4463
constexpr auto AVIF_ALLOW_PROGRESSIVE_BOOLEAN
Enable avif allow progressive.
Definition SDL3pp_image.h:4474
constexpr auto IOSTREAM_AUTOCLOSE_BOOLEAN
Enable iostream autoclose.
Definition SDL3pp_image.h:4445
constexpr auto GIF_NUM_COLORS_NUMBER
Number for gif num colors.
Definition SDL3pp_image.h:4488
constexpr auto FILENAME_STRING
String for filename.
Definition SDL3pp_image.h:4439
constexpr auto TIMEBASE_DENOMINATOR_NUMBER
Number for timebase denominator.
Definition SDL3pp_image.h:4458
Animation metadata properties.
Definition SDL3pp_image.h:4530
constexpr auto CREATION_TIME_STRING
String for creation time.
Definition SDL3pp_image.h:4547
constexpr auto COPYRIGHT_STRING
String for copyright.
Definition SDL3pp_image.h:4538
constexpr auto LOOP_COUNT_NUMBER
Loop count.
Definition SDL3pp_image.h:4553
constexpr auto IGNORE_PROPS_BOOLEAN
Enable ignore props.
Definition SDL3pp_image.h:4532
constexpr auto TITLE_STRING
String for title.
Definition SDL3pp_image.h:4541
constexpr auto AUTHOR_STRING
String for author.
Definition SDL3pp_image.h:4544
constexpr auto FRAME_COUNT_NUMBER
Frame count.
Definition SDL3pp_image.h:4550
constexpr auto DESCRIPTION_STRING
String for description.
Definition SDL3pp_image.h:4535
Supported properties for creating an animation encoder.
Definition SDL3pp_image.h:3943
constexpr auto AVIF_MAX_THREADS_NUMBER
Number for avif max threads.
Definition SDL3pp_image.h:3972
constexpr auto AVIF_KEYFRAME_INTERVAL_NUMBER
Number for avif keyframe interval.
Definition SDL3pp_image.h:3977
constexpr auto QUALITY_NUMBER
Number for quality.
Definition SDL3pp_image.h:3959
constexpr auto FILENAME_STRING
String for filename.
Definition SDL3pp_image.h:3945
constexpr auto IOSTREAM_AUTOCLOSE_BOOLEAN
Enable iostream autoclose.
Definition SDL3pp_image.h:3951
constexpr auto IOSTREAM_POINTER
Pointer to iostream.
Definition SDL3pp_image.h:3948
constexpr auto TYPE_STRING
String for type.
Definition SDL3pp_image.h:3956
constexpr auto GIF_USE_LUT_BOOLEAN
Enable gif use lut.
Definition SDL3pp_image.h:3983
constexpr auto TIMEBASE_DENOMINATOR_NUMBER
Number for timebase denominator.
Definition SDL3pp_image.h:3967
constexpr auto TIMEBASE_NUMERATOR_NUMBER
Number for timebase numerator.
Definition SDL3pp_image.h:3962
Main include header for the SDL3pp library.
Base class to Animation.
Definition SDL3pp_image.h:2689
constexpr ResourceBaseT()=default
Default constructor, creates null/invalid resource.
Base class to AnimationDecoder.
Definition SDL3pp_image.h:4067
constexpr ResourceBaseT()=default
Default constructor, creates null/invalid resource.
An object representing animation decoder.
Definition SDL3pp_image.h:4171
constexpr AnimationDecoder & operator=(AnimationDecoder &&other) noexcept
Assignment operator.
Definition SDL3pp_image.h:4296
constexpr AnimationDecoder(AnimationDecoderRaw resource) noexcept
Constructs from raw AnimationDecoder.
Definition SDL3pp_image.h:4181
~AnimationDecoder()
Destructor.
Definition SDL3pp_image.h:4293
constexpr AnimationDecoder(AnimationDecoder &&other) noexcept
Move constructor.
Definition SDL3pp_image.h:4187
Base class to AnimationEncoder.
Definition SDL3pp_image.h:3619
constexpr ResourceBaseT()=default
Default constructor, creates null/invalid resource.
An object representing the encoder context.
Definition SDL3pp_image.h:3664
constexpr AnimationEncoder & operator=(AnimationEncoder &&other) noexcept
Assignment operator.
Definition SDL3pp_image.h:3796
~AnimationEncoder()
Destructor.
Definition SDL3pp_image.h:3793
constexpr AnimationEncoder(AnimationEncoder &&other) noexcept
Move constructor.
Definition SDL3pp_image.h:3680
constexpr AnimationEncoder(AnimationEncoderRaw resource) noexcept
Constructs from raw AnimationEncoder.
Definition SDL3pp_image.h:3674
Animated image support.
Definition SDL3pp_image.h:2928
constexpr Animation(Animation &&other) noexcept
Move constructor.
Definition SDL3pp_image.h:2944
~Animation()
Destructor.
Definition SDL3pp_image.h:2996
constexpr Animation & operator=(Animation &&other) noexcept
Assignment operator.
Definition SDL3pp_image.h:2999
constexpr Animation(AnimationRaw resource) noexcept
Constructs from raw Animation.
Definition SDL3pp_image.h:2938
The structure used to identify an SDL cursor.
Definition SDL3pp_mouse.h:207
The structure that defines a point (using integers).
Definition SDL3pp_rect.h:97
A non-owning reference wrapper for a given resource.
Definition SDL3pp_resource.h:93
A collection of pixels used in software blitting.
Definition SDL3pp_surface.h:1677
static Surface borrow(SurfaceRaw resource)
Safely borrows the from SurfaceRaw.
Definition SDL3pp_surface.h:1844
constexpr Surface(SurfaceRaw resource) noexcept
Constructs from raw Surface.
Definition SDL3pp_surface.h:1687
An efficient driver-specific representation of pixel data.
Definition SDL3pp_render.h:2993
constexpr Texture(TextureRaw resource) noexcept
Constructs from raw Texture.
Definition SDL3pp_render.h:3003