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(std::move(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(*this, std::move(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(*this, dst, std::move(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(), std::move(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
3092{
3093 return Animation(std::move(file));
3094}
3095
3097 : Animation(IMG_LoadAnimation(file))
3098{
3099}
3100
3101inline Animation::Animation(IOStreamRef src, bool closeio)
3102 : Animation(IMG_LoadAnimation_IO(src, closeio))
3103{
3104}
3105
3130inline Animation LoadAnimation_IO(IOStreamRef src, bool closeio = false)
3131{
3132 return Animation(src, closeio);
3133}
3134
3167 StringParam type,
3168 bool closeio = false)
3169{
3170 return Animation(IMG_LoadAnimationTyped_IO(src, closeio, type));
3171}
3172
3173#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3174
3199{
3200 return Animation(IMG_LoadANIAnimation_IO(src));
3201}
3202
3227{
3228 return Animation(IMG_LoadAPNGAnimation_IO(src));
3229}
3230
3255{
3256 return Animation(IMG_LoadAVIFAnimation_IO(src));
3257}
3258
3259#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3260
3285{
3286 return Animation(IMG_LoadGIFAnimation_IO(src));
3287}
3288
3313{
3314 return Animation{IMG_LoadWEBPAnimation_IO(src)};
3315}
3316
3317#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3318
3338{
3339 CheckError(IMG_SaveAnimation(anim, file));
3340}
3341
3343{
3344 SDL::SaveAnimation(get(), std::move(file));
3345}
3346
3374 IOStreamRef dst,
3375 StringParam type,
3376 bool closeio = false)
3377{
3378 CheckError(IMG_SaveAnimationTyped_IO(anim, dst, closeio, type));
3379}
3380
3382 StringParam type,
3383 bool closeio)
3384{
3385 SDL::SaveAnimationTyped_IO(get(), dst, std::move(type), closeio);
3386}
3387
3410 IOStreamRef dst,
3411 bool closeio = false)
3412{
3413 CheckError(IMG_SaveANIAnimation_IO(anim, dst, closeio));
3414}
3415
3416inline void AnimationBase::SaveANI_IO(IOStreamRef dst, bool closeio)
3417{
3418 SDL::SaveANIAnimation_IO(get(), dst, closeio);
3419}
3420
3443 IOStreamRef dst,
3444 bool closeio = false)
3445{
3446 CheckError(IMG_SaveAPNGAnimation_IO(anim, dst, closeio));
3447}
3448
3449inline void AnimationBase::SaveAPNG_IO(IOStreamRef dst, bool closeio)
3450{
3451 SDL::SaveAPNGAnimation_IO(get(), dst, closeio);
3452}
3453
3478 IOStreamRef dst,
3479 int quality,
3480 bool closeio = false)
3481{
3482 CheckError(IMG_SaveAVIFAnimation_IO(anim, dst, closeio, quality));
3483}
3484
3486 int quality,
3487 bool closeio)
3488{
3489 SDL::SaveAVIFAnimation_IO(get(), dst, quality, closeio);
3490}
3491
3514 IOStreamRef dst,
3515 bool closeio = false)
3516{
3517 CheckError(IMG_SaveGIFAnimation_IO(anim, dst, closeio));
3518}
3519
3520inline void AnimationBase::SaveGIF_IO(IOStreamRef dst, bool closeio)
3521{
3522 SDL::SaveGIFAnimation_IO(get(), dst, closeio);
3523}
3524
3551 IOStreamRef dst,
3552 int quality,
3553 bool closeio = false)
3554{
3555 CheckError(IMG_SaveWEBPAnimation_IO(anim, dst, closeio, quality));
3556}
3557
3559 int quality,
3560 bool closeio)
3561{
3562 SDL::SaveWEBPAnimation_IO(get(), dst, quality, closeio);
3563}
3564
3580{
3581 return Cursor(
3582 CheckError(IMG_CreateAnimatedCursor(anim, hotspot.x, hotspot.y)));
3583}
3584
3586{
3587 return SDL::CreateAnimatedCursor(get(), hotspot);
3588}
3589
3590#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3591
3610inline void FreeAnimation(AnimationRaw anim) { IMG_FreeAnimation(anim); }
3611
3613
3614#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3615
3621struct AnimationEncoderBase : ResourceBaseT<AnimationEncoderRaw>
3622{
3624
3639 void Close();
3640
3658 void AddFrame(SurfaceRef surface, Uint64 duration);
3659};
3660
3667{
3668 using AnimationEncoderBase::AnimationEncoderBase;
3669
3677 constexpr explicit AnimationEncoder(AnimationEncoderRaw resource) noexcept
3678 : AnimationEncoderBase(resource)
3679 {
3680 }
3681
3683 constexpr AnimationEncoder(AnimationEncoder&& other) noexcept
3684 : AnimationEncoder(other.release())
3685 {
3686 }
3687
3714
3744 AnimationEncoder(IOStreamRef dst, StringParam type, bool closeio = false);
3745
3794
3796 ~AnimationEncoder() { IMG_CloseAnimationEncoder(get()); }
3797
3799 constexpr AnimationEncoder& operator=(AnimationEncoder&& other) noexcept
3800 {
3801 swap(*this, other);
3802 return *this;
3803 }
3804};
3805
3832{
3833 return AnimationEncoder(std::move(file));
3834}
3835
3837 : AnimationEncoder(CheckError(IMG_CreateAnimationEncoder(file)))
3838{
3839}
3840
3842 StringParam type,
3843 bool closeio)
3845 CheckError(IMG_CreateAnimationEncoder_IO(dst, closeio, type)))
3846{
3847}
3848
3851 CheckError(IMG_CreateAnimationEncoderWithProperties(props)))
3852{
3853}
3854
3883 StringParam type,
3884 bool closeio = false)
3885{
3886 return AnimationEncoder(dst, std::move(type), closeio);
3887}
3888
3940
3947
3948constexpr auto FILENAME_STRING =
3949 IMG_PROP_ANIMATION_ENCODER_CREATE_FILENAME_STRING;
3950
3951constexpr auto IOSTREAM_POINTER =
3952 IMG_PROP_ANIMATION_ENCODER_CREATE_IOSTREAM_POINTER;
3953
3955 IMG_PROP_ANIMATION_ENCODER_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN;
3958
3959constexpr auto TYPE_STRING =
3960 IMG_PROP_ANIMATION_ENCODER_CREATE_TYPE_STRING;
3961
3962constexpr auto QUALITY_NUMBER =
3963 IMG_PROP_ANIMATION_ENCODER_CREATE_QUALITY_NUMBER;
3964
3966 IMG_PROP_ANIMATION_ENCODER_CREATE_TIMEBASE_NUMERATOR_NUMBER;
3969
3971 IMG_PROP_ANIMATION_ENCODER_CREATE_TIMEBASE_DENOMINATOR_NUMBER;
3974
3976 IMG_PROP_ANIMATION_ENCODER_CREATE_AVIF_MAX_THREADS_NUMBER;
3979
3981 IMG_PROP_ANIMATION_ENCODER_CREATE_AVIF_KEYFRAME_INTERVAL_NUMBER;
3985
3986constexpr auto GIF_USE_LUT_BOOLEAN =
3987 IMG_PROP_ANIMATION_ENCODER_CREATE_GIF_USE_LUT_BOOLEAN;
3989
3990} // namespace prop::AnimationEncoder::Create
3991
4011 SurfaceRef surface,
4012 Uint64 duration)
4013{
4014 CheckError(IMG_AddAnimationEncoderFrame(encoder, surface, duration));
4015}
4016
4018{
4019 SDL::AddAnimationEncoderFrame(get(), surface, duration);
4020}
4021
4038{
4039 CheckError(IMG_CloseAnimationEncoder(encoder));
4040}
4041
4043
4049using AnimationDecoderStatus = IMG_AnimationDecoderStatus;
4050
4052 IMG_DECODER_STATUS_INVALID;
4053
4055 IMG_DECODER_STATUS_OK;
4056
4059 IMG_DECODER_STATUS_FAILED;
4060
4062 IMG_DECODER_STATUS_COMPLETE;
4063
4069struct AnimationDecoderBase : ResourceBaseT<AnimationDecoderRaw>
4070{
4072
4087 void Close();
4088
4110
4134 Surface GetFrame(Uint64* duration);
4135
4147
4165 void Reset();
4166};
4167
4174{
4175 using AnimationDecoderBase::AnimationDecoderBase;
4176
4184 constexpr explicit AnimationDecoder(AnimationDecoderRaw resource) noexcept
4185 : AnimationDecoderBase(resource)
4186 {
4187 }
4188
4190 constexpr AnimationDecoder(AnimationDecoder&& other) noexcept
4191 : AnimationDecoder(other.release())
4192 {
4193 }
4194
4222
4253 AnimationDecoder(IOStreamRef src, StringParam type, bool closeio = false);
4254
4294
4296 ~AnimationDecoder() { IMG_CloseAnimationDecoder(get()); }
4297
4299 constexpr AnimationDecoder& operator=(AnimationDecoder&& other) noexcept
4300 {
4301 swap(*this, other);
4302 return *this;
4303 }
4304};
4305
4333{
4334 return AnimationDecoder(std::move(file));
4335}
4336
4338 : AnimationDecoder(CheckError(IMG_CreateAnimationDecoder(file)))
4339{
4340}
4341
4343 StringParam type,
4344 bool closeio)
4346 CheckError(IMG_CreateAnimationDecoder_IO(src, closeio, type)))
4347{
4348}
4349
4352 CheckError(IMG_CreateAnimationDecoderWithProperties(props)))
4353{
4354}
4355
4385 StringParam type,
4386 bool closeio = false)
4387{
4388 return AnimationDecoder(src, std::move(type), closeio);
4389}
4390
4434
4441
4442constexpr auto FILENAME_STRING =
4443 IMG_PROP_ANIMATION_DECODER_CREATE_FILENAME_STRING;
4444
4445constexpr auto IOSTREAM_POINTER =
4446 IMG_PROP_ANIMATION_DECODER_CREATE_IOSTREAM_POINTER;
4447
4449 IMG_PROP_ANIMATION_DECODER_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN;
4452
4453constexpr auto TYPE_STRING =
4454 IMG_PROP_ANIMATION_DECODER_CREATE_TYPE_STRING;
4455
4457 IMG_PROP_ANIMATION_DECODER_CREATE_TIMEBASE_NUMERATOR_NUMBER;
4460
4462 IMG_PROP_ANIMATION_DECODER_CREATE_TIMEBASE_DENOMINATOR_NUMBER;
4465
4467 IMG_PROP_ANIMATION_DECODER_CREATE_AVIF_MAX_THREADS_NUMBER;
4470
4472 IMG_PROP_ANIMATION_DECODER_CREATE_AVIF_ALLOW_INCREMENTAL_BOOLEAN;
4476
4478 IMG_PROP_ANIMATION_DECODER_CREATE_AVIF_ALLOW_PROGRESSIVE_BOOLEAN;
4482
4484 IMG_PROP_ANIMATION_DECODER_CREATE_GIF_TRANSPARENT_COLOR_INDEX_NUMBER;
4490
4492 IMG_PROP_ANIMATION_DECODER_CREATE_GIF_NUM_COLORS_NUMBER;
4494
4495} // namespace prop::AnimationDecoder::Create
4496
4518{
4519 return IMG_GetAnimationDecoderProperties(decoder);
4520}
4521
4526
4534
4535constexpr auto IGNORE_PROPS_BOOLEAN =
4536 IMG_PROP_METADATA_IGNORE_PROPS_BOOLEAN;
4537
4538constexpr auto DESCRIPTION_STRING =
4539 IMG_PROP_METADATA_DESCRIPTION_STRING;
4540
4541constexpr auto COPYRIGHT_STRING =
4542 IMG_PROP_METADATA_COPYRIGHT_STRING;
4543
4544constexpr auto TITLE_STRING =
4545 IMG_PROP_METADATA_TITLE_STRING;
4546
4547constexpr auto AUTHOR_STRING =
4548 IMG_PROP_METADATA_AUTHOR_STRING;
4549
4550constexpr auto CREATION_TIME_STRING =
4551 IMG_PROP_METADATA_CREATION_TIME_STRING;
4552
4553constexpr auto FRAME_COUNT_NUMBER =
4554 IMG_PROP_METADATA_FRAME_COUNT_NUMBER;
4555
4556constexpr auto LOOP_COUNT_NUMBER =
4557 IMG_PROP_METADATA_LOOP_COUNT_NUMBER;
4558
4559} // namespace prop::AnimationDecoder::Metadata
4560
4585 Uint64* duration)
4586{
4587 SDL_Surface* frame = nullptr;
4588 CheckError(IMG_GetAnimationDecoderFrame(decoder, &frame, duration));
4589 return Surface::borrow(frame);
4590}
4591
4593{
4594 return SDL::GetAnimationDecoderFrame(get(), duration);
4595}
4596
4609 AnimationDecoderRef decoder)
4610{
4611 return IMG_GetAnimationDecoderStatus(decoder);
4612}
4613
4618
4638{
4639 CheckError(IMG_ResetAnimationDecoder(decoder));
4640}
4641
4643
4660{
4661 CheckError(IMG_CloseAnimationDecoder(decoder));
4662}
4663
4665
4666#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
4667
4669
4670} // namespace SDL
4671
4672#else // defined(SDL3PP_ENABLE_IMAGE) || defined(SDL3PP_DOC)
4673
4674namespace SDL {
4675
4676inline Surface::Surface(StringParam file)
4677 : Surface(LoadBMP(std::move(file)))
4678{
4679}
4680
4681inline Surface::Surface(IOStreamRef src, bool closeio)
4682 : Surface(LoadBMP_IO(std::move(src), closeio))
4683{
4684}
4685
4686inline Texture::Texture(RendererRef renderer, StringParam file)
4687 : Texture(std::move(renderer), Surface(std::move(file)))
4688{
4689}
4690
4691inline Texture::Texture(RendererRef renderer, IOStreamRef src, bool closeio)
4692 : Texture(std::move(renderer), Surface(std::move(src), closeio))
4693{
4694}
4695
4696} // namespace SDL
4697
4698#endif // defined(SDL3PP_ENABLE_IMAGE) || defined(SDL3PP_DOC)
4699
4700#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:43
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:53
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:3449
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:3935
Animation LoadWEBPAnimation_IO(IOStreamRef src)
Load a WEBP animation directly.
Definition SDL3pp_image.h:3312
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:4429
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:3226
void SaveAnimation(AnimationRef anim, StringParam file)
Save an animation to a file.
Definition SDL3pp_image.h:3337
Animation LoadAnimation_IO(IOStreamRef src, bool closeio=false)
Load an animation from an IOStream.
Definition SDL3pp_image.h:3130
void FreeAnimation(AnimationRaw anim)
Dispose of an Animation and free its resources.
Definition SDL3pp_image.h:3610
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:3831
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:3477
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:3585
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:4642
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:4010
Surface GetAnimationDecoderFrame(AnimationDecoderRef decoder, Uint64 *duration)
Get the next frame in an animation decoder.
Definition SDL3pp_image.h:4584
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:4049
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:3579
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:4659
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:3882
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:4664
void ResetAnimationDecoder(AnimationDecoderRef decoder)
Reset an animation decoder.
Definition SDL3pp_image.h:4637
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:4614
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:4517
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:4592
void SaveAVIF_IO(IOStreamRef dst, int quality, bool closeio=false)
Save an animation in AVIF format to an IOStream.
Definition SDL3pp_image.h:3485
void AddFrame(SurfaceRef surface, Uint64 duration)
Add a frame to an animation encoder.
Definition SDL3pp_image.h:4017
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:3520
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:3612
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:3550
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:4042
AnimationDecoderStatus GetAnimationDecoderStatus(AnimationDecoderRef decoder)
Get the decoder status indicating the current state of the decoder.
Definition SDL3pp_image.h:4608
void SaveANIAnimation_IO(AnimationRef anim, IOStreamRef dst, bool closeio=false)
Save an animation in ANI format to an IOStream.
Definition SDL3pp_image.h:3409
void SaveAnimationTyped_IO(AnimationRef anim, IOStreamRef dst, StringParam type, bool closeio=false)
Save an animation to an IOStream.
Definition SDL3pp_image.h:3373
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:4054
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:4061
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:4058
Animation LoadANIAnimation_IO(IOStreamRef src)
Load an ANI animation directly from an IOStream.
Definition SDL3pp_image.h:3198
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:4384
Animation LoadAVIFAnimation_IO(IOStreamRef src)
Load an AVIF animation directly from an IOStream.
Definition SDL3pp_image.h:3254
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:3558
void SaveANI_IO(IOStreamRef dst, bool closeio=false)
Save an animation in ANI format to an IOStream.
Definition SDL3pp_image.h:3416
Animation LoadAnimationTyped_IO(IOStreamRef src, StringParam type, bool closeio=false)
Load an animation from an IOStream.
Definition SDL3pp_image.h:3166
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:4522
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:3513
constexpr AnimationDecoderStatus DECODER_STATUS_INVALID
The decoder is invalid.
Definition SDL3pp_image.h:4051
void SaveAPNGAnimation_IO(AnimationRef anim, IOStreamRef dst, bool closeio=false)
Save an animation in APNG format to an IOStream.
Definition SDL3pp_image.h:3442
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:3381
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:4332
Animation LoadGIFAnimation_IO(IOStreamRef src)
Load a GIF animation directly.
Definition SDL3pp_image.h:3284
void CloseAnimationEncoder(AnimationEncoderRaw encoder)
Close an animation encoder, finishing any encoding.
Definition SDL3pp_image.h:4037
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:3342
::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:4440
constexpr auto AVIF_ALLOW_INCREMENTAL_BOOLEAN
Enable avif allow incremental.
Definition SDL3pp_image.h:4471
constexpr auto GIF_TRANSPARENT_COLOR_INDEX_NUMBER
Number for gif transparent color index.
Definition SDL3pp_image.h:4483
constexpr auto TYPE_STRING
String for type.
Definition SDL3pp_image.h:4453
constexpr auto TIMEBASE_NUMERATOR_NUMBER
Number for timebase numerator.
Definition SDL3pp_image.h:4456
constexpr auto IOSTREAM_POINTER
Pointer to iostream.
Definition SDL3pp_image.h:4445
constexpr auto AVIF_MAX_THREADS_NUMBER
Number for avif max threads.
Definition SDL3pp_image.h:4466
constexpr auto AVIF_ALLOW_PROGRESSIVE_BOOLEAN
Enable avif allow progressive.
Definition SDL3pp_image.h:4477
constexpr auto IOSTREAM_AUTOCLOSE_BOOLEAN
Enable iostream autoclose.
Definition SDL3pp_image.h:4448
constexpr auto GIF_NUM_COLORS_NUMBER
Number for gif num colors.
Definition SDL3pp_image.h:4491
constexpr auto FILENAME_STRING
String for filename.
Definition SDL3pp_image.h:4442
constexpr auto TIMEBASE_DENOMINATOR_NUMBER
Number for timebase denominator.
Definition SDL3pp_image.h:4461
Animation metadata properties.
Definition SDL3pp_image.h:4533
constexpr auto CREATION_TIME_STRING
String for creation time.
Definition SDL3pp_image.h:4550
constexpr auto COPYRIGHT_STRING
String for copyright.
Definition SDL3pp_image.h:4541
constexpr auto LOOP_COUNT_NUMBER
Loop count.
Definition SDL3pp_image.h:4556
constexpr auto IGNORE_PROPS_BOOLEAN
Enable ignore props.
Definition SDL3pp_image.h:4535
constexpr auto TITLE_STRING
String for title.
Definition SDL3pp_image.h:4544
constexpr auto AUTHOR_STRING
String for author.
Definition SDL3pp_image.h:4547
constexpr auto FRAME_COUNT_NUMBER
Frame count.
Definition SDL3pp_image.h:4553
constexpr auto DESCRIPTION_STRING
String for description.
Definition SDL3pp_image.h:4538
Supported properties for creating an animation encoder.
Definition SDL3pp_image.h:3946
constexpr auto AVIF_MAX_THREADS_NUMBER
Number for avif max threads.
Definition SDL3pp_image.h:3975
constexpr auto AVIF_KEYFRAME_INTERVAL_NUMBER
Number for avif keyframe interval.
Definition SDL3pp_image.h:3980
constexpr auto QUALITY_NUMBER
Number for quality.
Definition SDL3pp_image.h:3962
constexpr auto FILENAME_STRING
String for filename.
Definition SDL3pp_image.h:3948
constexpr auto IOSTREAM_AUTOCLOSE_BOOLEAN
Enable iostream autoclose.
Definition SDL3pp_image.h:3954
constexpr auto IOSTREAM_POINTER
Pointer to iostream.
Definition SDL3pp_image.h:3951
constexpr auto TYPE_STRING
String for type.
Definition SDL3pp_image.h:3959
constexpr auto GIF_USE_LUT_BOOLEAN
Enable gif use lut.
Definition SDL3pp_image.h:3986
constexpr auto TIMEBASE_DENOMINATOR_NUMBER
Number for timebase denominator.
Definition SDL3pp_image.h:3970
constexpr auto TIMEBASE_NUMERATOR_NUMBER
Number for timebase numerator.
Definition SDL3pp_image.h:3965
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:4070
constexpr ResourceBaseT()=default
Default constructor, creates null/invalid resource.
An object representing animation decoder.
Definition SDL3pp_image.h:4174
constexpr AnimationDecoder & operator=(AnimationDecoder &&other) noexcept
Assignment operator.
Definition SDL3pp_image.h:4299
constexpr AnimationDecoder(AnimationDecoderRaw resource) noexcept
Constructs from raw AnimationDecoder.
Definition SDL3pp_image.h:4184
~AnimationDecoder()
Destructor.
Definition SDL3pp_image.h:4296
constexpr AnimationDecoder(AnimationDecoder &&other) noexcept
Move constructor.
Definition SDL3pp_image.h:4190
Base class to AnimationEncoder.
Definition SDL3pp_image.h:3622
constexpr ResourceBaseT()=default
Default constructor, creates null/invalid resource.
An object representing the encoder context.
Definition SDL3pp_image.h:3667
constexpr AnimationEncoder & operator=(AnimationEncoder &&other) noexcept
Assignment operator.
Definition SDL3pp_image.h:3799
~AnimationEncoder()
Destructor.
Definition SDL3pp_image.h:3796
constexpr AnimationEncoder(AnimationEncoder &&other) noexcept
Move constructor.
Definition SDL3pp_image.h:3683
constexpr AnimationEncoder(AnimationEncoderRaw resource) noexcept
Constructs from raw AnimationEncoder.
Definition SDL3pp_image.h:3677
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