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
72using PixelFormatRaw = SDL_PixelFormat;
73
75using ColorspaceRaw = SDL_Colorspace;
76
78using ColorRaw = SDL_Color;
79
81using FColorRaw = SDL_FColor;
82
83// Forward decl
84struct Palette;
85
87using PaletteRaw = SDL_Palette*;
88
91{
93
96 : value(value)
97 {
98 }
99
101 constexpr PaletteParam(std::nullptr_t _ = nullptr)
102 : value(nullptr)
103 {
104 }
105
107 constexpr explicit operator bool() const { return !!value; }
108
110 constexpr auto operator<=>(const PaletteParam& other) const = default;
111
113 constexpr operator PaletteRaw() const { return value; }
114};
115
118{
120
123 : value(value)
124 {
125 }
126
129 : value(value.value)
130 {
131 }
132
134 constexpr PaletteConstParam(std::nullptr_t _ = nullptr)
135 : value(nullptr)
136 {
137 }
138
140 constexpr explicit operator bool() const { return !!value; }
141
143 constexpr auto operator<=>(const PaletteConstParam& other) const = default;
144
146 constexpr operator const PaletteRaw() const { return value; }
147};
148
149// Forward decl
150struct Color;
151
157using PixelFormatDetails = SDL_PixelFormatDetails;
158
166constexpr Uint8 ALPHA_OPAQUE = SDL_ALPHA_OPAQUE;
167
175constexpr float ALPHA_OPAQUE_FLOAT = SDL_ALPHA_OPAQUE_FLOAT;
176
184constexpr Uint8 ALPHA_TRANSPARENT = SDL_ALPHA_TRANSPARENT;
185
193constexpr float ALPHA_TRANSPARENT_FLOAT = SDL_ALPHA_TRANSPARENT_FLOAT;
194
207using PixelType = SDL_PixelType;
208
209constexpr PixelType PIXELTYPE_UNKNOWN = SDL_PIXELTYPE_UNKNOWN;
210
211constexpr PixelType PIXELTYPE_INDEX1 = SDL_PIXELTYPE_INDEX1;
212
213constexpr PixelType PIXELTYPE_INDEX4 = SDL_PIXELTYPE_INDEX4;
214
215constexpr PixelType PIXELTYPE_INDEX8 = SDL_PIXELTYPE_INDEX8;
216
217constexpr PixelType PIXELTYPE_PACKED8 = SDL_PIXELTYPE_PACKED8;
218
219constexpr PixelType PIXELTYPE_PACKED16 = SDL_PIXELTYPE_PACKED16;
220
221constexpr PixelType PIXELTYPE_PACKED32 = SDL_PIXELTYPE_PACKED32;
222
223constexpr PixelType PIXELTYPE_ARRAYU8 = SDL_PIXELTYPE_ARRAYU8;
224
225constexpr PixelType PIXELTYPE_ARRAYU16 = SDL_PIXELTYPE_ARRAYU16;
226
227constexpr PixelType PIXELTYPE_ARRAYU32 = SDL_PIXELTYPE_ARRAYU32;
228
229constexpr PixelType PIXELTYPE_ARRAYF16 = SDL_PIXELTYPE_ARRAYF16;
230
231constexpr PixelType PIXELTYPE_ARRAYF32 = SDL_PIXELTYPE_ARRAYF32;
232
233constexpr PixelType PIXELTYPE_INDEX2 = SDL_PIXELTYPE_INDEX2;
234
236
247using BitmapOrder = SDL_BitmapOrder;
248
249constexpr BitmapOrder BITMAPORDER_NONE = SDL_BITMAPORDER_NONE;
250
251constexpr BitmapOrder BITMAPORDER_4321 = SDL_BITMAPORDER_4321;
252
253constexpr BitmapOrder BITMAPORDER_1234 = SDL_BITMAPORDER_1234;
254
256
267using PackedOrder = SDL_PackedOrder;
268
269constexpr PackedOrder PACKEDORDER_NONE = SDL_PACKEDORDER_NONE;
270
271constexpr PackedOrder PACKEDORDER_XRGB = SDL_PACKEDORDER_XRGB;
272
273constexpr PackedOrder PACKEDORDER_RGBX = SDL_PACKEDORDER_RGBX;
274
275constexpr PackedOrder PACKEDORDER_ARGB = SDL_PACKEDORDER_ARGB;
276
277constexpr PackedOrder PACKEDORDER_RGBA = SDL_PACKEDORDER_RGBA;
278
279constexpr PackedOrder PACKEDORDER_XBGR = SDL_PACKEDORDER_XBGR;
280
281constexpr PackedOrder PACKEDORDER_BGRX = SDL_PACKEDORDER_BGRX;
282
283constexpr PackedOrder PACKEDORDER_ABGR = SDL_PACKEDORDER_ABGR;
284
285constexpr PackedOrder PACKEDORDER_BGRA = SDL_PACKEDORDER_BGRA;
286
288
299using ArrayOrder = SDL_ArrayOrder;
300
301constexpr ArrayOrder ARRAYORDER_NONE = SDL_ARRAYORDER_NONE;
302
303constexpr ArrayOrder ARRAYORDER_RGB = SDL_ARRAYORDER_RGB;
304
305constexpr ArrayOrder ARRAYORDER_RGBA = SDL_ARRAYORDER_RGBA;
306
307constexpr ArrayOrder ARRAYORDER_ARGB = SDL_ARRAYORDER_ARGB;
308
309constexpr ArrayOrder ARRAYORDER_BGR = SDL_ARRAYORDER_BGR;
310
311constexpr ArrayOrder ARRAYORDER_BGRA = SDL_ARRAYORDER_BGRA;
312
313constexpr ArrayOrder ARRAYORDER_ABGR = SDL_ARRAYORDER_ABGR;
314
316
327using PackedLayout = SDL_PackedLayout;
328
329constexpr PackedLayout PACKEDLAYOUT_NONE = SDL_PACKEDLAYOUT_NONE;
330
331constexpr PackedLayout PACKEDLAYOUT_332 = SDL_PACKEDLAYOUT_332;
332
333constexpr PackedLayout PACKEDLAYOUT_4444 = SDL_PACKEDLAYOUT_4444;
334
335constexpr PackedLayout PACKEDLAYOUT_1555 = SDL_PACKEDLAYOUT_1555;
336
337constexpr PackedLayout PACKEDLAYOUT_5551 = SDL_PACKEDLAYOUT_5551;
338
339constexpr PackedLayout PACKEDLAYOUT_565 = SDL_PACKEDLAYOUT_565;
340
341constexpr PackedLayout PACKEDLAYOUT_8888 = SDL_PACKEDLAYOUT_8888;
342
344 SDL_PACKEDLAYOUT_2101010;
345
347 SDL_PACKEDLAYOUT_1010102;
348
350
399{
400 PixelFormatRaw m_format;
401
402public:
408 constexpr PixelFormat(PixelFormatRaw format = {})
409 : m_format(format)
410 {
411 }
412
436 constexpr PixelFormat(PixelType type,
437 int order,
438 PackedLayout layout,
439 int bits,
440 int bytes)
441 : m_format(PixelFormatRaw(
442 SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes)))
443 {
444 }
445
451 constexpr operator PixelFormatRaw() const { return m_format; }
452
465 constexpr Uint8 GetFlags() const;
466
476 constexpr PixelType GetType() const;
477
490 constexpr int GetOrder() const;
491
504 constexpr PackedLayout GetLayout() const;
505
520 constexpr int GetBitsPerPixel() const;
521
539 constexpr int GetBytesPerPixel() const;
540
550 constexpr bool IsIndexed() const;
551
561 constexpr bool IsPacked() const;
562
572 constexpr bool IsArray() const;
573
583 constexpr bool Is10Bit() const;
584
594 constexpr bool IsFloat() const;
595
605 constexpr bool IsAlpha() const;
606
618 constexpr bool IsFourCC() const;
619
630 const char* GetName() const;
631
648 void GetMasks(int* bpp,
649 Uint32* Rmask,
650 Uint32* Gmask,
651 Uint32* Bmask,
652 Uint32* Amask) const;
653
674 static PixelFormat ForMasks(int bpp,
675 Uint32 Rmask,
676 Uint32 Gmask,
677 Uint32 Bmask,
678 Uint32 Amask);
679
694 const PixelFormatDetails& GetDetails() const;
695
728 Uint32 Map(Color color, PaletteConstParam palette) const;
729
754 Color Get(Uint32 pixel, PaletteConstParam palette) const;
755};
756
758 SDL_PIXELFORMAT_UNKNOWN;
759
761 SDL_PIXELFORMAT_INDEX1LSB;
762
764 SDL_PIXELFORMAT_INDEX1MSB;
765
767 SDL_PIXELFORMAT_INDEX2LSB;
768
770 SDL_PIXELFORMAT_INDEX2MSB;
771
773 SDL_PIXELFORMAT_INDEX4LSB;
774
776 SDL_PIXELFORMAT_INDEX4MSB;
777
778constexpr PixelFormat PIXELFORMAT_INDEX8 = SDL_PIXELFORMAT_INDEX8;
779
780constexpr PixelFormat PIXELFORMAT_RGB332 = SDL_PIXELFORMAT_RGB332;
781
783 SDL_PIXELFORMAT_XRGB4444;
784
786 SDL_PIXELFORMAT_XBGR4444;
787
789 SDL_PIXELFORMAT_XRGB1555;
790
792 SDL_PIXELFORMAT_XBGR1555;
793
795 SDL_PIXELFORMAT_ARGB4444;
796
798 SDL_PIXELFORMAT_RGBA4444;
799
801 SDL_PIXELFORMAT_ABGR4444;
802
804 SDL_PIXELFORMAT_BGRA4444;
805
807 SDL_PIXELFORMAT_ARGB1555;
808
810 SDL_PIXELFORMAT_RGBA5551;
811
813 SDL_PIXELFORMAT_ABGR1555;
814
816 SDL_PIXELFORMAT_BGRA5551;
817
818constexpr PixelFormat PIXELFORMAT_RGB565 = SDL_PIXELFORMAT_RGB565;
819
820constexpr PixelFormat PIXELFORMAT_BGR565 = SDL_PIXELFORMAT_BGR565;
821
822constexpr PixelFormat PIXELFORMAT_RGB24 = SDL_PIXELFORMAT_RGB24;
823
824constexpr PixelFormat PIXELFORMAT_BGR24 = SDL_PIXELFORMAT_BGR24;
825
827 SDL_PIXELFORMAT_XRGB8888;
828
830 SDL_PIXELFORMAT_RGBX8888;
831
833 SDL_PIXELFORMAT_XBGR8888;
834
836 SDL_PIXELFORMAT_BGRX8888;
837
839 SDL_PIXELFORMAT_ARGB8888;
840
842 SDL_PIXELFORMAT_RGBA8888;
843
845 SDL_PIXELFORMAT_ABGR8888;
846
848 SDL_PIXELFORMAT_BGRA8888;
849
851 SDL_PIXELFORMAT_XRGB2101010;
852
854 SDL_PIXELFORMAT_XBGR2101010;
855
857 SDL_PIXELFORMAT_ARGB2101010;
858
860 SDL_PIXELFORMAT_ABGR2101010;
861
862constexpr PixelFormat PIXELFORMAT_RGB48 = SDL_PIXELFORMAT_RGB48;
863
864constexpr PixelFormat PIXELFORMAT_BGR48 = SDL_PIXELFORMAT_BGR48;
865
866constexpr PixelFormat PIXELFORMAT_RGBA64 = SDL_PIXELFORMAT_RGBA64;
867
868constexpr PixelFormat PIXELFORMAT_ARGB64 = SDL_PIXELFORMAT_ARGB64;
869
870constexpr PixelFormat PIXELFORMAT_BGRA64 = SDL_PIXELFORMAT_BGRA64;
871
872constexpr PixelFormat PIXELFORMAT_ABGR64 = SDL_PIXELFORMAT_ABGR64;
873
875 SDL_PIXELFORMAT_RGB48_FLOAT;
876
878 SDL_PIXELFORMAT_BGR48_FLOAT;
879
881 SDL_PIXELFORMAT_RGBA64_FLOAT;
882
884 SDL_PIXELFORMAT_ARGB64_FLOAT;
885
887 SDL_PIXELFORMAT_BGRA64_FLOAT;
888
890 SDL_PIXELFORMAT_ABGR64_FLOAT;
891
893 SDL_PIXELFORMAT_RGB96_FLOAT;
894
896 SDL_PIXELFORMAT_BGR96_FLOAT;
897
899 SDL_PIXELFORMAT_RGBA128_FLOAT;
900
902 SDL_PIXELFORMAT_ARGB128_FLOAT;
903
905 SDL_PIXELFORMAT_BGRA128_FLOAT;
906
908 SDL_PIXELFORMAT_ABGR128_FLOAT;
909
911 SDL_PIXELFORMAT_YV12;
912
914 SDL_PIXELFORMAT_IYUV;
915
917 SDL_PIXELFORMAT_YUY2;
918
920 SDL_PIXELFORMAT_UYVY;
921
923 SDL_PIXELFORMAT_YVYU;
924
926 SDL_PIXELFORMAT_NV12;
927
929 SDL_PIXELFORMAT_NV21;
930
932 SDL_PIXELFORMAT_P010;
933
935 SDL_PIXELFORMAT_EXTERNAL_OES;
936
937#if SDL_VERSION_ATLEAST(3, 2, 10)
938
939constexpr PixelFormat PIXELFORMAT_MJPG = SDL_PIXELFORMAT_MJPG;
940
941#endif // SDL_VERSION_ATLEAST(3, 2, 10)
942
943constexpr PixelFormat PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_RGBA32;
944
945constexpr PixelFormat PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_ARGB32;
946
947constexpr PixelFormat PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_BGRA32;
948
949constexpr PixelFormat PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_ABGR32;
950
951constexpr PixelFormat PIXELFORMAT_RGBX32 = SDL_PIXELFORMAT_RGBX32;
952
953constexpr PixelFormat PIXELFORMAT_XRGB32 = SDL_PIXELFORMAT_XRGB32;
954
955constexpr PixelFormat PIXELFORMAT_BGRX32 = SDL_PIXELFORMAT_BGRX32;
956
957constexpr PixelFormat PIXELFORMAT_XBGR32 = SDL_PIXELFORMAT_XBGR32;
958
960
981{
982 return SDL_DEFINE_PIXELFOURCC(A, B, C, D);
983}
984
1009 int order,
1010 PackedLayout layout,
1011 int bits,
1012 int bytes)
1013{
1014 return PixelFormat(type, order, layout, bits, bytes);
1015}
1016
1031{
1032 return SDL_PIXELFLAG(format);
1033}
1034
1036{
1037 return SDL::PixelFormatFlags(m_format);
1038}
1039
1053{
1054 return PixelType(SDL_PIXELTYPE(format));
1055}
1056
1058{
1059 return SDL::PixelFormatType(m_format);
1060}
1061
1076{
1077 return SDL_PIXELORDER(format);
1078}
1079
1080constexpr int PixelFormat::GetOrder() const
1081{
1082 return SDL::PixelFormatOrder(m_format);
1083}
1084
1099{
1100 return PackedLayout(SDL_PIXELLAYOUT(format));
1101}
1102
1104{
1105 return SDL::PixelFormatLayout(m_format);
1106}
1107
1127{
1128 return SDL_BITSPERPIXEL(format);
1129}
1130
1131constexpr int PixelFormat::GetBitsPerPixel() const
1132{
1133 return SDL::PixelFormatBitsPerPixel(m_format);
1134}
1135
1155{
1156 return SDL_BYTESPERPIXEL(format);
1157}
1158
1160{
1161 return SDL::PixelFormatBytesPerPixel(m_format);
1162}
1163
1178{
1179 return SDL_ISPIXELFORMAT_INDEXED(format);
1180}
1181
1182constexpr bool PixelFormat::IsIndexed() const
1183{
1184 return SDL::IsPixelFormatIndexed(m_format);
1185}
1186
1201{
1202 return SDL_ISPIXELFORMAT_PACKED(format);
1203}
1204
1205constexpr bool PixelFormat::IsPacked() const
1206{
1207 return SDL::IsPixelFormatPacked(m_format);
1208}
1209
1224{
1225 return SDL_ISPIXELFORMAT_ARRAY(format);
1226}
1227
1228constexpr bool PixelFormat::IsArray() const
1229{
1230 return SDL::IsPixelFormatArray(m_format);
1231}
1232
1247{
1248 return SDL_ISPIXELFORMAT_10BIT(format);
1249}
1250
1251constexpr bool PixelFormat::Is10Bit() const
1252{
1253 return SDL::IsPixelFormat10Bit(m_format);
1254}
1255
1270{
1271 return SDL_ISPIXELFORMAT_FLOAT(format);
1272}
1273
1274constexpr bool PixelFormat::IsFloat() const
1275{
1276 return SDL::IsPixelFormatFloat(m_format);
1277}
1278
1298{
1299 return SDL_ISPIXELFORMAT_ALPHA(format);
1300}
1301
1302constexpr bool PixelFormat::IsAlpha() const
1303{
1304 return SDL::IsPixelFormatAlpha(m_format);
1305}
1306
1323{
1324 return SDL_ISPIXELFORMAT_FOURCC(format);
1325}
1326
1327constexpr bool PixelFormat::IsFourCC() const
1328{
1329 return SDL::IsPixelFormatFourCC(m_format);
1330}
1331
1337using ColorType = SDL_ColorType;
1338
1340 SDL_COLOR_TYPE_UNKNOWN;
1341
1342constexpr ColorType COLOR_TYPE_RGB = SDL_COLOR_TYPE_RGB;
1343
1345 SDL_COLOR_TYPE_YCBCR;
1346
1348
1360using ColorRange = SDL_ColorRange;
1361
1363 SDL_COLOR_RANGE_UNKNOWN;
1364
1368constexpr ColorRange COLOR_RANGE_LIMITED = SDL_COLOR_RANGE_LIMITED;
1369
1371constexpr ColorRange COLOR_RANGE_FULL = SDL_COLOR_RANGE_FULL;
1372
1374
1386using ColorPrimaries = SDL_ColorPrimaries;
1387
1389 SDL_COLOR_PRIMARIES_UNKNOWN;
1390
1392 SDL_COLOR_PRIMARIES_BT709;
1393
1395 SDL_COLOR_PRIMARIES_UNSPECIFIED;
1396
1398 SDL_COLOR_PRIMARIES_BT470M;
1399
1401 SDL_COLOR_PRIMARIES_BT470BG;
1403
1405 SDL_COLOR_PRIMARIES_BT601;
1406
1409 SDL_COLOR_PRIMARIES_SMPTE240;
1410
1412 SDL_COLOR_PRIMARIES_GENERIC_FILM;
1414
1416 SDL_COLOR_PRIMARIES_BT2020;
1417
1419 SDL_COLOR_PRIMARIES_XYZ;
1420
1422 SDL_COLOR_PRIMARIES_SMPTE431;
1423
1425 SDL_COLOR_PRIMARIES_SMPTE432;
1426
1428 SDL_COLOR_PRIMARIES_EBU3213;
1429
1431 SDL_COLOR_PRIMARIES_CUSTOM;
1432
1434
1447using TransferCharacteristics = SDL_TransferCharacteristics;
1448
1450 SDL_TRANSFER_CHARACTERISTICS_UNKNOWN;
1451
1453 SDL_TRANSFER_CHARACTERISTICS_BT709;
1454
1456 SDL_TRANSFER_CHARACTERISTICS_UNSPECIFIED;
1457
1460 SDL_TRANSFER_CHARACTERISTICS_GAMMA22;
1461
1463 SDL_TRANSFER_CHARACTERISTICS_GAMMA28;
1464
1466 SDL_TRANSFER_CHARACTERISTICS_BT601;
1468
1470 SDL_TRANSFER_CHARACTERISTICS_SMPTE240;
1471
1473 SDL_TRANSFER_CHARACTERISTICS_LINEAR;
1474
1476 SDL_TRANSFER_CHARACTERISTICS_LOG100;
1477
1479 SDL_TRANSFER_CHARACTERISTICS_LOG100_SQRT10;
1480
1482 SDL_TRANSFER_CHARACTERISTICS_IEC61966;
1483
1485 SDL_TRANSFER_CHARACTERISTICS_BT1361;
1486
1488 SDL_TRANSFER_CHARACTERISTICS_SRGB;
1489
1491 SDL_TRANSFER_CHARACTERISTICS_BT2020_10BIT;
1493
1495 SDL_TRANSFER_CHARACTERISTICS_BT2020_12BIT;
1497
1500 SDL_TRANSFER_CHARACTERISTICS_PQ;
1501
1503 SDL_TRANSFER_CHARACTERISTICS_SMPTE428;
1504
1506 SDL_TRANSFER_CHARACTERISTICS_HLG;
1508
1510 SDL_TRANSFER_CHARACTERISTICS_CUSTOM;
1511
1513
1526using MatrixCoefficients = SDL_MatrixCoefficients;
1527
1529 SDL_MATRIX_COEFFICIENTS_IDENTITY;
1530
1532 SDL_MATRIX_COEFFICIENTS_BT709;
1533
1535 SDL_MATRIX_COEFFICIENTS_UNSPECIFIED;
1536
1538 SDL_MATRIX_COEFFICIENTS_FCC;
1539
1545 SDL_MATRIX_COEFFICIENTS_BT470BG;
1546
1548 SDL_MATRIX_COEFFICIENTS_BT601;
1549
1551 SDL_MATRIX_COEFFICIENTS_SMPTE240;
1552
1554 SDL_MATRIX_COEFFICIENTS_YCGCO;
1555
1557 SDL_MATRIX_COEFFICIENTS_BT2020_NCL;
1559
1561 SDL_MATRIX_COEFFICIENTS_BT2020_CL;
1562
1564 SDL_MATRIX_COEFFICIENTS_SMPTE2085;
1565
1567 SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL;
1568
1570 SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL;
1571
1573 SDL_MATRIX_COEFFICIENTS_ICTCP;
1574
1576 SDL_MATRIX_COEFFICIENTS_CUSTOM;
1577
1579
1590using ChromaLocation = SDL_ChromaLocation;
1591
1593 SDL_CHROMA_LOCATION_NONE;
1594
1600constexpr ChromaLocation CHROMA_LOCATION_LEFT = SDL_CHROMA_LOCATION_LEFT;
1601
1607constexpr ChromaLocation CHROMA_LOCATION_CENTER = SDL_CHROMA_LOCATION_CENTER;
1608
1614constexpr ChromaLocation CHROMA_LOCATION_TOPLEFT = SDL_CHROMA_LOCATION_TOPLEFT;
1615
1617
1642{
1643 ColorspaceRaw m_cspace;
1644
1645public:
1651 constexpr Colorspace(ColorspaceRaw cspace = {})
1652 : m_cspace(cspace)
1653 {
1654 }
1655
1686 constexpr Colorspace(ColorType type,
1687 ColorRange range,
1688 ColorPrimaries primaries,
1689 TransferCharacteristics transfer,
1690 MatrixCoefficients matrix,
1691 ChromaLocation chroma)
1692 : m_cspace(ColorspaceRaw(SDL_DEFINE_COLORSPACE(type,
1693 range,
1694 primaries,
1695 transfer,
1696 matrix,
1697 chroma)))
1698 {
1699 }
1700
1706 constexpr operator ColorspaceRaw() const { return m_cspace; }
1707
1717 constexpr ColorType GetType() const;
1718
1728 constexpr ColorRange GetRange() const;
1729
1739 constexpr ChromaLocation GetChroma() const;
1740
1750 constexpr ColorPrimaries GetPrimaries() const;
1751
1761 constexpr TransferCharacteristics GetTransfer() const;
1762
1772 constexpr MatrixCoefficients GetMatrix() const;
1773
1783 constexpr bool IsMatrixBT601() const;
1784
1794 constexpr bool IsMatrixBT709() const;
1795
1805 constexpr bool IsMatrixBT2020_NCL() const;
1806
1816 constexpr bool IsLimitedRange() const;
1817
1827 constexpr bool IsFullRange() const;
1828};
1829
1830constexpr Colorspace COLORSPACE_UNKNOWN = SDL_COLORSPACE_UNKNOWN;
1831
1833constexpr Colorspace COLORSPACE_SRGB = SDL_COLORSPACE_SRGB;
1834
1836 SDL_COLORSPACE_SRGB_LINEAR;
1837
1839 SDL_COLORSPACE_HDR10;
1840
1842constexpr Colorspace COLORSPACE_JPEG = SDL_COLORSPACE_JPEG;
1843
1845constexpr Colorspace COLORSPACE_BT601_LIMITED = SDL_COLORSPACE_BT601_LIMITED;
1846
1848constexpr Colorspace COLORSPACE_BT601_FULL = SDL_COLORSPACE_BT601_FULL;
1849
1851constexpr Colorspace COLORSPACE_BT709_LIMITED = SDL_COLORSPACE_BT709_LIMITED;
1852
1854constexpr Colorspace COLORSPACE_BT709_FULL = SDL_COLORSPACE_BT709_FULL;
1855
1857constexpr Colorspace COLORSPACE_BT2020_LIMITED = SDL_COLORSPACE_BT2020_LIMITED;
1858
1860constexpr Colorspace COLORSPACE_BT2020_FULL = SDL_COLORSPACE_BT2020_FULL;
1861
1863constexpr Colorspace COLORSPACE_RGB_DEFAULT = SDL_COLORSPACE_RGB_DEFAULT;
1864
1866constexpr Colorspace COLORSPACE_YUV_DEFAULT = SDL_COLORSPACE_YUV_DEFAULT;
1867
1869
1901 ColorRange range,
1902 ColorPrimaries primaries,
1903 TransferCharacteristics transfer,
1904 MatrixCoefficients matrix,
1905 ChromaLocation chroma)
1906{
1907 return Colorspace(type, range, primaries, transfer, matrix, chroma);
1908}
1909
1921{
1922 return SDL_COLORSPACETYPE(cspace);
1923}
1924
1926{
1927 return SDL::ColorspaceType(m_cspace);
1928}
1929
1941{
1942 return SDL_COLORSPACERANGE(cspace);
1943}
1944
1946{
1947 return SDL::ColorspaceRange(m_cspace);
1948}
1949
1961{
1962 return SDL_COLORSPACECHROMA(cspace);
1963}
1964
1966{
1967 return SDL::ColorspaceChroma(m_cspace);
1968}
1969
1981{
1982 return SDL_COLORSPACEPRIMARIES(cspace);
1983}
1984
1986{
1987 return SDL::ColorspacePrimaries(m_cspace);
1988}
1989
2001{
2002 return SDL_COLORSPACETRANSFER(cspace);
2003}
2004
2006{
2007 return SDL::ColorspaceTransfer(m_cspace);
2008}
2009
2021{
2022 return SDL_COLORSPACEMATRIX(cspace);
2023}
2024
2026{
2027 return SDL::ColorspaceMatrix(m_cspace);
2028}
2029
2045{
2046 return SDL_ISCOLORSPACE_MATRIX_BT601(cspace);
2047}
2048
2049constexpr bool Colorspace::IsMatrixBT601() const
2050{
2051 return SDL::IsColorspaceMatrixBT601(m_cspace);
2052}
2053
2065{
2066 return SDL_ISCOLORSPACE_MATRIX_BT709(cspace);
2067}
2068
2069constexpr bool Colorspace::IsMatrixBT709() const
2070{
2071 return SDL::IsColorspaceMatrixBT709(m_cspace);
2072}
2073
2086{
2087 return SDL_ISCOLORSPACE_MATRIX_BT2020_NCL(cspace);
2088}
2089
2091{
2092 return SDL::IsColorspaceMatrixBT2020_NCL(m_cspace);
2093}
2094
2106{
2107 return SDL_ISCOLORSPACE_LIMITED_RANGE(cspace);
2108}
2109
2110constexpr bool Colorspace::IsLimitedRange() const
2111{
2112 return SDL::IsColorspaceLimitedRange(m_cspace);
2113}
2114
2126{
2127 return SDL_ISCOLORSPACE_FULL_RANGE(cspace);
2128}
2129
2130constexpr bool Colorspace::IsFullRange() const
2131{
2132 return SDL::IsColorspaceFullRange(m_cspace);
2133}
2134
2136constexpr bool operator==(ColorRaw lhs, ColorRaw rhs)
2137{
2138 return lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b && lhs.a == rhs.a;
2139}
2140
2142constexpr bool operator==(const FColorRaw& lhs, const FColorRaw& rhs)
2143{
2144 return lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b && lhs.a == rhs.a;
2145}
2146
2148constexpr auto operator<=>(ColorRaw lhs, ColorRaw rhs)
2149{
2150 if (lhs.r != rhs.r) return lhs.r <=> rhs.r;
2151 if (lhs.g != rhs.g) return lhs.g <=> rhs.g;
2152 if (lhs.b != rhs.b) return lhs.b <=> rhs.b;
2153 return lhs.a <=> rhs.a;
2154}
2155
2157constexpr auto operator<=>(const FColorRaw& lhs, const FColorRaw& rhs)
2158{
2159 if (lhs.r != rhs.r) return lhs.r <=> rhs.r;
2160 if (lhs.g != rhs.g) return lhs.g <=> rhs.g;
2161 if (lhs.b != rhs.b) return lhs.b <=> rhs.b;
2162 return lhs.a <=> rhs.a;
2163}
2164
2179{
2185 constexpr Color(ColorRaw color = {})
2186 : ColorRaw(color)
2187 {
2188 }
2189
2198 constexpr Color(Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255)
2199 : ColorRaw{r, g, b, a}
2200 {
2201 }
2202
2208 constexpr Uint8 GetR() const { return r; }
2209
2216 constexpr Color& SetR(Uint8 newR)
2217 {
2218 r = newR;
2219 return *this;
2220 }
2221
2228 constexpr Uint8 GetG() const { return g; }
2229
2236 constexpr Color& SetG(Uint8 newG)
2237 {
2238 g = newG;
2239 return *this;
2240 }
2241
2248 constexpr Uint8 GetB() const { return b; }
2249
2256 constexpr Color& SetB(Uint8 newB)
2257 {
2258 b = newB;
2259 return *this;
2260 }
2261
2268 constexpr Uint8 GetA() const { return a; }
2269
2276 constexpr Color& SetA(Uint8 newA)
2277 {
2278 a = newA;
2279 return *this;
2280 }
2281
2308 Uint32 Map(const PixelFormatDetails& format, PaletteConstParam palette) const;
2309
2336 static Color Get(Uint32 pixel,
2337 const PixelFormatDetails& format,
2338 PaletteConstParam palette);
2339};
2340
2352{
2358 constexpr FColor(const FColorRaw& color = {})
2359 : FColorRaw(color)
2360 {
2361 }
2362
2371 constexpr FColor(float r, float g, float b, float a = 1)
2372 : FColorRaw{r, g, b, a}
2373 {
2374 }
2375
2381 constexpr float GetR() const { return r; }
2382
2389 constexpr FColor& SetR(float newR)
2390 {
2391 r = newR;
2392 return *this;
2393 }
2394
2401 constexpr float GetG() const { return g; }
2402
2409 constexpr FColor& SetG(float newG)
2410 {
2411 g = newG;
2412 return *this;
2413 }
2414
2421 constexpr float GetB() const { return b; }
2422
2429 constexpr FColor& SetB(float newB)
2430 {
2431 b = newB;
2432 return *this;
2433 }
2434
2441 constexpr float GetA() const { return a; }
2442
2449 constexpr FColor& SetA(float newA)
2450 {
2451 a = newA;
2452 return *this;
2453 }
2454};
2455
2466{
2467 PaletteRaw m_resource = nullptr;
2468
2469public:
2471 constexpr Palette() = default;
2472
2480 constexpr explicit Palette(const PaletteRaw resource)
2481 : m_resource(resource)
2482 {
2483 }
2484
2486 constexpr Palette(const Palette& other) { ++m_resource->refcount; }
2487
2489 constexpr Palette(Palette&& other)
2490 : Palette(other.release())
2491 {
2492 }
2493
2511 Palette(int ncolors)
2512 : m_resource(CheckError(SDL_CreatePalette(ncolors)))
2513 {
2514 }
2515
2523 static constexpr Palette Borrow(PaletteParam resource)
2524 {
2525 if (resource) {
2526 ++resource.value->refcount;
2527 return Palette(resource.value);
2528 }
2529 return {};
2530 }
2531
2533 ~Palette() { SDL_DestroyPalette(m_resource); }
2534
2537 {
2538 std::swap(m_resource, other.m_resource);
2539 return *this;
2540 }
2541
2543 constexpr PaletteRaw get() const { return m_resource; }
2544
2547 {
2548 auto r = m_resource;
2549 m_resource = nullptr;
2550 return r;
2551 }
2552
2554 constexpr auto operator<=>(const Palette& other) const = default;
2555
2557 constexpr bool operator==(std::nullptr_t _) const { return !m_resource; }
2558
2560 constexpr explicit operator bool() const { return !!m_resource; }
2561
2563 constexpr operator PaletteParam() const { return {m_resource}; }
2564
2576 void Destroy();
2577
2579 constexpr int GetSize() const { return m_resource->ncolors; }
2580
2582 constexpr Color operator[](int index) const
2583 {
2584 return m_resource->colors[index];
2585 }
2586
2601 void SetColors(SpanRef<const ColorRaw> colors, int firstcolor = 0);
2602};
2603
2615inline const char* GetPixelFormatName(PixelFormatRaw format)
2616{
2617 return SDL_GetPixelFormatName(format);
2618}
2619
2620inline const char* PixelFormat::GetName() const
2621{
2622 return SDL::GetPixelFormatName(m_format);
2623}
2624
2643 int* bpp,
2644 Uint32* Rmask,
2645 Uint32* Gmask,
2646 Uint32* Bmask,
2647 Uint32* Amask)
2648{
2649 CheckError(
2650 SDL_GetMasksForPixelFormat(format, bpp, Rmask, Gmask, Bmask, Amask));
2651}
2652
2653inline void PixelFormat::GetMasks(int* bpp,
2654 Uint32* Rmask,
2655 Uint32* Gmask,
2656 Uint32* Bmask,
2657 Uint32* Amask) const
2658{
2659 SDL::GetMasksForPixelFormat(m_format, bpp, Rmask, Gmask, Bmask, Amask);
2660}
2661
2683 Uint32 Rmask,
2684 Uint32 Gmask,
2685 Uint32 Bmask,
2686 Uint32 Amask)
2687{
2688 return SDL_GetPixelFormatForMasks(bpp, Rmask, Gmask, Bmask, Amask);
2689}
2690
2692 Uint32 Rmask,
2693 Uint32 Gmask,
2694 Uint32 Bmask,
2695 Uint32 Amask)
2696{
2697 return SDL::GetPixelFormatForMasks(bpp, Rmask, Gmask, Bmask, Amask);
2698}
2699
2716{
2717 return *SDL_GetPixelFormatDetails(format);
2718}
2719
2721{
2722 return SDL::GetPixelFormatDetails(m_format);
2723}
2724
2742inline Palette CreatePalette(int ncolors) { return Palette(ncolors); }
2743
2757inline void SetPaletteColors(PaletteParam palette,
2759 int firstcolor = 0)
2760{
2761 CheckError(
2762 SDL_SetPaletteColors(palette, colors.data(), firstcolor, colors.size()));
2763}
2764
2765inline void Palette::SetColors(SpanRef<const ColorRaw> colors, int firstcolor)
2766{
2767 SDL::SetPaletteColors(m_resource, colors, firstcolor);
2768}
2769
2782inline void DestroyPalette(PaletteRaw palette) { SDL_DestroyPalette(palette); }
2783
2785
2822inline Uint32 MapRGB(const PixelFormatDetails& format,
2823 PaletteConstParam palette,
2824 Uint8 r,
2825 Uint8 g,
2826 Uint8 b)
2827{
2828 return SDL_MapRGB(&format, palette, r, g, b);
2829}
2830
2865inline Uint32 MapRGBA(const PixelFormatDetails& format,
2866 PaletteConstParam palette,
2867 ColorRaw c)
2868{
2869 return SDL_MapRGBA(&format, palette, c.r, c.g, c.b, c.a);
2870}
2871
2898inline void GetRGB(Uint32 pixel,
2899 const PixelFormatDetails& format,
2900 PaletteConstParam palette,
2901 Uint8* r,
2902 Uint8* g,
2903 Uint8* b)
2904{
2905 SDL_GetRGB(pixel, &format, palette, r, g, b);
2906}
2907
2938inline void GetRGBA(Uint32 pixel,
2939 const PixelFormatDetails& format,
2940 PaletteConstParam palette,
2941 Uint8* r,
2942 Uint8* g,
2943 Uint8* b,
2944 Uint8* a)
2945{
2946 SDL_GetRGBA(pixel, &format, palette, r, g, b, a);
2947}
2948
2950
2952 PaletteConstParam palette = nullptr) const
2953{
2954 return MapRGBA(format, palette, {r, g, b, a});
2955}
2956
2958 const PixelFormatDetails& format,
2959 PaletteConstParam palette = nullptr)
2960{
2961 Color c;
2962 GetRGBA(pixel, format, palette, &c.r, &c.g, &c.b, &c.a);
2963 return c;
2964}
2965
2967 PaletteConstParam palette = nullptr) const
2968{
2969 return color.Map(GetDetails(), palette);
2970}
2971
2973 PaletteConstParam palette = nullptr) const
2974{
2975 return Color::Get(pixel, GetDetails(), palette);
2976}
2977
2978} // namespace SDL
2979
2980#endif /* SDL3PP_PIXELS_H_ */
Colorspace definitions.
Definition: SDL3pp_pixels.h:1642
constexpr Colorspace(ColorType type, ColorRange range, ColorPrimaries primaries, TransferCharacteristics transfer, MatrixCoefficients matrix, ChromaLocation chroma)
Define custom Colorspace formats.
Definition: SDL3pp_pixels.h:1686
constexpr Colorspace(ColorspaceRaw cspace={})
Wraps Colorspace.
Definition: SDL3pp_pixels.h:1651
A set of indexed colors representing a palette.
Definition: SDL3pp_pixels.h:2466
static constexpr Palette Borrow(PaletteParam resource)
Safely borrows the from PaletteParam.
Definition: SDL3pp_pixels.h:2523
constexpr Palette(Palette &&other)
Move constructor.
Definition: SDL3pp_pixels.h:2489
Palette & operator=(Palette other)
Assignment operator.
Definition: SDL3pp_pixels.h:2536
constexpr Palette(const PaletteRaw resource)
Constructs from PaletteParam.
Definition: SDL3pp_pixels.h:2480
constexpr bool operator==(std::nullptr_t _) const
Comparison.
Definition: SDL3pp_pixels.h:2557
constexpr PaletteRaw get() const
Retrieves underlying PaletteRaw.
Definition: SDL3pp_pixels.h:2543
constexpr PaletteRaw release()
Retrieves underlying PaletteRaw and clear this.
Definition: SDL3pp_pixels.h:2546
constexpr Palette(const Palette &other)
Copy constructor.
Definition: SDL3pp_pixels.h:2486
constexpr Color operator[](int index) const
Access specific pallete index.
Definition: SDL3pp_pixels.h:2582
~Palette()
Destructor.
Definition: SDL3pp_pixels.h:2533
constexpr int GetSize() const
Returns number of colors in the palette.
Definition: SDL3pp_pixels.h:2579
constexpr auto operator<=>(const Palette &other) const =default
Comparison.
Palette(int ncolors)
Create a palette structure with the specified number of color entries.
Definition: SDL3pp_pixels.h:2511
constexpr Palette()=default
Default ctor.
Pixel format.
Definition: SDL3pp_pixels.h:399
Color Get(Uint32 pixel, PaletteConstParam palette) const
Get RGBA values from a pixel in the specified format.
Definition: SDL3pp_pixels.h:2972
constexpr PixelFormat(PixelType type, int order, PackedLayout layout, int bits, int bytes)
Defining custom non-FourCC pixel formats.
Definition: SDL3pp_pixels.h:436
constexpr PixelFormat(PixelFormatRaw format={})
Wraps PixelFormat.
Definition: SDL3pp_pixels.h:408
Uint32 Map(Color color, PaletteConstParam palette) const
Map an RGBA quadruple to a pixel value for a given pixel format.
Definition: SDL3pp_pixels.h:2966
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:198
constexpr PixelFormat PIXELFORMAT_ABGR1555
ABGR1555.
Definition: SDL3pp_pixels.h:812
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_FCC
US FCC Title 47.
Definition: SDL3pp_pixels.h:1537
constexpr bool IsMatrixBT709() const
Determine if an Colorspace uses BT709 matrix coefficients.
Definition: SDL3pp_pixels.h:2069
constexpr PixelFormat PIXELFORMAT_IYUV
Planar mode: Y + U + V (3 planes)
Definition: SDL3pp_pixels.h:913
constexpr bool IsPixelFormatArray(PixelFormatRaw format)
A macro to determine if an PixelFormat is an array format.
Definition: SDL3pp_pixels.h:1223
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_SMPTE240
SMPTE 240M.
Definition: SDL3pp_pixels.h:1550
constexpr ColorPrimaries COLOR_PRIMARIES_UNSPECIFIED
COLOR_PRIMARIES_UNSPECIFIED.
Definition: SDL3pp_pixels.h:1394
constexpr ColorPrimaries COLOR_PRIMARIES_BT709
ITU-R BT.709-6.
Definition: SDL3pp_pixels.h:1391
constexpr PixelFormat PIXELFORMAT_BGRA64
BGRA64.
Definition: SDL3pp_pixels.h:870
constexpr PixelType PIXELTYPE_PACKED8
PACKED8.
Definition: SDL3pp_pixels.h:217
void DestroyPalette(PaletteRaw palette)
Free a palette created with Palette.Palette().
Definition: SDL3pp_pixels.h:2782
constexpr PackedLayout PACKEDLAYOUT_1555
1555
Definition: SDL3pp_pixels.h:335
constexpr PixelFormat PIXELFORMAT_RGB96_FLOAT
RGB96_FLOAT.
Definition: SDL3pp_pixels.h:892
constexpr ChromaLocation ColorspaceChroma(ColorspaceRaw cspace)
A macro to retrieve the chroma sample location of an Colorspace.
Definition: SDL3pp_pixels.h:1960
constexpr PixelFormat PIXELFORMAT_P010
Planar mode: Y + U/V interleaved (2 planes)
Definition: SDL3pp_pixels.h:931
constexpr int PixelFormatOrder(PixelFormatRaw format)
A macro to retrieve the order of an PixelFormat.
Definition: SDL3pp_pixels.h:1075
const char * GetName() const
Get the human readable name of a pixel format.
Definition: SDL3pp_pixels.h:2620
constexpr PixelFormat PIXELFORMAT_XRGB32
XRGB32.
Definition: SDL3pp_pixels.h:953
constexpr ColorPrimaries ColorspacePrimaries(ColorspaceRaw cspace)
A macro to retrieve the primaries of an Colorspace.
Definition: SDL3pp_pixels.h:1980
constexpr ColorType GetType() const
Retrieve the type of a Colorspace.
Definition: SDL3pp_pixels.h:1925
constexpr PixelType PIXELTYPE_ARRAYF32
ARRAYF32.
Definition: SDL3pp_pixels.h:231
constexpr Uint8 GetFlags() const
Retrieve the flags of an PixelFormat.
Definition: SDL3pp_pixels.h:1035
constexpr bool IsPixelFormat10Bit(PixelFormatRaw format)
A macro to determine if an PixelFormat is a 10-bit format.
Definition: SDL3pp_pixels.h:1246
constexpr PixelFormat PIXELFORMAT_MJPG
Motion JPEG.
Definition: SDL3pp_pixels.h:939
constexpr ColorRange COLOR_RANGE_LIMITED
Narrow range, e.g.
Definition: SDL3pp_pixels.h:1368
constexpr ColorType ColorspaceType(ColorspaceRaw cspace)
A macro to retrieve the type of an Colorspace.
Definition: SDL3pp_pixels.h:1920
constexpr bool IsColorspaceLimitedRange(ColorspaceRaw cspace)
A macro to determine if an Colorspace has a limited range.
Definition: SDL3pp_pixels.h:2105
constexpr PixelFormat PIXELFORMAT_XRGB1555
XRGB1555.
Definition: SDL3pp_pixels.h:788
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_SMPTE240
SMPTE ST 240M.
Definition: SDL3pp_pixels.h:1469
constexpr PackedLayout PACKEDLAYOUT_1010102
1010102
Definition: SDL3pp_pixels.h:346
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT2020_12BIT
ITU-R BT2020 for 12-bit system.
Definition: SDL3pp_pixels.h:1494
constexpr ArrayOrder ARRAYORDER_RGB
RGB.
Definition: SDL3pp_pixels.h:303
SDL_PackedLayout PackedLayout
Packed component layout.
Definition: SDL3pp_pixels.h:327
SDL_ArrayOrder ArrayOrder
Array component order, low byte -> high byte.
Definition: SDL3pp_pixels.h:299
constexpr PixelFormat PIXELFORMAT_EXTERNAL_OES
Android video texture format.
Definition: SDL3pp_pixels.h:934
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_UNSPECIFIED
MATRIX_COEFFICIENTS_UNSPECIFIED.
Definition: SDL3pp_pixels.h:1534
constexpr Uint8 PixelFormatFlags(PixelFormatRaw format)
Retrieve the flags of an PixelFormat.
Definition: SDL3pp_pixels.h:1030
constexpr PixelFormat PIXELFORMAT_INDEX1MSB
INDEX1MSB.
Definition: SDL3pp_pixels.h:763
constexpr PixelType PIXELTYPE_PACKED32
PACKED32.
Definition: SDL3pp_pixels.h:221
constexpr PixelType PIXELTYPE_ARRAYF16
ARRAYF16.
Definition: SDL3pp_pixels.h:229
constexpr PixelFormat PIXELFORMAT_ABGR8888
ABGR8888.
Definition: SDL3pp_pixels.h:844
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:1386
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_SMPTE2085
SMPTE ST 2085.
Definition: SDL3pp_pixels.h:1563
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_ICTCP
ITU-R BT.2100-0 ICTCP.
Definition: SDL3pp_pixels.h:1572
void Destroy()
Free a palette created with Palette.Palette().
Definition: SDL3pp_pixels.h:2784
constexpr PixelFormat PIXELFORMAT_NV21
Planar mode: Y + V/U interleaved (2 planes)
Definition: SDL3pp_pixels.h:928
SDL_ChromaLocation ChromaLocation
Colorspace chroma sample location.
Definition: SDL3pp_pixels.h:1590
constexpr bool IsPixelFormatPacked(PixelFormatRaw format)
A macro to determine if an PixelFormat is a packed format.
Definition: SDL3pp_pixels.h:1200
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_LOG100
TRANSFER_CHARACTERISTICS_LOG100.
Definition: SDL3pp_pixels.h:1475
constexpr ColorType COLOR_TYPE_YCBCR
COLOR_TYPE_YCBCR.
Definition: SDL3pp_pixels.h:1344
constexpr PixelFormat PIXELFORMAT_ARGB2101010
ARGB2101010.
Definition: SDL3pp_pixels.h:856
constexpr bool IsPixelFormatAlpha(PixelFormatRaw format)
A macro to determine if an PixelFormat has an alpha channel.
Definition: SDL3pp_pixels.h:1297
constexpr PixelFormat PIXELFORMAT_INDEX4MSB
INDEX4MSB.
Definition: SDL3pp_pixels.h:775
constexpr int PixelFormatBytesPerPixel(PixelFormatRaw format)
A macro to determine an PixelFormat's bytes per pixel.
Definition: SDL3pp_pixels.h:1154
constexpr PixelFormat PIXELFORMAT_UNKNOWN
UNKNOWN.
Definition: SDL3pp_pixels.h:757
constexpr ColorPrimaries COLOR_PRIMARIES_UNKNOWN
COLOR_PRIMARIES_UNKNOWN.
Definition: SDL3pp_pixels.h:1388
constexpr PixelFormat PIXELFORMAT_ABGR4444
ABGR4444.
Definition: SDL3pp_pixels.h:800
constexpr PixelFormat PIXELFORMAT_BGRA64_FLOAT
BGRA64_FLOAT.
Definition: SDL3pp_pixels.h:886
constexpr BitmapOrder BITMAPORDER_1234
1234
Definition: SDL3pp_pixels.h:253
constexpr PixelFormat PIXELFORMAT_ABGR32
ABGR32.
Definition: SDL3pp_pixels.h:949
constexpr PixelFormat PIXELFORMAT_BGRA128_FLOAT
BGRA128_FLOAT.
Definition: SDL3pp_pixels.h:904
constexpr PixelFormat PIXELFORMAT_XBGR2101010
XBGR2101010.
Definition: SDL3pp_pixels.h:853
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT601
SMPTE ST 170M / ITU-R BT.601-7 525 or.
Definition: SDL3pp_pixels.h:1465
constexpr ColorRange ColorspaceRange(ColorspaceRaw cspace)
A macro to retrieve the range of an Colorspace.
Definition: SDL3pp_pixels.h:1940
constexpr bool IsColorspaceFullRange(ColorspaceRaw cspace)
A macro to determine if an Colorspace has a full range.
Definition: SDL3pp_pixels.h:2125
constexpr PackedLayout PACKEDLAYOUT_565
565
Definition: SDL3pp_pixels.h:339
const char * GetPixelFormatName(PixelFormatRaw format)
Get the human readable name of a pixel format.
Definition: SDL3pp_pixels.h:2615
constexpr PackedOrder PACKEDORDER_BGRA
BGRA.
Definition: SDL3pp_pixels.h:285
constexpr PixelFormat PIXELFORMAT_XRGB8888
XRGB8888.
Definition: SDL3pp_pixels.h:826
constexpr PixelFormat PIXELFORMAT_BGR96_FLOAT
BGR96_FLOAT.
Definition: SDL3pp_pixels.h:895
constexpr bool Is10Bit() const
Determine if this is a 10-bit format.
Definition: SDL3pp_pixels.h:1251
SDL_Colorspace ColorspaceRaw
Alias to raw representation for Colorspace.
Definition: SDL3pp_pixels.h:75
constexpr bool IsIndexed() const
Determine if this is an indexed format.
Definition: SDL3pp_pixels.h:1182
constexpr PixelFormat PIXELFORMAT_INDEX8
INDEX8.
Definition: SDL3pp_pixels.h:778
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL
MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL.
Definition: SDL3pp_pixels.h:1569
constexpr MatrixCoefficients ColorspaceMatrix(ColorspaceRaw cspace)
A macro to retrieve the matrix coefficients of an Colorspace.
Definition: SDL3pp_pixels.h:2020
constexpr PixelFormat PIXELFORMAT_INDEX1LSB
INDEX1LSB.
Definition: SDL3pp_pixels.h:760
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_SMPTE428
SMPTE ST 428-1.
Definition: SDL3pp_pixels.h:1502
constexpr TransferCharacteristics GetTransfer() const
Retrieve the transfer characteristics of an Colorspace.
Definition: SDL3pp_pixels.h:2005
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:1614
constexpr ChromaLocation GetChroma() const
Retrieve the chroma sample location of an Colorspace.
Definition: SDL3pp_pixels.h:1965
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_GAMMA22
ITU-R BT.470-6 System M / ITU-R BT1700 625 PAL & SECAM.
Definition: SDL3pp_pixels.h:1459
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT2020_NCL
ITU-R BT.2020-2 non-constant luminance.
Definition: SDL3pp_pixels.h:1556
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:1544
SDL_TransferCharacteristics TransferCharacteristics
Colorspace transfer characteristics.
Definition: SDL3pp_pixels.h:1447
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_SRGB
IEC 61966-2-1 (sRGB or sYCC)
Definition: SDL3pp_pixels.h:1487
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:1900
constexpr PixelFormat PIXELFORMAT_BGRA8888
BGRA8888.
Definition: SDL3pp_pixels.h:847
constexpr PixelFormat PIXELFORMAT_RGBX8888
RGBX8888.
Definition: SDL3pp_pixels.h:829
constexpr PixelFormat PIXELFORMAT_YVYU
Packed mode: Y0+V0+Y1+U0 (1 plane)
Definition: SDL3pp_pixels.h:922
constexpr Uint8 ALPHA_TRANSPARENT
A fully transparent 8-bit alpha value.
Definition: SDL3pp_pixels.h:184
constexpr ColorPrimaries COLOR_PRIMARIES_BT470BG
ITU-R BT.470-6 System B, G / ITU-R BT.601-7.
Definition: SDL3pp_pixels.h:1400
constexpr ArrayOrder ARRAYORDER_NONE
NONE.
Definition: SDL3pp_pixels.h:301
constexpr PackedOrder PACKEDORDER_ARGB
ARGB.
Definition: SDL3pp_pixels.h:275
constexpr Uint8 ALPHA_OPAQUE
A fully opaque 8-bit alpha value.
Definition: SDL3pp_pixels.h:166
constexpr PackedLayout PixelFormatLayout(PixelFormatRaw format)
A macro to retrieve the layout of an PixelFormat.
Definition: SDL3pp_pixels.h:1098
constexpr PixelFormat PIXELFORMAT_RGB24
RGB24.
Definition: SDL3pp_pixels.h:822
constexpr ColorPrimaries GetPrimaries() const
Retrieve the primaries of an Colorspace.
Definition: SDL3pp_pixels.h:1985
constexpr Colorspace COLORSPACE_UNKNOWN
UNKNOWN.
Definition: SDL3pp_pixels.h:1830
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:1600
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT2020_CL
ITU-R BT.2020-2 constant luminance.
Definition: SDL3pp_pixels.h:1560
constexpr Colorspace COLORSPACE_BT601_FULL
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601.
Definition: SDL3pp_pixels.h:1848
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:2691
constexpr PixelFormat PIXELFORMAT_ARGB8888
ARGB8888.
Definition: SDL3pp_pixels.h:838
constexpr Colorspace COLORSPACE_SRGB_LINEAR
[object Object]
Definition: SDL3pp_pixels.h:1835
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_HLG
ARIB STD-B67, known as "hybrid log-gamma" (HLG)
Definition: SDL3pp_pixels.h:1505
constexpr auto operator<=>(ColorRaw lhs, ColorRaw rhs)
Spaceship operator for Color.
Definition: SDL3pp_pixels.h:2148
constexpr PackedLayout PACKEDLAYOUT_NONE
NONE.
Definition: SDL3pp_pixels.h:329
SDL_Palette * PaletteRaw
Alias to raw representation for Palette.
Definition: SDL3pp_pixels.h:87
constexpr PixelFormat PIXELFORMAT_ARGB128_FLOAT
ARGB128_FLOAT.
Definition: SDL3pp_pixels.h:901
constexpr PixelType PIXELTYPE_ARRAYU16
ARRAYU16.
Definition: SDL3pp_pixels.h:225
constexpr ColorType COLOR_TYPE_UNKNOWN
COLOR_TYPE_UNKNOWN.
Definition: SDL3pp_pixels.h:1339
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT709
ITU-R BT.709-6.
Definition: SDL3pp_pixels.h:1531
constexpr PixelFormat PIXELFORMAT_RGBX32
RGBX32.
Definition: SDL3pp_pixels.h:951
constexpr PackedOrder PACKEDORDER_RGBX
RGBX.
Definition: SDL3pp_pixels.h:273
constexpr Colorspace COLORSPACE_SRGB
Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709.
Definition: SDL3pp_pixels.h:1833
constexpr bool IsMatrixBT2020_NCL() const
Determine if an Colorspace uses BT2020_NCL matrix coefficients.
Definition: SDL3pp_pixels.h:2090
constexpr PackedLayout PACKEDLAYOUT_4444
4444
Definition: SDL3pp_pixels.h:333
constexpr PixelFormat PIXELFORMAT_RGBA5551
RGBA5551.
Definition: SDL3pp_pixels.h:809
Uint32 MapRGBA(const PixelFormatDetails &format, PaletteConstParam palette, ColorRaw c)
Map an RGBA quadruple to a pixel value for a given pixel format.
Definition: SDL3pp_pixels.h:2865
constexpr float ALPHA_TRANSPARENT_FLOAT
A fully transparent floating point alpha value.
Definition: SDL3pp_pixels.h:193
constexpr bool operator==(ColorRaw lhs, ColorRaw rhs)
Comparison operator for Color.
Definition: SDL3pp_pixels.h:2136
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:1360
void GetRGBA(Uint32 pixel, 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:2938
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:1008
constexpr PixelFormat PIXELFORMAT_XBGR8888
XBGR8888.
Definition: SDL3pp_pixels.h:832
constexpr PixelFormat PIXELFORMAT_BGR48
BGR48.
Definition: SDL3pp_pixels.h:864
constexpr PixelType PIXELTYPE_UNKNOWN
UNKNOWN.
Definition: SDL3pp_pixels.h:209
constexpr bool IsFloat() const
Determine if this is a floating point format.
Definition: SDL3pp_pixels.h:1274
constexpr Colorspace COLORSPACE_BT601_LIMITED
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601.
Definition: SDL3pp_pixels.h:1845
constexpr PixelFormat PIXELFORMAT_ARGB1555
ARGB1555.
Definition: SDL3pp_pixels.h:806
void SetColors(SpanRef< const ColorRaw > colors, int firstcolor=0)
Set a range of colors in a palette.
Definition: SDL3pp_pixels.h:2765
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT601
ITU-R BT.601-7 525.
Definition: SDL3pp_pixels.h:1547
constexpr ColorPrimaries COLOR_PRIMARIES_EBU3213
EBU Tech. 3213-E.
Definition: SDL3pp_pixels.h:1427
constexpr PackedOrder PACKEDORDER_ABGR
ABGR.
Definition: SDL3pp_pixels.h:283
constexpr bool IsMatrixBT601() const
Determine if a Colorspace uses BT601 (or BT470BG) matrix coefficients.
Definition: SDL3pp_pixels.h:2049
constexpr ColorPrimaries COLOR_PRIMARIES_SMPTE240
SMPTE 240M, functionally the same as COLOR_PRIMARIES_BT601.
Definition: SDL3pp_pixels.h:1408
constexpr Colorspace COLORSPACE_BT709_LIMITED
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709.
Definition: SDL3pp_pixels.h:1851
constexpr BitmapOrder BITMAPORDER_NONE
NONE.
Definition: SDL3pp_pixels.h:249
constexpr PixelFormat PIXELFORMAT_ARGB64_FLOAT
ARGB64_FLOAT.
Definition: SDL3pp_pixels.h:883
SDL_PixelFormatDetails PixelFormatDetails
Details about the format of a pixel.
Definition: SDL3pp_pixels.h:157
constexpr PixelFormat PIXELFORMAT_XRGB2101010
XRGB2101010.
Definition: SDL3pp_pixels.h:850
constexpr BitmapOrder BITMAPORDER_4321
4321
Definition: SDL3pp_pixels.h:251
constexpr bool IsPacked() const
Determine if this is a packed format.
Definition: SDL3pp_pixels.h:1205
constexpr ColorPrimaries COLOR_PRIMARIES_CUSTOM
COLOR_PRIMARIES_CUSTOM.
Definition: SDL3pp_pixels.h:1430
constexpr ColorPrimaries COLOR_PRIMARIES_BT2020
ITU-R BT.2020-2 / ITU-R BT.2100-0.
Definition: SDL3pp_pixels.h:1415
constexpr ColorType COLOR_TYPE_RGB
COLOR_TYPE_RGB.
Definition: SDL3pp_pixels.h:1342
constexpr PixelType PIXELTYPE_INDEX4
INDEX4.
Definition: SDL3pp_pixels.h:213
constexpr Colorspace COLORSPACE_BT709_FULL
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709.
Definition: SDL3pp_pixels.h:1854
SDL_PixelFormat PixelFormatRaw
Alias to raw representation for PixelFormat.
Definition: SDL3pp_pixels.h:72
constexpr PixelFormat PIXELFORMAT_XBGR4444
XBGR4444.
Definition: SDL3pp_pixels.h:785
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT1361
ITU-R BT1361 Extended Colour Gamut.
Definition: SDL3pp_pixels.h:1484
constexpr PixelType PIXELTYPE_PACKED16
PACKED16.
Definition: SDL3pp_pixels.h:219
const PixelFormatDetails & GetPixelFormatDetails(PixelFormatRaw format)
Create an PixelFormatDetails structure corresponding to a pixel format.
Definition: SDL3pp_pixels.h:2715
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_YCGCO
MATRIX_COEFFICIENTS_YCGCO.
Definition: SDL3pp_pixels.h:1553
constexpr PackedLayout PACKEDLAYOUT_332
332
Definition: SDL3pp_pixels.h:331
constexpr PixelFormat PIXELFORMAT_RGBA8888
RGBA8888.
Definition: SDL3pp_pixels.h:841
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_PQ
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition: SDL3pp_pixels.h:1499
constexpr bool IsColorspaceMatrixBT601(ColorspaceRaw cspace)
A macro to determine if an Colorspace uses BT601 (or BT470BG) matrix coefficients.
Definition: SDL3pp_pixels.h:2044
constexpr PackedLayout GetLayout() const
Retrieve the layout.
Definition: SDL3pp_pixels.h:1103
constexpr PixelFormat PIXELFORMAT_RGBA4444
RGBA4444.
Definition: SDL3pp_pixels.h:797
constexpr PixelType PIXELTYPE_ARRAYU8
ARRAYU8.
Definition: SDL3pp_pixels.h:223
constexpr PixelFormat PIXELFORMAT_ARGB32
ARGB32.
Definition: SDL3pp_pixels.h:945
constexpr PixelFormat PIXELFORMAT_INDEX4LSB
INDEX4LSB.
Definition: SDL3pp_pixels.h:772
constexpr bool IsPixelFormatFloat(PixelFormatRaw format)
A macro to determine if an PixelFormat is a floating point format.
Definition: SDL3pp_pixels.h:1269
constexpr ArrayOrder ARRAYORDER_ABGR
ABGR.
Definition: SDL3pp_pixels.h:313
constexpr bool IsFourCC() const
Determine if this is a "FourCC" format.
Definition: SDL3pp_pixels.h:1327
constexpr PixelFormat PIXELFORMAT_ABGR64_FLOAT
ABGR64_FLOAT.
Definition: SDL3pp_pixels.h:889
constexpr bool IsPixelFormatFourCC(PixelFormatRaw format)
A macro to determine if an PixelFormat is a "FourCC" format.
Definition: SDL3pp_pixels.h:1322
constexpr ColorPrimaries COLOR_PRIMARIES_BT470M
ITU-R BT.470-6 System M.
Definition: SDL3pp_pixels.h:1397
constexpr ColorPrimaries COLOR_PRIMARIES_SMPTE431
SMPTE RP 431-2.
Definition: SDL3pp_pixels.h:1421
constexpr PixelFormat PIXELFORMAT_ABGR128_FLOAT
ABGR128_FLOAT.
Definition: SDL3pp_pixels.h:907
constexpr ColorPrimaries COLOR_PRIMARIES_XYZ
SMPTE ST 428-1.
Definition: SDL3pp_pixels.h:1418
constexpr PixelFormat PIXELFORMAT_ABGR2101010
ABGR2101010.
Definition: SDL3pp_pixels.h:859
SDL_ColorType ColorType
Colorspace color type.
Definition: SDL3pp_pixels.h:1337
constexpr PixelFormat PIXELFORMAT_BGRX8888
BGRX8888.
Definition: SDL3pp_pixels.h:835
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL
MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL.
Definition: SDL3pp_pixels.h:1566
constexpr float ALPHA_OPAQUE_FLOAT
A fully opaque floating point alpha value.
Definition: SDL3pp_pixels.h:175
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_CUSTOM
MATRIX_COEFFICIENTS_CUSTOM.
Definition: SDL3pp_pixels.h:1575
constexpr PixelFormat PIXELFORMAT_YV12
Planar mode: Y + V + U (3 planes)
Definition: SDL3pp_pixels.h:910
constexpr PixelFormat PIXELFORMAT_BGRX32
BGRX32.
Definition: SDL3pp_pixels.h:955
constexpr PixelFormat PIXELFORMAT_BGRA4444
BGRA4444.
Definition: SDL3pp_pixels.h:803
constexpr PixelFormat PIXELFORMAT_INDEX2MSB
INDEX2MSB.
Definition: SDL3pp_pixels.h:769
void SetPaletteColors(PaletteParam palette, SpanRef< const ColorRaw > colors, int firstcolor=0)
Set a range of colors in a palette.
Definition: SDL3pp_pixels.h:2757
constexpr PixelFormat PIXELFORMAT_BGR565
BGR565.
Definition: SDL3pp_pixels.h:820
constexpr PixelFormat PIXELFORMAT_RGB48_FLOAT
RGB48_FLOAT.
Definition: SDL3pp_pixels.h:874
constexpr PixelFormat PIXELFORMAT_RGB565
RGB565.
Definition: SDL3pp_pixels.h:818
constexpr PixelFormat PIXELFORMAT_RGBA32
RGBA32.
Definition: SDL3pp_pixels.h:943
constexpr PixelFormat PIXELFORMAT_BGR24
BGR24.
Definition: SDL3pp_pixels.h:824
constexpr PackedLayout PACKEDLAYOUT_2101010
2101010
Definition: SDL3pp_pixels.h:343
constexpr bool IsColorspaceMatrixBT709(ColorspaceRaw cspace)
A macro to determine if an Colorspace uses BT709 matrix coefficients.
Definition: SDL3pp_pixels.h:2064
constexpr int GetOrder() const
Retrieve the order.
Definition: SDL3pp_pixels.h:1080
constexpr PixelFormat PIXELFORMAT_NV12
Planar mode: Y + U/V interleaved (2 planes)
Definition: SDL3pp_pixels.h:925
SDL_MatrixCoefficients MatrixCoefficients
Colorspace matrix coefficients.
Definition: SDL3pp_pixels.h:1526
constexpr ColorPrimaries COLOR_PRIMARIES_SMPTE432
SMPTE EG 432-1 / DCI P3.
Definition: SDL3pp_pixels.h:1424
constexpr Colorspace COLORSPACE_JPEG
Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601.
Definition: SDL3pp_pixels.h:1842
constexpr PixelFormat PIXELFORMAT_INDEX2LSB
INDEX2LSB.
Definition: SDL3pp_pixels.h:766
SDL_PackedOrder PackedOrder
Packed component order, high bit -> low bit.
Definition: SDL3pp_pixels.h:267
constexpr PackedLayout PACKEDLAYOUT_5551
5551
Definition: SDL3pp_pixels.h:337
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:2822
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:1371
constexpr bool IsArray() const
Determine if this is an array format.
Definition: SDL3pp_pixels.h:1228
constexpr PixelFormat PIXELFORMAT_ABGR64
ABGR64.
Definition: SDL3pp_pixels.h:872
constexpr PackedOrder PACKEDORDER_RGBA
RGBA.
Definition: SDL3pp_pixels.h:277
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:2642
constexpr Uint32 DefinePixelFourCC(Uint8 A, Uint8 B, Uint8 C, Uint8 D)
A function for defining custom FourCC pixel formats.
Definition: SDL3pp_pixels.h:980
constexpr PixelFormat PIXELFORMAT_RGBA128_FLOAT
RGBA128_FLOAT.
Definition: SDL3pp_pixels.h:898
constexpr Colorspace COLORSPACE_BT2020_LIMITED
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020.
Definition: SDL3pp_pixels.h:1857
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:2682
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_UNSPECIFIED
TRANSFER_CHARACTERISTICS_UNSPECIFIED.
Definition: SDL3pp_pixels.h:1455
constexpr int PixelFormatBitsPerPixel(PixelFormatRaw format)
A macro to determine an PixelFormat's bits per pixel.
Definition: SDL3pp_pixels.h:1126
constexpr int GetBytesPerPixel() const
Determine this's bytes per pixel.
Definition: SDL3pp_pixels.h:1159
constexpr PixelFormat PIXELFORMAT_RGB332
RGB332.
Definition: SDL3pp_pixels.h:780
constexpr PixelFormat PIXELFORMAT_BGRA5551
BGRA5551.
Definition: SDL3pp_pixels.h:815
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_CUSTOM
TRANSFER_CHARACTERISTICS_CUSTOM.
Definition: SDL3pp_pixels.h:1509
constexpr ArrayOrder ARRAYORDER_BGRA
BGRA.
Definition: SDL3pp_pixels.h:311
constexpr ColorPrimaries COLOR_PRIMARIES_GENERIC_FILM
Generic film (color filters using Illuminant C)
Definition: SDL3pp_pixels.h:1411
constexpr PixelType PIXELTYPE_INDEX2
INDEX2.
Definition: SDL3pp_pixels.h:233
constexpr ColorRange COLOR_RANGE_UNKNOWN
COLOR_RANGE_UNKNOWN.
Definition: SDL3pp_pixels.h:1362
constexpr ColorPrimaries COLOR_PRIMARIES_BT601
ITU-R BT.601-7 525, SMPTE 170M.
Definition: SDL3pp_pixels.h:1404
constexpr bool IsAlpha() const
Determine if this has an alpha channel.
Definition: SDL3pp_pixels.h:1302
constexpr MatrixCoefficients GetMatrix() const
Retrieve the matrix coefficients of an Colorspace.
Definition: SDL3pp_pixels.h:2025
constexpr PixelFormat PIXELFORMAT_YUY2
Packed mode: Y0+U0+Y1+V0 (1 plane)
Definition: SDL3pp_pixels.h:916
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_LINEAR
TRANSFER_CHARACTERISTICS_LINEAR.
Definition: SDL3pp_pixels.h:1472
constexpr PixelType PIXELTYPE_ARRAYU32
ARRAYU32.
Definition: SDL3pp_pixels.h:227
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_UNKNOWN
TRANSFER_CHARACTERISTICS_UNKNOWN.
Definition: SDL3pp_pixels.h:1449
constexpr PixelType GetType() const
Retrieve the type.
Definition: SDL3pp_pixels.h:1057
constexpr ArrayOrder ARRAYORDER_RGBA
RGBA.
Definition: SDL3pp_pixels.h:305
constexpr PixelFormat PIXELFORMAT_RGBA64_FLOAT
RGBA64_FLOAT.
Definition: SDL3pp_pixels.h:880
constexpr bool IsColorspaceMatrixBT2020_NCL(ColorspaceRaw cspace)
A macro to determine if an Colorspace uses BT2020_NCL matrix coefficients.
Definition: SDL3pp_pixels.h:2085
constexpr PixelFormat PIXELFORMAT_XRGB4444
XRGB4444.
Definition: SDL3pp_pixels.h:782
constexpr Colorspace COLORSPACE_BT2020_FULL
Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020.
Definition: SDL3pp_pixels.h:1860
constexpr TransferCharacteristics ColorspaceTransfer(ColorspaceRaw cspace)
A macro to retrieve the transfer characteristics of an Colorspace.
Definition: SDL3pp_pixels.h:2000
constexpr ChromaLocation CHROMA_LOCATION_NONE
RGB, no chroma sampling.
Definition: SDL3pp_pixels.h:1592
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT2020_10BIT
ITU-R BT2020 for 10-bit system.
Definition: SDL3pp_pixels.h:1490
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:1607
constexpr PixelFormat PIXELFORMAT_RGBA64
RGBA64.
Definition: SDL3pp_pixels.h:866
SDL_FColor FColorRaw
Alias to raw representation for FColor.
Definition: SDL3pp_pixels.h:81
constexpr PixelFormat PIXELFORMAT_UYVY
Packed mode: U0+Y0+V0+Y1 (1 plane)
Definition: SDL3pp_pixels.h:919
constexpr Colorspace COLORSPACE_RGB_DEFAULT
The default colorspace for RGB surfaces if no colorspace is specified.
Definition: SDL3pp_pixels.h:1863
constexpr PackedOrder PACKEDORDER_NONE
NONE.
Definition: SDL3pp_pixels.h:269
constexpr PixelType PixelFormatType(PixelFormatRaw format)
A macro to retrieve the type of an PixelFormat.
Definition: SDL3pp_pixels.h:1052
SDL_Color ColorRaw
Alias to raw representation for Color.
Definition: SDL3pp_pixels.h:78
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_GAMMA28
ITU-R BT.470-6 System B, G.
Definition: SDL3pp_pixels.h:1462
constexpr PixelFormat PIXELFORMAT_ARGB4444
ARGB4444.
Definition: SDL3pp_pixels.h:794
SDL_BitmapOrder BitmapOrder
Bitmap pixel order, high bit -> low bit.
Definition: SDL3pp_pixels.h:247
constexpr ArrayOrder ARRAYORDER_BGR
BGR.
Definition: SDL3pp_pixels.h:309
constexpr PixelFormat PIXELFORMAT_BGRA32
BGRA32.
Definition: SDL3pp_pixels.h:947
void GetRGB(Uint32 pixel, 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:2898
constexpr bool IsFullRange() const
A function to determine if an Colorspace has a full range.
Definition: SDL3pp_pixels.h:2130
constexpr int GetBitsPerPixel() const
Determine this's bits per pixel.
Definition: SDL3pp_pixels.h:1131
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT709
Rec. ITU-R BT.709-6 / ITU-R BT1361.
Definition: SDL3pp_pixels.h:1452
constexpr PixelType PIXELTYPE_INDEX1
INDEX1.
Definition: SDL3pp_pixels.h:211
constexpr PixelFormat PIXELFORMAT_XBGR32
XBGR32.
Definition: SDL3pp_pixels.h:957
constexpr bool IsPixelFormatIndexed(PixelFormatRaw format)
A macro to determine if an PixelFormat is an indexed format.
Definition: SDL3pp_pixels.h:1177
SDL_PixelType PixelType
Pixel type.
Definition: SDL3pp_pixels.h:207
constexpr ArrayOrder ARRAYORDER_ARGB
ARGB.
Definition: SDL3pp_pixels.h:307
constexpr PixelFormat PIXELFORMAT_ARGB64
ARGB64.
Definition: SDL3pp_pixels.h:868
constexpr Colorspace COLORSPACE_HDR10
[object Object]
Definition: SDL3pp_pixels.h:1838
constexpr PackedOrder PACKEDORDER_XRGB
XRGB.
Definition: SDL3pp_pixels.h:271
constexpr PackedLayout PACKEDLAYOUT_8888
8888
Definition: SDL3pp_pixels.h:341
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:2653
const PixelFormatDetails & GetDetails() const
Create an PixelFormatDetails structure corresponding to a pixel format.
Definition: SDL3pp_pixels.h:2720
constexpr PixelFormat PIXELFORMAT_RGB48
RGB48.
Definition: SDL3pp_pixels.h:862
constexpr bool IsLimitedRange() const
A function to determine if an Colorspace has a limited range.
Definition: SDL3pp_pixels.h:2110
constexpr PixelFormat PIXELFORMAT_XBGR1555
XBGR1555.
Definition: SDL3pp_pixels.h:791
constexpr ColorRange GetRange() const
Retrieve the range of a Colorspace.
Definition: SDL3pp_pixels.h:1945
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_LOG100_SQRT10
TRANSFER_CHARACTERISTICS_LOG100_SQRT10.
Definition: SDL3pp_pixels.h:1478
Palette CreatePalette(int ncolors)
Create a palette structure with the specified number of color entries.
Definition: SDL3pp_pixels.h:2742
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_IEC61966
IEC 61966-2-4.
Definition: SDL3pp_pixels.h:1481
constexpr PackedOrder PACKEDORDER_BGRX
BGRX.
Definition: SDL3pp_pixels.h:281
constexpr Colorspace COLORSPACE_YUV_DEFAULT
The default colorspace for YUV surfaces if no colorspace is specified.
Definition: SDL3pp_pixels.h:1866
constexpr PackedOrder PACKEDORDER_XBGR
XBGR.
Definition: SDL3pp_pixels.h:279
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_IDENTITY
MATRIX_COEFFICIENTS_IDENTITY.
Definition: SDL3pp_pixels.h:1528
constexpr PixelFormat PIXELFORMAT_BGR48_FLOAT
BGR48_FLOAT.
Definition: SDL3pp_pixels.h:877
constexpr PixelType PIXELTYPE_INDEX8
INDEX8.
Definition: SDL3pp_pixels.h:215
Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:325
Uint8 Uint8
An unsigned 8-bit integer type.
Definition: SDL3pp_stdinc.h:257
Main include header for the SDL3pp library.
A structure that represents a color as RGBA components.
Definition: SDL3pp_pixels.h:2179
constexpr Uint8 GetR() const
Get the red component from the color.
Definition: SDL3pp_pixels.h:2208
constexpr Uint8 GetB() const
Get the blue component from the color.
Definition: SDL3pp_pixels.h:2248
constexpr Color & SetG(Uint8 newG)
Set the green component from the color.
Definition: SDL3pp_pixels.h:2236
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:2951
constexpr Color(Uint8 r, Uint8 g, Uint8 b, Uint8 a=255)
Constructs from its fields.
Definition: SDL3pp_pixels.h:2198
constexpr Color & SetR(Uint8 newR)
Set the red component from the color.
Definition: SDL3pp_pixels.h:2216
constexpr Uint8 GetG() const
Get the green component from the color.
Definition: SDL3pp_pixels.h:2228
constexpr Color(ColorRaw color={})
Wraps Color.
Definition: SDL3pp_pixels.h:2185
constexpr Color & SetA(Uint8 newA)
Set the alpha component from the color.
Definition: SDL3pp_pixels.h:2276
constexpr Color & SetB(Uint8 newB)
Set the blue component from the color.
Definition: SDL3pp_pixels.h:2256
constexpr Uint8 GetA() const
Get the alpha component from the color.
Definition: SDL3pp_pixels.h:2268
static Color Get(Uint32 pixel, const PixelFormatDetails &format, PaletteConstParam palette)
Get RGBA values from a pixel in the specified format.
Definition: SDL3pp_pixels.h:2957
The bits of this structure can be directly reinterpreted as a float-packed color which uses the PIXEL...
Definition: SDL3pp_pixels.h:2352
constexpr FColor & SetG(float newG)
Set the green component from the color.
Definition: SDL3pp_pixels.h:2409
constexpr float GetA() const
Get the alpha component from the color.
Definition: SDL3pp_pixels.h:2441
constexpr FColor(float r, float g, float b, float a=1)
Constructs from its fields.
Definition: SDL3pp_pixels.h:2371
constexpr float GetR() const
Get the red component from the color.
Definition: SDL3pp_pixels.h:2381
constexpr float GetG() const
Get the green component from the color.
Definition: SDL3pp_pixels.h:2401
constexpr FColor & SetR(float newR)
Set the red component from the color.
Definition: SDL3pp_pixels.h:2389
constexpr FColor & SetA(float newA)
Set the alpha component from the color.
Definition: SDL3pp_pixels.h:2449
constexpr FColor & SetB(float newB)
Set the blue component from the color.
Definition: SDL3pp_pixels.h:2429
constexpr FColor(const FColorRaw &color={})
Wraps FColor.
Definition: SDL3pp_pixels.h:2358
constexpr float GetB() const
Get the blue component from the color.
Definition: SDL3pp_pixels.h:2421
Safely wrap Palette for non owning const parameters.
Definition: SDL3pp_pixels.h:118
constexpr PaletteConstParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_pixels.h:134
constexpr PaletteConstParam(PaletteParam value)
Constructs from PaletteParam.
Definition: SDL3pp_pixels.h:128
const PaletteRaw value
parameter's const PaletteRaw
Definition: SDL3pp_pixels.h:119
constexpr PaletteConstParam(const PaletteRaw value)
Constructs from const PaletteRaw.
Definition: SDL3pp_pixels.h:122
constexpr auto operator<=>(const PaletteConstParam &other) const =default
Comparison.
Safely wrap Palette for non owning parameters.
Definition: SDL3pp_pixels.h:91
constexpr PaletteParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_pixels.h:101
constexpr auto operator<=>(const PaletteParam &other) const =default
Comparison.
PaletteRaw value
parameter's PaletteRaw
Definition: SDL3pp_pixels.h:92
constexpr PaletteParam(PaletteRaw value)
Constructs from PaletteRaw.
Definition: SDL3pp_pixels.h:95