SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
SDL3pp_pixels.h
1#ifndef SDL3PP_PIXELS_H_
2#define SDL3PP_PIXELS_H_
3
4#include <SDL3/SDL_pixels.h>
5#include "SDL3pp_error.h"
6#include "SDL3pp_spanRef.h"
7#include "SDL3pp_version.h"
8
9namespace SDL {
10
71using PixelFormatRaw = SDL_PixelFormat;
72
73// Forward decl
74struct PixelFormat;
75
77using ColorspaceRaw = SDL_Colorspace;
78
79// Forward decl
80struct Colorspace;
81
83using ColorRaw = SDL_Color;
84
85// Forward decl
86struct Color;
87
89using FColorRaw = SDL_FColor;
90
91// Forward decl
92struct FColor;
93
94// Forward decl
95struct Palette;
96
98using PaletteRaw = SDL_Palette*;
99
100// Forward decl
101struct PaletteRef;
102
105{
107
110 : value(value)
111 {
112 }
113
115 constexpr PaletteParam(std::nullptr_t = nullptr)
116 : value(nullptr)
117 {
118 }
119
121 constexpr explicit operator bool() const { return !!value; }
122
124 constexpr auto operator<=>(const PaletteParam& other) const = default;
125
127 constexpr operator PaletteRaw() const { return value; }
128
130 constexpr auto operator->() { return value; }
131};
132
135{
137
140 : value(value)
141 {
142 }
143
146 : value(value.value)
147 {
148 }
149
151 constexpr PaletteConstParam(std::nullptr_t = nullptr)
152 : value(nullptr)
153 {
154 }
155
157 constexpr explicit operator bool() const { return !!value; }
158
160 constexpr auto operator<=>(const PaletteConstParam& other) const = default;
161
163 constexpr operator const PaletteRaw() const { return value; }
164
166 constexpr auto operator->() { return value; }
167};
168
174using PixelFormatDetails = SDL_PixelFormatDetails;
175
183constexpr Uint8 ALPHA_OPAQUE = SDL_ALPHA_OPAQUE;
184
192constexpr float ALPHA_OPAQUE_FLOAT = SDL_ALPHA_OPAQUE_FLOAT;
193
201constexpr Uint8 ALPHA_TRANSPARENT = SDL_ALPHA_TRANSPARENT;
202
210constexpr float ALPHA_TRANSPARENT_FLOAT = SDL_ALPHA_TRANSPARENT_FLOAT;
211
224using PixelType = SDL_PixelType;
225
226constexpr PixelType PIXELTYPE_UNKNOWN = SDL_PIXELTYPE_UNKNOWN;
227
228constexpr PixelType PIXELTYPE_INDEX1 = SDL_PIXELTYPE_INDEX1;
229
230constexpr PixelType PIXELTYPE_INDEX4 = SDL_PIXELTYPE_INDEX4;
231
232constexpr PixelType PIXELTYPE_INDEX8 = SDL_PIXELTYPE_INDEX8;
233
234constexpr PixelType PIXELTYPE_PACKED8 = SDL_PIXELTYPE_PACKED8;
235
236constexpr PixelType PIXELTYPE_PACKED16 = SDL_PIXELTYPE_PACKED16;
237
238constexpr PixelType PIXELTYPE_PACKED32 = SDL_PIXELTYPE_PACKED32;
239
240constexpr PixelType PIXELTYPE_ARRAYU8 = SDL_PIXELTYPE_ARRAYU8;
241
242constexpr PixelType PIXELTYPE_ARRAYU16 = SDL_PIXELTYPE_ARRAYU16;
243
244constexpr PixelType PIXELTYPE_ARRAYU32 = SDL_PIXELTYPE_ARRAYU32;
245
246constexpr PixelType PIXELTYPE_ARRAYF16 = SDL_PIXELTYPE_ARRAYF16;
247
248constexpr PixelType PIXELTYPE_ARRAYF32 = SDL_PIXELTYPE_ARRAYF32;
249
250constexpr PixelType PIXELTYPE_INDEX2 = SDL_PIXELTYPE_INDEX2;
251
253
264using BitmapOrder = SDL_BitmapOrder;
265
266constexpr BitmapOrder BITMAPORDER_NONE = SDL_BITMAPORDER_NONE;
267
268constexpr BitmapOrder BITMAPORDER_4321 = SDL_BITMAPORDER_4321;
269
270constexpr BitmapOrder BITMAPORDER_1234 = SDL_BITMAPORDER_1234;
271
273
284using PackedOrder = SDL_PackedOrder;
285
286constexpr PackedOrder PACKEDORDER_NONE = SDL_PACKEDORDER_NONE;
287
288constexpr PackedOrder PACKEDORDER_XRGB = SDL_PACKEDORDER_XRGB;
289
290constexpr PackedOrder PACKEDORDER_RGBX = SDL_PACKEDORDER_RGBX;
291
292constexpr PackedOrder PACKEDORDER_ARGB = SDL_PACKEDORDER_ARGB;
293
294constexpr PackedOrder PACKEDORDER_RGBA = SDL_PACKEDORDER_RGBA;
295
296constexpr PackedOrder PACKEDORDER_XBGR = SDL_PACKEDORDER_XBGR;
297
298constexpr PackedOrder PACKEDORDER_BGRX = SDL_PACKEDORDER_BGRX;
299
300constexpr PackedOrder PACKEDORDER_ABGR = SDL_PACKEDORDER_ABGR;
301
302constexpr PackedOrder PACKEDORDER_BGRA = SDL_PACKEDORDER_BGRA;
303
305
316using ArrayOrder = SDL_ArrayOrder;
317
318constexpr ArrayOrder ARRAYORDER_NONE = SDL_ARRAYORDER_NONE;
319
320constexpr ArrayOrder ARRAYORDER_RGB = SDL_ARRAYORDER_RGB;
321
322constexpr ArrayOrder ARRAYORDER_RGBA = SDL_ARRAYORDER_RGBA;
323
324constexpr ArrayOrder ARRAYORDER_ARGB = SDL_ARRAYORDER_ARGB;
325
326constexpr ArrayOrder ARRAYORDER_BGR = SDL_ARRAYORDER_BGR;
327
328constexpr ArrayOrder ARRAYORDER_BGRA = SDL_ARRAYORDER_BGRA;
329
330constexpr ArrayOrder ARRAYORDER_ABGR = SDL_ARRAYORDER_ABGR;
331
333
344using PackedLayout = SDL_PackedLayout;
345
346constexpr PackedLayout PACKEDLAYOUT_NONE = SDL_PACKEDLAYOUT_NONE;
347
348constexpr PackedLayout PACKEDLAYOUT_332 = SDL_PACKEDLAYOUT_332;
349
350constexpr PackedLayout PACKEDLAYOUT_4444 = SDL_PACKEDLAYOUT_4444;
351
352constexpr PackedLayout PACKEDLAYOUT_1555 = SDL_PACKEDLAYOUT_1555;
353
354constexpr PackedLayout PACKEDLAYOUT_5551 = SDL_PACKEDLAYOUT_5551;
355
356constexpr PackedLayout PACKEDLAYOUT_565 = SDL_PACKEDLAYOUT_565;
357
358constexpr PackedLayout PACKEDLAYOUT_8888 = SDL_PACKEDLAYOUT_8888;
359
361 SDL_PACKEDLAYOUT_2101010;
362
364 SDL_PACKEDLAYOUT_1010102;
365
367
414{
415 PixelFormatRaw m_format;
416
417public:
423 constexpr PixelFormat(PixelFormatRaw format = {}) noexcept
424 : m_format(format)
425 {
426 }
427
451 constexpr PixelFormat(PixelType type,
452 int order,
453 PackedLayout layout,
454 int bits,
455 int bytes)
456 : m_format(PixelFormatRaw(
457 SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes)))
458 {
459 }
460
466 constexpr operator PixelFormatRaw() const noexcept { return m_format; }
467
487 static PixelFormat ForMasks(int bpp,
488 Uint32 Rmask,
489 Uint32 Gmask,
490 Uint32 Bmask,
491 Uint32 Amask);
492
505 constexpr Uint8 GetFlags() const;
506
516 constexpr PixelType GetType() const;
517
530 constexpr int GetOrder() const;
531
544 constexpr PackedLayout GetLayout() const;
545
560 constexpr int GetBitsPerPixel() const;
561
579 constexpr int GetBytesPerPixel() const;
580
590 constexpr bool IsIndexed() const;
591
601 constexpr bool IsPacked() const;
602
612 constexpr bool IsArray() const;
613
623 constexpr bool Is10Bit() const;
624
634 constexpr bool IsFloat() const;
635
645 constexpr bool IsAlpha() const;
646
658 constexpr bool IsFourCC() const;
659
670 const char* GetName() const;
671
688 void GetMasks(int* bpp,
689 Uint32* Rmask,
690 Uint32* Gmask,
691 Uint32* Bmask,
692 Uint32* Amask) const;
693
708 const PixelFormatDetails& GetDetails() const;
709
711 operator const PixelFormatDetails&() const;
712
745 Uint32 Map(ColorRaw c, PaletteConstParam palette = {}) const;
746
771 Color Get(Uint32 pixel, PaletteConstParam palette = {}) const;
772};
773
775 SDL_PIXELFORMAT_UNKNOWN;
776
778 SDL_PIXELFORMAT_INDEX1LSB;
779
781 SDL_PIXELFORMAT_INDEX1MSB;
782
784 SDL_PIXELFORMAT_INDEX2LSB;
785
787 SDL_PIXELFORMAT_INDEX2MSB;
788
790 SDL_PIXELFORMAT_INDEX4LSB;
791
793 SDL_PIXELFORMAT_INDEX4MSB;
794
795constexpr PixelFormat PIXELFORMAT_INDEX8 = SDL_PIXELFORMAT_INDEX8;
796
797constexpr PixelFormat PIXELFORMAT_RGB332 = SDL_PIXELFORMAT_RGB332;
798
800 SDL_PIXELFORMAT_XRGB4444;
801
803 SDL_PIXELFORMAT_XBGR4444;
804
806 SDL_PIXELFORMAT_XRGB1555;
807
809 SDL_PIXELFORMAT_XBGR1555;
810
812 SDL_PIXELFORMAT_ARGB4444;
813
815 SDL_PIXELFORMAT_RGBA4444;
816
818 SDL_PIXELFORMAT_ABGR4444;
819
821 SDL_PIXELFORMAT_BGRA4444;
822
824 SDL_PIXELFORMAT_ARGB1555;
825
827 SDL_PIXELFORMAT_RGBA5551;
828
830 SDL_PIXELFORMAT_ABGR1555;
831
833 SDL_PIXELFORMAT_BGRA5551;
834
835constexpr PixelFormat PIXELFORMAT_RGB565 = SDL_PIXELFORMAT_RGB565;
836
837constexpr PixelFormat PIXELFORMAT_BGR565 = SDL_PIXELFORMAT_BGR565;
838
839constexpr PixelFormat PIXELFORMAT_RGB24 = SDL_PIXELFORMAT_RGB24;
840
841constexpr PixelFormat PIXELFORMAT_BGR24 = SDL_PIXELFORMAT_BGR24;
842
844 SDL_PIXELFORMAT_XRGB8888;
845
847 SDL_PIXELFORMAT_RGBX8888;
848
850 SDL_PIXELFORMAT_XBGR8888;
851
853 SDL_PIXELFORMAT_BGRX8888;
854
856 SDL_PIXELFORMAT_ARGB8888;
857
859 SDL_PIXELFORMAT_RGBA8888;
860
862 SDL_PIXELFORMAT_ABGR8888;
863
865 SDL_PIXELFORMAT_BGRA8888;
866
868 SDL_PIXELFORMAT_XRGB2101010;
869
871 SDL_PIXELFORMAT_XBGR2101010;
872
874 SDL_PIXELFORMAT_ARGB2101010;
875
877 SDL_PIXELFORMAT_ABGR2101010;
878
879constexpr PixelFormat PIXELFORMAT_RGB48 = SDL_PIXELFORMAT_RGB48;
880
881constexpr PixelFormat PIXELFORMAT_BGR48 = SDL_PIXELFORMAT_BGR48;
882
883constexpr PixelFormat PIXELFORMAT_RGBA64 = SDL_PIXELFORMAT_RGBA64;
884
885constexpr PixelFormat PIXELFORMAT_ARGB64 = SDL_PIXELFORMAT_ARGB64;
886
887constexpr PixelFormat PIXELFORMAT_BGRA64 = SDL_PIXELFORMAT_BGRA64;
888
889constexpr PixelFormat PIXELFORMAT_ABGR64 = SDL_PIXELFORMAT_ABGR64;
890
892 SDL_PIXELFORMAT_RGB48_FLOAT;
893
895 SDL_PIXELFORMAT_BGR48_FLOAT;
896
898 SDL_PIXELFORMAT_RGBA64_FLOAT;
899
901 SDL_PIXELFORMAT_ARGB64_FLOAT;
902
904 SDL_PIXELFORMAT_BGRA64_FLOAT;
905
907 SDL_PIXELFORMAT_ABGR64_FLOAT;
908
910 SDL_PIXELFORMAT_RGB96_FLOAT;
911
913 SDL_PIXELFORMAT_BGR96_FLOAT;
914
916 SDL_PIXELFORMAT_RGBA128_FLOAT;
917
919 SDL_PIXELFORMAT_ARGB128_FLOAT;
920
922 SDL_PIXELFORMAT_BGRA128_FLOAT;
923
925 SDL_PIXELFORMAT_ABGR128_FLOAT;
926
928 SDL_PIXELFORMAT_YV12;
929
931 SDL_PIXELFORMAT_IYUV;
932
934 SDL_PIXELFORMAT_YUY2;
935
937 SDL_PIXELFORMAT_UYVY;
938
940 SDL_PIXELFORMAT_YVYU;
941
943 SDL_PIXELFORMAT_NV12;
944
946 SDL_PIXELFORMAT_NV21;
947
949 SDL_PIXELFORMAT_P010;
950
952 SDL_PIXELFORMAT_EXTERNAL_OES;
953
954#if SDL_VERSION_ATLEAST(3, 2, 10)
955
956constexpr PixelFormat PIXELFORMAT_MJPG = SDL_PIXELFORMAT_MJPG;
957
958#endif // SDL_VERSION_ATLEAST(3, 2, 10)
959
960constexpr PixelFormat PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_RGBA32;
961
962constexpr PixelFormat PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_ARGB32;
963
964constexpr PixelFormat PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_BGRA32;
965
966constexpr PixelFormat PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_ABGR32;
967
968constexpr PixelFormat PIXELFORMAT_RGBX32 = SDL_PIXELFORMAT_RGBX32;
969
970constexpr PixelFormat PIXELFORMAT_XRGB32 = SDL_PIXELFORMAT_XRGB32;
971
972constexpr PixelFormat PIXELFORMAT_BGRX32 = SDL_PIXELFORMAT_BGRX32;
973
974constexpr PixelFormat PIXELFORMAT_XBGR32 = SDL_PIXELFORMAT_XBGR32;
975
977
998{
999 return SDL_DEFINE_PIXELFOURCC(A, B, C, D);
1000}
1001
1026 int order,
1027 PackedLayout layout,
1028 int bits,
1029 int bytes)
1030{
1031 return PixelFormat(type, order, layout, bits, bytes);
1032}
1033
1048{
1049 return SDL_PIXELFLAG(format);
1050}
1051
1053{
1054 return SDL::PixelFormatFlags(m_format);
1055}
1056
1070{
1071 return PixelType(SDL_PIXELTYPE(format));
1072}
1073
1075{
1076 return SDL::PixelFormatType(m_format);
1077}
1078
1093{
1094 return SDL_PIXELORDER(format);
1095}
1096
1097constexpr int PixelFormat::GetOrder() const
1098{
1099 return SDL::PixelFormatOrder(m_format);
1100}
1101
1116{
1117 return PackedLayout(SDL_PIXELLAYOUT(format));
1118}
1119
1121{
1122 return SDL::PixelFormatLayout(m_format);
1123}
1124
1144{
1145 return SDL_BITSPERPIXEL(format);
1146}
1147
1148constexpr int PixelFormat::GetBitsPerPixel() const
1149{
1150 return SDL::PixelFormatBitsPerPixel(m_format);
1151}
1152
1172{
1173 return SDL_BYTESPERPIXEL(format);
1174}
1175
1177{
1178 return SDL::PixelFormatBytesPerPixel(m_format);
1179}
1180
1195{
1196 return SDL_ISPIXELFORMAT_INDEXED(format);
1197}
1198
1199constexpr bool PixelFormat::IsIndexed() const
1200{
1201 return SDL::IsPixelFormatIndexed(m_format);
1202}
1203
1218{
1219 return SDL_ISPIXELFORMAT_PACKED(format);
1220}
1221
1222constexpr bool PixelFormat::IsPacked() const
1223{
1224 return SDL::IsPixelFormatPacked(m_format);
1225}
1226
1241{
1242 return SDL_ISPIXELFORMAT_ARRAY(format);
1243}
1244
1245constexpr bool PixelFormat::IsArray() const
1246{
1247 return SDL::IsPixelFormatArray(m_format);
1248}
1249
1264{
1265 return SDL_ISPIXELFORMAT_10BIT(format);
1266}
1267
1268constexpr bool PixelFormat::Is10Bit() const
1269{
1270 return SDL::IsPixelFormat10Bit(m_format);
1271}
1272
1287{
1288 return SDL_ISPIXELFORMAT_FLOAT(format);
1289}
1290
1291constexpr bool PixelFormat::IsFloat() const
1292{
1293 return SDL::IsPixelFormatFloat(m_format);
1294}
1295
1315{
1316 return SDL_ISPIXELFORMAT_ALPHA(format);
1317}
1318
1319constexpr bool PixelFormat::IsAlpha() const
1320{
1321 return SDL::IsPixelFormatAlpha(m_format);
1322}
1323
1340{
1341 return SDL_ISPIXELFORMAT_FOURCC(format);
1342}
1343
1344constexpr bool PixelFormat::IsFourCC() const
1345{
1346 return SDL::IsPixelFormatFourCC(m_format);
1347}
1348
1354using ColorType = SDL_ColorType;
1355
1357 SDL_COLOR_TYPE_UNKNOWN;
1358
1359constexpr ColorType COLOR_TYPE_RGB = SDL_COLOR_TYPE_RGB;
1360
1362 SDL_COLOR_TYPE_YCBCR;
1363
1365
1377using ColorRange = SDL_ColorRange;
1378
1380 SDL_COLOR_RANGE_UNKNOWN;
1381
1385constexpr ColorRange COLOR_RANGE_LIMITED = SDL_COLOR_RANGE_LIMITED;
1386
1388constexpr ColorRange COLOR_RANGE_FULL = SDL_COLOR_RANGE_FULL;
1389
1391
1403using ColorPrimaries = SDL_ColorPrimaries;
1404
1406 SDL_COLOR_PRIMARIES_UNKNOWN;
1407
1409 SDL_COLOR_PRIMARIES_BT709;
1410
1412 SDL_COLOR_PRIMARIES_UNSPECIFIED;
1413
1415 SDL_COLOR_PRIMARIES_BT470M;
1416
1418 SDL_COLOR_PRIMARIES_BT470BG;
1420
1422 SDL_COLOR_PRIMARIES_BT601;
1423
1426 SDL_COLOR_PRIMARIES_SMPTE240;
1427
1429 SDL_COLOR_PRIMARIES_GENERIC_FILM;
1431
1433 SDL_COLOR_PRIMARIES_BT2020;
1434
1436 SDL_COLOR_PRIMARIES_XYZ;
1437
1439 SDL_COLOR_PRIMARIES_SMPTE431;
1440
1442 SDL_COLOR_PRIMARIES_SMPTE432;
1443
1445 SDL_COLOR_PRIMARIES_EBU3213;
1446
1448 SDL_COLOR_PRIMARIES_CUSTOM;
1449
1451
1464using TransferCharacteristics = SDL_TransferCharacteristics;
1465
1467 SDL_TRANSFER_CHARACTERISTICS_UNKNOWN;
1468
1470 SDL_TRANSFER_CHARACTERISTICS_BT709;
1471
1473 SDL_TRANSFER_CHARACTERISTICS_UNSPECIFIED;
1474
1477 SDL_TRANSFER_CHARACTERISTICS_GAMMA22;
1478
1480 SDL_TRANSFER_CHARACTERISTICS_GAMMA28;
1481
1483 SDL_TRANSFER_CHARACTERISTICS_BT601;
1485
1487 SDL_TRANSFER_CHARACTERISTICS_SMPTE240;
1488
1490 SDL_TRANSFER_CHARACTERISTICS_LINEAR;
1491
1493 SDL_TRANSFER_CHARACTERISTICS_LOG100;
1494
1496 SDL_TRANSFER_CHARACTERISTICS_LOG100_SQRT10;
1497
1499 SDL_TRANSFER_CHARACTERISTICS_IEC61966;
1500
1502 SDL_TRANSFER_CHARACTERISTICS_BT1361;
1503
1505 SDL_TRANSFER_CHARACTERISTICS_SRGB;
1506
1508 SDL_TRANSFER_CHARACTERISTICS_BT2020_10BIT;
1509
1511 SDL_TRANSFER_CHARACTERISTICS_BT2020_12BIT;
1512
1514 SDL_TRANSFER_CHARACTERISTICS_PQ;
1516
1518 SDL_TRANSFER_CHARACTERISTICS_SMPTE428;
1519
1521 SDL_TRANSFER_CHARACTERISTICS_HLG;
1523
1525 SDL_TRANSFER_CHARACTERISTICS_CUSTOM;
1526
1528
1541using MatrixCoefficients = SDL_MatrixCoefficients;
1542
1544 SDL_MATRIX_COEFFICIENTS_IDENTITY;
1545
1547 SDL_MATRIX_COEFFICIENTS_BT709;
1548
1550 SDL_MATRIX_COEFFICIENTS_UNSPECIFIED;
1551
1553 SDL_MATRIX_COEFFICIENTS_FCC;
1554
1560 SDL_MATRIX_COEFFICIENTS_BT470BG;
1561
1563 SDL_MATRIX_COEFFICIENTS_BT601;
1564
1566 SDL_MATRIX_COEFFICIENTS_SMPTE240;
1567
1569 SDL_MATRIX_COEFFICIENTS_YCGCO;
1570
1572 SDL_MATRIX_COEFFICIENTS_BT2020_NCL;
1574
1576 SDL_MATRIX_COEFFICIENTS_BT2020_CL;
1577
1579 SDL_MATRIX_COEFFICIENTS_SMPTE2085;
1580
1582 SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL;
1583
1585 SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL;
1586
1588 SDL_MATRIX_COEFFICIENTS_ICTCP;
1589
1591 SDL_MATRIX_COEFFICIENTS_CUSTOM;
1592
1594
1605using ChromaLocation = SDL_ChromaLocation;
1606
1608 SDL_CHROMA_LOCATION_NONE;
1609
1615constexpr ChromaLocation CHROMA_LOCATION_LEFT = SDL_CHROMA_LOCATION_LEFT;
1616
1622constexpr ChromaLocation CHROMA_LOCATION_CENTER = SDL_CHROMA_LOCATION_CENTER;
1623
1629constexpr ChromaLocation CHROMA_LOCATION_TOPLEFT = SDL_CHROMA_LOCATION_TOPLEFT;
1630
1632
1657{
1658 ColorspaceRaw m_cspace;
1659
1660public:
1666 constexpr Colorspace(ColorspaceRaw cspace = {}) noexcept
1667 : m_cspace(cspace)
1668 {
1669 }
1670
1701 constexpr Colorspace(ColorType type,
1702 ColorRange range,
1703 ColorPrimaries primaries,
1704 TransferCharacteristics transfer,
1705 MatrixCoefficients matrix,
1706 ChromaLocation chroma)
1707 : m_cspace(ColorspaceRaw(SDL_DEFINE_COLORSPACE(type,
1708 range,
1709 primaries,
1710 transfer,
1711 matrix,
1712 chroma)))
1713 {
1714 }
1715
1721 constexpr operator ColorspaceRaw() const noexcept { return m_cspace; }
1722
1732 constexpr ColorType GetType() const;
1733
1743 constexpr ColorRange GetRange() const;
1744
1754 constexpr ChromaLocation GetChroma() const;
1755
1765 constexpr ColorPrimaries GetPrimaries() const;
1766
1776 constexpr TransferCharacteristics GetTransfer() const;
1777
1787 constexpr MatrixCoefficients GetMatrix() const;
1788
1798 constexpr bool IsMatrixBT601() const;
1799
1809 constexpr bool IsMatrixBT709() const;
1810
1820 constexpr bool IsMatrixBT2020_NCL() const;
1821
1831 constexpr bool IsLimitedRange() const;
1832
1842 constexpr bool IsFullRange() const;
1843};
1844
1845constexpr Colorspace COLORSPACE_UNKNOWN = SDL_COLORSPACE_UNKNOWN;
1846
1848constexpr Colorspace COLORSPACE_SRGB = SDL_COLORSPACE_SRGB;
1849
1851constexpr Colorspace COLORSPACE_SRGB_LINEAR = SDL_COLORSPACE_SRGB_LINEAR;
1852
1854constexpr Colorspace COLORSPACE_HDR10 = SDL_COLORSPACE_HDR10;
1855
1857constexpr Colorspace COLORSPACE_JPEG = SDL_COLORSPACE_JPEG;
1858
1860constexpr Colorspace COLORSPACE_BT601_LIMITED = SDL_COLORSPACE_BT601_LIMITED;
1861
1863constexpr Colorspace COLORSPACE_BT601_FULL = SDL_COLORSPACE_BT601_FULL;
1864
1866constexpr Colorspace COLORSPACE_BT709_LIMITED = SDL_COLORSPACE_BT709_LIMITED;
1867
1869constexpr Colorspace COLORSPACE_BT709_FULL = SDL_COLORSPACE_BT709_FULL;
1870
1872constexpr Colorspace COLORSPACE_BT2020_LIMITED = SDL_COLORSPACE_BT2020_LIMITED;
1873
1875constexpr Colorspace COLORSPACE_BT2020_FULL = SDL_COLORSPACE_BT2020_FULL;
1876
1878constexpr Colorspace COLORSPACE_RGB_DEFAULT = SDL_COLORSPACE_RGB_DEFAULT;
1879
1881constexpr Colorspace COLORSPACE_YUV_DEFAULT = SDL_COLORSPACE_YUV_DEFAULT;
1882
1884
1916 ColorRange range,
1917 ColorPrimaries primaries,
1918 TransferCharacteristics transfer,
1919 MatrixCoefficients matrix,
1920 ChromaLocation chroma)
1921{
1922 return Colorspace(type, range, primaries, transfer, matrix, chroma);
1923}
1924
1936{
1937 return SDL_COLORSPACETYPE(cspace);
1938}
1939
1941{
1942 return SDL::ColorspaceType(m_cspace);
1943}
1944
1956{
1957 return SDL_COLORSPACERANGE(cspace);
1958}
1959
1961{
1962 return SDL::ColorspaceRange(m_cspace);
1963}
1964
1976{
1977 return SDL_COLORSPACECHROMA(cspace);
1978}
1979
1981{
1982 return SDL::ColorspaceChroma(m_cspace);
1983}
1984
1996{
1997 return SDL_COLORSPACEPRIMARIES(cspace);
1998}
1999
2001{
2002 return SDL::ColorspacePrimaries(m_cspace);
2003}
2004
2016{
2017 return SDL_COLORSPACETRANSFER(cspace);
2018}
2019
2021{
2022 return SDL::ColorspaceTransfer(m_cspace);
2023}
2024
2036{
2037 return SDL_COLORSPACEMATRIX(cspace);
2038}
2039
2041{
2042 return SDL::ColorspaceMatrix(m_cspace);
2043}
2044
2060{
2061 return SDL_ISCOLORSPACE_MATRIX_BT601(cspace);
2062}
2063
2064constexpr bool Colorspace::IsMatrixBT601() const
2065{
2066 return SDL::IsColorspaceMatrixBT601(m_cspace);
2067}
2068
2080{
2081 return SDL_ISCOLORSPACE_MATRIX_BT709(cspace);
2082}
2083
2084constexpr bool Colorspace::IsMatrixBT709() const
2085{
2086 return SDL::IsColorspaceMatrixBT709(m_cspace);
2087}
2088
2100{
2101 return SDL_ISCOLORSPACE_MATRIX_BT2020_NCL(cspace);
2102}
2103
2105{
2106 return SDL::IsColorspaceMatrixBT2020_NCL(m_cspace);
2107}
2108
2120{
2121 return SDL_ISCOLORSPACE_LIMITED_RANGE(cspace);
2122}
2123
2124constexpr bool Colorspace::IsLimitedRange() const
2125{
2126 return SDL::IsColorspaceLimitedRange(m_cspace);
2127}
2128
2140{
2141 return SDL_ISCOLORSPACE_FULL_RANGE(cspace);
2142}
2143
2144constexpr bool Colorspace::IsFullRange() const
2145{
2146 return SDL::IsColorspaceFullRange(m_cspace);
2147}
2148
2150constexpr bool operator==(ColorRaw lhs, ColorRaw rhs) noexcept
2151{
2152 return lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b && lhs.a == rhs.a;
2153}
2154
2156constexpr bool operator==(const FColorRaw& lhs, const FColorRaw& rhs) noexcept
2157{
2158 return lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b && lhs.a == rhs.a;
2159}
2160
2162constexpr auto operator<=>(ColorRaw lhs, ColorRaw rhs) noexcept
2163{
2164 if (lhs.r != rhs.r) return lhs.r <=> rhs.r;
2165 if (lhs.g != rhs.g) return lhs.g <=> rhs.g;
2166 if (lhs.b != rhs.b) return lhs.b <=> rhs.b;
2167 return lhs.a <=> rhs.a;
2168}
2169
2171constexpr auto operator<=>(const FColorRaw& lhs, const FColorRaw& rhs) noexcept
2172{
2173 if (lhs.r != rhs.r) return lhs.r <=> rhs.r;
2174 if (lhs.g != rhs.g) return lhs.g <=> rhs.g;
2175 if (lhs.b != rhs.b) return lhs.b <=> rhs.b;
2176 return lhs.a <=> rhs.a;
2177}
2178
2192{
2198 constexpr Color(ColorRaw color = {}) noexcept
2199 : ColorRaw(color)
2200 {
2201 }
2202
2211 constexpr Color(Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255) noexcept
2212 : ColorRaw{r, g, b, a}
2213 {
2214 }
2215
2221 constexpr Uint8 GetR() const noexcept { return r; }
2222
2229 constexpr Color& SetR(Uint8 newR) noexcept
2230 {
2231 r = newR;
2232 return *this;
2233 }
2234
2241 constexpr Uint8 GetG() const noexcept { return g; }
2242
2249 constexpr Color& SetG(Uint8 newG) noexcept
2250 {
2251 g = newG;
2252 return *this;
2253 }
2254
2261 constexpr Uint8 GetB() const noexcept { return b; }
2262
2269 constexpr Color& SetB(Uint8 newB) noexcept
2270 {
2271 b = newB;
2272 return *this;
2273 }
2274
2281 constexpr Uint8 GetA() const noexcept { return a; }
2282
2289 constexpr Color& SetA(Uint8 newA) noexcept
2290 {
2291 a = newA;
2292 return *this;
2293 }
2294
2321 Uint32 Map(const PixelFormatDetails& format, PaletteConstParam palette) const;
2322
2349 static Color Get(Uint32 pixel,
2350 const PixelFormatDetails& format,
2351 PaletteConstParam palette);
2352};
2353
2365{
2371 constexpr FColor(const FColorRaw& color = {}) noexcept
2372 : FColorRaw(color)
2373 {
2374 }
2375
2384 constexpr FColor(float r, float g, float b, float a = 1) noexcept
2385 : FColorRaw{r, g, b, a}
2386 {
2387 }
2388
2394 constexpr float GetR() const noexcept { return r; }
2395
2402 constexpr FColor& SetR(float newR) noexcept
2403 {
2404 r = newR;
2405 return *this;
2406 }
2407
2414 constexpr float GetG() const noexcept { return g; }
2415
2422 constexpr FColor& SetG(float newG) noexcept
2423 {
2424 g = newG;
2425 return *this;
2426 }
2427
2434 constexpr float GetB() const noexcept { return b; }
2435
2442 constexpr FColor& SetB(float newB) noexcept
2443 {
2444 b = newB;
2445 return *this;
2446 }
2447
2454 constexpr float GetA() const noexcept { return a; }
2455
2462 constexpr FColor& SetA(float newA) noexcept
2463 {
2464 a = newA;
2465 return *this;
2466 }
2467};
2468
2479{
2480 PaletteRaw m_resource = nullptr;
2481
2482public:
2484 constexpr Palette(std::nullptr_t = nullptr) noexcept
2485 : m_resource(0)
2486 {
2487 }
2488
2496 constexpr explicit Palette(const PaletteRaw resource) noexcept
2497 : m_resource(resource)
2498 {
2499 }
2500
2502 constexpr Palette(const Palette& other)
2503 : m_resource(other.m_resource)
2504 {
2505 ++m_resource->refcount;
2506 }
2507
2509 constexpr Palette(Palette&& other) noexcept
2510 : Palette(other.release())
2511 {
2512 }
2513
2531 Palette(int ncolors)
2532 : m_resource(CheckError(SDL_CreatePalette(ncolors)))
2533 {
2534 }
2535
2543 static constexpr Palette Borrow(PaletteParam resource)
2544 {
2545 if (resource) {
2546 ++resource.value->refcount;
2547 return Palette(resource.value);
2548 }
2549 return {};
2550 }
2551
2553 constexpr const PaletteRaw operator->() const noexcept { return m_resource; }
2554
2556 constexpr PaletteRaw operator->() noexcept { return m_resource; }
2557
2559 ~Palette() { SDL_DestroyPalette(m_resource); }
2560
2562 constexpr Palette& operator=(Palette&& other) noexcept
2563 {
2564 std::swap(m_resource, other.m_resource);
2565 return *this;
2566 }
2567
2569 constexpr Palette& operator=(const Palette& other) noexcept = default;
2570
2572 constexpr PaletteRaw get() const noexcept { return m_resource; }
2573
2575 constexpr PaletteRaw release() noexcept
2576 {
2577 auto r = m_resource;
2578 m_resource = nullptr;
2579 return r;
2580 }
2581
2583 constexpr auto operator<=>(const Palette& other) const noexcept = default;
2584
2586 constexpr explicit operator bool() const noexcept { return !!m_resource; }
2587
2589 constexpr operator PaletteParam() const noexcept { return {m_resource}; }
2590
2601 void Destroy();
2602
2604 constexpr const ColorRaw* data() const { return m_resource->colors; }
2605
2607 constexpr int size() const { return m_resource->ncolors; }
2608
2610 constexpr ColorRaw operator[](int index) const
2611 {
2612 return m_resource->colors[index];
2613 }
2614
2629 void SetColors(SpanRef<const ColorRaw> colors, int firstcolor = 0);
2630};
2631
2634{
2635 using Palette::Palette;
2636
2644 PaletteRef(PaletteRaw resource) noexcept
2645 : Palette(Borrow(resource))
2646 {
2647 }
2648
2650 PaletteRef(Palette resource) noexcept
2651 : Palette(std::move(resource))
2652 {
2653 }
2654};
2655
2667inline const char* GetPixelFormatName(PixelFormatRaw format)
2668{
2669 return SDL_GetPixelFormatName(format);
2670}
2671
2672inline const char* PixelFormat::GetName() const
2673{
2674 return SDL::GetPixelFormatName(m_format);
2675}
2676
2695 int* bpp,
2696 Uint32* Rmask,
2697 Uint32* Gmask,
2698 Uint32* Bmask,
2699 Uint32* Amask)
2700{
2701 CheckError(
2702 SDL_GetMasksForPixelFormat(format, bpp, Rmask, Gmask, Bmask, Amask));
2703}
2704
2705inline void PixelFormat::GetMasks(int* bpp,
2706 Uint32* Rmask,
2707 Uint32* Gmask,
2708 Uint32* Bmask,
2709 Uint32* Amask) const
2710{
2711 SDL::GetMasksForPixelFormat(m_format, bpp, Rmask, Gmask, Bmask, Amask);
2712}
2713
2734 Uint32 Rmask,
2735 Uint32 Gmask,
2736 Uint32 Bmask,
2737 Uint32 Amask)
2738{
2739 return SDL_GetPixelFormatForMasks(bpp, Rmask, Gmask, Bmask, Amask);
2740}
2741
2743 Uint32 Rmask,
2744 Uint32 Gmask,
2745 Uint32 Bmask,
2746 Uint32 Amask)
2747{
2748 return SDL::GetPixelFormatForMasks(bpp, Rmask, Gmask, Bmask, Amask);
2749}
2750
2767{
2768 return *CheckError(SDL_GetPixelFormatDetails(format));
2769}
2770
2772{
2773 return SDL::GetPixelFormatDetails(m_format);
2774}
2775
2776inline PixelFormat::operator const PixelFormatDetails&() const
2777{
2778 return GetDetails();
2779}
2780
2798inline Palette CreatePalette(int ncolors) { return Palette(ncolors); }
2799
2813inline void SetPaletteColors(PaletteParam palette,
2815 int firstcolor = 0)
2816{
2817 CheckError(
2818 SDL_SetPaletteColors(palette, colors.data(), firstcolor, colors.size()));
2819}
2820
2821inline void Palette::SetColors(SpanRef<const ColorRaw> colors, int firstcolor)
2822{
2823 SDL::SetPaletteColors(m_resource, colors, firstcolor);
2824}
2825
2838inline void DestroyPalette(PaletteRaw palette) { SDL_DestroyPalette(palette); }
2839
2841
2877inline Uint32 MapRGB(const PixelFormatDetails& format,
2878 PaletteConstParam palette,
2879 Uint8 r,
2880 Uint8 g,
2881 Uint8 b)
2882{
2883 return SDL_MapRGB(&format, palette, r, g, b);
2884}
2885
2923inline Uint32 MapRGBA(const PixelFormatDetails& format,
2924 Uint8 r,
2925 Uint8 g,
2926 Uint8 b,
2927 Uint8 a,
2928 PaletteConstParam palette = {})
2929{
2930 return SDL_MapRGBA(&format, palette, r, g, b, a);
2931}
2932
2967 ColorRaw c,
2968 PaletteConstParam palette = {})
2969{
2970 return SDL_MapRGBA(&format, palette, c.r, c.g, c.b, c.a);
2971}
2972
2974 PaletteConstParam palette) const
2975{
2976 return MapColor(format, *this, palette);
2977}
2978
2980{
2981 return MapColor(GetDetails(), c, palette);
2982}
2983
3009inline void GetRGB(Uint32 pixelvalue,
3010 const PixelFormatDetails& format,
3011 PaletteConstParam palette,
3012 Uint8* r,
3013 Uint8* g,
3014 Uint8* b)
3015{
3016 SDL_GetRGB(pixelvalue, &format, palette, r, g, b);
3017}
3018
3048inline void GetRGBA(Uint32 pixelvalue,
3049 const PixelFormatDetails& format,
3050 PaletteConstParam palette,
3051 Uint8* r,
3052 Uint8* g,
3053 Uint8* b,
3054 Uint8* a)
3055{
3056 SDL_GetRGBA(pixelvalue, &format, palette, r, g, b, a);
3057}
3058
3086inline Color GetColor(Uint32 pixel,
3087 const PixelFormatDetails& format,
3088 PaletteConstParam palette = {})
3089{
3090 Color c;
3091 GetRGBA(pixel, format, palette, &c.r, &c.g, &c.b, &c.a);
3092 return c;
3093}
3094
3096 const PixelFormatDetails& format,
3097 PaletteConstParam palette)
3098{
3099 return GetColor(pixel, format, palette);
3100}
3101
3103{
3104 return GetColor(pixel, GetDetails(), palette);
3105}
3106
3108
3109} // namespace SDL
3110
3111#endif /* SDL3PP_PIXELS_H_ */
Colorspace definitions.
Definition: SDL3pp_pixels.h:1657
constexpr Colorspace(ColorType type, ColorRange range, ColorPrimaries primaries, TransferCharacteristics transfer, MatrixCoefficients matrix, ChromaLocation chroma)
Define custom Colorspace formats.
Definition: SDL3pp_pixels.h:1701
constexpr Colorspace(ColorspaceRaw cspace={}) noexcept
Wraps Colorspace.
Definition: SDL3pp_pixels.h:1666
A set of indexed colors representing a palette.
Definition: SDL3pp_pixels.h:2479
constexpr Palette(Palette &&other) noexcept
Move constructor.
Definition: SDL3pp_pixels.h:2509
static constexpr Palette Borrow(PaletteParam resource)
Safely borrows the from PaletteParam.
Definition: SDL3pp_pixels.h:2543
constexpr auto operator<=>(const Palette &other) const noexcept=default
Comparison.
constexpr Palette(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_pixels.h:2484
constexpr PaletteRaw get() const noexcept
Retrieves underlying PaletteRaw.
Definition: SDL3pp_pixels.h:2572
constexpr Palette(const Palette &other)
Copy constructor.
Definition: SDL3pp_pixels.h:2502
~Palette()
Destructor.
Definition: SDL3pp_pixels.h:2559
constexpr Palette & operator=(Palette &&other) noexcept
Assignment operator.
Definition: SDL3pp_pixels.h:2562
constexpr Palette & operator=(const Palette &other) noexcept=default
Assignment operator.
constexpr PaletteRaw operator->() noexcept
member access to underlying PaletteRaw.
Definition: SDL3pp_pixels.h:2556
constexpr int size() const
Returns number of colors in the palette.
Definition: SDL3pp_pixels.h:2607
constexpr ColorRaw operator[](int index) const
Access specific pallete index.
Definition: SDL3pp_pixels.h:2610
constexpr PaletteRaw release() noexcept
Retrieves underlying PaletteRaw and clear this.
Definition: SDL3pp_pixels.h:2575
Palette(int ncolors)
Create a palette structure with the specified number of color entries.
Definition: SDL3pp_pixels.h:2531
constexpr Palette(const PaletteRaw resource) noexcept
Constructs from PaletteParam.
Definition: SDL3pp_pixels.h:2496
constexpr const PaletteRaw operator->() const noexcept
member access to underlying PaletteRaw.
Definition: SDL3pp_pixels.h:2553
constexpr const ColorRaw * data() const
Access specific pallete colors.
Definition: SDL3pp_pixels.h:2604
Pixel format.
Definition: SDL3pp_pixels.h:414
constexpr PixelFormat(PixelFormatRaw format={}) noexcept
Wraps PixelFormat.
Definition: SDL3pp_pixels.h:423
constexpr PixelFormat(PixelType type, int order, PackedLayout layout, int bits, int bytes)
Defining custom non-FourCC pixel formats.
Definition: SDL3pp_pixels.h:451
span-like for empty-derived structs
Definition: SDL3pp_spanRef.h:24
constexpr T * data() const
Retrieves contained data.
Definition: SDL3pp_spanRef.h:75
constexpr size_t size() const
Retrieves contained size.
Definition: SDL3pp_spanRef.h:69
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition: SDL3pp_error.h:197
Uint32 MapColor(const PixelFormatDetails &format, ColorRaw c, PaletteConstParam palette={})
Map an RGBA quadruple to a pixel value for a given pixel format.
Definition: SDL3pp_pixels.h:2966
constexpr PixelFormat PIXELFORMAT_ABGR1555
ABGR1555.
Definition: SDL3pp_pixels.h:829
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_FCC
US FCC Title 47.
Definition: SDL3pp_pixels.h:1552
constexpr bool IsMatrixBT709() const
Determine if an Colorspace uses BT709 matrix coefficients.
Definition: SDL3pp_pixels.h:2084
constexpr PixelFormat PIXELFORMAT_IYUV
Planar mode: Y + U + V (3 planes)
Definition: SDL3pp_pixels.h:930
constexpr bool IsPixelFormatArray(PixelFormatRaw format)
A macro to determine if an PixelFormat is an array format.
Definition: SDL3pp_pixels.h:1240
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_SMPTE240
SMPTE 240M.
Definition: SDL3pp_pixels.h:1565
constexpr ColorPrimaries COLOR_PRIMARIES_UNSPECIFIED
COLOR_PRIMARIES_UNSPECIFIED.
Definition: SDL3pp_pixels.h:1411
constexpr ColorPrimaries COLOR_PRIMARIES_BT709
ITU-R BT.709-6.
Definition: SDL3pp_pixels.h:1408
constexpr PixelFormat PIXELFORMAT_BGRA64
BGRA64.
Definition: SDL3pp_pixels.h:887
constexpr PixelType PIXELTYPE_PACKED8
PACKED8.
Definition: SDL3pp_pixels.h:234
void DestroyPalette(PaletteRaw palette)
Free a palette created with Palette.Palette().
Definition: SDL3pp_pixels.h:2838
constexpr PackedLayout PACKEDLAYOUT_1555
1555
Definition: SDL3pp_pixels.h:352
constexpr PixelFormat PIXELFORMAT_RGB96_FLOAT
RGB96_FLOAT.
Definition: SDL3pp_pixels.h:909
constexpr ChromaLocation ColorspaceChroma(ColorspaceRaw cspace)
A macro to retrieve the chroma sample location of an Colorspace.
Definition: SDL3pp_pixels.h:1975
Color Get(Uint32 pixel, PaletteConstParam palette={}) const
Get RGBA values from a pixel in the specified format.
Definition: SDL3pp_pixels.h:3102
constexpr PixelFormat PIXELFORMAT_P010
Planar mode: Y + U/V interleaved (2 planes)
Definition: SDL3pp_pixels.h:948
constexpr int PixelFormatOrder(PixelFormatRaw format)
A macro to retrieve the order of an PixelFormat.
Definition: SDL3pp_pixels.h:1092
const char * GetName() const
Get the human readable name of a pixel format.
Definition: SDL3pp_pixels.h:2672
constexpr PixelFormat PIXELFORMAT_XRGB32
XRGB32.
Definition: SDL3pp_pixels.h:970
constexpr ColorPrimaries ColorspacePrimaries(ColorspaceRaw cspace)
A macro to retrieve the primaries of an Colorspace.
Definition: SDL3pp_pixels.h:1995
constexpr ColorType GetType() const
Retrieve the type of a Colorspace.
Definition: SDL3pp_pixels.h:1940
constexpr PixelType PIXELTYPE_ARRAYF32
ARRAYF32.
Definition: SDL3pp_pixels.h:248
constexpr Uint8 GetFlags() const
Retrieve the flags of an PixelFormat.
Definition: SDL3pp_pixels.h:1052
constexpr bool IsPixelFormat10Bit(PixelFormatRaw format)
A macro to determine if an PixelFormat is a 10-bit format.
Definition: SDL3pp_pixels.h:1263
constexpr PixelFormat PIXELFORMAT_MJPG
Motion JPEG.
Definition: SDL3pp_pixels.h:956
constexpr ColorRange COLOR_RANGE_LIMITED
Narrow range, e.g.
Definition: SDL3pp_pixels.h:1385
constexpr ColorType ColorspaceType(ColorspaceRaw cspace)
A macro to retrieve the type of an Colorspace.
Definition: SDL3pp_pixels.h:1935
constexpr bool IsColorspaceLimitedRange(ColorspaceRaw cspace)
A macro to determine if an Colorspace has a limited range.
Definition: SDL3pp_pixels.h:2119
constexpr PixelFormat PIXELFORMAT_XRGB1555
XRGB1555.
Definition: SDL3pp_pixels.h:805
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_SMPTE240
SMPTE ST 240M.
Definition: SDL3pp_pixels.h:1486
constexpr PackedLayout PACKEDLAYOUT_1010102
1010102
Definition: SDL3pp_pixels.h:363
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT2020_12BIT
ITU-R BT2020 for 12-bit system.
Definition: SDL3pp_pixels.h:1510
constexpr ArrayOrder ARRAYORDER_RGB
RGB.
Definition: SDL3pp_pixels.h:320
SDL_PackedLayout PackedLayout
Packed component layout.
Definition: SDL3pp_pixels.h:344
SDL_ArrayOrder ArrayOrder
Array component order, low byte -> high byte.
Definition: SDL3pp_pixels.h:316
constexpr PixelFormat PIXELFORMAT_EXTERNAL_OES
Android video texture format.
Definition: SDL3pp_pixels.h:951
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_UNSPECIFIED
MATRIX_COEFFICIENTS_UNSPECIFIED.
Definition: SDL3pp_pixels.h:1549
constexpr Uint8 PixelFormatFlags(PixelFormatRaw format)
Retrieve the flags of an PixelFormat.
Definition: SDL3pp_pixels.h:1047
constexpr PixelFormat PIXELFORMAT_INDEX1MSB
INDEX1MSB.
Definition: SDL3pp_pixels.h:780
constexpr PixelType PIXELTYPE_PACKED32
PACKED32.
Definition: SDL3pp_pixels.h:238
constexpr PixelType PIXELTYPE_ARRAYF16
ARRAYF16.
Definition: SDL3pp_pixels.h:246
constexpr PixelFormat PIXELFORMAT_ABGR8888
ABGR8888.
Definition: SDL3pp_pixels.h:861
SDL_ColorPrimaries ColorPrimaries
Colorspace color primaries, as described by https://www.itu.int/rec/T-REC-H.273-201612-S/en.
Definition: SDL3pp_pixels.h:1403
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_SMPTE2085
SMPTE ST 2085.
Definition: SDL3pp_pixels.h:1578
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_ICTCP
ITU-R BT.2100-0 ICTCP.
Definition: SDL3pp_pixels.h:1587
void Destroy()
Free a palette created with Palette.Palette().
Definition: SDL3pp_pixels.h:2840
constexpr PixelFormat PIXELFORMAT_NV21
Planar mode: Y + V/U interleaved (2 planes)
Definition: SDL3pp_pixels.h:945
SDL_ChromaLocation ChromaLocation
Colorspace chroma sample location.
Definition: SDL3pp_pixels.h:1605
constexpr bool IsPixelFormatPacked(PixelFormatRaw format)
A macro to determine if an PixelFormat is a packed format.
Definition: SDL3pp_pixels.h:1217
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_LOG100
TRANSFER_CHARACTERISTICS_LOG100.
Definition: SDL3pp_pixels.h:1492
constexpr ColorType COLOR_TYPE_YCBCR
COLOR_TYPE_YCBCR.
Definition: SDL3pp_pixels.h:1361
Uint32 MapRGBA(const PixelFormatDetails &format, Uint8 r, Uint8 g, Uint8 b, Uint8 a, PaletteConstParam palette={})
Map an RGBA quadruple to a pixel value for a given pixel format.
Definition: SDL3pp_pixels.h:2923
constexpr PixelFormat PIXELFORMAT_ARGB2101010
ARGB2101010.
Definition: SDL3pp_pixels.h:873
constexpr bool IsPixelFormatAlpha(PixelFormatRaw format)
A macro to determine if an PixelFormat has an alpha channel.
Definition: SDL3pp_pixels.h:1314
constexpr PixelFormat PIXELFORMAT_INDEX4MSB
INDEX4MSB.
Definition: SDL3pp_pixels.h:792
constexpr int PixelFormatBytesPerPixel(PixelFormatRaw format)
A macro to determine an PixelFormat's bytes per pixel.
Definition: SDL3pp_pixels.h:1171
constexpr PixelFormat PIXELFORMAT_UNKNOWN
UNKNOWN.
Definition: SDL3pp_pixels.h:774
constexpr ColorPrimaries COLOR_PRIMARIES_UNKNOWN
COLOR_PRIMARIES_UNKNOWN.
Definition: SDL3pp_pixels.h:1405
constexpr PixelFormat PIXELFORMAT_ABGR4444
ABGR4444.
Definition: SDL3pp_pixels.h:817
constexpr PixelFormat PIXELFORMAT_BGRA64_FLOAT
BGRA64_FLOAT.
Definition: SDL3pp_pixels.h:903
constexpr BitmapOrder BITMAPORDER_1234
1234
Definition: SDL3pp_pixels.h:270
constexpr PixelFormat PIXELFORMAT_ABGR32
ABGR32.
Definition: SDL3pp_pixels.h:966
constexpr PixelFormat PIXELFORMAT_BGRA128_FLOAT
BGRA128_FLOAT.
Definition: SDL3pp_pixels.h:921
Uint32 Map(const PixelFormatDetails &format, PaletteConstParam palette) const
Map an RGBA quadruple to a pixel value for a given pixel format.
Definition: SDL3pp_pixels.h:2973
constexpr PixelFormat PIXELFORMAT_XBGR2101010
XBGR2101010.
Definition: SDL3pp_pixels.h:870
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT601
SMPTE ST 170M / ITU-R BT.601-7 525 or 625.
Definition: SDL3pp_pixels.h:1482
constexpr ColorRange ColorspaceRange(ColorspaceRaw cspace)
A macro to retrieve the range of an Colorspace.
Definition: SDL3pp_pixels.h:1955
constexpr bool IsColorspaceFullRange(ColorspaceRaw cspace)
A macro to determine if an Colorspace has a full range.
Definition: SDL3pp_pixels.h:2139
constexpr PackedLayout PACKEDLAYOUT_565
565
Definition: SDL3pp_pixels.h:356
void GetRGB(Uint32 pixelvalue, const PixelFormatDetails &format, PaletteConstParam palette, Uint8 *r, Uint8 *g, Uint8 *b)
Get RGB values from a pixel in the specified format.
Definition: SDL3pp_pixels.h:3009
const char * GetPixelFormatName(PixelFormatRaw format)
Get the human readable name of a pixel format.
Definition: SDL3pp_pixels.h:2667
constexpr PackedOrder PACKEDORDER_BGRA
BGRA.
Definition: SDL3pp_pixels.h:302
constexpr PixelFormat PIXELFORMAT_XRGB8888
XRGB8888.
Definition: SDL3pp_pixels.h:843
constexpr PixelFormat PIXELFORMAT_BGR96_FLOAT
BGR96_FLOAT.
Definition: SDL3pp_pixels.h:912
constexpr bool Is10Bit() const
Determine if this is a 10-bit format.
Definition: SDL3pp_pixels.h:1268
SDL_Colorspace ColorspaceRaw
Alias to raw representation for Colorspace.
Definition: SDL3pp_pixels.h:77
constexpr bool IsIndexed() const
Determine if this is an indexed format.
Definition: SDL3pp_pixels.h:1199
constexpr PixelFormat PIXELFORMAT_INDEX8
INDEX8.
Definition: SDL3pp_pixels.h:795
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL
MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL.
Definition: SDL3pp_pixels.h:1584
constexpr MatrixCoefficients ColorspaceMatrix(ColorspaceRaw cspace)
A macro to retrieve the matrix coefficients of an Colorspace.
Definition: SDL3pp_pixels.h:2035
constexpr PixelFormat PIXELFORMAT_INDEX1LSB
INDEX1LSB.
Definition: SDL3pp_pixels.h:777
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_SMPTE428
SMPTE ST 428-1.
Definition: SDL3pp_pixels.h:1517
constexpr TransferCharacteristics GetTransfer() const
Retrieve the transfer characteristics of an Colorspace.
Definition: SDL3pp_pixels.h:2020
constexpr ChromaLocation CHROMA_LOCATION_TOPLEFT
In HEVC for BT.2020 and BT.2100 content (in particular on Blu-rays), Cb and Cr are sampled at the sam...
Definition: SDL3pp_pixels.h:1629
constexpr ChromaLocation GetChroma() const
Retrieve the chroma sample location of an Colorspace.
Definition: SDL3pp_pixels.h:1980
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_GAMMA22
ITU-R BT.470-6 System M / ITU-R BT1700 625 PAL & SECAM.
Definition: SDL3pp_pixels.h:1476
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT2020_NCL
ITU-R BT.2020-2 non-constant luminance.
Definition: SDL3pp_pixels.h:1571
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT470BG
ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625, functionally the same as MATRIX_COEFFICIENTS_BT601.
Definition: SDL3pp_pixels.h:1559
SDL_TransferCharacteristics TransferCharacteristics
Colorspace transfer characteristics.
Definition: SDL3pp_pixels.h:1464
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_SRGB
IEC 61966-2-1 (sRGB or sYCC)
Definition: SDL3pp_pixels.h:1504
constexpr Colorspace DefineColorspace(ColorType type, ColorRange range, ColorPrimaries primaries, TransferCharacteristics transfer, MatrixCoefficients matrix, ChromaLocation chroma)
A macro for defining custom Colorspace formats.
Definition: SDL3pp_pixels.h:1915
constexpr PixelFormat PIXELFORMAT_BGRA8888
BGRA8888.
Definition: SDL3pp_pixels.h:864
constexpr PixelFormat PIXELFORMAT_RGBX8888
RGBX8888.
Definition: SDL3pp_pixels.h:846
constexpr PixelFormat PIXELFORMAT_YVYU
Packed mode: Y0+V0+Y1+U0 (1 plane)
Definition: SDL3pp_pixels.h:939
constexpr Uint8 ALPHA_TRANSPARENT
A fully transparent 8-bit alpha value.
Definition: SDL3pp_pixels.h:201
constexpr ColorPrimaries COLOR_PRIMARIES_BT470BG
ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625.
Definition: SDL3pp_pixels.h:1417
constexpr ArrayOrder ARRAYORDER_NONE
NONE.
Definition: SDL3pp_pixels.h:318
constexpr PackedOrder PACKEDORDER_ARGB
ARGB.
Definition: SDL3pp_pixels.h:292
constexpr Uint8 ALPHA_OPAQUE
A fully opaque 8-bit alpha value.
Definition: SDL3pp_pixels.h:183
constexpr PackedLayout PixelFormatLayout(PixelFormatRaw format)
A macro to retrieve the layout of an PixelFormat.
Definition: SDL3pp_pixels.h:1115
constexpr PixelFormat PIXELFORMAT_RGB24
RGB24.
Definition: SDL3pp_pixels.h:839
constexpr ColorPrimaries GetPrimaries() const
Retrieve the primaries of an Colorspace.
Definition: SDL3pp_pixels.h:2000
constexpr bool operator==(ColorRaw lhs, ColorRaw rhs) noexcept
Comparison operator for Color.
Definition: SDL3pp_pixels.h:2150
constexpr Colorspace COLORSPACE_UNKNOWN
UNKNOWN.
Definition: SDL3pp_pixels.h:1845
constexpr ChromaLocation CHROMA_LOCATION_LEFT
In MPEG-2, MPEG-4, and AVC, Cb and Cr are taken on midpoint of the left-edge of the 2x2 square.
Definition: SDL3pp_pixels.h:1615
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT2020_CL
ITU-R BT.2020-2 constant luminance.
Definition: SDL3pp_pixels.h:1575
constexpr Colorspace COLORSPACE_BT601_FULL
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601.
Definition: SDL3pp_pixels.h:1863
static PixelFormat ForMasks(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
Convert a bpp value and RGBA masks to an enumerated pixel format.
Definition: SDL3pp_pixels.h:2742
constexpr PixelFormat PIXELFORMAT_ARGB8888
ARGB8888.
Definition: SDL3pp_pixels.h:855
constexpr Colorspace COLORSPACE_SRGB_LINEAR
Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709.
Definition: SDL3pp_pixels.h:1851
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_HLG
ARIB STD-B67, known as "hybrid log-gamma" (HLG)
Definition: SDL3pp_pixels.h:1520
constexpr PackedLayout PACKEDLAYOUT_NONE
NONE.
Definition: SDL3pp_pixels.h:346
SDL_Palette * PaletteRaw
Alias to raw representation for Palette.
Definition: SDL3pp_pixels.h:98
constexpr PixelFormat PIXELFORMAT_ARGB128_FLOAT
ARGB128_FLOAT.
Definition: SDL3pp_pixels.h:918
constexpr PixelType PIXELTYPE_ARRAYU16
ARRAYU16.
Definition: SDL3pp_pixels.h:242
constexpr ColorType COLOR_TYPE_UNKNOWN
COLOR_TYPE_UNKNOWN.
Definition: SDL3pp_pixels.h:1356
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT709
ITU-R BT.709-6.
Definition: SDL3pp_pixels.h:1546
constexpr PixelFormat PIXELFORMAT_RGBX32
RGBX32.
Definition: SDL3pp_pixels.h:968
constexpr PackedOrder PACKEDORDER_RGBX
RGBX.
Definition: SDL3pp_pixels.h:290
constexpr Colorspace COLORSPACE_SRGB
Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709.
Definition: SDL3pp_pixels.h:1848
constexpr bool IsMatrixBT2020_NCL() const
Determine if an Colorspace uses BT2020_NCL matrix coefficients.
Definition: SDL3pp_pixels.h:2104
constexpr PackedLayout PACKEDLAYOUT_4444
4444
Definition: SDL3pp_pixels.h:350
constexpr PixelFormat PIXELFORMAT_RGBA5551
RGBA5551.
Definition: SDL3pp_pixels.h:826
constexpr float ALPHA_TRANSPARENT_FLOAT
A fully transparent floating point alpha value.
Definition: SDL3pp_pixels.h:210
SDL_ColorRange ColorRange
Colorspace color range, as described by https://www.itu.int/rec/R-REC-BT.2100-2-201807-I/en.
Definition: SDL3pp_pixels.h:1377
constexpr PixelFormat DefinePixelFormat(PixelType type, int order, PackedLayout layout, int bits, int bytes)
A macro for defining custom non-FourCC pixel formats.
Definition: SDL3pp_pixels.h:1025
constexpr PixelFormat PIXELFORMAT_XBGR8888
XBGR8888.
Definition: SDL3pp_pixels.h:849
constexpr PixelFormat PIXELFORMAT_BGR48
BGR48.
Definition: SDL3pp_pixels.h:881
constexpr PixelType PIXELTYPE_UNKNOWN
UNKNOWN.
Definition: SDL3pp_pixels.h:226
constexpr bool IsFloat() const
Determine if this is a floating point format.
Definition: SDL3pp_pixels.h:1291
constexpr Colorspace COLORSPACE_BT601_LIMITED
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601.
Definition: SDL3pp_pixels.h:1860
constexpr PixelFormat PIXELFORMAT_ARGB1555
ARGB1555.
Definition: SDL3pp_pixels.h:823
void SetColors(SpanRef< const ColorRaw > colors, int firstcolor=0)
Set a range of colors in a palette.
Definition: SDL3pp_pixels.h:2821
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT601
ITU-R BT.601-7 525.
Definition: SDL3pp_pixels.h:1562
constexpr ColorPrimaries COLOR_PRIMARIES_EBU3213
EBU Tech. 3213-E.
Definition: SDL3pp_pixels.h:1444
constexpr PackedOrder PACKEDORDER_ABGR
ABGR.
Definition: SDL3pp_pixels.h:300
constexpr bool IsMatrixBT601() const
Determine if a Colorspace uses BT601 (or BT470BG) matrix coefficients.
Definition: SDL3pp_pixels.h:2064
constexpr ColorPrimaries COLOR_PRIMARIES_SMPTE240
SMPTE 240M, functionally the same as COLOR_PRIMARIES_BT601.
Definition: SDL3pp_pixels.h:1425
constexpr Colorspace COLORSPACE_BT709_LIMITED
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709.
Definition: SDL3pp_pixels.h:1866
constexpr BitmapOrder BITMAPORDER_NONE
NONE.
Definition: SDL3pp_pixels.h:266
constexpr PixelFormat PIXELFORMAT_ARGB64_FLOAT
ARGB64_FLOAT.
Definition: SDL3pp_pixels.h:900
SDL_PixelFormatDetails PixelFormatDetails
Details about the format of a pixel.
Definition: SDL3pp_pixels.h:174
constexpr PixelFormat PIXELFORMAT_XRGB2101010
XRGB2101010.
Definition: SDL3pp_pixels.h:867
constexpr BitmapOrder BITMAPORDER_4321
4321
Definition: SDL3pp_pixels.h:268
constexpr bool IsPacked() const
Determine if this is a packed format.
Definition: SDL3pp_pixels.h:1222
constexpr ColorPrimaries COLOR_PRIMARIES_CUSTOM
COLOR_PRIMARIES_CUSTOM.
Definition: SDL3pp_pixels.h:1447
constexpr ColorPrimaries COLOR_PRIMARIES_BT2020
ITU-R BT.2020-2 / ITU-R BT.2100-0.
Definition: SDL3pp_pixels.h:1432
constexpr ColorType COLOR_TYPE_RGB
COLOR_TYPE_RGB.
Definition: SDL3pp_pixels.h:1359
constexpr PixelType PIXELTYPE_INDEX4
INDEX4.
Definition: SDL3pp_pixels.h:230
constexpr Colorspace COLORSPACE_BT709_FULL
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709.
Definition: SDL3pp_pixels.h:1869
SDL_PixelFormat PixelFormatRaw
Alias to raw representation for PixelFormat.
Definition: SDL3pp_pixels.h:71
constexpr PixelFormat PIXELFORMAT_XBGR4444
XBGR4444.
Definition: SDL3pp_pixels.h:802
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT1361
ITU-R BT1361 Extended Colour Gamut.
Definition: SDL3pp_pixels.h:1501
constexpr PixelType PIXELTYPE_PACKED16
PACKED16.
Definition: SDL3pp_pixels.h:236
const PixelFormatDetails & GetPixelFormatDetails(PixelFormatRaw format)
Create an PixelFormatDetails structure corresponding to a pixel format.
Definition: SDL3pp_pixels.h:2766
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_YCGCO
MATRIX_COEFFICIENTS_YCGCO.
Definition: SDL3pp_pixels.h:1568
constexpr PackedLayout PACKEDLAYOUT_332
332
Definition: SDL3pp_pixels.h:348
constexpr PixelFormat PIXELFORMAT_RGBA8888
RGBA8888.
Definition: SDL3pp_pixels.h:858
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_PQ
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition: SDL3pp_pixels.h:1513
constexpr bool IsColorspaceMatrixBT601(ColorspaceRaw cspace)
A macro to determine if an Colorspace uses BT601 (or BT470BG) matrix coefficients.
Definition: SDL3pp_pixels.h:2059
constexpr PackedLayout GetLayout() const
Retrieve the layout.
Definition: SDL3pp_pixels.h:1120
constexpr PixelFormat PIXELFORMAT_RGBA4444
RGBA4444.
Definition: SDL3pp_pixels.h:814
constexpr auto operator<=>(ColorRaw lhs, ColorRaw rhs) noexcept
Spaceship operator for Color.
Definition: SDL3pp_pixels.h:2162
constexpr PixelType PIXELTYPE_ARRAYU8
ARRAYU8.
Definition: SDL3pp_pixels.h:240
constexpr PixelFormat PIXELFORMAT_ARGB32
ARGB32.
Definition: SDL3pp_pixels.h:962
constexpr PixelFormat PIXELFORMAT_INDEX4LSB
INDEX4LSB.
Definition: SDL3pp_pixels.h:789
constexpr bool IsPixelFormatFloat(PixelFormatRaw format)
A macro to determine if an PixelFormat is a floating point format.
Definition: SDL3pp_pixels.h:1286
constexpr ArrayOrder ARRAYORDER_ABGR
ABGR.
Definition: SDL3pp_pixels.h:330
constexpr bool IsFourCC() const
Determine if this is a "FourCC" format.
Definition: SDL3pp_pixels.h:1344
constexpr PixelFormat PIXELFORMAT_ABGR64_FLOAT
ABGR64_FLOAT.
Definition: SDL3pp_pixels.h:906
constexpr bool IsPixelFormatFourCC(PixelFormatRaw format)
A macro to determine if an PixelFormat is a "FourCC" format.
Definition: SDL3pp_pixels.h:1339
constexpr ColorPrimaries COLOR_PRIMARIES_BT470M
ITU-R BT.470-6 System M.
Definition: SDL3pp_pixels.h:1414
constexpr ColorPrimaries COLOR_PRIMARIES_SMPTE431
SMPTE RP 431-2.
Definition: SDL3pp_pixels.h:1438
constexpr PixelFormat PIXELFORMAT_ABGR128_FLOAT
ABGR128_FLOAT.
Definition: SDL3pp_pixels.h:924
constexpr ColorPrimaries COLOR_PRIMARIES_XYZ
SMPTE ST 428-1.
Definition: SDL3pp_pixels.h:1435
constexpr PixelFormat PIXELFORMAT_ABGR2101010
ABGR2101010.
Definition: SDL3pp_pixels.h:876
SDL_ColorType ColorType
Colorspace color type.
Definition: SDL3pp_pixels.h:1354
constexpr PixelFormat PIXELFORMAT_BGRX8888
BGRX8888.
Definition: SDL3pp_pixels.h:852
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL
MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL.
Definition: SDL3pp_pixels.h:1581
constexpr float ALPHA_OPAQUE_FLOAT
A fully opaque floating point alpha value.
Definition: SDL3pp_pixels.h:192
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_CUSTOM
MATRIX_COEFFICIENTS_CUSTOM.
Definition: SDL3pp_pixels.h:1590
constexpr PixelFormat PIXELFORMAT_YV12
Planar mode: Y + V + U (3 planes)
Definition: SDL3pp_pixels.h:927
constexpr PixelFormat PIXELFORMAT_BGRX32
BGRX32.
Definition: SDL3pp_pixels.h:972
constexpr PixelFormat PIXELFORMAT_BGRA4444
BGRA4444.
Definition: SDL3pp_pixels.h:820
Color GetColor(Uint32 pixel, const PixelFormatDetails &format, PaletteConstParam palette={})
Get RGBA values from a pixel in the specified format.
Definition: SDL3pp_pixels.h:3086
constexpr PixelFormat PIXELFORMAT_INDEX2MSB
INDEX2MSB.
Definition: SDL3pp_pixels.h:786
void SetPaletteColors(PaletteParam palette, SpanRef< const ColorRaw > colors, int firstcolor=0)
Set a range of colors in a palette.
Definition: SDL3pp_pixels.h:2813
constexpr PixelFormat PIXELFORMAT_BGR565
BGR565.
Definition: SDL3pp_pixels.h:837
constexpr PixelFormat PIXELFORMAT_RGB48_FLOAT
RGB48_FLOAT.
Definition: SDL3pp_pixels.h:891
void GetRGBA(Uint32 pixelvalue, const PixelFormatDetails &format, PaletteConstParam palette, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
Get RGBA values from a pixel in the specified format.
Definition: SDL3pp_pixels.h:3048
constexpr PixelFormat PIXELFORMAT_RGB565
RGB565.
Definition: SDL3pp_pixels.h:835
constexpr PixelFormat PIXELFORMAT_RGBA32
RGBA32.
Definition: SDL3pp_pixels.h:960
constexpr PixelFormat PIXELFORMAT_BGR24
BGR24.
Definition: SDL3pp_pixels.h:841
constexpr PackedLayout PACKEDLAYOUT_2101010
2101010
Definition: SDL3pp_pixels.h:360
Uint32 Map(ColorRaw c, PaletteConstParam palette={}) const
Map an RGBA quadruple to a pixel value for a given pixel format.
Definition: SDL3pp_pixels.h:2979
constexpr bool IsColorspaceMatrixBT709(ColorspaceRaw cspace)
A macro to determine if an Colorspace uses BT709 matrix coefficients.
Definition: SDL3pp_pixels.h:2079
constexpr int GetOrder() const
Retrieve the order.
Definition: SDL3pp_pixels.h:1097
constexpr PixelFormat PIXELFORMAT_NV12
Planar mode: Y + U/V interleaved (2 planes)
Definition: SDL3pp_pixels.h:942
SDL_MatrixCoefficients MatrixCoefficients
Colorspace matrix coefficients.
Definition: SDL3pp_pixels.h:1541
constexpr ColorPrimaries COLOR_PRIMARIES_SMPTE432
SMPTE EG 432-1 / DCI P3.
Definition: SDL3pp_pixels.h:1441
constexpr Colorspace COLORSPACE_JPEG
Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601.
Definition: SDL3pp_pixels.h:1857
constexpr PixelFormat PIXELFORMAT_INDEX2LSB
INDEX2LSB.
Definition: SDL3pp_pixels.h:783
SDL_PackedOrder PackedOrder
Packed component order, high bit -> low bit.
Definition: SDL3pp_pixels.h:284
constexpr PackedLayout PACKEDLAYOUT_5551
5551
Definition: SDL3pp_pixels.h:354
Uint32 MapRGB(const PixelFormatDetails &format, PaletteConstParam palette, Uint8 r, Uint8 g, Uint8 b)
Map an RGB triple to an opaque pixel value for a given pixel format.
Definition: SDL3pp_pixels.h:2877
constexpr ColorRange COLOR_RANGE_FULL
Full range, e.g. 0-255 for 8-bit RGB and luma, and 1-255 for 8-bit chroma.
Definition: SDL3pp_pixels.h:1388
constexpr bool IsArray() const
Determine if this is an array format.
Definition: SDL3pp_pixels.h:1245
constexpr PixelFormat PIXELFORMAT_ABGR64
ABGR64.
Definition: SDL3pp_pixels.h:889
constexpr PackedOrder PACKEDORDER_RGBA
RGBA.
Definition: SDL3pp_pixels.h:294
void GetMasksForPixelFormat(PixelFormatRaw format, int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask)
Convert one of the enumerated pixel formats to a bpp value and RGBA masks.
Definition: SDL3pp_pixels.h:2694
constexpr Uint32 DefinePixelFourCC(Uint8 A, Uint8 B, Uint8 C, Uint8 D)
A function for defining custom FourCC pixel formats.
Definition: SDL3pp_pixels.h:997
constexpr PixelFormat PIXELFORMAT_RGBA128_FLOAT
RGBA128_FLOAT.
Definition: SDL3pp_pixels.h:915
constexpr Colorspace COLORSPACE_BT2020_LIMITED
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020.
Definition: SDL3pp_pixels.h:1872
PixelFormat GetPixelFormatForMasks(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
Convert a bpp value and RGBA masks to an enumerated pixel format.
Definition: SDL3pp_pixels.h:2733
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_UNSPECIFIED
TRANSFER_CHARACTERISTICS_UNSPECIFIED.
Definition: SDL3pp_pixels.h:1472
constexpr int PixelFormatBitsPerPixel(PixelFormatRaw format)
A macro to determine an PixelFormat's bits per pixel.
Definition: SDL3pp_pixels.h:1143
constexpr int GetBytesPerPixel() const
Determine this's bytes per pixel.
Definition: SDL3pp_pixels.h:1176
constexpr PixelFormat PIXELFORMAT_RGB332
RGB332.
Definition: SDL3pp_pixels.h:797
constexpr PixelFormat PIXELFORMAT_BGRA5551
BGRA5551.
Definition: SDL3pp_pixels.h:832
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_CUSTOM
TRANSFER_CHARACTERISTICS_CUSTOM.
Definition: SDL3pp_pixels.h:1524
constexpr ArrayOrder ARRAYORDER_BGRA
BGRA.
Definition: SDL3pp_pixels.h:328
constexpr ColorPrimaries COLOR_PRIMARIES_GENERIC_FILM
Generic film (color filters using Illuminant C)
Definition: SDL3pp_pixels.h:1428
constexpr PixelType PIXELTYPE_INDEX2
INDEX2.
Definition: SDL3pp_pixels.h:250
constexpr ColorRange COLOR_RANGE_UNKNOWN
COLOR_RANGE_UNKNOWN.
Definition: SDL3pp_pixels.h:1379
constexpr ColorPrimaries COLOR_PRIMARIES_BT601
ITU-R BT.601-7 525, SMPTE 170M.
Definition: SDL3pp_pixels.h:1421
constexpr bool IsAlpha() const
Determine if this has an alpha channel.
Definition: SDL3pp_pixels.h:1319
constexpr MatrixCoefficients GetMatrix() const
Retrieve the matrix coefficients of an Colorspace.
Definition: SDL3pp_pixels.h:2040
constexpr PixelFormat PIXELFORMAT_YUY2
Packed mode: Y0+U0+Y1+V0 (1 plane)
Definition: SDL3pp_pixels.h:933
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_LINEAR
TRANSFER_CHARACTERISTICS_LINEAR.
Definition: SDL3pp_pixels.h:1489
constexpr PixelType PIXELTYPE_ARRAYU32
ARRAYU32.
Definition: SDL3pp_pixels.h:244
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_UNKNOWN
TRANSFER_CHARACTERISTICS_UNKNOWN.
Definition: SDL3pp_pixels.h:1466
constexpr PixelType GetType() const
Retrieve the type.
Definition: SDL3pp_pixels.h:1074
constexpr ArrayOrder ARRAYORDER_RGBA
RGBA.
Definition: SDL3pp_pixels.h:322
constexpr PixelFormat PIXELFORMAT_RGBA64_FLOAT
RGBA64_FLOAT.
Definition: SDL3pp_pixels.h:897
constexpr bool IsColorspaceMatrixBT2020_NCL(ColorspaceRaw cspace)
Determine if an Colorspace uses BT2020_NCL matrix coefficients.
Definition: SDL3pp_pixels.h:2099
constexpr PixelFormat PIXELFORMAT_XRGB4444
XRGB4444.
Definition: SDL3pp_pixels.h:799
constexpr Colorspace COLORSPACE_BT2020_FULL
Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020.
Definition: SDL3pp_pixels.h:1875
constexpr TransferCharacteristics ColorspaceTransfer(ColorspaceRaw cspace)
A macro to retrieve the transfer characteristics of an Colorspace.
Definition: SDL3pp_pixels.h:2015
constexpr ChromaLocation CHROMA_LOCATION_NONE
RGB, no chroma sampling.
Definition: SDL3pp_pixels.h:1607
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT2020_10BIT
ITU-R BT2020 for 10-bit system.
Definition: SDL3pp_pixels.h:1507
constexpr ChromaLocation CHROMA_LOCATION_CENTER
In JPEG/JFIF, H.261, and MPEG-1, Cb and Cr are taken at the center of the 2x2 square.
Definition: SDL3pp_pixels.h:1622
constexpr PixelFormat PIXELFORMAT_RGBA64
RGBA64.
Definition: SDL3pp_pixels.h:883
SDL_FColor FColorRaw
Alias to raw representation for FColor.
Definition: SDL3pp_pixels.h:89
constexpr PixelFormat PIXELFORMAT_UYVY
Packed mode: U0+Y0+V0+Y1 (1 plane)
Definition: SDL3pp_pixels.h:936
constexpr Colorspace COLORSPACE_RGB_DEFAULT
The default colorspace for RGB surfaces if no colorspace is specified.
Definition: SDL3pp_pixels.h:1878
constexpr PackedOrder PACKEDORDER_NONE
NONE.
Definition: SDL3pp_pixels.h:286
constexpr PixelType PixelFormatType(PixelFormatRaw format)
A macro to retrieve the type of an PixelFormat.
Definition: SDL3pp_pixels.h:1069
SDL_Color ColorRaw
Alias to raw representation for Color.
Definition: SDL3pp_pixels.h:83
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_GAMMA28
ITU-R BT.470-6 System B, G.
Definition: SDL3pp_pixels.h:1479
constexpr PixelFormat PIXELFORMAT_ARGB4444
ARGB4444.
Definition: SDL3pp_pixels.h:811
SDL_BitmapOrder BitmapOrder
Bitmap pixel order, high bit -> low bit.
Definition: SDL3pp_pixels.h:264
constexpr ArrayOrder ARRAYORDER_BGR
BGR.
Definition: SDL3pp_pixels.h:326
constexpr PixelFormat PIXELFORMAT_BGRA32
BGRA32.
Definition: SDL3pp_pixels.h:964
constexpr bool IsFullRange() const
A function to determine if an Colorspace has a full range.
Definition: SDL3pp_pixels.h:2144
constexpr int GetBitsPerPixel() const
Determine this's bits per pixel.
Definition: SDL3pp_pixels.h:1148
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT709
Rec. ITU-R BT.709-6 / ITU-R BT1361.
Definition: SDL3pp_pixels.h:1469
constexpr PixelType PIXELTYPE_INDEX1
INDEX1.
Definition: SDL3pp_pixels.h:228
constexpr PixelFormat PIXELFORMAT_XBGR32
XBGR32.
Definition: SDL3pp_pixels.h:974
constexpr bool IsPixelFormatIndexed(PixelFormatRaw format)
A macro to determine if an PixelFormat is an indexed format.
Definition: SDL3pp_pixels.h:1194
SDL_PixelType PixelType
Pixel type.
Definition: SDL3pp_pixels.h:224
constexpr ArrayOrder ARRAYORDER_ARGB
ARGB.
Definition: SDL3pp_pixels.h:324
constexpr PixelFormat PIXELFORMAT_ARGB64
ARGB64.
Definition: SDL3pp_pixels.h:885
constexpr Colorspace COLORSPACE_HDR10
Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020.
Definition: SDL3pp_pixels.h:1854
constexpr PackedOrder PACKEDORDER_XRGB
XRGB.
Definition: SDL3pp_pixels.h:288
constexpr PackedLayout PACKEDLAYOUT_8888
8888
Definition: SDL3pp_pixels.h:358
void GetMasks(int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask) const
Convert one of the enumerated pixel formats to a bpp value and RGBA masks.
Definition: SDL3pp_pixels.h:2705
const PixelFormatDetails & GetDetails() const
Create an PixelFormatDetails structure corresponding to a pixel format.
Definition: SDL3pp_pixels.h:2771
constexpr PixelFormat PIXELFORMAT_RGB48
RGB48.
Definition: SDL3pp_pixels.h:879
static Color Get(Uint32 pixel, const PixelFormatDetails &format, PaletteConstParam palette)
Get RGBA values from a pixel in the specified format.
Definition: SDL3pp_pixels.h:3095
constexpr bool IsLimitedRange() const
A function to determine if an Colorspace has a limited range.
Definition: SDL3pp_pixels.h:2124
constexpr PixelFormat PIXELFORMAT_XBGR1555
XBGR1555.
Definition: SDL3pp_pixels.h:808
constexpr ColorRange GetRange() const
Retrieve the range of a Colorspace.
Definition: SDL3pp_pixels.h:1960
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_LOG100_SQRT10
TRANSFER_CHARACTERISTICS_LOG100_SQRT10.
Definition: SDL3pp_pixels.h:1495
Palette CreatePalette(int ncolors)
Create a palette structure with the specified number of color entries.
Definition: SDL3pp_pixels.h:2798
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_IEC61966
IEC 61966-2-4.
Definition: SDL3pp_pixels.h:1498
constexpr PackedOrder PACKEDORDER_BGRX
BGRX.
Definition: SDL3pp_pixels.h:298
constexpr Colorspace COLORSPACE_YUV_DEFAULT
The default colorspace for YUV surfaces if no colorspace is specified.
Definition: SDL3pp_pixels.h:1881
constexpr PackedOrder PACKEDORDER_XBGR
XBGR.
Definition: SDL3pp_pixels.h:296
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_IDENTITY
MATRIX_COEFFICIENTS_IDENTITY.
Definition: SDL3pp_pixels.h:1543
constexpr PixelFormat PIXELFORMAT_BGR48_FLOAT
BGR48_FLOAT.
Definition: SDL3pp_pixels.h:894
constexpr PixelType PIXELTYPE_INDEX8
INDEX8.
Definition: SDL3pp_pixels.h:232
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:341
::Uint8 Uint8
An unsigned 8-bit integer type.
Definition: SDL3pp_stdinc.h:289
Main include header for the SDL3pp library.
A structure that represents a color as RGBA components.
Definition: SDL3pp_pixels.h:2192
constexpr Uint8 GetG() const noexcept
Get the green component from the color.
Definition: SDL3pp_pixels.h:2241
constexpr Uint8 GetA() const noexcept
Get the alpha component from the color.
Definition: SDL3pp_pixels.h:2281
constexpr Color & SetB(Uint8 newB) noexcept
Set the blue component from the color.
Definition: SDL3pp_pixels.h:2269
constexpr Uint8 GetB() const noexcept
Get the blue component from the color.
Definition: SDL3pp_pixels.h:2261
constexpr Color & SetR(Uint8 newR) noexcept
Set the red component from the color.
Definition: SDL3pp_pixels.h:2229
constexpr Color(Uint8 r, Uint8 g, Uint8 b, Uint8 a=255) noexcept
Constructs from its fields.
Definition: SDL3pp_pixels.h:2211
constexpr Uint8 GetR() const noexcept
Get the red component from the color.
Definition: SDL3pp_pixels.h:2221
constexpr Color & SetA(Uint8 newA) noexcept
Set the alpha component from the color.
Definition: SDL3pp_pixels.h:2289
constexpr Color & SetG(Uint8 newG) noexcept
Set the green component from the color.
Definition: SDL3pp_pixels.h:2249
constexpr Color(ColorRaw color={}) noexcept
Wraps Color.
Definition: SDL3pp_pixels.h:2198
The bits of this structure can be directly reinterpreted as a float-packed color which uses the PIXEL...
Definition: SDL3pp_pixels.h:2365
constexpr FColor & SetB(float newB) noexcept
Set the blue component from the color.
Definition: SDL3pp_pixels.h:2442
constexpr float GetG() const noexcept
Get the green component from the color.
Definition: SDL3pp_pixels.h:2414
constexpr FColor(float r, float g, float b, float a=1) noexcept
Constructs from its fields.
Definition: SDL3pp_pixels.h:2384
constexpr FColor(const FColorRaw &color={}) noexcept
Wraps FColor.
Definition: SDL3pp_pixels.h:2371
constexpr FColor & SetR(float newR) noexcept
Set the red component from the color.
Definition: SDL3pp_pixels.h:2402
constexpr float GetB() const noexcept
Get the blue component from the color.
Definition: SDL3pp_pixels.h:2434
constexpr FColor & SetG(float newG) noexcept
Set the green component from the color.
Definition: SDL3pp_pixels.h:2422
constexpr FColor & SetA(float newA) noexcept
Set the alpha component from the color.
Definition: SDL3pp_pixels.h:2462
constexpr float GetR() const noexcept
Get the red component from the color.
Definition: SDL3pp_pixels.h:2394
constexpr float GetA() const noexcept
Get the alpha component from the color.
Definition: SDL3pp_pixels.h:2454
Safely wrap Palette for non owning const parameters.
Definition: SDL3pp_pixels.h:135
constexpr auto operator->()
member access to underlying PaletteRaw.
Definition: SDL3pp_pixels.h:166
constexpr PaletteConstParam(PaletteParam value)
Constructs from PaletteParam.
Definition: SDL3pp_pixels.h:145
constexpr PaletteConstParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_pixels.h:151
const PaletteRaw value
parameter's const PaletteRaw
Definition: SDL3pp_pixels.h:136
constexpr PaletteConstParam(const PaletteRaw value)
Constructs from const PaletteRaw.
Definition: SDL3pp_pixels.h:139
constexpr auto operator<=>(const PaletteConstParam &other) const =default
Comparison.
Safely wrap Palette for non owning parameters.
Definition: SDL3pp_pixels.h:105
constexpr PaletteParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_pixels.h:115
constexpr auto operator<=>(const PaletteParam &other) const =default
Comparison.
constexpr auto operator->()
member access to underlying PaletteRaw.
Definition: SDL3pp_pixels.h:130
PaletteRaw value
parameter's PaletteRaw
Definition: SDL3pp_pixels.h:106
constexpr PaletteParam(PaletteRaw value)
Constructs from PaletteRaw.
Definition: SDL3pp_pixels.h:109
Safe reference for Palette.
Definition: SDL3pp_pixels.h:2634
PaletteRef(Palette resource) noexcept
Constructs from Palette.
Definition: SDL3pp_pixels.h:2650
PaletteRef(PaletteRaw resource) noexcept
Constructs from PaletteRaw.
Definition: SDL3pp_pixels.h:2644