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
102{
104
107 : value(value)
108 {
109 }
110
112 constexpr PaletteParam(std::nullptr_t _ = nullptr)
113 : value(nullptr)
114 {
115 }
116
118 constexpr explicit operator bool() const { return !!value; }
119
121 constexpr auto operator<=>(const PaletteParam& other) const = default;
122
124 constexpr operator PaletteRaw() const { return value; }
125
127 constexpr auto operator->() { return value; }
128};
129
132{
134
137 : value(value)
138 {
139 }
140
143 : value(value.value)
144 {
145 }
146
148 constexpr PaletteConstParam(std::nullptr_t _ = nullptr)
149 : value(nullptr)
150 {
151 }
152
154 constexpr explicit operator bool() const { return !!value; }
155
157 constexpr auto operator<=>(const PaletteConstParam& other) const = default;
158
160 constexpr operator const PaletteRaw() const { return value; }
161
163 constexpr auto operator->() { return value; }
164};
165
171using PixelFormatDetails = SDL_PixelFormatDetails;
172
180constexpr Uint8 ALPHA_OPAQUE = SDL_ALPHA_OPAQUE;
181
189constexpr float ALPHA_OPAQUE_FLOAT = SDL_ALPHA_OPAQUE_FLOAT;
190
198constexpr Uint8 ALPHA_TRANSPARENT = SDL_ALPHA_TRANSPARENT;
199
207constexpr float ALPHA_TRANSPARENT_FLOAT = SDL_ALPHA_TRANSPARENT_FLOAT;
208
221using PixelType = SDL_PixelType;
222
223constexpr PixelType PIXELTYPE_UNKNOWN = SDL_PIXELTYPE_UNKNOWN;
224
225constexpr PixelType PIXELTYPE_INDEX1 = SDL_PIXELTYPE_INDEX1;
226
227constexpr PixelType PIXELTYPE_INDEX4 = SDL_PIXELTYPE_INDEX4;
228
229constexpr PixelType PIXELTYPE_INDEX8 = SDL_PIXELTYPE_INDEX8;
230
231constexpr PixelType PIXELTYPE_PACKED8 = SDL_PIXELTYPE_PACKED8;
232
233constexpr PixelType PIXELTYPE_PACKED16 = SDL_PIXELTYPE_PACKED16;
234
235constexpr PixelType PIXELTYPE_PACKED32 = SDL_PIXELTYPE_PACKED32;
236
237constexpr PixelType PIXELTYPE_ARRAYU8 = SDL_PIXELTYPE_ARRAYU8;
238
239constexpr PixelType PIXELTYPE_ARRAYU16 = SDL_PIXELTYPE_ARRAYU16;
240
241constexpr PixelType PIXELTYPE_ARRAYU32 = SDL_PIXELTYPE_ARRAYU32;
242
243constexpr PixelType PIXELTYPE_ARRAYF16 = SDL_PIXELTYPE_ARRAYF16;
244
245constexpr PixelType PIXELTYPE_ARRAYF32 = SDL_PIXELTYPE_ARRAYF32;
246
247constexpr PixelType PIXELTYPE_INDEX2 = SDL_PIXELTYPE_INDEX2;
248
250
261using BitmapOrder = SDL_BitmapOrder;
262
263constexpr BitmapOrder BITMAPORDER_NONE = SDL_BITMAPORDER_NONE;
264
265constexpr BitmapOrder BITMAPORDER_4321 = SDL_BITMAPORDER_4321;
266
267constexpr BitmapOrder BITMAPORDER_1234 = SDL_BITMAPORDER_1234;
268
270
281using PackedOrder = SDL_PackedOrder;
282
283constexpr PackedOrder PACKEDORDER_NONE = SDL_PACKEDORDER_NONE;
284
285constexpr PackedOrder PACKEDORDER_XRGB = SDL_PACKEDORDER_XRGB;
286
287constexpr PackedOrder PACKEDORDER_RGBX = SDL_PACKEDORDER_RGBX;
288
289constexpr PackedOrder PACKEDORDER_ARGB = SDL_PACKEDORDER_ARGB;
290
291constexpr PackedOrder PACKEDORDER_RGBA = SDL_PACKEDORDER_RGBA;
292
293constexpr PackedOrder PACKEDORDER_XBGR = SDL_PACKEDORDER_XBGR;
294
295constexpr PackedOrder PACKEDORDER_BGRX = SDL_PACKEDORDER_BGRX;
296
297constexpr PackedOrder PACKEDORDER_ABGR = SDL_PACKEDORDER_ABGR;
298
299constexpr PackedOrder PACKEDORDER_BGRA = SDL_PACKEDORDER_BGRA;
300
302
313using ArrayOrder = SDL_ArrayOrder;
314
315constexpr ArrayOrder ARRAYORDER_NONE = SDL_ARRAYORDER_NONE;
316
317constexpr ArrayOrder ARRAYORDER_RGB = SDL_ARRAYORDER_RGB;
318
319constexpr ArrayOrder ARRAYORDER_RGBA = SDL_ARRAYORDER_RGBA;
320
321constexpr ArrayOrder ARRAYORDER_ARGB = SDL_ARRAYORDER_ARGB;
322
323constexpr ArrayOrder ARRAYORDER_BGR = SDL_ARRAYORDER_BGR;
324
325constexpr ArrayOrder ARRAYORDER_BGRA = SDL_ARRAYORDER_BGRA;
326
327constexpr ArrayOrder ARRAYORDER_ABGR = SDL_ARRAYORDER_ABGR;
328
330
341using PackedLayout = SDL_PackedLayout;
342
343constexpr PackedLayout PACKEDLAYOUT_NONE = SDL_PACKEDLAYOUT_NONE;
344
345constexpr PackedLayout PACKEDLAYOUT_332 = SDL_PACKEDLAYOUT_332;
346
347constexpr PackedLayout PACKEDLAYOUT_4444 = SDL_PACKEDLAYOUT_4444;
348
349constexpr PackedLayout PACKEDLAYOUT_1555 = SDL_PACKEDLAYOUT_1555;
350
351constexpr PackedLayout PACKEDLAYOUT_5551 = SDL_PACKEDLAYOUT_5551;
352
353constexpr PackedLayout PACKEDLAYOUT_565 = SDL_PACKEDLAYOUT_565;
354
355constexpr PackedLayout PACKEDLAYOUT_8888 = SDL_PACKEDLAYOUT_8888;
356
358 SDL_PACKEDLAYOUT_2101010;
359
361 SDL_PACKEDLAYOUT_1010102;
362
364
411{
412 PixelFormatRaw m_format;
413
414public:
420 constexpr PixelFormat(PixelFormatRaw format = {})
421 : m_format(format)
422 {
423 }
424
448 constexpr PixelFormat(PixelType type,
449 int order,
450 PackedLayout layout,
451 int bits,
452 int bytes)
453 : m_format(PixelFormatRaw(
454 SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes)))
455 {
456 }
457
463 constexpr operator PixelFormatRaw() const { return m_format; }
464
484 static PixelFormat ForMasks(int bpp,
485 Uint32 Rmask,
486 Uint32 Gmask,
487 Uint32 Bmask,
488 Uint32 Amask);
489
502 constexpr Uint8 GetFlags() const;
503
513 constexpr PixelType GetType() const;
514
527 constexpr int GetOrder() const;
528
541 constexpr PackedLayout GetLayout() const;
542
557 constexpr int GetBitsPerPixel() const;
558
576 constexpr int GetBytesPerPixel() const;
577
587 constexpr bool IsIndexed() const;
588
598 constexpr bool IsPacked() const;
599
609 constexpr bool IsArray() const;
610
620 constexpr bool Is10Bit() const;
621
631 constexpr bool IsFloat() const;
632
642 constexpr bool IsAlpha() const;
643
655 constexpr bool IsFourCC() const;
656
667 const char* GetName() const;
668
685 void GetMasks(int* bpp,
686 Uint32* Rmask,
687 Uint32* Gmask,
688 Uint32* Bmask,
689 Uint32* Amask) const;
690
705 const PixelFormatDetails& GetDetails() const;
706
708 operator const PixelFormatDetails&() const;
709
742 Uint32 Map(ColorRaw c, PaletteConstParam palette = {}) const;
743
768 Color Get(Uint32 pixel, PaletteConstParam palette = {}) const;
769};
770
772 SDL_PIXELFORMAT_UNKNOWN;
773
775 SDL_PIXELFORMAT_INDEX1LSB;
776
778 SDL_PIXELFORMAT_INDEX1MSB;
779
781 SDL_PIXELFORMAT_INDEX2LSB;
782
784 SDL_PIXELFORMAT_INDEX2MSB;
785
787 SDL_PIXELFORMAT_INDEX4LSB;
788
790 SDL_PIXELFORMAT_INDEX4MSB;
791
792constexpr PixelFormat PIXELFORMAT_INDEX8 = SDL_PIXELFORMAT_INDEX8;
793
794constexpr PixelFormat PIXELFORMAT_RGB332 = SDL_PIXELFORMAT_RGB332;
795
797 SDL_PIXELFORMAT_XRGB4444;
798
800 SDL_PIXELFORMAT_XBGR4444;
801
803 SDL_PIXELFORMAT_XRGB1555;
804
806 SDL_PIXELFORMAT_XBGR1555;
807
809 SDL_PIXELFORMAT_ARGB4444;
810
812 SDL_PIXELFORMAT_RGBA4444;
813
815 SDL_PIXELFORMAT_ABGR4444;
816
818 SDL_PIXELFORMAT_BGRA4444;
819
821 SDL_PIXELFORMAT_ARGB1555;
822
824 SDL_PIXELFORMAT_RGBA5551;
825
827 SDL_PIXELFORMAT_ABGR1555;
828
830 SDL_PIXELFORMAT_BGRA5551;
831
832constexpr PixelFormat PIXELFORMAT_RGB565 = SDL_PIXELFORMAT_RGB565;
833
834constexpr PixelFormat PIXELFORMAT_BGR565 = SDL_PIXELFORMAT_BGR565;
835
836constexpr PixelFormat PIXELFORMAT_RGB24 = SDL_PIXELFORMAT_RGB24;
837
838constexpr PixelFormat PIXELFORMAT_BGR24 = SDL_PIXELFORMAT_BGR24;
839
841 SDL_PIXELFORMAT_XRGB8888;
842
844 SDL_PIXELFORMAT_RGBX8888;
845
847 SDL_PIXELFORMAT_XBGR8888;
848
850 SDL_PIXELFORMAT_BGRX8888;
851
853 SDL_PIXELFORMAT_ARGB8888;
854
856 SDL_PIXELFORMAT_RGBA8888;
857
859 SDL_PIXELFORMAT_ABGR8888;
860
862 SDL_PIXELFORMAT_BGRA8888;
863
865 SDL_PIXELFORMAT_XRGB2101010;
866
868 SDL_PIXELFORMAT_XBGR2101010;
869
871 SDL_PIXELFORMAT_ARGB2101010;
872
874 SDL_PIXELFORMAT_ABGR2101010;
875
876constexpr PixelFormat PIXELFORMAT_RGB48 = SDL_PIXELFORMAT_RGB48;
877
878constexpr PixelFormat PIXELFORMAT_BGR48 = SDL_PIXELFORMAT_BGR48;
879
880constexpr PixelFormat PIXELFORMAT_RGBA64 = SDL_PIXELFORMAT_RGBA64;
881
882constexpr PixelFormat PIXELFORMAT_ARGB64 = SDL_PIXELFORMAT_ARGB64;
883
884constexpr PixelFormat PIXELFORMAT_BGRA64 = SDL_PIXELFORMAT_BGRA64;
885
886constexpr PixelFormat PIXELFORMAT_ABGR64 = SDL_PIXELFORMAT_ABGR64;
887
889 SDL_PIXELFORMAT_RGB48_FLOAT;
890
892 SDL_PIXELFORMAT_BGR48_FLOAT;
893
895 SDL_PIXELFORMAT_RGBA64_FLOAT;
896
898 SDL_PIXELFORMAT_ARGB64_FLOAT;
899
901 SDL_PIXELFORMAT_BGRA64_FLOAT;
902
904 SDL_PIXELFORMAT_ABGR64_FLOAT;
905
907 SDL_PIXELFORMAT_RGB96_FLOAT;
908
910 SDL_PIXELFORMAT_BGR96_FLOAT;
911
913 SDL_PIXELFORMAT_RGBA128_FLOAT;
914
916 SDL_PIXELFORMAT_ARGB128_FLOAT;
917
919 SDL_PIXELFORMAT_BGRA128_FLOAT;
920
922 SDL_PIXELFORMAT_ABGR128_FLOAT;
923
925 SDL_PIXELFORMAT_YV12;
926
928 SDL_PIXELFORMAT_IYUV;
929
931 SDL_PIXELFORMAT_YUY2;
932
934 SDL_PIXELFORMAT_UYVY;
935
937 SDL_PIXELFORMAT_YVYU;
938
940 SDL_PIXELFORMAT_NV12;
941
943 SDL_PIXELFORMAT_NV21;
944
946 SDL_PIXELFORMAT_P010;
947
949 SDL_PIXELFORMAT_EXTERNAL_OES;
950
951#if SDL_VERSION_ATLEAST(3, 2, 10)
952
953constexpr PixelFormat PIXELFORMAT_MJPG = SDL_PIXELFORMAT_MJPG;
954
955#endif // SDL_VERSION_ATLEAST(3, 2, 10)
956
957constexpr PixelFormat PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_RGBA32;
958
959constexpr PixelFormat PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_ARGB32;
960
961constexpr PixelFormat PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_BGRA32;
962
963constexpr PixelFormat PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_ABGR32;
964
965constexpr PixelFormat PIXELFORMAT_RGBX32 = SDL_PIXELFORMAT_RGBX32;
966
967constexpr PixelFormat PIXELFORMAT_XRGB32 = SDL_PIXELFORMAT_XRGB32;
968
969constexpr PixelFormat PIXELFORMAT_BGRX32 = SDL_PIXELFORMAT_BGRX32;
970
971constexpr PixelFormat PIXELFORMAT_XBGR32 = SDL_PIXELFORMAT_XBGR32;
972
974
995{
996 return SDL_DEFINE_PIXELFOURCC(A, B, C, D);
997}
998
1023 int order,
1024 PackedLayout layout,
1025 int bits,
1026 int bytes)
1027{
1028 return PixelFormat(type, order, layout, bits, bytes);
1029}
1030
1045{
1046 return SDL_PIXELFLAG(format);
1047}
1048
1050{
1051 return SDL::PixelFormatFlags(m_format);
1052}
1053
1067{
1068 return PixelType(SDL_PIXELTYPE(format));
1069}
1070
1072{
1073 return SDL::PixelFormatType(m_format);
1074}
1075
1090{
1091 return SDL_PIXELORDER(format);
1092}
1093
1094constexpr int PixelFormat::GetOrder() const
1095{
1096 return SDL::PixelFormatOrder(m_format);
1097}
1098
1113{
1114 return PackedLayout(SDL_PIXELLAYOUT(format));
1115}
1116
1118{
1119 return SDL::PixelFormatLayout(m_format);
1120}
1121
1141{
1142 return SDL_BITSPERPIXEL(format);
1143}
1144
1145constexpr int PixelFormat::GetBitsPerPixel() const
1146{
1147 return SDL::PixelFormatBitsPerPixel(m_format);
1148}
1149
1169{
1170 return SDL_BYTESPERPIXEL(format);
1171}
1172
1174{
1175 return SDL::PixelFormatBytesPerPixel(m_format);
1176}
1177
1192{
1193 return SDL_ISPIXELFORMAT_INDEXED(format);
1194}
1195
1196constexpr bool PixelFormat::IsIndexed() const
1197{
1198 return SDL::IsPixelFormatIndexed(m_format);
1199}
1200
1215{
1216 return SDL_ISPIXELFORMAT_PACKED(format);
1217}
1218
1219constexpr bool PixelFormat::IsPacked() const
1220{
1221 return SDL::IsPixelFormatPacked(m_format);
1222}
1223
1238{
1239 return SDL_ISPIXELFORMAT_ARRAY(format);
1240}
1241
1242constexpr bool PixelFormat::IsArray() const
1243{
1244 return SDL::IsPixelFormatArray(m_format);
1245}
1246
1261{
1262 return SDL_ISPIXELFORMAT_10BIT(format);
1263}
1264
1265constexpr bool PixelFormat::Is10Bit() const
1266{
1267 return SDL::IsPixelFormat10Bit(m_format);
1268}
1269
1284{
1285 return SDL_ISPIXELFORMAT_FLOAT(format);
1286}
1287
1288constexpr bool PixelFormat::IsFloat() const
1289{
1290 return SDL::IsPixelFormatFloat(m_format);
1291}
1292
1312{
1313 return SDL_ISPIXELFORMAT_ALPHA(format);
1314}
1315
1316constexpr bool PixelFormat::IsAlpha() const
1317{
1318 return SDL::IsPixelFormatAlpha(m_format);
1319}
1320
1337{
1338 return SDL_ISPIXELFORMAT_FOURCC(format);
1339}
1340
1341constexpr bool PixelFormat::IsFourCC() const
1342{
1343 return SDL::IsPixelFormatFourCC(m_format);
1344}
1345
1351using ColorType = SDL_ColorType;
1352
1354 SDL_COLOR_TYPE_UNKNOWN;
1355
1356constexpr ColorType COLOR_TYPE_RGB = SDL_COLOR_TYPE_RGB;
1357
1359 SDL_COLOR_TYPE_YCBCR;
1360
1362
1374using ColorRange = SDL_ColorRange;
1375
1377 SDL_COLOR_RANGE_UNKNOWN;
1378
1382constexpr ColorRange COLOR_RANGE_LIMITED = SDL_COLOR_RANGE_LIMITED;
1383
1385constexpr ColorRange COLOR_RANGE_FULL = SDL_COLOR_RANGE_FULL;
1386
1388
1400using ColorPrimaries = SDL_ColorPrimaries;
1401
1403 SDL_COLOR_PRIMARIES_UNKNOWN;
1404
1406 SDL_COLOR_PRIMARIES_BT709;
1407
1409 SDL_COLOR_PRIMARIES_UNSPECIFIED;
1410
1412 SDL_COLOR_PRIMARIES_BT470M;
1413
1415 SDL_COLOR_PRIMARIES_BT470BG;
1417
1419 SDL_COLOR_PRIMARIES_BT601;
1420
1423 SDL_COLOR_PRIMARIES_SMPTE240;
1424
1426 SDL_COLOR_PRIMARIES_GENERIC_FILM;
1428
1430 SDL_COLOR_PRIMARIES_BT2020;
1431
1433 SDL_COLOR_PRIMARIES_XYZ;
1434
1436 SDL_COLOR_PRIMARIES_SMPTE431;
1437
1439 SDL_COLOR_PRIMARIES_SMPTE432;
1440
1442 SDL_COLOR_PRIMARIES_EBU3213;
1443
1445 SDL_COLOR_PRIMARIES_CUSTOM;
1446
1448
1461using TransferCharacteristics = SDL_TransferCharacteristics;
1462
1464 SDL_TRANSFER_CHARACTERISTICS_UNKNOWN;
1465
1467 SDL_TRANSFER_CHARACTERISTICS_BT709;
1468
1470 SDL_TRANSFER_CHARACTERISTICS_UNSPECIFIED;
1471
1474 SDL_TRANSFER_CHARACTERISTICS_GAMMA22;
1475
1477 SDL_TRANSFER_CHARACTERISTICS_GAMMA28;
1478
1480 SDL_TRANSFER_CHARACTERISTICS_BT601;
1482
1484 SDL_TRANSFER_CHARACTERISTICS_SMPTE240;
1485
1487 SDL_TRANSFER_CHARACTERISTICS_LINEAR;
1488
1490 SDL_TRANSFER_CHARACTERISTICS_LOG100;
1491
1493 SDL_TRANSFER_CHARACTERISTICS_LOG100_SQRT10;
1494
1496 SDL_TRANSFER_CHARACTERISTICS_IEC61966;
1497
1499 SDL_TRANSFER_CHARACTERISTICS_BT1361;
1500
1502 SDL_TRANSFER_CHARACTERISTICS_SRGB;
1503
1505 SDL_TRANSFER_CHARACTERISTICS_BT2020_10BIT;
1506
1508 SDL_TRANSFER_CHARACTERISTICS_BT2020_12BIT;
1509
1511 SDL_TRANSFER_CHARACTERISTICS_PQ;
1513
1515 SDL_TRANSFER_CHARACTERISTICS_SMPTE428;
1516
1518 SDL_TRANSFER_CHARACTERISTICS_HLG;
1520
1522 SDL_TRANSFER_CHARACTERISTICS_CUSTOM;
1523
1525
1538using MatrixCoefficients = SDL_MatrixCoefficients;
1539
1541 SDL_MATRIX_COEFFICIENTS_IDENTITY;
1542
1544 SDL_MATRIX_COEFFICIENTS_BT709;
1545
1547 SDL_MATRIX_COEFFICIENTS_UNSPECIFIED;
1548
1550 SDL_MATRIX_COEFFICIENTS_FCC;
1551
1557 SDL_MATRIX_COEFFICIENTS_BT470BG;
1558
1560 SDL_MATRIX_COEFFICIENTS_BT601;
1561
1563 SDL_MATRIX_COEFFICIENTS_SMPTE240;
1564
1566 SDL_MATRIX_COEFFICIENTS_YCGCO;
1567
1569 SDL_MATRIX_COEFFICIENTS_BT2020_NCL;
1571
1573 SDL_MATRIX_COEFFICIENTS_BT2020_CL;
1574
1576 SDL_MATRIX_COEFFICIENTS_SMPTE2085;
1577
1579 SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL;
1580
1582 SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL;
1583
1585 SDL_MATRIX_COEFFICIENTS_ICTCP;
1586
1588 SDL_MATRIX_COEFFICIENTS_CUSTOM;
1589
1591
1602using ChromaLocation = SDL_ChromaLocation;
1603
1605 SDL_CHROMA_LOCATION_NONE;
1606
1612constexpr ChromaLocation CHROMA_LOCATION_LEFT = SDL_CHROMA_LOCATION_LEFT;
1613
1619constexpr ChromaLocation CHROMA_LOCATION_CENTER = SDL_CHROMA_LOCATION_CENTER;
1620
1626constexpr ChromaLocation CHROMA_LOCATION_TOPLEFT = SDL_CHROMA_LOCATION_TOPLEFT;
1627
1629
1654{
1655 ColorspaceRaw m_cspace;
1656
1657public:
1663 constexpr Colorspace(ColorspaceRaw cspace = {})
1664 : m_cspace(cspace)
1665 {
1666 }
1667
1698 constexpr Colorspace(ColorType type,
1699 ColorRange range,
1700 ColorPrimaries primaries,
1701 TransferCharacteristics transfer,
1702 MatrixCoefficients matrix,
1703 ChromaLocation chroma)
1704 : m_cspace(ColorspaceRaw(SDL_DEFINE_COLORSPACE(type,
1705 range,
1706 primaries,
1707 transfer,
1708 matrix,
1709 chroma)))
1710 {
1711 }
1712
1718 constexpr operator ColorspaceRaw() const { return m_cspace; }
1719
1729 constexpr ColorType GetType() const;
1730
1740 constexpr ColorRange GetRange() const;
1741
1751 constexpr ChromaLocation GetChroma() const;
1752
1762 constexpr ColorPrimaries GetPrimaries() const;
1763
1773 constexpr TransferCharacteristics GetTransfer() const;
1774
1784 constexpr MatrixCoefficients GetMatrix() const;
1785
1795 constexpr bool IsMatrixBT601() const;
1796
1806 constexpr bool IsMatrixBT709() const;
1807
1817 constexpr bool IsMatrixBT2020_NCL() const;
1818
1828 constexpr bool IsLimitedRange() const;
1829
1839 constexpr bool IsFullRange() const;
1840};
1841
1842constexpr Colorspace COLORSPACE_UNKNOWN = SDL_COLORSPACE_UNKNOWN;
1843
1845constexpr Colorspace COLORSPACE_SRGB = SDL_COLORSPACE_SRGB;
1846
1848constexpr Colorspace COLORSPACE_SRGB_LINEAR = SDL_COLORSPACE_SRGB_LINEAR;
1849
1851constexpr Colorspace COLORSPACE_HDR10 = SDL_COLORSPACE_HDR10;
1852
1854constexpr Colorspace COLORSPACE_JPEG = SDL_COLORSPACE_JPEG;
1855
1857constexpr Colorspace COLORSPACE_BT601_LIMITED = SDL_COLORSPACE_BT601_LIMITED;
1858
1860constexpr Colorspace COLORSPACE_BT601_FULL = SDL_COLORSPACE_BT601_FULL;
1861
1863constexpr Colorspace COLORSPACE_BT709_LIMITED = SDL_COLORSPACE_BT709_LIMITED;
1864
1866constexpr Colorspace COLORSPACE_BT709_FULL = SDL_COLORSPACE_BT709_FULL;
1867
1869constexpr Colorspace COLORSPACE_BT2020_LIMITED = SDL_COLORSPACE_BT2020_LIMITED;
1870
1872constexpr Colorspace COLORSPACE_BT2020_FULL = SDL_COLORSPACE_BT2020_FULL;
1873
1875constexpr Colorspace COLORSPACE_RGB_DEFAULT = SDL_COLORSPACE_RGB_DEFAULT;
1876
1878constexpr Colorspace COLORSPACE_YUV_DEFAULT = SDL_COLORSPACE_YUV_DEFAULT;
1879
1881
1913 ColorRange range,
1914 ColorPrimaries primaries,
1915 TransferCharacteristics transfer,
1916 MatrixCoefficients matrix,
1917 ChromaLocation chroma)
1918{
1919 return Colorspace(type, range, primaries, transfer, matrix, chroma);
1920}
1921
1933{
1934 return SDL_COLORSPACETYPE(cspace);
1935}
1936
1938{
1939 return SDL::ColorspaceType(m_cspace);
1940}
1941
1953{
1954 return SDL_COLORSPACERANGE(cspace);
1955}
1956
1958{
1959 return SDL::ColorspaceRange(m_cspace);
1960}
1961
1973{
1974 return SDL_COLORSPACECHROMA(cspace);
1975}
1976
1978{
1979 return SDL::ColorspaceChroma(m_cspace);
1980}
1981
1993{
1994 return SDL_COLORSPACEPRIMARIES(cspace);
1995}
1996
1998{
1999 return SDL::ColorspacePrimaries(m_cspace);
2000}
2001
2013{
2014 return SDL_COLORSPACETRANSFER(cspace);
2015}
2016
2018{
2019 return SDL::ColorspaceTransfer(m_cspace);
2020}
2021
2033{
2034 return SDL_COLORSPACEMATRIX(cspace);
2035}
2036
2038{
2039 return SDL::ColorspaceMatrix(m_cspace);
2040}
2041
2057{
2058 return SDL_ISCOLORSPACE_MATRIX_BT601(cspace);
2059}
2060
2061constexpr bool Colorspace::IsMatrixBT601() const
2062{
2063 return SDL::IsColorspaceMatrixBT601(m_cspace);
2064}
2065
2077{
2078 return SDL_ISCOLORSPACE_MATRIX_BT709(cspace);
2079}
2080
2081constexpr bool Colorspace::IsMatrixBT709() const
2082{
2083 return SDL::IsColorspaceMatrixBT709(m_cspace);
2084}
2085
2097{
2098 return SDL_ISCOLORSPACE_MATRIX_BT2020_NCL(cspace);
2099}
2100
2102{
2103 return SDL::IsColorspaceMatrixBT2020_NCL(m_cspace);
2104}
2105
2117{
2118 return SDL_ISCOLORSPACE_LIMITED_RANGE(cspace);
2119}
2120
2121constexpr bool Colorspace::IsLimitedRange() const
2122{
2123 return SDL::IsColorspaceLimitedRange(m_cspace);
2124}
2125
2137{
2138 return SDL_ISCOLORSPACE_FULL_RANGE(cspace);
2139}
2140
2141constexpr bool Colorspace::IsFullRange() const
2142{
2143 return SDL::IsColorspaceFullRange(m_cspace);
2144}
2145
2147constexpr bool operator==(ColorRaw lhs, ColorRaw rhs)
2148{
2149 return lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b && lhs.a == rhs.a;
2150}
2151
2153constexpr bool operator==(const FColorRaw& lhs, const FColorRaw& rhs)
2154{
2155 return lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b && lhs.a == rhs.a;
2156}
2157
2159constexpr auto operator<=>(ColorRaw lhs, ColorRaw rhs)
2160{
2161 if (lhs.r != rhs.r) return lhs.r <=> rhs.r;
2162 if (lhs.g != rhs.g) return lhs.g <=> rhs.g;
2163 if (lhs.b != rhs.b) return lhs.b <=> rhs.b;
2164 return lhs.a <=> rhs.a;
2165}
2166
2168constexpr auto operator<=>(const FColorRaw& lhs, const FColorRaw& rhs)
2169{
2170 if (lhs.r != rhs.r) return lhs.r <=> rhs.r;
2171 if (lhs.g != rhs.g) return lhs.g <=> rhs.g;
2172 if (lhs.b != rhs.b) return lhs.b <=> rhs.b;
2173 return lhs.a <=> rhs.a;
2174}
2175
2189{
2195 constexpr Color(ColorRaw color = {})
2196 : ColorRaw(color)
2197 {
2198 }
2199
2208 constexpr Color(Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255)
2209 : ColorRaw{r, g, b, a}
2210 {
2211 }
2212
2218 constexpr Uint8 GetR() const { return r; }
2219
2226 constexpr Color& SetR(Uint8 newR)
2227 {
2228 r = newR;
2229 return *this;
2230 }
2231
2238 constexpr Uint8 GetG() const { return g; }
2239
2246 constexpr Color& SetG(Uint8 newG)
2247 {
2248 g = newG;
2249 return *this;
2250 }
2251
2258 constexpr Uint8 GetB() const { return b; }
2259
2266 constexpr Color& SetB(Uint8 newB)
2267 {
2268 b = newB;
2269 return *this;
2270 }
2271
2278 constexpr Uint8 GetA() const { return a; }
2279
2286 constexpr Color& SetA(Uint8 newA)
2287 {
2288 a = newA;
2289 return *this;
2290 }
2291
2318 Uint32 Map(const PixelFormatDetails& format, PaletteConstParam palette) const;
2319
2346 static Color Get(Uint32 pixel,
2347 const PixelFormatDetails& format,
2348 PaletteConstParam palette);
2349};
2350
2362{
2368 constexpr FColor(const FColorRaw& color = {})
2369 : FColorRaw(color)
2370 {
2371 }
2372
2381 constexpr FColor(float r, float g, float b, float a = 1)
2382 : FColorRaw{r, g, b, a}
2383 {
2384 }
2385
2391 constexpr float GetR() const { return r; }
2392
2399 constexpr FColor& SetR(float newR)
2400 {
2401 r = newR;
2402 return *this;
2403 }
2404
2411 constexpr float GetG() const { return g; }
2412
2419 constexpr FColor& SetG(float newG)
2420 {
2421 g = newG;
2422 return *this;
2423 }
2424
2431 constexpr float GetB() const { return b; }
2432
2439 constexpr FColor& SetB(float newB)
2440 {
2441 b = newB;
2442 return *this;
2443 }
2444
2451 constexpr float GetA() const { return a; }
2452
2459 constexpr FColor& SetA(float newA)
2460 {
2461 a = newA;
2462 return *this;
2463 }
2464};
2465
2476{
2477 PaletteRaw m_resource = nullptr;
2478
2479public:
2481 constexpr Palette() = default;
2482
2490 constexpr explicit Palette(const PaletteRaw resource)
2491 : m_resource(resource)
2492 {
2493 }
2494
2496 constexpr Palette(const Palette& other) { ++m_resource->refcount; }
2497
2499 constexpr Palette(Palette&& other)
2500 : Palette(other.release())
2501 {
2502 }
2503
2521 Palette(int ncolors)
2522 : m_resource(CheckError(SDL_CreatePalette(ncolors)))
2523 {
2524 }
2525
2533 static constexpr Palette Borrow(PaletteParam resource)
2534 {
2535 if (resource) {
2536 ++resource.value->refcount;
2537 return Palette(resource.value);
2538 }
2539 return {};
2540 }
2541
2543 constexpr const PaletteRaw operator->() const { return m_resource; }
2544
2546 constexpr PaletteRaw operator->() { return m_resource; }
2547
2549 ~Palette() { SDL_DestroyPalette(m_resource); }
2550
2553 {
2554 std::swap(m_resource, other.m_resource);
2555 return *this;
2556 }
2557
2559 constexpr PaletteRaw get() const { return m_resource; }
2560
2563 {
2564 auto r = m_resource;
2565 m_resource = nullptr;
2566 return r;
2567 }
2568
2570 constexpr auto operator<=>(const Palette& other) const = default;
2571
2573 constexpr bool operator==(std::nullptr_t _) const { return !m_resource; }
2574
2576 constexpr explicit operator bool() const { return !!m_resource; }
2577
2579 constexpr operator PaletteParam() const { return {m_resource}; }
2580
2591 void Destroy();
2592
2594 constexpr const ColorRaw* data() const { return m_resource->colors; }
2595
2597 constexpr int size() const { return m_resource->ncolors; }
2598
2600 constexpr ColorRaw operator[](int index) const
2601 {
2602 return m_resource->colors[index];
2603 }
2604
2619 void SetColors(SpanRef<const ColorRaw> colors, int firstcolor = 0);
2620};
2621
2633inline const char* GetPixelFormatName(PixelFormatRaw format)
2634{
2635 return SDL_GetPixelFormatName(format);
2636}
2637
2638inline const char* PixelFormat::GetName() const
2639{
2640 return SDL::GetPixelFormatName(m_format);
2641}
2642
2661 int* bpp,
2662 Uint32* Rmask,
2663 Uint32* Gmask,
2664 Uint32* Bmask,
2665 Uint32* Amask)
2666{
2667 CheckError(
2668 SDL_GetMasksForPixelFormat(format, bpp, Rmask, Gmask, Bmask, Amask));
2669}
2670
2671inline void PixelFormat::GetMasks(int* bpp,
2672 Uint32* Rmask,
2673 Uint32* Gmask,
2674 Uint32* Bmask,
2675 Uint32* Amask) const
2676{
2677 SDL::GetMasksForPixelFormat(m_format, bpp, Rmask, Gmask, Bmask, Amask);
2678}
2679
2700 Uint32 Rmask,
2701 Uint32 Gmask,
2702 Uint32 Bmask,
2703 Uint32 Amask)
2704{
2705 return SDL_GetPixelFormatForMasks(bpp, Rmask, Gmask, Bmask, Amask);
2706}
2707
2709 Uint32 Rmask,
2710 Uint32 Gmask,
2711 Uint32 Bmask,
2712 Uint32 Amask)
2713{
2714 return SDL::GetPixelFormatForMasks(bpp, Rmask, Gmask, Bmask, Amask);
2715}
2716
2733{
2734 return *CheckError(SDL_GetPixelFormatDetails(format));
2735}
2736
2738{
2739 return SDL::GetPixelFormatDetails(m_format);
2740}
2741
2742inline PixelFormat::operator const PixelFormatDetails&() const
2743{
2744 return GetDetails();
2745}
2746
2764inline Palette CreatePalette(int ncolors) { return Palette(ncolors); }
2765
2779inline void SetPaletteColors(PaletteParam palette,
2781 int firstcolor = 0)
2782{
2783 CheckError(
2784 SDL_SetPaletteColors(palette, colors.data(), firstcolor, colors.size()));
2785}
2786
2787inline void Palette::SetColors(SpanRef<const ColorRaw> colors, int firstcolor)
2788{
2789 SDL::SetPaletteColors(m_resource, colors, firstcolor);
2790}
2791
2804inline void DestroyPalette(PaletteRaw palette) { SDL_DestroyPalette(palette); }
2805
2807
2843inline Uint32 MapRGB(const PixelFormatDetails& format,
2844 PaletteConstParam palette,
2845 Uint8 r,
2846 Uint8 g,
2847 Uint8 b)
2848{
2849 return SDL_MapRGB(&format, palette, r, g, b);
2850}
2851
2889inline Uint32 MapRGBA(const PixelFormatDetails& format,
2890 Uint8 r,
2891 Uint8 g,
2892 Uint8 b,
2893 Uint8 a,
2894 PaletteConstParam palette = {})
2895{
2896 return SDL_MapRGBA(&format, palette, r, g, b, a);
2897}
2898
2933 ColorRaw c,
2934 PaletteConstParam palette = {})
2935{
2936 return SDL_MapRGBA(&format, palette, c.r, c.g, c.b, c.a);
2937}
2938
2940 PaletteConstParam palette) const
2941{
2942 return MapColor(format, *this, palette);
2943}
2944
2946{
2947 return MapColor(GetDetails(), c, palette);
2948}
2949
2975inline void GetRGB(Uint32 pixel,
2976 const PixelFormatDetails& format,
2977 PaletteConstParam palette,
2978 Uint8* r,
2979 Uint8* g,
2980 Uint8* b)
2981{
2982 SDL_GetRGB(pixel, &format, palette, r, g, b);
2983}
2984
3014inline void GetRGBA(Uint32 pixel,
3015 const PixelFormatDetails& format,
3016 PaletteConstParam palette,
3017 Uint8* r,
3018 Uint8* g,
3019 Uint8* b,
3020 Uint8* a)
3021{
3022 SDL_GetRGBA(pixel, &format, palette, r, g, b, a);
3023}
3024
3052inline Color GetColor(Uint32 pixel,
3053 const PixelFormatDetails& format,
3054 PaletteConstParam palette = {})
3055{
3056 Color c;
3057 GetRGBA(pixel, format, palette, &c.r, &c.g, &c.b, &c.a);
3058 return c;
3059}
3060
3062 const PixelFormatDetails& format,
3063 PaletteConstParam palette)
3064{
3065 return GetColor(pixel, format, palette);
3066}
3067
3069{
3070 return GetColor(pixel, GetDetails(), palette);
3071}
3072
3074
3075} // namespace SDL
3076
3077#endif /* SDL3PP_PIXELS_H_ */
Colorspace definitions.
Definition: SDL3pp_pixels.h:1654
constexpr Colorspace(ColorType type, ColorRange range, ColorPrimaries primaries, TransferCharacteristics transfer, MatrixCoefficients matrix, ChromaLocation chroma)
Define custom Colorspace formats.
Definition: SDL3pp_pixels.h:1698
constexpr Colorspace(ColorspaceRaw cspace={})
Wraps Colorspace.
Definition: SDL3pp_pixels.h:1663
A set of indexed colors representing a palette.
Definition: SDL3pp_pixels.h:2476
constexpr PaletteRaw operator->()
member access to underlying PaletteRaw.
Definition: SDL3pp_pixels.h:2546
static constexpr Palette Borrow(PaletteParam resource)
Safely borrows the from PaletteParam.
Definition: SDL3pp_pixels.h:2533
constexpr Palette(Palette &&other)
Move constructor.
Definition: SDL3pp_pixels.h:2499
Palette & operator=(Palette other)
Assignment operator.
Definition: SDL3pp_pixels.h:2552
constexpr Palette(const PaletteRaw resource)
Constructs from PaletteParam.
Definition: SDL3pp_pixels.h:2490
constexpr bool operator==(std::nullptr_t _) const
Comparison.
Definition: SDL3pp_pixels.h:2573
constexpr PaletteRaw get() const
Retrieves underlying PaletteRaw.
Definition: SDL3pp_pixels.h:2559
constexpr PaletteRaw release()
Retrieves underlying PaletteRaw and clear this.
Definition: SDL3pp_pixels.h:2562
constexpr const PaletteRaw operator->() const
member access to underlying PaletteRaw.
Definition: SDL3pp_pixels.h:2543
constexpr Palette(const Palette &other)
Copy constructor.
Definition: SDL3pp_pixels.h:2496
~Palette()
Destructor.
Definition: SDL3pp_pixels.h:2549
constexpr int size() const
Returns number of colors in the palette.
Definition: SDL3pp_pixels.h:2597
constexpr ColorRaw operator[](int index) const
Access specific pallete index.
Definition: SDL3pp_pixels.h:2600
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:2521
constexpr Palette()=default
Default ctor.
constexpr const ColorRaw * data() const
Access specific pallete colors.
Definition: SDL3pp_pixels.h:2594
Pixel format.
Definition: SDL3pp_pixels.h:411
constexpr PixelFormat(PixelType type, int order, PackedLayout layout, int bits, int bytes)
Defining custom non-FourCC pixel formats.
Definition: SDL3pp_pixels.h:448
constexpr PixelFormat(PixelFormatRaw format={})
Wraps PixelFormat.
Definition: SDL3pp_pixels.h:420
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:2932
constexpr PixelFormat PIXELFORMAT_ABGR1555
ABGR1555.
Definition: SDL3pp_pixels.h:826
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_FCC
US FCC Title 47.
Definition: SDL3pp_pixels.h:1549
constexpr bool IsMatrixBT709() const
Determine if an Colorspace uses BT709 matrix coefficients.
Definition: SDL3pp_pixels.h:2081
constexpr PixelFormat PIXELFORMAT_IYUV
Planar mode: Y + U + V (3 planes)
Definition: SDL3pp_pixels.h:927
constexpr bool IsPixelFormatArray(PixelFormatRaw format)
A macro to determine if an PixelFormat is an array format.
Definition: SDL3pp_pixels.h:1237
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_SMPTE240
SMPTE 240M.
Definition: SDL3pp_pixels.h:1562
constexpr ColorPrimaries COLOR_PRIMARIES_UNSPECIFIED
COLOR_PRIMARIES_UNSPECIFIED.
Definition: SDL3pp_pixels.h:1408
constexpr ColorPrimaries COLOR_PRIMARIES_BT709
ITU-R BT.709-6.
Definition: SDL3pp_pixels.h:1405
constexpr PixelFormat PIXELFORMAT_BGRA64
BGRA64.
Definition: SDL3pp_pixels.h:884
constexpr PixelType PIXELTYPE_PACKED8
PACKED8.
Definition: SDL3pp_pixels.h:231
void DestroyPalette(PaletteRaw palette)
Free a palette created with Palette.Palette().
Definition: SDL3pp_pixels.h:2804
constexpr PackedLayout PACKEDLAYOUT_1555
1555
Definition: SDL3pp_pixels.h:349
constexpr PixelFormat PIXELFORMAT_RGB96_FLOAT
RGB96_FLOAT.
Definition: SDL3pp_pixels.h:906
constexpr ChromaLocation ColorspaceChroma(ColorspaceRaw cspace)
A macro to retrieve the chroma sample location of an Colorspace.
Definition: SDL3pp_pixels.h:1972
Color Get(Uint32 pixel, PaletteConstParam palette={}) const
Get RGBA values from a pixel in the specified format.
Definition: SDL3pp_pixels.h:3068
constexpr PixelFormat PIXELFORMAT_P010
Planar mode: Y + U/V interleaved (2 planes)
Definition: SDL3pp_pixels.h:945
constexpr int PixelFormatOrder(PixelFormatRaw format)
A macro to retrieve the order of an PixelFormat.
Definition: SDL3pp_pixels.h:1089
const char * GetName() const
Get the human readable name of a pixel format.
Definition: SDL3pp_pixels.h:2638
constexpr PixelFormat PIXELFORMAT_XRGB32
XRGB32.
Definition: SDL3pp_pixels.h:967
constexpr ColorPrimaries ColorspacePrimaries(ColorspaceRaw cspace)
A macro to retrieve the primaries of an Colorspace.
Definition: SDL3pp_pixels.h:1992
constexpr ColorType GetType() const
Retrieve the type of a Colorspace.
Definition: SDL3pp_pixels.h:1937
constexpr PixelType PIXELTYPE_ARRAYF32
ARRAYF32.
Definition: SDL3pp_pixels.h:245
constexpr Uint8 GetFlags() const
Retrieve the flags of an PixelFormat.
Definition: SDL3pp_pixels.h:1049
constexpr bool IsPixelFormat10Bit(PixelFormatRaw format)
A macro to determine if an PixelFormat is a 10-bit format.
Definition: SDL3pp_pixels.h:1260
constexpr PixelFormat PIXELFORMAT_MJPG
Motion JPEG.
Definition: SDL3pp_pixels.h:953
constexpr ColorRange COLOR_RANGE_LIMITED
Narrow range, e.g.
Definition: SDL3pp_pixels.h:1382
constexpr ColorType ColorspaceType(ColorspaceRaw cspace)
A macro to retrieve the type of an Colorspace.
Definition: SDL3pp_pixels.h:1932
constexpr bool IsColorspaceLimitedRange(ColorspaceRaw cspace)
A macro to determine if an Colorspace has a limited range.
Definition: SDL3pp_pixels.h:2116
constexpr PixelFormat PIXELFORMAT_XRGB1555
XRGB1555.
Definition: SDL3pp_pixels.h:802
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_SMPTE240
SMPTE ST 240M.
Definition: SDL3pp_pixels.h:1483
constexpr PackedLayout PACKEDLAYOUT_1010102
1010102
Definition: SDL3pp_pixels.h:360
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT2020_12BIT
ITU-R BT2020 for 12-bit system.
Definition: SDL3pp_pixels.h:1507
constexpr ArrayOrder ARRAYORDER_RGB
RGB.
Definition: SDL3pp_pixels.h:317
SDL_PackedLayout PackedLayout
Packed component layout.
Definition: SDL3pp_pixels.h:341
SDL_ArrayOrder ArrayOrder
Array component order, low byte -> high byte.
Definition: SDL3pp_pixels.h:313
constexpr PixelFormat PIXELFORMAT_EXTERNAL_OES
Android video texture format.
Definition: SDL3pp_pixels.h:948
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_UNSPECIFIED
MATRIX_COEFFICIENTS_UNSPECIFIED.
Definition: SDL3pp_pixels.h:1546
constexpr Uint8 PixelFormatFlags(PixelFormatRaw format)
Retrieve the flags of an PixelFormat.
Definition: SDL3pp_pixels.h:1044
constexpr PixelFormat PIXELFORMAT_INDEX1MSB
INDEX1MSB.
Definition: SDL3pp_pixels.h:777
constexpr PixelType PIXELTYPE_PACKED32
PACKED32.
Definition: SDL3pp_pixels.h:235
constexpr PixelType PIXELTYPE_ARRAYF16
ARRAYF16.
Definition: SDL3pp_pixels.h:243
constexpr PixelFormat PIXELFORMAT_ABGR8888
ABGR8888.
Definition: SDL3pp_pixels.h:858
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:1400
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_SMPTE2085
SMPTE ST 2085.
Definition: SDL3pp_pixels.h:1575
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_ICTCP
ITU-R BT.2100-0 ICTCP.
Definition: SDL3pp_pixels.h:1584
void Destroy()
Free a palette created with Palette.Palette().
Definition: SDL3pp_pixels.h:2806
constexpr PixelFormat PIXELFORMAT_NV21
Planar mode: Y + V/U interleaved (2 planes)
Definition: SDL3pp_pixels.h:942
SDL_ChromaLocation ChromaLocation
Colorspace chroma sample location.
Definition: SDL3pp_pixels.h:1602
constexpr bool IsPixelFormatPacked(PixelFormatRaw format)
A macro to determine if an PixelFormat is a packed format.
Definition: SDL3pp_pixels.h:1214
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_LOG100
TRANSFER_CHARACTERISTICS_LOG100.
Definition: SDL3pp_pixels.h:1489
constexpr ColorType COLOR_TYPE_YCBCR
COLOR_TYPE_YCBCR.
Definition: SDL3pp_pixels.h:1358
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:2889
constexpr PixelFormat PIXELFORMAT_ARGB2101010
ARGB2101010.
Definition: SDL3pp_pixels.h:870
constexpr bool IsPixelFormatAlpha(PixelFormatRaw format)
A macro to determine if an PixelFormat has an alpha channel.
Definition: SDL3pp_pixels.h:1311
constexpr PixelFormat PIXELFORMAT_INDEX4MSB
INDEX4MSB.
Definition: SDL3pp_pixels.h:789
constexpr int PixelFormatBytesPerPixel(PixelFormatRaw format)
A macro to determine an PixelFormat's bytes per pixel.
Definition: SDL3pp_pixels.h:1168
constexpr PixelFormat PIXELFORMAT_UNKNOWN
UNKNOWN.
Definition: SDL3pp_pixels.h:771
constexpr ColorPrimaries COLOR_PRIMARIES_UNKNOWN
COLOR_PRIMARIES_UNKNOWN.
Definition: SDL3pp_pixels.h:1402
constexpr PixelFormat PIXELFORMAT_ABGR4444
ABGR4444.
Definition: SDL3pp_pixels.h:814
constexpr PixelFormat PIXELFORMAT_BGRA64_FLOAT
BGRA64_FLOAT.
Definition: SDL3pp_pixels.h:900
constexpr BitmapOrder BITMAPORDER_1234
1234
Definition: SDL3pp_pixels.h:267
constexpr PixelFormat PIXELFORMAT_ABGR32
ABGR32.
Definition: SDL3pp_pixels.h:963
constexpr PixelFormat PIXELFORMAT_BGRA128_FLOAT
BGRA128_FLOAT.
Definition: SDL3pp_pixels.h:918
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:2939
constexpr PixelFormat PIXELFORMAT_XBGR2101010
XBGR2101010.
Definition: SDL3pp_pixels.h:867
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT601
SMPTE ST 170M / ITU-R BT.601-7 525 or 625.
Definition: SDL3pp_pixels.h:1479
constexpr ColorRange ColorspaceRange(ColorspaceRaw cspace)
A macro to retrieve the range of an Colorspace.
Definition: SDL3pp_pixels.h:1952
constexpr bool IsColorspaceFullRange(ColorspaceRaw cspace)
A macro to determine if an Colorspace has a full range.
Definition: SDL3pp_pixels.h:2136
constexpr PackedLayout PACKEDLAYOUT_565
565
Definition: SDL3pp_pixels.h:353
const char * GetPixelFormatName(PixelFormatRaw format)
Get the human readable name of a pixel format.
Definition: SDL3pp_pixels.h:2633
constexpr PackedOrder PACKEDORDER_BGRA
BGRA.
Definition: SDL3pp_pixels.h:299
constexpr PixelFormat PIXELFORMAT_XRGB8888
XRGB8888.
Definition: SDL3pp_pixels.h:840
constexpr PixelFormat PIXELFORMAT_BGR96_FLOAT
BGR96_FLOAT.
Definition: SDL3pp_pixels.h:909
constexpr bool Is10Bit() const
Determine if this is a 10-bit format.
Definition: SDL3pp_pixels.h:1265
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:1196
constexpr PixelFormat PIXELFORMAT_INDEX8
INDEX8.
Definition: SDL3pp_pixels.h:792
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL
MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL.
Definition: SDL3pp_pixels.h:1581
constexpr MatrixCoefficients ColorspaceMatrix(ColorspaceRaw cspace)
A macro to retrieve the matrix coefficients of an Colorspace.
Definition: SDL3pp_pixels.h:2032
constexpr PixelFormat PIXELFORMAT_INDEX1LSB
INDEX1LSB.
Definition: SDL3pp_pixels.h:774
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_SMPTE428
SMPTE ST 428-1.
Definition: SDL3pp_pixels.h:1514
constexpr TransferCharacteristics GetTransfer() const
Retrieve the transfer characteristics of an Colorspace.
Definition: SDL3pp_pixels.h:2017
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:1626
constexpr ChromaLocation GetChroma() const
Retrieve the chroma sample location of an Colorspace.
Definition: SDL3pp_pixels.h:1977
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_GAMMA22
ITU-R BT.470-6 System M / ITU-R BT1700 625 PAL & SECAM.
Definition: SDL3pp_pixels.h:1473
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT2020_NCL
ITU-R BT.2020-2 non-constant luminance.
Definition: SDL3pp_pixels.h:1568
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:1556
SDL_TransferCharacteristics TransferCharacteristics
Colorspace transfer characteristics.
Definition: SDL3pp_pixels.h:1461
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_SRGB
IEC 61966-2-1 (sRGB or sYCC)
Definition: SDL3pp_pixels.h:1501
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:1912
constexpr PixelFormat PIXELFORMAT_BGRA8888
BGRA8888.
Definition: SDL3pp_pixels.h:861
constexpr PixelFormat PIXELFORMAT_RGBX8888
RGBX8888.
Definition: SDL3pp_pixels.h:843
constexpr PixelFormat PIXELFORMAT_YVYU
Packed mode: Y0+V0+Y1+U0 (1 plane)
Definition: SDL3pp_pixels.h:936
constexpr Uint8 ALPHA_TRANSPARENT
A fully transparent 8-bit alpha value.
Definition: SDL3pp_pixels.h:198
constexpr ColorPrimaries COLOR_PRIMARIES_BT470BG
ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625.
Definition: SDL3pp_pixels.h:1414
constexpr ArrayOrder ARRAYORDER_NONE
NONE.
Definition: SDL3pp_pixels.h:315
constexpr PackedOrder PACKEDORDER_ARGB
ARGB.
Definition: SDL3pp_pixels.h:289
constexpr Uint8 ALPHA_OPAQUE
A fully opaque 8-bit alpha value.
Definition: SDL3pp_pixels.h:180
constexpr PackedLayout PixelFormatLayout(PixelFormatRaw format)
A macro to retrieve the layout of an PixelFormat.
Definition: SDL3pp_pixels.h:1112
constexpr PixelFormat PIXELFORMAT_RGB24
RGB24.
Definition: SDL3pp_pixels.h:836
constexpr ColorPrimaries GetPrimaries() const
Retrieve the primaries of an Colorspace.
Definition: SDL3pp_pixels.h:1997
constexpr Colorspace COLORSPACE_UNKNOWN
UNKNOWN.
Definition: SDL3pp_pixels.h:1842
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:1612
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT2020_CL
ITU-R BT.2020-2 constant luminance.
Definition: SDL3pp_pixels.h:1572
constexpr Colorspace COLORSPACE_BT601_FULL
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601.
Definition: SDL3pp_pixels.h:1860
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:2708
constexpr PixelFormat PIXELFORMAT_ARGB8888
ARGB8888.
Definition: SDL3pp_pixels.h:852
constexpr Colorspace COLORSPACE_SRGB_LINEAR
Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709.
Definition: SDL3pp_pixels.h:1848
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_HLG
ARIB STD-B67, known as "hybrid log-gamma" (HLG)
Definition: SDL3pp_pixels.h:1517
constexpr auto operator<=>(ColorRaw lhs, ColorRaw rhs)
Spaceship operator for Color.
Definition: SDL3pp_pixels.h:2159
constexpr PackedLayout PACKEDLAYOUT_NONE
NONE.
Definition: SDL3pp_pixels.h:343
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:915
constexpr PixelType PIXELTYPE_ARRAYU16
ARRAYU16.
Definition: SDL3pp_pixels.h:239
constexpr ColorType COLOR_TYPE_UNKNOWN
COLOR_TYPE_UNKNOWN.
Definition: SDL3pp_pixels.h:1353
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT709
ITU-R BT.709-6.
Definition: SDL3pp_pixels.h:1543
constexpr PixelFormat PIXELFORMAT_RGBX32
RGBX32.
Definition: SDL3pp_pixels.h:965
constexpr PackedOrder PACKEDORDER_RGBX
RGBX.
Definition: SDL3pp_pixels.h:287
constexpr Colorspace COLORSPACE_SRGB
Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709.
Definition: SDL3pp_pixels.h:1845
constexpr bool IsMatrixBT2020_NCL() const
Determine if an Colorspace uses BT2020_NCL matrix coefficients.
Definition: SDL3pp_pixels.h:2101
constexpr PackedLayout PACKEDLAYOUT_4444
4444
Definition: SDL3pp_pixels.h:347
constexpr PixelFormat PIXELFORMAT_RGBA5551
RGBA5551.
Definition: SDL3pp_pixels.h:823
constexpr float ALPHA_TRANSPARENT_FLOAT
A fully transparent floating point alpha value.
Definition: SDL3pp_pixels.h:207
constexpr bool operator==(ColorRaw lhs, ColorRaw rhs)
Comparison operator for Color.
Definition: SDL3pp_pixels.h:2147
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:1374
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:3014
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:1022
constexpr PixelFormat PIXELFORMAT_XBGR8888
XBGR8888.
Definition: SDL3pp_pixels.h:846
constexpr PixelFormat PIXELFORMAT_BGR48
BGR48.
Definition: SDL3pp_pixels.h:878
constexpr PixelType PIXELTYPE_UNKNOWN
UNKNOWN.
Definition: SDL3pp_pixels.h:223
constexpr bool IsFloat() const
Determine if this is a floating point format.
Definition: SDL3pp_pixels.h:1288
constexpr Colorspace COLORSPACE_BT601_LIMITED
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601.
Definition: SDL3pp_pixels.h:1857
constexpr PixelFormat PIXELFORMAT_ARGB1555
ARGB1555.
Definition: SDL3pp_pixels.h:820
void SetColors(SpanRef< const ColorRaw > colors, int firstcolor=0)
Set a range of colors in a palette.
Definition: SDL3pp_pixels.h:2787
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT601
ITU-R BT.601-7 525.
Definition: SDL3pp_pixels.h:1559
constexpr ColorPrimaries COLOR_PRIMARIES_EBU3213
EBU Tech. 3213-E.
Definition: SDL3pp_pixels.h:1441
constexpr PackedOrder PACKEDORDER_ABGR
ABGR.
Definition: SDL3pp_pixels.h:297
constexpr bool IsMatrixBT601() const
Determine if a Colorspace uses BT601 (or BT470BG) matrix coefficients.
Definition: SDL3pp_pixels.h:2061
constexpr ColorPrimaries COLOR_PRIMARIES_SMPTE240
SMPTE 240M, functionally the same as COLOR_PRIMARIES_BT601.
Definition: SDL3pp_pixels.h:1422
constexpr Colorspace COLORSPACE_BT709_LIMITED
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709.
Definition: SDL3pp_pixels.h:1863
constexpr BitmapOrder BITMAPORDER_NONE
NONE.
Definition: SDL3pp_pixels.h:263
constexpr PixelFormat PIXELFORMAT_ARGB64_FLOAT
ARGB64_FLOAT.
Definition: SDL3pp_pixels.h:897
SDL_PixelFormatDetails PixelFormatDetails
Details about the format of a pixel.
Definition: SDL3pp_pixels.h:171
constexpr PixelFormat PIXELFORMAT_XRGB2101010
XRGB2101010.
Definition: SDL3pp_pixels.h:864
constexpr BitmapOrder BITMAPORDER_4321
4321
Definition: SDL3pp_pixels.h:265
constexpr bool IsPacked() const
Determine if this is a packed format.
Definition: SDL3pp_pixels.h:1219
constexpr ColorPrimaries COLOR_PRIMARIES_CUSTOM
COLOR_PRIMARIES_CUSTOM.
Definition: SDL3pp_pixels.h:1444
constexpr ColorPrimaries COLOR_PRIMARIES_BT2020
ITU-R BT.2020-2 / ITU-R BT.2100-0.
Definition: SDL3pp_pixels.h:1429
constexpr ColorType COLOR_TYPE_RGB
COLOR_TYPE_RGB.
Definition: SDL3pp_pixels.h:1356
constexpr PixelType PIXELTYPE_INDEX4
INDEX4.
Definition: SDL3pp_pixels.h:227
constexpr Colorspace COLORSPACE_BT709_FULL
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709.
Definition: SDL3pp_pixels.h:1866
SDL_PixelFormat PixelFormatRaw
Alias to raw representation for PixelFormat.
Definition: SDL3pp_pixels.h:71
constexpr PixelFormat PIXELFORMAT_XBGR4444
XBGR4444.
Definition: SDL3pp_pixels.h:799
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT1361
ITU-R BT1361 Extended Colour Gamut.
Definition: SDL3pp_pixels.h:1498
constexpr PixelType PIXELTYPE_PACKED16
PACKED16.
Definition: SDL3pp_pixels.h:233
const PixelFormatDetails & GetPixelFormatDetails(PixelFormatRaw format)
Create an PixelFormatDetails structure corresponding to a pixel format.
Definition: SDL3pp_pixels.h:2732
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_YCGCO
MATRIX_COEFFICIENTS_YCGCO.
Definition: SDL3pp_pixels.h:1565
constexpr PackedLayout PACKEDLAYOUT_332
332
Definition: SDL3pp_pixels.h:345
constexpr PixelFormat PIXELFORMAT_RGBA8888
RGBA8888.
Definition: SDL3pp_pixels.h:855
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_PQ
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition: SDL3pp_pixels.h:1510
constexpr bool IsColorspaceMatrixBT601(ColorspaceRaw cspace)
A macro to determine if an Colorspace uses BT601 (or BT470BG) matrix coefficients.
Definition: SDL3pp_pixels.h:2056
constexpr PackedLayout GetLayout() const
Retrieve the layout.
Definition: SDL3pp_pixels.h:1117
constexpr PixelFormat PIXELFORMAT_RGBA4444
RGBA4444.
Definition: SDL3pp_pixels.h:811
constexpr PixelType PIXELTYPE_ARRAYU8
ARRAYU8.
Definition: SDL3pp_pixels.h:237
constexpr PixelFormat PIXELFORMAT_ARGB32
ARGB32.
Definition: SDL3pp_pixels.h:959
constexpr PixelFormat PIXELFORMAT_INDEX4LSB
INDEX4LSB.
Definition: SDL3pp_pixels.h:786
constexpr bool IsPixelFormatFloat(PixelFormatRaw format)
A macro to determine if an PixelFormat is a floating point format.
Definition: SDL3pp_pixels.h:1283
constexpr ArrayOrder ARRAYORDER_ABGR
ABGR.
Definition: SDL3pp_pixels.h:327
constexpr bool IsFourCC() const
Determine if this is a "FourCC" format.
Definition: SDL3pp_pixels.h:1341
constexpr PixelFormat PIXELFORMAT_ABGR64_FLOAT
ABGR64_FLOAT.
Definition: SDL3pp_pixels.h:903
constexpr bool IsPixelFormatFourCC(PixelFormatRaw format)
A macro to determine if an PixelFormat is a "FourCC" format.
Definition: SDL3pp_pixels.h:1336
constexpr ColorPrimaries COLOR_PRIMARIES_BT470M
ITU-R BT.470-6 System M.
Definition: SDL3pp_pixels.h:1411
constexpr ColorPrimaries COLOR_PRIMARIES_SMPTE431
SMPTE RP 431-2.
Definition: SDL3pp_pixels.h:1435
constexpr PixelFormat PIXELFORMAT_ABGR128_FLOAT
ABGR128_FLOAT.
Definition: SDL3pp_pixels.h:921
constexpr ColorPrimaries COLOR_PRIMARIES_XYZ
SMPTE ST 428-1.
Definition: SDL3pp_pixels.h:1432
constexpr PixelFormat PIXELFORMAT_ABGR2101010
ABGR2101010.
Definition: SDL3pp_pixels.h:873
SDL_ColorType ColorType
Colorspace color type.
Definition: SDL3pp_pixels.h:1351
constexpr PixelFormat PIXELFORMAT_BGRX8888
BGRX8888.
Definition: SDL3pp_pixels.h:849
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL
MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL.
Definition: SDL3pp_pixels.h:1578
constexpr float ALPHA_OPAQUE_FLOAT
A fully opaque floating point alpha value.
Definition: SDL3pp_pixels.h:189
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_CUSTOM
MATRIX_COEFFICIENTS_CUSTOM.
Definition: SDL3pp_pixels.h:1587
constexpr PixelFormat PIXELFORMAT_YV12
Planar mode: Y + V + U (3 planes)
Definition: SDL3pp_pixels.h:924
constexpr PixelFormat PIXELFORMAT_BGRX32
BGRX32.
Definition: SDL3pp_pixels.h:969
constexpr PixelFormat PIXELFORMAT_BGRA4444
BGRA4444.
Definition: SDL3pp_pixels.h:817
Color GetColor(Uint32 pixel, const PixelFormatDetails &format, PaletteConstParam palette={})
Get RGBA values from a pixel in the specified format.
Definition: SDL3pp_pixels.h:3052
constexpr PixelFormat PIXELFORMAT_INDEX2MSB
INDEX2MSB.
Definition: SDL3pp_pixels.h:783
void SetPaletteColors(PaletteParam palette, SpanRef< const ColorRaw > colors, int firstcolor=0)
Set a range of colors in a palette.
Definition: SDL3pp_pixels.h:2779
constexpr PixelFormat PIXELFORMAT_BGR565
BGR565.
Definition: SDL3pp_pixels.h:834
constexpr PixelFormat PIXELFORMAT_RGB48_FLOAT
RGB48_FLOAT.
Definition: SDL3pp_pixels.h:888
constexpr PixelFormat PIXELFORMAT_RGB565
RGB565.
Definition: SDL3pp_pixels.h:832
constexpr PixelFormat PIXELFORMAT_RGBA32
RGBA32.
Definition: SDL3pp_pixels.h:957
constexpr PixelFormat PIXELFORMAT_BGR24
BGR24.
Definition: SDL3pp_pixels.h:838
constexpr PackedLayout PACKEDLAYOUT_2101010
2101010
Definition: SDL3pp_pixels.h:357
Uint32 Map(ColorRaw c, PaletteConstParam palette={}) const
Map an RGBA quadruple to a pixel value for a given pixel format.
Definition: SDL3pp_pixels.h:2945
constexpr bool IsColorspaceMatrixBT709(ColorspaceRaw cspace)
A macro to determine if an Colorspace uses BT709 matrix coefficients.
Definition: SDL3pp_pixels.h:2076
constexpr int GetOrder() const
Retrieve the order.
Definition: SDL3pp_pixels.h:1094
constexpr PixelFormat PIXELFORMAT_NV12
Planar mode: Y + U/V interleaved (2 planes)
Definition: SDL3pp_pixels.h:939
SDL_MatrixCoefficients MatrixCoefficients
Colorspace matrix coefficients.
Definition: SDL3pp_pixels.h:1538
constexpr ColorPrimaries COLOR_PRIMARIES_SMPTE432
SMPTE EG 432-1 / DCI P3.
Definition: SDL3pp_pixels.h:1438
constexpr Colorspace COLORSPACE_JPEG
Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601.
Definition: SDL3pp_pixels.h:1854
constexpr PixelFormat PIXELFORMAT_INDEX2LSB
INDEX2LSB.
Definition: SDL3pp_pixels.h:780
SDL_PackedOrder PackedOrder
Packed component order, high bit -> low bit.
Definition: SDL3pp_pixels.h:281
constexpr PackedLayout PACKEDLAYOUT_5551
5551
Definition: SDL3pp_pixels.h:351
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:2843
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:1385
constexpr bool IsArray() const
Determine if this is an array format.
Definition: SDL3pp_pixels.h:1242
constexpr PixelFormat PIXELFORMAT_ABGR64
ABGR64.
Definition: SDL3pp_pixels.h:886
constexpr PackedOrder PACKEDORDER_RGBA
RGBA.
Definition: SDL3pp_pixels.h:291
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:2660
constexpr Uint32 DefinePixelFourCC(Uint8 A, Uint8 B, Uint8 C, Uint8 D)
A function for defining custom FourCC pixel formats.
Definition: SDL3pp_pixels.h:994
constexpr PixelFormat PIXELFORMAT_RGBA128_FLOAT
RGBA128_FLOAT.
Definition: SDL3pp_pixels.h:912
constexpr Colorspace COLORSPACE_BT2020_LIMITED
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020.
Definition: SDL3pp_pixels.h:1869
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:2699
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_UNSPECIFIED
TRANSFER_CHARACTERISTICS_UNSPECIFIED.
Definition: SDL3pp_pixels.h:1469
constexpr int PixelFormatBitsPerPixel(PixelFormatRaw format)
A macro to determine an PixelFormat's bits per pixel.
Definition: SDL3pp_pixels.h:1140
constexpr int GetBytesPerPixel() const
Determine this's bytes per pixel.
Definition: SDL3pp_pixels.h:1173
constexpr PixelFormat PIXELFORMAT_RGB332
RGB332.
Definition: SDL3pp_pixels.h:794
constexpr PixelFormat PIXELFORMAT_BGRA5551
BGRA5551.
Definition: SDL3pp_pixels.h:829
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_CUSTOM
TRANSFER_CHARACTERISTICS_CUSTOM.
Definition: SDL3pp_pixels.h:1521
constexpr ArrayOrder ARRAYORDER_BGRA
BGRA.
Definition: SDL3pp_pixels.h:325
constexpr ColorPrimaries COLOR_PRIMARIES_GENERIC_FILM
Generic film (color filters using Illuminant C)
Definition: SDL3pp_pixels.h:1425
constexpr PixelType PIXELTYPE_INDEX2
INDEX2.
Definition: SDL3pp_pixels.h:247
constexpr ColorRange COLOR_RANGE_UNKNOWN
COLOR_RANGE_UNKNOWN.
Definition: SDL3pp_pixels.h:1376
constexpr ColorPrimaries COLOR_PRIMARIES_BT601
ITU-R BT.601-7 525, SMPTE 170M.
Definition: SDL3pp_pixels.h:1418
constexpr bool IsAlpha() const
Determine if this has an alpha channel.
Definition: SDL3pp_pixels.h:1316
constexpr MatrixCoefficients GetMatrix() const
Retrieve the matrix coefficients of an Colorspace.
Definition: SDL3pp_pixels.h:2037
constexpr PixelFormat PIXELFORMAT_YUY2
Packed mode: Y0+U0+Y1+V0 (1 plane)
Definition: SDL3pp_pixels.h:930
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_LINEAR
TRANSFER_CHARACTERISTICS_LINEAR.
Definition: SDL3pp_pixels.h:1486
constexpr PixelType PIXELTYPE_ARRAYU32
ARRAYU32.
Definition: SDL3pp_pixels.h:241
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_UNKNOWN
TRANSFER_CHARACTERISTICS_UNKNOWN.
Definition: SDL3pp_pixels.h:1463
constexpr PixelType GetType() const
Retrieve the type.
Definition: SDL3pp_pixels.h:1071
constexpr ArrayOrder ARRAYORDER_RGBA
RGBA.
Definition: SDL3pp_pixels.h:319
constexpr PixelFormat PIXELFORMAT_RGBA64_FLOAT
RGBA64_FLOAT.
Definition: SDL3pp_pixels.h:894
constexpr bool IsColorspaceMatrixBT2020_NCL(ColorspaceRaw cspace)
Determine if an Colorspace uses BT2020_NCL matrix coefficients.
Definition: SDL3pp_pixels.h:2096
constexpr PixelFormat PIXELFORMAT_XRGB4444
XRGB4444.
Definition: SDL3pp_pixels.h:796
constexpr Colorspace COLORSPACE_BT2020_FULL
Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020.
Definition: SDL3pp_pixels.h:1872
constexpr TransferCharacteristics ColorspaceTransfer(ColorspaceRaw cspace)
A macro to retrieve the transfer characteristics of an Colorspace.
Definition: SDL3pp_pixels.h:2012
constexpr ChromaLocation CHROMA_LOCATION_NONE
RGB, no chroma sampling.
Definition: SDL3pp_pixels.h:1604
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT2020_10BIT
ITU-R BT2020 for 10-bit system.
Definition: SDL3pp_pixels.h:1504
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:1619
constexpr PixelFormat PIXELFORMAT_RGBA64
RGBA64.
Definition: SDL3pp_pixels.h:880
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:933
constexpr Colorspace COLORSPACE_RGB_DEFAULT
The default colorspace for RGB surfaces if no colorspace is specified.
Definition: SDL3pp_pixels.h:1875
constexpr PackedOrder PACKEDORDER_NONE
NONE.
Definition: SDL3pp_pixels.h:283
constexpr PixelType PixelFormatType(PixelFormatRaw format)
A macro to retrieve the type of an PixelFormat.
Definition: SDL3pp_pixels.h:1066
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:1476
constexpr PixelFormat PIXELFORMAT_ARGB4444
ARGB4444.
Definition: SDL3pp_pixels.h:808
SDL_BitmapOrder BitmapOrder
Bitmap pixel order, high bit -> low bit.
Definition: SDL3pp_pixels.h:261
constexpr ArrayOrder ARRAYORDER_BGR
BGR.
Definition: SDL3pp_pixels.h:323
constexpr PixelFormat PIXELFORMAT_BGRA32
BGRA32.
Definition: SDL3pp_pixels.h:961
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:2975
constexpr bool IsFullRange() const
A function to determine if an Colorspace has a full range.
Definition: SDL3pp_pixels.h:2141
constexpr int GetBitsPerPixel() const
Determine this's bits per pixel.
Definition: SDL3pp_pixels.h:1145
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT709
Rec. ITU-R BT.709-6 / ITU-R BT1361.
Definition: SDL3pp_pixels.h:1466
constexpr PixelType PIXELTYPE_INDEX1
INDEX1.
Definition: SDL3pp_pixels.h:225
constexpr PixelFormat PIXELFORMAT_XBGR32
XBGR32.
Definition: SDL3pp_pixels.h:971
constexpr bool IsPixelFormatIndexed(PixelFormatRaw format)
A macro to determine if an PixelFormat is an indexed format.
Definition: SDL3pp_pixels.h:1191
SDL_PixelType PixelType
Pixel type.
Definition: SDL3pp_pixels.h:221
constexpr ArrayOrder ARRAYORDER_ARGB
ARGB.
Definition: SDL3pp_pixels.h:321
constexpr PixelFormat PIXELFORMAT_ARGB64
ARGB64.
Definition: SDL3pp_pixels.h:882
constexpr Colorspace COLORSPACE_HDR10
Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020.
Definition: SDL3pp_pixels.h:1851
constexpr PackedOrder PACKEDORDER_XRGB
XRGB.
Definition: SDL3pp_pixels.h:285
constexpr PackedLayout PACKEDLAYOUT_8888
8888
Definition: SDL3pp_pixels.h:355
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:2671
const PixelFormatDetails & GetDetails() const
Create an PixelFormatDetails structure corresponding to a pixel format.
Definition: SDL3pp_pixels.h:2737
constexpr PixelFormat PIXELFORMAT_RGB48
RGB48.
Definition: SDL3pp_pixels.h:876
static Color Get(Uint32 pixel, const PixelFormatDetails &format, PaletteConstParam palette)
Get RGBA values from a pixel in the specified format.
Definition: SDL3pp_pixels.h:3061
constexpr bool IsLimitedRange() const
A function to determine if an Colorspace has a limited range.
Definition: SDL3pp_pixels.h:2121
constexpr PixelFormat PIXELFORMAT_XBGR1555
XBGR1555.
Definition: SDL3pp_pixels.h:805
constexpr ColorRange GetRange() const
Retrieve the range of a Colorspace.
Definition: SDL3pp_pixels.h:1957
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_LOG100_SQRT10
TRANSFER_CHARACTERISTICS_LOG100_SQRT10.
Definition: SDL3pp_pixels.h:1492
Palette CreatePalette(int ncolors)
Create a palette structure with the specified number of color entries.
Definition: SDL3pp_pixels.h:2764
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_IEC61966
IEC 61966-2-4.
Definition: SDL3pp_pixels.h:1495
constexpr PackedOrder PACKEDORDER_BGRX
BGRX.
Definition: SDL3pp_pixels.h:295
constexpr Colorspace COLORSPACE_YUV_DEFAULT
The default colorspace for YUV surfaces if no colorspace is specified.
Definition: SDL3pp_pixels.h:1878
constexpr PackedOrder PACKEDORDER_XBGR
XBGR.
Definition: SDL3pp_pixels.h:293
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_IDENTITY
MATRIX_COEFFICIENTS_IDENTITY.
Definition: SDL3pp_pixels.h:1540
constexpr PixelFormat PIXELFORMAT_BGR48_FLOAT
BGR48_FLOAT.
Definition: SDL3pp_pixels.h:891
constexpr PixelType PIXELTYPE_INDEX8
INDEX8.
Definition: SDL3pp_pixels.h:229
::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:2189
constexpr Uint8 GetR() const
Get the red component from the color.
Definition: SDL3pp_pixels.h:2218
constexpr Uint8 GetB() const
Get the blue component from the color.
Definition: SDL3pp_pixels.h:2258
constexpr Color & SetG(Uint8 newG)
Set the green component from the color.
Definition: SDL3pp_pixels.h:2246
constexpr Color(Uint8 r, Uint8 g, Uint8 b, Uint8 a=255)
Constructs from its fields.
Definition: SDL3pp_pixels.h:2208
constexpr Color & SetR(Uint8 newR)
Set the red component from the color.
Definition: SDL3pp_pixels.h:2226
constexpr Uint8 GetG() const
Get the green component from the color.
Definition: SDL3pp_pixels.h:2238
constexpr Color(ColorRaw color={})
Wraps Color.
Definition: SDL3pp_pixels.h:2195
constexpr Color & SetA(Uint8 newA)
Set the alpha component from the color.
Definition: SDL3pp_pixels.h:2286
constexpr Color & SetB(Uint8 newB)
Set the blue component from the color.
Definition: SDL3pp_pixels.h:2266
constexpr Uint8 GetA() const
Get the alpha component from the color.
Definition: SDL3pp_pixels.h:2278
The bits of this structure can be directly reinterpreted as a float-packed color which uses the PIXEL...
Definition: SDL3pp_pixels.h:2362
constexpr FColor & SetG(float newG)
Set the green component from the color.
Definition: SDL3pp_pixels.h:2419
constexpr float GetA() const
Get the alpha component from the color.
Definition: SDL3pp_pixels.h:2451
constexpr FColor(float r, float g, float b, float a=1)
Constructs from its fields.
Definition: SDL3pp_pixels.h:2381
constexpr float GetR() const
Get the red component from the color.
Definition: SDL3pp_pixels.h:2391
constexpr float GetG() const
Get the green component from the color.
Definition: SDL3pp_pixels.h:2411
constexpr FColor & SetR(float newR)
Set the red component from the color.
Definition: SDL3pp_pixels.h:2399
constexpr FColor & SetA(float newA)
Set the alpha component from the color.
Definition: SDL3pp_pixels.h:2459
constexpr FColor & SetB(float newB)
Set the blue component from the color.
Definition: SDL3pp_pixels.h:2439
constexpr FColor(const FColorRaw &color={})
Wraps FColor.
Definition: SDL3pp_pixels.h:2368
constexpr float GetB() const
Get the blue component from the color.
Definition: SDL3pp_pixels.h:2431
Safely wrap Palette for non owning const parameters.
Definition: SDL3pp_pixels.h:132
constexpr PaletteConstParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_pixels.h:148
constexpr auto operator->()
member access to underlying PaletteRaw.
Definition: SDL3pp_pixels.h:163
constexpr PaletteConstParam(PaletteParam value)
Constructs from PaletteParam.
Definition: SDL3pp_pixels.h:142
const PaletteRaw value
parameter's const PaletteRaw
Definition: SDL3pp_pixels.h:133
constexpr PaletteConstParam(const PaletteRaw value)
Constructs from const PaletteRaw.
Definition: SDL3pp_pixels.h:136
constexpr auto operator<=>(const PaletteConstParam &other) const =default
Comparison.
Safely wrap Palette for non owning parameters.
Definition: SDL3pp_pixels.h:102
constexpr PaletteParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_pixels.h:112
constexpr auto operator<=>(const PaletteParam &other) const =default
Comparison.
constexpr auto operator->()
member access to underlying PaletteRaw.
Definition: SDL3pp_pixels.h:127
PaletteRaw value
parameter's PaletteRaw
Definition: SDL3pp_pixels.h:103
constexpr PaletteParam(PaletteRaw value)
Constructs from PaletteRaw.
Definition: SDL3pp_pixels.h:106