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 Animation;
30
32using AnimationRaw = IMG_Animation*;
33
35using AnimationRawConst = const IMG_Animation*;
36
43
46
47#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
48
49// Forward decl
50struct AnimationEncoder;
51
53using AnimationEncoderRaw = IMG_AnimationEncoder*;
54
61
62// Forward decl
63struct AnimationDecoder;
64
66using AnimationDecoderRaw = IMG_AnimationDecoder*;
67
74
75#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
76
77#ifdef SDL3PP_DOC
78
84#define SDL_IMAGE_MAJOR_VERSION
85
86#define SDL_IMAGE_MINOR_VERSION
87
88#define SDL_IMAGE_MICRO_VERSION
89
91
95#define SDL_IMAGE_VERSION \
96 SDL_VERSIONNUM( \
97 SDL_IMAGE_MAJOR_VERSION, SDL_IMAGE_MINOR_VERSION, SDL_IMAGE_MICRO_VERSION)
98
100#define SDL_IMAGE_VERSION_ATLEAST(X, Y, Z) \
101 ((SDL_IMAGE_MAJOR_VERSION >= X) && \
102 (SDL_IMAGE_MAJOR_VERSION > X || SDL_IMAGE_MINOR_VERSION >= Y) && \
103 (SDL_IMAGE_MAJOR_VERSION > X || SDL_IMAGE_MINOR_VERSION > Y || \
104 SDL_IMAGE_MICRO_VERSION >= Z))
105
106#endif // SDL3PP_DOC
107
108namespace IMG {
109
117inline int Version() { return IMG_Version(); }
118
119} // namespace IMG
120
155inline Surface LoadSurface(StringParam file) { return Surface{IMG_Load(file)}; }
156
158 : Surface(IMG_Load(file))
159{
160}
161
162inline Surface::Surface(IOStreamRef src, bool closeio)
163 : Surface(IMG_Load_IO(src, closeio))
164{
165}
166
212inline Surface LoadSurface_IO(IOStreamRef src, bool closeio = false)
213{
214 return Surface{IMG_Load_IO(src, closeio)};
215}
216
271 StringParam type,
272 bool closeio = false)
273{
274 return Surface(IMG_LoadTyped_IO(src, closeio, type));
275}
276
306{
307 return Texture(IMG_LoadTexture(renderer, file));
308}
309
311 : Texture(IMG_LoadTexture(renderer, file))
312{
313}
314
315inline Texture::Texture(RendererRef renderer, IOStreamRef src, bool closeio)
316 : Texture(IMG_LoadTexture_IO(renderer, src, closeio))
317{
318}
319
360 IOStreamRef src,
361 bool closeio = false)
362{
363 return Texture(IMG_LoadTexture_IO(renderer, src, closeio));
364}
365
414 IOStreamRef src,
415 StringParam type,
416 bool closeio = false)
417{
418 return Texture(IMG_LoadTextureTyped_IO(renderer, src, closeio, type));
419}
420
421#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
422
455 GPUCopyPass copy_pass,
456 StringParam file,
457 int* width = nullptr,
458 int* height = nullptr)
459{
460 return IMG_LoadGPUTexture(device, copy_pass, file, width, height);
461}
462
505inline GPUTexture LoadGPUTexture_IO(GPUDeviceRef device,
506 GPUCopyPass copy_pass,
507 IOStreamRef src,
508 bool closeio = false,
509 int* width = nullptr,
510 int* height = nullptr)
511{
512 return IMG_LoadGPUTexture_IO(device, copy_pass, src, closeio, width, height);
513}
514
565inline GPUTexture LoadGPUTextureTyped_IO(GPUDeviceRef device,
566 GPUCopyPass copy_pass,
567 IOStreamRef src,
568 StringParam type,
569 bool closeio = false,
570 int* width = nullptr,
571 int* height = nullptr)
572{
573 return IMG_LoadGPUTextureTyped_IO(
574 device, copy_pass, src, closeio, type, width, height);
575}
576
587inline Surface GetClipboardImage() { return Surface{IMG_GetClipboardImage()}; }
588
630inline bool isANI(IOStreamRef src) { return IMG_isANI(src); }
631
632#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
633
675inline bool isAVIF(IOStreamRef src) { return IMG_isAVIF(src); }
676
718inline bool isCUR(IOStreamRef src) { return IMG_isCUR(src); }
719
761inline bool isBMP(IOStreamRef src) { return IMG_isBMP(src); }
762
804inline bool isGIF(IOStreamRef src) { return IMG_isGIF(src); }
805
847inline bool isICO(IOStreamRef src) { return IMG_isICO(src); }
848
890inline bool isJPG(IOStreamRef src) { return IMG_isJPG(src); }
891
933inline bool isJXL(IOStreamRef src) { return IMG_isJXL(src); }
934
976inline bool isLBM(IOStreamRef src) { return IMG_isLBM(src); }
977
1019inline bool isPCX(IOStreamRef src) { return IMG_isPCX(src); }
1020
1062inline bool isPNG(IOStreamRef src) { return IMG_isPNG(src); }
1063
1105inline bool isPNM(IOStreamRef src) { return IMG_isPNM(src); }
1106
1148inline bool isQOI(IOStreamRef src) { return IMG_isQOI(src); }
1149
1191inline bool isSVG(IOStreamRef src) { return IMG_isSVG(src); }
1192
1234inline bool isTIF(IOStreamRef src) { return IMG_isTIF(src); }
1235
1277inline bool isWEBP(IOStreamRef src) { return IMG_isWEBP(src); }
1278
1320inline bool isXCF(IOStreamRef src) { return IMG_isXCF(src); }
1321
1363inline bool isXPM(IOStreamRef src) { return IMG_isXPM(src); }
1364
1406inline bool isXV(IOStreamRef src) { return IMG_isXV(src); }
1407
1441{
1442 return Surface(IMG_LoadAVIF_IO(src));
1443}
1444
1478{
1479 return Surface{IMG_LoadCUR_IO(src)};
1480}
1481
1515{
1516 return Surface{IMG_LoadGIF_IO(src)};
1517}
1518
1552{
1553 return Surface{IMG_LoadICO_IO(src)};
1554}
1555
1589{
1590 return Surface{IMG_LoadJPG_IO(src)};
1591}
1592
1626{
1627 return Surface{IMG_LoadJXL_IO(src)};
1628}
1629
1663{
1664 return Surface{IMG_LoadLBM_IO(src)};
1665}
1666
1700{
1701 return Surface{IMG_LoadPCX_IO(src)};
1702}
1703
1737{
1738 return Surface{IMG_LoadPNG_IO(src)};
1739}
1740
1775inline Surface LoadPNG_IO(IOStreamRef src, bool closeio)
1776{
1777 if (!closeio) return Surface{LoadPNG_IO(src)};
1778 Surface temp{LoadPNG_IO(src)};
1779 src.Close();
1780 return temp;
1781}
1782
1815{
1816 return LoadPNG_IO(IOFromFile(std::move(file), "rb"));
1817}
1818
1852{
1853 return Surface{IMG_LoadPNM_IO(src)};
1854}
1855
1890{
1891 return Surface{IMG_LoadSVG_IO(src)};
1892}
1893
1915{
1916 return Surface{IMG_LoadSizedSVG_IO(src, size.x, size.y)};
1917}
1918
1952{
1953 return Surface{IMG_LoadQOI_IO(src)};
1954}
1955
1989{
1990 return Surface{IMG_LoadTGA_IO(src)};
1991}
1992
2026{
2027 return Surface{IMG_LoadTIF_IO(src)};
2028}
2029
2063{
2064 return Surface{IMG_LoadWEBP_IO(src)};
2065}
2066
2100{
2101 return Surface{IMG_LoadXCF_IO(src)};
2102}
2103
2137{
2138 return Surface{IMG_LoadXPM_IO(src)};
2139}
2140
2174{
2175 return Surface{IMG_LoadXV_IO(src)};
2176}
2177
2192inline Surface ReadXPMFromArray(char** xpm)
2193{
2194 return Surface{IMG_ReadXPMFromArray(xpm)};
2195}
2196
2211{
2212 return Surface{IMG_ReadXPMFromArrayToRGB888(xpm)};
2213}
2214
2215#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2216
2241inline void Save(SurfaceConstRef surface, StringParam file)
2242{
2243 CheckError(IMG_Save(surface, file));
2244}
2245
2246inline void Surface::Save(StringParam filename) const
2247{
2248 SDL::Save(*this, std::move(filename));
2249}
2250
2282inline void SaveTyped_IO(SurfaceConstRef surface,
2283 IOStreamRef dst,
2284 StringParam type,
2285 bool closeio = false)
2286{
2287 CheckError(IMG_SaveTyped_IO(surface, dst, closeio, type));
2288}
2289
2291 StringParam type,
2292 bool closeio) const
2293{
2294 SDL::SaveTyped_IO(*this, dst, std::move(type), closeio);
2295}
2296
2297#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2298
2314inline void SaveAVIF(SurfaceRef surface, StringParam file, int quality)
2315{
2316 CheckError(IMG_SaveAVIF(surface, file, quality));
2317}
2318
2339inline void SaveAVIF_IO(SurfaceRef surface,
2340 IOStreamRef dst,
2341 int quality,
2342 bool closeio = false)
2343{
2344 CheckError(IMG_SaveAVIF_IO(surface, dst, closeio, quality));
2345}
2346
2347#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2348
2362inline void SaveCUR(SurfaceRef surface, StringParam file)
2363{
2364 CheckError(IMG_SaveCUR(surface, file));
2365}
2366
2385inline void SaveCUR_IO(SurfaceRef surface,
2386 IOStreamRef dst,
2387 bool closeio = false)
2388{
2389 CheckError(IMG_SaveCUR_IO(surface, dst, closeio));
2390}
2391
2405inline void SaveGIF(SurfaceRef surface, StringParam file)
2406{
2407 CheckError(IMG_SaveGIF(surface, file));
2408}
2409
2428inline void SaveGIF_IO(SurfaceRef surface,
2429 IOStreamRef dst,
2430 bool closeio = false)
2431{
2432 CheckError(IMG_SaveGIF_IO(surface, dst, closeio));
2433}
2434
2448inline void SaveICO(SurfaceRef surface, StringParam file)
2449{
2450 CheckError(IMG_SaveICO(surface, file));
2451}
2452
2471inline void SaveICO_IO(SurfaceRef surface,
2472 IOStreamRef dst,
2473 bool closeio = false)
2474{
2475 CheckError(IMG_SaveICO_IO(surface, dst, closeio));
2476}
2477
2478#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2479
2495inline void SaveJPG(SurfaceRef surface, StringParam file, int quality)
2496{
2497 CheckError(IMG_SaveJPG(surface, file, quality));
2498}
2499
2520inline void SaveJPG_IO(SurfaceRef surface,
2521 IOStreamRef dst,
2522 int quality,
2523 bool closeio = false)
2524{
2525 CheckError(IMG_SaveJPG_IO(surface, dst, closeio, quality));
2526}
2527
2541inline void SavePNG(SurfaceRef surface, StringParam file)
2542{
2543 CheckError(IMG_SavePNG(surface, file));
2544}
2545
2546inline void Surface::SavePNG(StringParam file) const
2547{
2548 SDL::SavePNG(get(), std::move(file));
2549}
2550
2569inline void SavePNG_IO(SurfaceRef surface,
2570 IOStreamRef dst,
2571 bool closeio = false)
2572{
2573 CheckError(IMG_SavePNG_IO(surface, dst, closeio));
2574}
2575
2576inline void Surface::SavePNG_IO(IOStreamRef dst, bool closeio) const
2577{
2578 SDL::SavePNG_IO(get(), dst, closeio);
2579}
2580
2581#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2582
2596inline void SaveTGA(SurfaceRef surface, StringParam file)
2597{
2598 CheckError(IMG_SaveTGA(surface, file));
2599}
2600
2619inline void SaveTGA_IO(SurfaceRef surface,
2620 IOStreamRef dst,
2621 bool closeio = false)
2622{
2623 CheckError(IMG_SaveTGA_IO(surface, dst, closeio));
2624}
2625
2643inline void SaveWEBP(SurfaceRef surface, StringParam file, float quality)
2644{
2645 CheckError(IMG_SaveWEBP(surface, file, quality));
2646}
2647
2670inline void SaveWEBP_IO(SurfaceRef surface,
2671 IOStreamRef dst,
2672 float quality,
2673 bool closeio = false)
2674{
2675 CheckError(IMG_SaveWEBP_IO(surface, dst, closeio, quality));
2676}
2677
2678#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2679
2685struct Animation : ResourceBase<AnimationRaw, AnimationRawConst>
2686{
2688
2696 constexpr explicit Animation(AnimationRaw resource) noexcept
2697 : ResourceBase(resource)
2698 {
2699 }
2700
2702 constexpr Animation(const Animation& other) = delete;
2703
2705 constexpr Animation(Animation&& other) noexcept
2706 : Animation(other.release())
2707 {
2708 }
2709
2710 constexpr Animation(const AnimationRef& other) = delete;
2711
2712 constexpr Animation(AnimationRef&& other) = delete;
2713
2735 Animation(StringParam file);
2736
2764 Animation(IOStreamRef src, bool closeio = false);
2765
2767 constexpr operator AnimationConstRef() const noexcept { return get(); }
2768
2770 ~Animation() { IMG_FreeAnimation(get()); }
2771
2773 constexpr Animation& operator=(Animation&& other) noexcept
2774 {
2775 swap(*this, other);
2776 return *this;
2777 }
2778
2780 Animation& operator=(const Animation& other) = delete;
2781
2798 void Free();
2799
2801 int GetWidth() const;
2802
2804 int GetHeight() const;
2805
2807 Point GetSize() const;
2808
2810 int GetCount() const;
2811
2817 Surface GetFrame(int index) const;
2818
2824 int GetDelay(int index) const;
2825
2826#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
2827
2845 void Save(StringParam file);
2846
2873 void SaveTyped_IO(IOStreamRef dst, StringParam type, bool closeio = false);
2874
2895 void SaveANI_IO(IOStreamRef dst, bool closeio = false);
2896
2917 void SaveAPNG_IO(IOStreamRef dst, bool closeio = false);
2918
2941 void SaveAVIF_IO(IOStreamRef dst, int quality, bool closeio = false);
2942
2963 void SaveGIF_IO(IOStreamRef dst, bool closeio = false);
2964
2989 void SaveWEBP_IO(IOStreamRef dst, int quality, bool closeio = false);
2990
3004 Cursor CreateCursor(const PointRaw& hotspot);
3005
3006#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3007};
3008
3010inline int GetAnimationWidth(AnimationConstRef anim) { return anim->w; }
3011
3012inline int Animation::GetWidth() const { return SDL::GetAnimationWidth(get()); }
3013
3015inline int GetAnimationHeight(AnimationConstRef anim) { return anim->h; }
3016
3017inline int Animation::GetHeight() const
3018{
3019 return SDL::GetAnimationHeight(get());
3020}
3021
3024{
3025 return {anim->w, anim->h};
3026}
3027
3029
3031inline int GetAnimationCount(AnimationConstRef anim) { return anim->count; }
3032
3033inline int Animation::GetCount() const { return SDL::GetAnimationCount(get()); }
3034
3042{
3043 return Surface::Borrow(anim->frames[index]);
3044}
3045
3046inline Surface Animation::GetFrame(int index) const
3047{
3048 return SDL::GetAnimationFrame(get(), index);
3049}
3050
3057inline int GetAnimationDelay(AnimationConstRef anim, int index)
3058{
3059 return anim->delays[index];
3060}
3061
3062inline int Animation::GetDelay(int index) const
3063{
3064 return SDL::GetAnimationDelay(get(), index);
3065}
3066
3089{
3090 return Animation(std::move(file));
3091}
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
3130inline Animation LoadAnimation_IO(IOStreamRef src, bool closeio = false)
3131{
3132 return Animation(src, closeio);
3133}
3134
3170 StringParam type,
3171 bool closeio = false)
3172{
3173 return Animation(IMG_LoadAnimationTyped_IO(src, closeio, type));
3174}
3175
3176#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3177
3205{
3206 return Animation(IMG_LoadANIAnimation_IO(src));
3207}
3208
3236{
3237 return Animation(IMG_LoadAPNGAnimation_IO(src));
3238}
3239
3267{
3268 return Animation(IMG_LoadAVIFAnimation_IO(src));
3269}
3270
3271#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3272
3297{
3298 return Animation(IMG_LoadGIFAnimation_IO(src));
3299}
3300
3325{
3326 return Animation{IMG_LoadWEBPAnimation_IO(src)};
3327}
3328
3329#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3330
3350{
3351 CheckError(IMG_SaveAnimation(anim, file));
3352}
3353
3355{
3356 SDL::SaveAnimation(get(), std::move(file));
3357}
3358
3386 IOStreamRef dst,
3387 StringParam type,
3388 bool closeio = false)
3389{
3390 CheckError(IMG_SaveAnimationTyped_IO(anim, dst, closeio, type));
3391}
3392
3394 StringParam type,
3395 bool closeio)
3396{
3397 SDL::SaveAnimationTyped_IO(get(), dst, std::move(type), closeio);
3398}
3399
3422 IOStreamRef dst,
3423 bool closeio = false)
3424{
3425 CheckError(IMG_SaveANIAnimation_IO(anim, dst, closeio));
3426}
3427
3428inline void Animation::SaveANI_IO(IOStreamRef dst, bool closeio)
3429{
3430 SDL::SaveANIAnimation_IO(get(), dst, closeio);
3431}
3432
3455 IOStreamRef dst,
3456 bool closeio = false)
3457{
3458 CheckError(IMG_SaveAPNGAnimation_IO(anim, dst, closeio));
3459}
3460
3461inline void Animation::SaveAPNG_IO(IOStreamRef dst, bool closeio)
3462{
3463 SDL::SaveAPNGAnimation_IO(get(), dst, closeio);
3464}
3465
3490 IOStreamRef dst,
3491 int quality,
3492 bool closeio = false)
3493{
3494 CheckError(IMG_SaveAVIFAnimation_IO(anim, dst, closeio, quality));
3495}
3496
3497inline void Animation::SaveAVIF_IO(IOStreamRef dst, int quality, bool closeio)
3498{
3499 SDL::SaveAVIFAnimation_IO(get(), dst, quality, closeio);
3500}
3501
3524 IOStreamRef dst,
3525 bool closeio = false)
3526{
3527 CheckError(IMG_SaveGIFAnimation_IO(anim, dst, closeio));
3528}
3529
3530inline void Animation::SaveGIF_IO(IOStreamRef dst, bool closeio)
3531{
3532 SDL::SaveGIFAnimation_IO(get(), dst, closeio);
3533}
3534
3561 IOStreamRef dst,
3562 int quality,
3563 bool closeio = false)
3564{
3565 CheckError(IMG_SaveWEBPAnimation_IO(anim, dst, closeio, quality));
3566}
3567
3568inline void Animation::SaveWEBP_IO(IOStreamRef dst, int quality, bool closeio)
3569{
3570 SDL::SaveWEBPAnimation_IO(get(), dst, quality, closeio);
3571}
3572
3588{
3589 return Cursor{
3590 CheckError(IMG_CreateAnimatedCursor(anim, hotspot.x, hotspot.y))};
3591}
3592
3594{
3595 return SDL::CreateAnimatedCursor(get(), hotspot);
3596}
3597
3598#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3599
3618inline void FreeAnimation(AnimationRaw anim) { IMG_FreeAnimation(anim); }
3619
3621
3622#if SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
3623
3629struct AnimationEncoder : ResourceBase<AnimationEncoderRaw>
3630{
3632
3640 constexpr explicit AnimationEncoder(AnimationEncoderRaw resource) noexcept
3641 : ResourceBase(resource)
3642 {
3643 }
3644
3646 constexpr AnimationEncoder(const AnimationEncoder& other) = delete;
3647
3649 constexpr AnimationEncoder(AnimationEncoder&& other) noexcept
3650 : AnimationEncoder(other.release())
3651 {
3652 }
3653
3654 constexpr AnimationEncoder(const AnimationEncoderRef& other) = delete;
3655
3656 constexpr AnimationEncoder(AnimationEncoderRef&& other) = delete;
3657
3684
3714 AnimationEncoder(IOStreamRef dst, StringParam type, bool closeio = false);
3715
3764
3766 ~AnimationEncoder() { IMG_CloseAnimationEncoder(get()); }
3767
3769 constexpr AnimationEncoder& operator=(AnimationEncoder&& other) noexcept
3770 {
3771 swap(*this, other);
3772 return *this;
3773 }
3774
3777
3792 void Close();
3793
3811 void AddFrame(SurfaceRef surface, Uint64 duration);
3812};
3813
3840{
3841 return AnimationEncoder(std::move(file));
3842}
3843
3845 : AnimationEncoder(CheckError(IMG_CreateAnimationEncoder(file)))
3846{
3847}
3848
3850 StringParam type,
3851 bool closeio)
3853 CheckError(IMG_CreateAnimationEncoder_IO(dst, closeio, type)))
3854{
3855}
3856
3859 CheckError(IMG_CreateAnimationEncoderWithProperties(props)))
3860{
3861}
3862
3891 StringParam type,
3892 bool closeio = false)
3893{
3894 return AnimationEncoder(dst, std::move(type), closeio);
3895}
3896
3948
3955
3956constexpr auto CREATE_FILENAME_STRING =
3957 IMG_PROP_ANIMATION_ENCODER_CREATE_FILENAME_STRING;
3958
3959constexpr auto CREATE_IOSTREAM_POINTER =
3960 IMG_PROP_ANIMATION_ENCODER_CREATE_IOSTREAM_POINTER;
3961
3962constexpr auto CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN =
3963 IMG_PROP_ANIMATION_ENCODER_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN;
3964
3965constexpr auto CREATE_TYPE_STRING =
3966 IMG_PROP_ANIMATION_ENCODER_CREATE_TYPE_STRING;
3967
3968constexpr auto CREATE_QUALITY_NUMBER =
3969 IMG_PROP_ANIMATION_ENCODER_CREATE_QUALITY_NUMBER;
3970
3971constexpr auto CREATE_TIMEBASE_NUMERATOR_NUMBER =
3972 IMG_PROP_ANIMATION_ENCODER_CREATE_TIMEBASE_NUMERATOR_NUMBER;
3973
3974constexpr auto CREATE_TIMEBASE_DENOMINATOR_NUMBER =
3975 IMG_PROP_ANIMATION_ENCODER_CREATE_TIMEBASE_DENOMINATOR_NUMBER;
3976
3977constexpr auto CREATE_AVIF_MAX_THREADS_NUMBER =
3978 IMG_PROP_ANIMATION_ENCODER_CREATE_AVIF_MAX_THREADS_NUMBER;
3979
3980constexpr auto CREATE_AVIF_KEYFRAME_INTERVAL_NUMBER =
3981 IMG_PROP_ANIMATION_ENCODER_CREATE_AVIF_KEYFRAME_INTERVAL_NUMBER;
3982
3983constexpr auto CREATE_GIF_USE_LUT_BOOLEAN =
3984 IMG_PROP_ANIMATION_ENCODER_CREATE_GIF_USE_LUT_BOOLEAN;
3985
3986} // namespace prop::AnimationEncoder
3987
4007 SurfaceRef surface,
4008 Uint64 duration)
4009{
4010 CheckError(IMG_AddAnimationEncoderFrame(encoder, surface, duration));
4011}
4012
4013inline void AnimationEncoder::AddFrame(SurfaceRef surface, Uint64 duration)
4014{
4015 SDL::AddAnimationEncoderFrame(get(), surface, duration);
4016}
4017
4034{
4035 CheckError(IMG_CloseAnimationEncoder(encoder));
4036}
4037
4039
4045using AnimationDecoderStatus = IMG_AnimationDecoderStatus;
4046
4048 IMG_DECODER_STATUS_INVALID;
4049
4051 IMG_DECODER_STATUS_OK;
4052
4055 IMG_DECODER_STATUS_FAILED;
4056
4058 IMG_DECODER_STATUS_COMPLETE;
4059
4065struct AnimationDecoder : ResourceBase<AnimationDecoderRaw>
4066{
4068
4076 constexpr explicit AnimationDecoder(AnimationDecoderRaw resource) noexcept
4077 : ResourceBase(resource)
4078 {
4079 }
4080
4082 constexpr AnimationDecoder(const AnimationDecoder& other) = delete;
4083
4085 constexpr AnimationDecoder(AnimationDecoder&& other) noexcept
4086 : AnimationDecoder(other.release())
4087 {
4088 }
4089
4090 constexpr AnimationDecoder(const AnimationDecoderRef& other) = delete;
4091
4092 constexpr AnimationDecoder(AnimationDecoderRef&& other) = delete;
4093
4121
4152 AnimationDecoder(IOStreamRef src, StringParam type, bool closeio = false);
4153
4193
4195 ~AnimationDecoder() { IMG_CloseAnimationDecoder(get()); }
4196
4198 constexpr AnimationDecoder& operator=(AnimationDecoder&& other) noexcept
4199 {
4200 swap(*this, other);
4201 return *this;
4202 }
4203
4206
4221 void Close();
4222
4240
4264 Surface GetFrame(Uint64* duration);
4265
4277
4295 void Reset();
4296};
4297
4325{
4326 return AnimationDecoder(std::move(file));
4327}
4328
4330 : AnimationDecoder(CheckError(IMG_CreateAnimationDecoder(file)))
4331{
4332}
4333
4335 StringParam type,
4336 bool closeio)
4338 CheckError(IMG_CreateAnimationDecoder_IO(src, closeio, type)))
4339{
4340}
4341
4344 CheckError(IMG_CreateAnimationDecoderWithProperties(props)))
4345{
4346}
4347
4377 StringParam type,
4378 bool closeio = false)
4379{
4380 return AnimationDecoder(src, std::move(type), closeio);
4381}
4382
4426
4433
4434constexpr auto CREATE_FILENAME_STRING =
4435 IMG_PROP_ANIMATION_DECODER_CREATE_FILENAME_STRING;
4436
4437constexpr auto CREATE_IOSTREAM_POINTER =
4438 IMG_PROP_ANIMATION_DECODER_CREATE_IOSTREAM_POINTER;
4439
4440constexpr auto CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN =
4441 IMG_PROP_ANIMATION_DECODER_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN;
4442
4443constexpr auto CREATE_TYPE_STRING =
4444 IMG_PROP_ANIMATION_DECODER_CREATE_TYPE_STRING;
4445
4446constexpr auto CREATE_TIMEBASE_NUMERATOR_NUMBER =
4447 IMG_PROP_ANIMATION_DECODER_CREATE_TIMEBASE_NUMERATOR_NUMBER;
4448
4449constexpr auto CREATE_TIMEBASE_DENOMINATOR_NUMBER =
4450 IMG_PROP_ANIMATION_DECODER_CREATE_TIMEBASE_DENOMINATOR_NUMBER;
4451
4452constexpr auto CREATE_AVIF_MAX_THREADS_NUMBER =
4453 IMG_PROP_ANIMATION_DECODER_CREATE_AVIF_MAX_THREADS_NUMBER;
4454
4455constexpr auto CREATE_AVIF_ALLOW_INCREMENTAL_BOOLEAN =
4456 IMG_PROP_ANIMATION_DECODER_CREATE_AVIF_ALLOW_INCREMENTAL_BOOLEAN;
4457
4458constexpr auto CREATE_AVIF_ALLOW_PROGRESSIVE_BOOLEAN =
4459 IMG_PROP_ANIMATION_DECODER_CREATE_AVIF_ALLOW_PROGRESSIVE_BOOLEAN;
4460
4461constexpr auto CREATE_GIF_TRANSPARENT_COLOR_INDEX_NUMBER =
4462 IMG_PROP_ANIMATION_DECODER_CREATE_GIF_TRANSPARENT_COLOR_INDEX_NUMBER;
4463
4464constexpr auto CREATE_GIF_NUM_COLORS_NUMBER =
4465 IMG_PROP_ANIMATION_DECODER_CREATE_GIF_NUM_COLORS_NUMBER;
4466
4467} // namespace prop::AnimationDecoder
4468
4487{
4488 return IMG_GetAnimationDecoderProperties(decoder);
4489}
4490
4495
4503
4504constexpr auto IGNORE_PROPS_BOOLEAN = IMG_PROP_METADATA_IGNORE_PROPS_BOOLEAN;
4505
4506constexpr auto DESCRIPTION_STRING = IMG_PROP_METADATA_DESCRIPTION_STRING;
4507
4508constexpr auto COPYRIGHT_STRING = IMG_PROP_METADATA_COPYRIGHT_STRING;
4509
4510constexpr auto TITLE_STRING = IMG_PROP_METADATA_TITLE_STRING;
4511
4512constexpr auto AUTHOR_STRING = IMG_PROP_METADATA_AUTHOR_STRING;
4513
4514constexpr auto CREATION_TIME_STRING = IMG_PROP_METADATA_CREATION_TIME_STRING;
4515
4516constexpr auto FRAME_COUNT_NUMBER = IMG_PROP_METADATA_FRAME_COUNT_NUMBER;
4517
4518constexpr auto LOOP_COUNT_NUMBER = IMG_PROP_METADATA_LOOP_COUNT_NUMBER;
4519
4520} // namespace prop::Metadata
4521
4546 Uint64* duration)
4547{
4548 SDL_Surface* frame = nullptr;
4549 CheckError(IMG_GetAnimationDecoderFrame(decoder, &frame, duration));
4550 return Surface::Borrow(frame);
4551}
4552
4554{
4555 return SDL::GetAnimationDecoderFrame(get(), duration);
4556}
4557
4570 AnimationDecoderRef decoder)
4571{
4572 return IMG_GetAnimationDecoderStatus(decoder);
4573}
4574
4579
4599{
4600 CheckError(IMG_ResetAnimationDecoder(decoder));
4601}
4602
4604
4621{
4622 CheckError(IMG_CloseAnimationDecoder(decoder));
4623}
4624
4626
4627#endif // SDL_IMAGE_VERSION_ATLEAST(3, 4, 0)
4628
4630
4631} // namespace SDL
4632
4633#else // defined(SDL3PP_ENABLE_IMAGE) || defined(SDL3PP_DOC)
4634
4635namespace SDL {
4636
4637inline Surface::Surface(StringParam file)
4638 : Surface(LoadBMP(std::move(file)))
4639{
4640}
4641
4642inline Surface::Surface(IOStreamRef src, bool closeio)
4643 : Surface(LoadBMP_IO(std::move(src), closeio))
4644{
4645}
4646
4647inline Texture::Texture(RendererRef renderer, StringParam file)
4648 : Texture(std::move(renderer), Surface(std::move(file)))
4649{
4650}
4651
4652inline Texture::Texture(RendererRef renderer, IOStreamRef src, bool closeio)
4653 : Texture(std::move(renderer), Surface(std::move(src), closeio))
4654{
4655}
4656
4657} // namespace SDL
4658
4659#endif // defined(SDL3PP_ENABLE_IMAGE) || defined(SDL3PP_DOC)
4660
4661#endif /* SDL3PP_IMAGE_H_ */
An opaque handle representing a copy pass.
Definition SDL3pp_gpu.h:1743
An opaque handle representing a texture.
Definition SDL3pp_gpu.h:674
constexpr RawPointer get() const noexcept
Definition SDL3pp_resource.h:53
constexpr RawPointer release() noexcept
Definition SDL3pp_resource.h:56
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
Const reference wrapper for a given resource,.
Definition SDL3pp_resource.h:111
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
ResourceRef< GPUDevice > GPUDeviceRef
Reference for GPUDevice.
Definition SDL3pp_gpu.h:386
void Close()
Close and free an allocated IOStream structure.
Definition SDL3pp_iostream.h:1944
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
ResourceRef< IOStream > IOStreamRef
Reference for IOStream.
Definition SDL3pp_iostream.h:34
ResourceRef< Properties > PropertiesRef
Reference for Properties.
Definition SDL3pp_properties.h:54
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:1551
Surface LoadJXL_IO(IOStreamRef src)
Load a JXL image directly.
Definition SDL3pp_image.h:1625
Surface ReadXPMFromArrayToRGB888(char **xpm)
Load an XPM image from a memory array.
Definition SDL3pp_image.h:2210
AnimationEncoder CreateAnimationEncoderWithProperties(PropertiesRef props)
Create an animation encoder with the specified properties.
Definition SDL3pp_image.h:3943
void Save(StringParam filename) const
Save an Surface into an image file.
Definition SDL3pp_image.h:2246
int GetWidth() const
Get the width in pixels.
Definition SDL3pp_image.h:3012
Animation LoadWEBPAnimation_IO(IOStreamRef src)
Load a WEBP animation directly.
Definition SDL3pp_image.h:3324
bool isPNG(IOStreamRef src)
Detect PNG image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1062
Surface LoadPNG_IO(IOStreamRef src)
Load a PNG image directly.
Definition SDL3pp_image.h:1736
AnimationDecoder CreateAnimationDecoderWithProperties(PropertiesRef props)
Create an animation decoder with the specified properties.
Definition SDL3pp_image.h:4421
Surface ReadXPMFromArray(char **xpm)
Load an XPM image from a memory array.
Definition SDL3pp_image.h:2192
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:3235
void SaveAnimation(AnimationRef anim, StringParam file)
Save an animation to a file.
Definition SDL3pp_image.h:3349
ResourceRef< AnimationDecoder > AnimationDecoderRef
Reference for AnimationDecoder.
Definition SDL3pp_image.h:73
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:3618
void AddFrame(SurfaceRef surface, Uint64 duration)
Add a frame to an animation encoder.
Definition SDL3pp_image.h:4013
void SaveCUR(SurfaceRef surface, StringParam file)
Save an Surface into a CUR image file.
Definition SDL3pp_image.h:2362
Surface LoadWEBP_IO(IOStreamRef src)
Load a WEBP image directly.
Definition SDL3pp_image.h:2062
bool isTIF(IOStreamRef src)
Detect TIFF image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1234
int GetHeight() const
Get the height in pixels.
Definition SDL3pp_image.h:3017
AnimationEncoder CreateAnimationEncoder(StringParam file)
Create an encoder to save a series of images to a file.
Definition SDL3pp_image.h:3839
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:3489
Surface LoadPNG(StringParam file)
Load a PNG image from a file.
Definition SDL3pp_image.h:1814
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:359
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:2282
ResourceConstRef< AnimationRaw, AnimationRawConst > AnimationConstRef
Safely wrap Animation for non owning const parameters.
Definition SDL3pp_image.h:45
void SaveWEBP(SurfaceRef surface, StringParam file, float quality)
Save an Surface into a WEBP image file.
Definition SDL3pp_image.h:2643
bool isWEBP(IOStreamRef src)
Detect WEBP image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1277
Surface LoadGIF_IO(IOStreamRef src)
Load a GIF image directly.
Definition SDL3pp_image.h:1514
Surface LoadXPM_IO(IOStreamRef src)
Load a XPM image directly.
Definition SDL3pp_image.h:2136
Cursor CreateCursor(const PointRaw &hotspot)
Create an animated cursor from an animation.
Definition SDL3pp_image.h:3593
Surface LoadTIF_IO(IOStreamRef src)
Load a TIFF image directly.
Definition SDL3pp_image.h:2025
bool isXPM(IOStreamRef src)
Detect XPM image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1363
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:2670
bool isPCX(IOStreamRef src)
Detect PCX image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1019
Surface GetAnimationFrame(AnimationConstRef anim, int index)
Return the frame image under given index.
Definition SDL3pp_image.h:3041
bool isJXL(IOStreamRef src)
Detect JXL image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:933
int GetDelay(int index) const
Return the frame delay under given index.
Definition SDL3pp_image.h:3062
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:976
bool isICO(IOStreamRef src)
Detect ICO image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:847
void AddAnimationEncoderFrame(AnimationEncoderRef encoder, SurfaceRef surface, Uint64 duration)
Add a frame to an animation encoder.
Definition SDL3pp_image.h:4006
void SaveANI_IO(IOStreamRef dst, bool closeio=false)
Save an animation in ANI format to an IOStream.
Definition SDL3pp_image.h:3428
Surface GetAnimationDecoderFrame(AnimationDecoderRef decoder, Uint64 *duration)
Get the next frame in an animation decoder.
Definition SDL3pp_image.h:4545
bool isPNM(IOStreamRef src)
Detect PNM image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1105
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:2339
IMG_AnimationDecoderStatus AnimationDecoderStatus
An enum representing the status of an animation decoder.
Definition SDL3pp_image.h:4045
int GetAnimationDelay(AnimationConstRef anim, int index)
Return the frame delay under given index.
Definition SDL3pp_image.h:3057
Surface LoadTGA_IO(IOStreamRef src)
Load a TGA image directly.
Definition SDL3pp_image.h:1988
void Close()
Close an animation encoder, finishing any encoding.
Definition SDL3pp_image.h:4038
void SaveAVIF(SurfaceRef surface, StringParam file, int quality)
Save an Surface into a AVIF image file.
Definition SDL3pp_image.h:2314
Surface GetFrame(Uint64 *duration)
Get the next frame in an animation decoder.
Definition SDL3pp_image.h:4553
Animation LoadAnimation(StringParam file)
Load an animation from a file.
Definition SDL3pp_image.h:3088
void Save(SurfaceConstRef surface, StringParam file)
Save an Surface into an image file.
Definition SDL3pp_image.h:2241
Surface LoadXCF_IO(IOStreamRef src)
Load a XCF image directly.
Definition SDL3pp_image.h:2099
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:2520
void SaveTGA_IO(SurfaceRef surface, IOStreamRef dst, bool closeio=false)
Save an Surface into TGA image data, via an IOStream.
Definition SDL3pp_image.h:2619
int GetAnimationCount(AnimationConstRef anim)
Return the number of frames.
Definition SDL3pp_image.h:3031
Surface GetClipboardImage()
Load an image from an SDL data source into a GPU texture.
Definition SDL3pp_image.h:587
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:2290
void SaveJPG(SurfaceRef surface, StringParam file, int quality)
Save an Surface into a JPEG image file.
Definition SDL3pp_image.h:2495
bool isJPG(IOStreamRef src)
Detect JPG image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:890
Cursor CreateAnimatedCursor(AnimationRef anim, const PointRaw &hotspot)
Create an animated cursor from an animation.
Definition SDL3pp_image.h:3587
void SaveICO_IO(SurfaceRef surface, IOStreamRef dst, bool closeio=false)
Save an Surface into ICO image data, via an IOStream.
Definition SDL3pp_image.h:2471
void CloseAnimationDecoder(AnimationDecoderRaw decoder)
Close an animation decoder, finishing any decoding.
Definition SDL3pp_image.h:4620
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:3890
IMG_Animation * AnimationRaw
Alias to raw representation for Animation.
Definition SDL3pp_image.h:32
Surface LoadLBM_IO(IOStreamRef src)
Load a LBM image directly.
Definition SDL3pp_image.h:1662
IMG_AnimationDecoder * AnimationDecoderRaw
Alias to raw representation for AnimationDecoder.
Definition SDL3pp_image.h:66
Surface LoadCUR_IO(IOStreamRef src)
Load a CUR image directly.
Definition SDL3pp_image.h:1477
bool isXCF(IOStreamRef src)
Detect XCF image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1320
void ResetAnimationDecoder(AnimationDecoderRef decoder)
Reset an animation decoder.
Definition SDL3pp_image.h:4598
void SavePNG_IO(SurfaceRef surface, IOStreamRef dst, bool closeio=false)
Save an Surface into PNG image data, via an IOStream.
Definition SDL3pp_image.h:2569
void Free()
Dispose of an Animation and free its resources.
Definition SDL3pp_image.h:3620
ResourceRef< AnimationEncoder > AnimationEncoderRef
Reference for AnimationEncoder.
Definition SDL3pp_image.h:60
void SaveGIF(SurfaceRef surface, StringParam file)
Save an Surface into a GIF image file.
Definition SDL3pp_image.h:2405
void SaveGIF_IO(IOStreamRef dst, bool closeio=false)
Save an animation in GIF format to an IOStream.
Definition SDL3pp_image.h:3530
void SaveICO(SurfaceRef surface, StringParam file)
Save an Surface into a ICO image file.
Definition SDL3pp_image.h:2448
bool isANI(IOStreamRef src)
Detect ANI animated cursor data on a readable/seekable IOStream.
Definition SDL3pp_image.h:630
void SaveTGA(SurfaceRef surface, StringParam file)
Save an Surface into a TGA image file.
Definition SDL3pp_image.h:2596
bool isSVG(IOStreamRef src)
Detect SVG image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1191
PropertiesRef GetAnimationDecoderProperties(AnimationDecoderRef decoder)
Get the properties of an animation decoder.
Definition SDL3pp_image.h:4486
Surface LoadXV_IO(IOStreamRef src)
Load a XV image directly.
Definition SDL3pp_image.h:2173
void SaveWEBP_IO(IOStreamRef dst, int quality, bool closeio=false)
Save an animation in WEBP format to an IOStream.
Definition SDL3pp_image.h:3568
Surface GetFrame(int index) const
Return the frame image under given index.
Definition SDL3pp_image.h:3046
void Close()
Close an animation decoder, finishing any decoding.
Definition SDL3pp_image.h:4625
Surface LoadSVG_IO(IOStreamRef src)
Load a SVG image directly.
Definition SDL3pp_image.h:1889
void SavePNG(SurfaceRef surface, StringParam file)
Save an Surface into a PNG image file.
Definition SDL3pp_image.h:2541
bool isBMP(IOStreamRef src)
Detect BMP image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:761
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:3560
Surface LoadPCX_IO(IOStreamRef src)
Load a PCX image directly.
Definition SDL3pp_image.h:1699
const IMG_Animation * AnimationRawConst
Alias to const raw representation for Animation.
Definition SDL3pp_image.h:35
ResourceRef< Animation > AnimationRef
Reference for Animation.
Definition SDL3pp_image.h:42
void SaveCUR_IO(SurfaceRef surface, IOStreamRef dst, bool closeio=false)
Save an Surface into CUR image data, via an IOStream.
Definition SDL3pp_image.h:2385
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:270
Surface LoadPNM_IO(IOStreamRef src)
Load a PNM image directly.
Definition SDL3pp_image.h:1851
void SavePNG(StringParam file) const
Save a surface to a file in PNG format.
Definition SDL3pp_image.h:2546
AnimationDecoderStatus GetAnimationDecoderStatus(AnimationDecoderRef decoder)
Get the decoder status indicating the current state of the decoder.
Definition SDL3pp_image.h:4569
void SaveANIAnimation_IO(AnimationRef anim, IOStreamRef dst, bool closeio=false)
Save an animation in ANI format to an IOStream.
Definition SDL3pp_image.h:3421
void SaveAnimationTyped_IO(AnimationRef anim, IOStreamRef dst, StringParam type, bool closeio=false)
Save an animation to an IOStream.
Definition SDL3pp_image.h:3385
Surface LoadAVIF_IO(IOStreamRef src)
Load a AVIF image directly.
Definition SDL3pp_image.h:1440
constexpr AnimationDecoderStatus DECODER_STATUS_OK
The decoder is ready to decode the next frame.
Definition SDL3pp_image.h:4050
bool isXV(IOStreamRef src)
Detect XV image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1406
Texture LoadTexture(RendererRef renderer, StringParam file)
Load an image from a filesystem path into a texture.
Definition SDL3pp_image.h:305
void SaveGIF_IO(SurfaceRef surface, IOStreamRef dst, bool closeio=false)
Save an Surface into GIF image data, via an IOStream.
Definition SDL3pp_image.h:2428
Surface LoadSurface_IO(IOStreamRef src, bool closeio=false)
Load an image from an SDL data source into a software surface.
Definition SDL3pp_image.h:212
int GetAnimationWidth(AnimationConstRef anim)
Get the width in pixels.
Definition SDL3pp_image.h:3010
constexpr AnimationDecoderStatus DECODER_STATUS_COMPLETE
No more frames available.
Definition SDL3pp_image.h:4057
bool isQOI(IOStreamRef src)
Detect QOI image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:1148
constexpr AnimationDecoderStatus DECODER_STATUS_FAILED
The decoder failed to decode a frame, call GetError() for more information.
Definition SDL3pp_image.h:4054
Animation LoadANIAnimation_IO(IOStreamRef src)
Load an ANI animation directly from an IOStream.
Definition SDL3pp_image.h:3204
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:4376
int GetCount() const
Return the number of frames.
Definition SDL3pp_image.h:3033
Animation LoadAVIFAnimation_IO(IOStreamRef src)
Load an AVIF animation directly from an IOStream.
Definition SDL3pp_image.h:3266
void Reset()
Reset an animation decoder.
Definition SDL3pp_image.h:4603
AnimationDecoderStatus GetStatus()
Get the decoder status indicating the current state of the decoder.
Definition SDL3pp_image.h:4575
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:2576
void SaveTyped_IO(IOStreamRef dst, StringParam type, bool closeio=false)
Save an animation to an IOStream.
Definition SDL3pp_image.h:3393
Animation LoadAnimationTyped_IO(IOStreamRef src, StringParam type, bool closeio=false)
Load an animation from an IOStream.
Definition SDL3pp_image.h:3169
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:413
bool isAVIF(IOStreamRef src)
Detect AVIF image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:675
Surface LoadQOI_IO(IOStreamRef src)
Load a QOI image directly.
Definition SDL3pp_image.h:1951
Surface LoadSizedSVG_IO(IOStreamRef src, const PointRaw &size)
Load an SVG image, scaled to a specific size.
Definition SDL3pp_image.h:1914
Surface LoadJPG_IO(IOStreamRef src)
Load a JPG image directly.
Definition SDL3pp_image.h:1588
bool isGIF(IOStreamRef src)
Detect GIF image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:804
void SaveGIFAnimation_IO(AnimationRef anim, IOStreamRef dst, bool closeio=false)
Save an animation in GIF format to an IOStream.
Definition SDL3pp_image.h:3523
constexpr AnimationDecoderStatus DECODER_STATUS_INVALID
The decoder is invalid.
Definition SDL3pp_image.h:4047
void SaveAPNGAnimation_IO(AnimationRef anim, IOStreamRef dst, bool closeio=false)
Save an animation in APNG format to an IOStream.
Definition SDL3pp_image.h:3454
void SaveAVIF_IO(IOStreamRef dst, int quality, bool closeio=false)
Save an animation in AVIF format to an IOStream.
Definition SDL3pp_image.h:3497
bool isCUR(IOStreamRef src)
Detect CUR image data on a readable/seekable IOStream.
Definition SDL3pp_image.h:718
PropertiesRef GetProperties()
Get the properties of an animation decoder.
Definition SDL3pp_image.h:4491
Surface LoadSurface(StringParam file)
Load an image from a filesystem path into a software surface.
Definition SDL3pp_image.h:155
AnimationDecoder CreateAnimationDecoder(StringParam file)
Create a decoder to read a series of images from a file.
Definition SDL3pp_image.h:4324
Animation LoadGIFAnimation_IO(IOStreamRef src)
Load a GIF animation directly.
Definition SDL3pp_image.h:3296
void SaveAPNG_IO(IOStreamRef dst, bool closeio=false)
Save an animation in APNG format to an IOStream.
Definition SDL3pp_image.h:3461
void CloseAnimationEncoder(AnimationEncoderRaw encoder)
Close an animation encoder, finishing any encoding.
Definition SDL3pp_image.h:4033
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:454
IMG_AnimationEncoder * AnimationEncoderRaw
Alias to raw representation for AnimationEncoder.
Definition SDL3pp_image.h:53
void Save(StringParam file)
Save an animation to a file.
Definition SDL3pp_image.h:3354
Point GetSize() const
Get the size in pixels.
Definition SDL3pp_image.h:3028
::Uint64 Uint64
An unsigned 64-bit integer type.
Definition SDL3pp_stdinc.h:320
Surface LoadBMP_IO(IOStreamRef src, bool closeio=false)
Load a BMP image from a seekable SDL data stream.
Definition SDL3pp_surface.h:2695
Surface LoadBMP(StringParam file)
Load a BMP image from a file.
Definition SDL3pp_surface.h:2718
ResourceConstRef< SurfaceRaw, SurfaceRawConst > SurfaceConstRef
Safely wrap Surface for non owning const parameters.
Definition SDL3pp_surface.h:57
ResourceRef< Surface > SurfaceRef
Reference for Surface.
Definition SDL3pp_surface.h:54
ResourceRef< Renderer > RendererRef
Reference for Renderer.
Definition SDL3pp_video.h:75
Supported properties for creating an animation decoder.
Definition SDL3pp_image.h:4432
Supported properties for creating an animation encoder.
Definition SDL3pp_image.h:3954
Animation metadata properties.
Definition SDL3pp_image.h:4502
Main include header for the SDL3pp library.
An object representing animation decoder.
Definition SDL3pp_image.h:4066
constexpr AnimationDecoder & operator=(AnimationDecoder &&other) noexcept
Assignment operator.
Definition SDL3pp_image.h:4198
constexpr AnimationDecoder(const AnimationDecoder &other)=delete
Copy constructor.
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
AnimationDecoder & operator=(const AnimationDecoder &other)=delete
Assignment operator.
constexpr AnimationDecoder(AnimationDecoderRaw resource) noexcept
Constructs from raw AnimationDecoder.
Definition SDL3pp_image.h:4076
~AnimationDecoder()
Destructor.
Definition SDL3pp_image.h:4195
constexpr AnimationDecoder(AnimationDecoder &&other) noexcept
Move constructor.
Definition SDL3pp_image.h:4085
An object representing the encoder context.
Definition SDL3pp_image.h:3630
constexpr AnimationEncoder(const AnimationEncoder &other)=delete
Copy constructor.
constexpr AnimationEncoder & operator=(AnimationEncoder &&other) noexcept
Assignment operator.
Definition SDL3pp_image.h:3769
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
~AnimationEncoder()
Destructor.
Definition SDL3pp_image.h:3766
constexpr AnimationEncoder(AnimationEncoder &&other) noexcept
Move constructor.
Definition SDL3pp_image.h:3649
AnimationEncoder & operator=(const AnimationEncoder &other)=delete
Assignment operator.
constexpr AnimationEncoder(AnimationEncoderRaw resource) noexcept
Constructs from raw AnimationEncoder.
Definition SDL3pp_image.h:3640
Animated image support.
Definition SDL3pp_image.h:2686
constexpr Animation(Animation &&other) noexcept
Move constructor.
Definition SDL3pp_image.h:2705
~Animation()
Destructor.
Definition SDL3pp_image.h:2770
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
Animation & operator=(const Animation &other)=delete
Assignment operator.
constexpr Animation & operator=(Animation &&other) noexcept
Assignment operator.
Definition SDL3pp_image.h:2773
constexpr Animation(const Animation &other)=delete
Copy constructor.
constexpr Animation(AnimationRaw resource) noexcept
Constructs from raw Animation.
Definition SDL3pp_image.h:2696
The structure used to identify an SDL cursor.
Definition SDL3pp_mouse.h:159
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:156
A collection of pixels used in software blitting.
Definition SDL3pp_surface.h:172
constexpr Surface(SurfaceRaw resource) noexcept
Constructs from raw Surface.
Definition SDL3pp_surface.h:182
static Surface Borrow(SurfaceRaw resource)
Safely borrows the from SurfaceRaw.
Definition SDL3pp_surface.h:340
An efficient driver-specific representation of pixel data.
Definition SDL3pp_render.h:2249
constexpr Texture(TextureRaw resource) noexcept
Constructs from raw Texture.
Definition SDL3pp_render.h:2259