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_assert.h"
6#include "SDL3pp_stdinc.h"
7#include "SDL3pp_version.h"
8
9namespace SDL {
10
69
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 PaletteBase;
96
97// Forward decl
98struct Palette;
99
101using PaletteRaw = SDL_Palette*;
102
104using PaletteRawConst = const SDL_Palette*;
105
112
115
121using PixelFormatDetails = SDL_PixelFormatDetails;
122
130constexpr Uint8 ALPHA_OPAQUE = SDL_ALPHA_OPAQUE;
131
139constexpr float ALPHA_OPAQUE_FLOAT = SDL_ALPHA_OPAQUE_FLOAT;
140
148constexpr Uint8 ALPHA_TRANSPARENT = SDL_ALPHA_TRANSPARENT;
149
157constexpr float ALPHA_TRANSPARENT_FLOAT = SDL_ALPHA_TRANSPARENT_FLOAT;
158
165
171using PixelType = SDL_PixelType;
172
173constexpr PixelType PIXELTYPE_UNKNOWN = SDL_PIXELTYPE_UNKNOWN;
174
175constexpr PixelType PIXELTYPE_INDEX1 = SDL_PIXELTYPE_INDEX1;
176
177constexpr PixelType PIXELTYPE_INDEX4 = SDL_PIXELTYPE_INDEX4;
178
179constexpr PixelType PIXELTYPE_INDEX8 = SDL_PIXELTYPE_INDEX8;
180
181constexpr PixelType PIXELTYPE_PACKED8 = SDL_PIXELTYPE_PACKED8;
182
183constexpr PixelType PIXELTYPE_PACKED16 = SDL_PIXELTYPE_PACKED16;
184
185constexpr PixelType PIXELTYPE_PACKED32 = SDL_PIXELTYPE_PACKED32;
186
187constexpr PixelType PIXELTYPE_ARRAYU8 = SDL_PIXELTYPE_ARRAYU8;
188
189constexpr PixelType PIXELTYPE_ARRAYU16 = SDL_PIXELTYPE_ARRAYU16;
190
191constexpr PixelType PIXELTYPE_ARRAYU32 = SDL_PIXELTYPE_ARRAYU32;
192
193constexpr PixelType PIXELTYPE_ARRAYF16 = SDL_PIXELTYPE_ARRAYF16;
194
195constexpr PixelType PIXELTYPE_ARRAYF32 = SDL_PIXELTYPE_ARRAYF32;
196
197constexpr PixelType PIXELTYPE_INDEX2 = SDL_PIXELTYPE_INDEX2;
198
200
205
211using BitmapOrder = SDL_BitmapOrder;
212
213constexpr BitmapOrder BITMAPORDER_NONE = SDL_BITMAPORDER_NONE;
214
215constexpr BitmapOrder BITMAPORDER_4321 = SDL_BITMAPORDER_4321;
216
217constexpr BitmapOrder BITMAPORDER_1234 = SDL_BITMAPORDER_1234;
218
220
225
231using PackedOrder = SDL_PackedOrder;
232
233constexpr PackedOrder PACKEDORDER_NONE = SDL_PACKEDORDER_NONE;
234
235constexpr PackedOrder PACKEDORDER_XRGB = SDL_PACKEDORDER_XRGB;
236
237constexpr PackedOrder PACKEDORDER_RGBX = SDL_PACKEDORDER_RGBX;
238
239constexpr PackedOrder PACKEDORDER_ARGB = SDL_PACKEDORDER_ARGB;
240
241constexpr PackedOrder PACKEDORDER_RGBA = SDL_PACKEDORDER_RGBA;
242
243constexpr PackedOrder PACKEDORDER_XBGR = SDL_PACKEDORDER_XBGR;
244
245constexpr PackedOrder PACKEDORDER_BGRX = SDL_PACKEDORDER_BGRX;
246
247constexpr PackedOrder PACKEDORDER_ABGR = SDL_PACKEDORDER_ABGR;
248
249constexpr PackedOrder PACKEDORDER_BGRA = SDL_PACKEDORDER_BGRA;
250
252
257
263using ArrayOrder = SDL_ArrayOrder;
264
265constexpr ArrayOrder ARRAYORDER_NONE = SDL_ARRAYORDER_NONE;
266
267constexpr ArrayOrder ARRAYORDER_RGB = SDL_ARRAYORDER_RGB;
268
269constexpr ArrayOrder ARRAYORDER_RGBA = SDL_ARRAYORDER_RGBA;
270
271constexpr ArrayOrder ARRAYORDER_ARGB = SDL_ARRAYORDER_ARGB;
272
273constexpr ArrayOrder ARRAYORDER_BGR = SDL_ARRAYORDER_BGR;
274
275constexpr ArrayOrder ARRAYORDER_BGRA = SDL_ARRAYORDER_BGRA;
276
277constexpr ArrayOrder ARRAYORDER_ABGR = SDL_ARRAYORDER_ABGR;
278
280
285
291using PackedLayout = SDL_PackedLayout;
292
293constexpr PackedLayout PACKEDLAYOUT_NONE = SDL_PACKEDLAYOUT_NONE;
294
295constexpr PackedLayout PACKEDLAYOUT_332 = SDL_PACKEDLAYOUT_332;
296
297constexpr PackedLayout PACKEDLAYOUT_4444 = SDL_PACKEDLAYOUT_4444;
298
299constexpr PackedLayout PACKEDLAYOUT_1555 = SDL_PACKEDLAYOUT_1555;
300
301constexpr PackedLayout PACKEDLAYOUT_5551 = SDL_PACKEDLAYOUT_5551;
302
303constexpr PackedLayout PACKEDLAYOUT_565 = SDL_PACKEDLAYOUT_565;
304
305constexpr PackedLayout PACKEDLAYOUT_8888 = SDL_PACKEDLAYOUT_8888;
306
308 SDL_PACKEDLAYOUT_2101010;
309
311 SDL_PACKEDLAYOUT_1010102;
312
314
319
361{
362 PixelFormatRaw m_format;
363
364public:
370 constexpr PixelFormat(PixelFormatRaw format = {}) noexcept
371 : m_format(format)
372 {
373 }
374
398 constexpr PixelFormat(PixelType type,
399 int order,
400 PackedLayout layout,
401 int bits,
402 int bytes);
403
409 constexpr operator PixelFormatRaw() const noexcept { return m_format; }
410
430 static PixelFormat ForMasks(int bpp,
431 Uint32 Rmask,
432 Uint32 Gmask,
433 Uint32 Bmask,
434 Uint32 Amask);
435
448 constexpr Uint8 GetFlags() const;
449
459 constexpr PixelType GetType() const;
460
473 constexpr int GetOrder() const;
474
487 constexpr PackedLayout GetLayout() const;
488
503 constexpr int GetBitsPerPixel() const;
504
522 constexpr int GetBytesPerPixel() const;
523
533 constexpr bool IsIndexed() const;
534
544 constexpr bool IsPacked() const;
545
555 constexpr bool IsArray() const;
556
566 constexpr bool Is10Bit() const;
567
577 constexpr bool IsFloat() const;
578
588 constexpr bool IsAlpha() const;
589
601 constexpr bool IsFourCC() const;
602
613 const char* GetName() const;
614
631 void GetMasks(int* bpp,
632 Uint32* Rmask,
633 Uint32* Gmask,
634 Uint32* Bmask,
635 Uint32* Amask) const;
636
651 const PixelFormatDetails& GetDetails() const;
652
654 operator const PixelFormatDetails&() const;
655
688 Uint32 Map(ColorRaw c, PaletteConstRef palette = {}) const;
689
714 Color Get(Uint32 pixel, PaletteConstRef palette = {}) const;
715};
716
718 SDL_PIXELFORMAT_UNKNOWN;
719
721 SDL_PIXELFORMAT_INDEX1LSB;
722
724 SDL_PIXELFORMAT_INDEX1MSB;
725
727 SDL_PIXELFORMAT_INDEX2LSB;
728
730 SDL_PIXELFORMAT_INDEX2MSB;
731
733 SDL_PIXELFORMAT_INDEX4LSB;
734
736 SDL_PIXELFORMAT_INDEX4MSB;
737
738constexpr PixelFormat PIXELFORMAT_INDEX8 = SDL_PIXELFORMAT_INDEX8;
739
740constexpr PixelFormat PIXELFORMAT_RGB332 = SDL_PIXELFORMAT_RGB332;
741
743 SDL_PIXELFORMAT_XRGB4444;
744
746 SDL_PIXELFORMAT_XBGR4444;
747
749 SDL_PIXELFORMAT_XRGB1555;
750
752 SDL_PIXELFORMAT_XBGR1555;
753
755 SDL_PIXELFORMAT_ARGB4444;
756
758 SDL_PIXELFORMAT_RGBA4444;
759
761 SDL_PIXELFORMAT_ABGR4444;
762
764 SDL_PIXELFORMAT_BGRA4444;
765
767 SDL_PIXELFORMAT_ARGB1555;
768
770 SDL_PIXELFORMAT_RGBA5551;
771
773 SDL_PIXELFORMAT_ABGR1555;
774
776 SDL_PIXELFORMAT_BGRA5551;
777
778constexpr PixelFormat PIXELFORMAT_RGB565 = SDL_PIXELFORMAT_RGB565;
779
780constexpr PixelFormat PIXELFORMAT_BGR565 = SDL_PIXELFORMAT_BGR565;
781
782constexpr PixelFormat PIXELFORMAT_RGB24 = SDL_PIXELFORMAT_RGB24;
783
784constexpr PixelFormat PIXELFORMAT_BGR24 = SDL_PIXELFORMAT_BGR24;
785
787 SDL_PIXELFORMAT_XRGB8888;
788
790 SDL_PIXELFORMAT_RGBX8888;
791
793 SDL_PIXELFORMAT_XBGR8888;
794
796 SDL_PIXELFORMAT_BGRX8888;
797
799 SDL_PIXELFORMAT_ARGB8888;
800
802 SDL_PIXELFORMAT_RGBA8888;
803
805 SDL_PIXELFORMAT_ABGR8888;
806
808 SDL_PIXELFORMAT_BGRA8888;
809
811 SDL_PIXELFORMAT_XRGB2101010;
812
814 SDL_PIXELFORMAT_XBGR2101010;
815
817 SDL_PIXELFORMAT_ARGB2101010;
818
820 SDL_PIXELFORMAT_ABGR2101010;
821
822constexpr PixelFormat PIXELFORMAT_RGB48 = SDL_PIXELFORMAT_RGB48;
823
824constexpr PixelFormat PIXELFORMAT_BGR48 = SDL_PIXELFORMAT_BGR48;
825
826constexpr PixelFormat PIXELFORMAT_RGBA64 = SDL_PIXELFORMAT_RGBA64;
827
828constexpr PixelFormat PIXELFORMAT_ARGB64 = SDL_PIXELFORMAT_ARGB64;
829
830constexpr PixelFormat PIXELFORMAT_BGRA64 = SDL_PIXELFORMAT_BGRA64;
831
832constexpr PixelFormat PIXELFORMAT_ABGR64 = SDL_PIXELFORMAT_ABGR64;
833
835 SDL_PIXELFORMAT_RGB48_FLOAT;
836
838 SDL_PIXELFORMAT_BGR48_FLOAT;
839
841 SDL_PIXELFORMAT_RGBA64_FLOAT;
842
844 SDL_PIXELFORMAT_ARGB64_FLOAT;
845
847 SDL_PIXELFORMAT_BGRA64_FLOAT;
848
850 SDL_PIXELFORMAT_ABGR64_FLOAT;
851
853 SDL_PIXELFORMAT_RGB96_FLOAT;
854
856 SDL_PIXELFORMAT_BGR96_FLOAT;
857
859 SDL_PIXELFORMAT_RGBA128_FLOAT;
860
862 SDL_PIXELFORMAT_ARGB128_FLOAT;
863
865 SDL_PIXELFORMAT_BGRA128_FLOAT;
866
868 SDL_PIXELFORMAT_ABGR128_FLOAT;
869
871 SDL_PIXELFORMAT_YV12;
872
874 SDL_PIXELFORMAT_IYUV;
875
877 SDL_PIXELFORMAT_YUY2;
878
880 SDL_PIXELFORMAT_UYVY;
881
883 SDL_PIXELFORMAT_YVYU;
884
886 SDL_PIXELFORMAT_NV12;
887
889 SDL_PIXELFORMAT_NV21;
890
892 SDL_PIXELFORMAT_P010;
893
895 SDL_PIXELFORMAT_EXTERNAL_OES;
896
897#if SDL_VERSION_ATLEAST(3, 2, 10)
898
899constexpr PixelFormat PIXELFORMAT_MJPG = SDL_PIXELFORMAT_MJPG;
900
901#endif // SDL_VERSION_ATLEAST(3, 2, 10)
902
903constexpr PixelFormat PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_RGBA32;
904
905constexpr PixelFormat PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_ARGB32;
906
907constexpr PixelFormat PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_BGRA32;
908
909constexpr PixelFormat PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_ABGR32;
910
911constexpr PixelFormat PIXELFORMAT_RGBX32 = SDL_PIXELFORMAT_RGBX32;
912
913constexpr PixelFormat PIXELFORMAT_XRGB32 = SDL_PIXELFORMAT_XRGB32;
914
915constexpr PixelFormat PIXELFORMAT_BGRX32 = SDL_PIXELFORMAT_BGRX32;
916
917constexpr PixelFormat PIXELFORMAT_XBGR32 = SDL_PIXELFORMAT_XBGR32;
918
920
941{
942 return SDL_DEFINE_PIXELFOURCC(A, B, C, D);
943}
944
969 int order,
970 PackedLayout layout,
971 int bits,
972 int bytes)
973{
974 return PixelFormat(type, order, layout, bits, bytes);
975}
976
978 int order,
979 PackedLayout layout,
980 int bits,
981 int bytes)
982 : m_format(
983 PixelFormatRaw(SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes)))
984{
985}
986
1001{
1002 return SDL_PIXELFLAG(format);
1003}
1004
1006{
1007 return SDL::PixelFormatFlags(m_format);
1008}
1009
1023{
1024 return PixelType(SDL_PIXELTYPE(format));
1025}
1026
1028{
1029 return SDL::PixelFormatType(m_format);
1030}
1031
1046{
1047 return SDL_PIXELORDER(format);
1048}
1049
1050constexpr int PixelFormat::GetOrder() const
1051{
1052 return SDL::PixelFormatOrder(m_format);
1053}
1054
1069{
1070 return PackedLayout(SDL_PIXELLAYOUT(format));
1071}
1072
1074{
1075 return SDL::PixelFormatLayout(m_format);
1076}
1077
1094{
1095 return SDL_BITSPERPIXEL(format);
1096}
1097
1098constexpr int PixelFormat::GetBitsPerPixel() const
1099{
1100 return SDL::PixelFormatBitsPerPixel(m_format);
1101}
1102
1119{
1120 return SDL_BYTESPERPIXEL(format);
1121}
1122
1124{
1125 return SDL::PixelFormatBytesPerPixel(m_format);
1126}
1127
1139{
1140 return SDL_ISPIXELFORMAT_INDEXED(format);
1141}
1142
1143constexpr bool PixelFormat::IsIndexed() const
1144{
1145 return SDL::IsPixelFormatIndexed(m_format);
1146}
1147
1159{
1160 return SDL_ISPIXELFORMAT_PACKED(format);
1161}
1162
1163constexpr bool PixelFormat::IsPacked() const
1164{
1165 return SDL::IsPixelFormatPacked(m_format);
1166}
1167
1179{
1180 return SDL_ISPIXELFORMAT_ARRAY(format);
1181}
1182
1183constexpr bool PixelFormat::IsArray() const
1184{
1185 return SDL::IsPixelFormatArray(m_format);
1186}
1187
1199{
1200 return SDL_ISPIXELFORMAT_10BIT(format);
1201}
1202
1203constexpr bool PixelFormat::Is10Bit() const
1204{
1205 return SDL::IsPixelFormat10Bit(m_format);
1206}
1207
1219{
1220 return SDL_ISPIXELFORMAT_FLOAT(format);
1221}
1222
1223constexpr bool PixelFormat::IsFloat() const
1224{
1225 return SDL::IsPixelFormatFloat(m_format);
1226}
1227
1232
1244{
1245 return SDL_ISPIXELFORMAT_ALPHA(format);
1246}
1247
1248constexpr bool PixelFormat::IsAlpha() const
1249{
1250 return SDL::IsPixelFormatAlpha(m_format);
1251}
1252
1266{
1267 return SDL_ISPIXELFORMAT_FOURCC(format);
1268}
1269
1270constexpr bool PixelFormat::IsFourCC() const
1271{
1272 return SDL::IsPixelFormatFourCC(m_format);
1273}
1274
1280using ColorType = SDL_ColorType;
1281
1283 SDL_COLOR_TYPE_UNKNOWN;
1284
1285constexpr ColorType COLOR_TYPE_RGB = SDL_COLOR_TYPE_RGB;
1286
1288 SDL_COLOR_TYPE_YCBCR;
1289
1291
1296
1303using ColorRange = SDL_ColorRange;
1304
1306 SDL_COLOR_RANGE_UNKNOWN;
1307
1311constexpr ColorRange COLOR_RANGE_LIMITED = SDL_COLOR_RANGE_LIMITED;
1312
1314constexpr ColorRange COLOR_RANGE_FULL = SDL_COLOR_RANGE_FULL;
1315
1317
1322
1329using ColorPrimaries = SDL_ColorPrimaries;
1330
1332 SDL_COLOR_PRIMARIES_UNKNOWN;
1333
1335 SDL_COLOR_PRIMARIES_BT709;
1336
1338 SDL_COLOR_PRIMARIES_UNSPECIFIED;
1339
1341 SDL_COLOR_PRIMARIES_BT470M;
1342
1344 SDL_COLOR_PRIMARIES_BT470BG;
1346
1348 SDL_COLOR_PRIMARIES_BT601;
1349
1352 SDL_COLOR_PRIMARIES_SMPTE240;
1353
1355 SDL_COLOR_PRIMARIES_GENERIC_FILM;
1357
1359 SDL_COLOR_PRIMARIES_BT2020;
1360
1362 SDL_COLOR_PRIMARIES_XYZ;
1363
1365 SDL_COLOR_PRIMARIES_SMPTE431;
1366
1368 SDL_COLOR_PRIMARIES_SMPTE432;
1369
1371 SDL_COLOR_PRIMARIES_EBU3213;
1372
1374 SDL_COLOR_PRIMARIES_CUSTOM;
1375
1377
1382
1390using TransferCharacteristics = SDL_TransferCharacteristics;
1391
1393 SDL_TRANSFER_CHARACTERISTICS_UNKNOWN;
1394
1396 SDL_TRANSFER_CHARACTERISTICS_BT709;
1397
1399 SDL_TRANSFER_CHARACTERISTICS_UNSPECIFIED;
1400
1403 SDL_TRANSFER_CHARACTERISTICS_GAMMA22;
1404
1406 SDL_TRANSFER_CHARACTERISTICS_GAMMA28;
1407
1409 SDL_TRANSFER_CHARACTERISTICS_BT601;
1411
1413 SDL_TRANSFER_CHARACTERISTICS_SMPTE240;
1414
1416 SDL_TRANSFER_CHARACTERISTICS_LINEAR;
1417
1419 SDL_TRANSFER_CHARACTERISTICS_LOG100;
1420
1422 SDL_TRANSFER_CHARACTERISTICS_LOG100_SQRT10;
1423
1425 SDL_TRANSFER_CHARACTERISTICS_IEC61966;
1426
1428 SDL_TRANSFER_CHARACTERISTICS_BT1361;
1429
1431 SDL_TRANSFER_CHARACTERISTICS_SRGB;
1432
1434 SDL_TRANSFER_CHARACTERISTICS_BT2020_10BIT;
1435
1437 SDL_TRANSFER_CHARACTERISTICS_BT2020_12BIT;
1438
1440 SDL_TRANSFER_CHARACTERISTICS_PQ;
1442
1444 SDL_TRANSFER_CHARACTERISTICS_SMPTE428;
1445
1447 SDL_TRANSFER_CHARACTERISTICS_HLG;
1449
1451 SDL_TRANSFER_CHARACTERISTICS_CUSTOM;
1452
1454
1459
1467using MatrixCoefficients = SDL_MatrixCoefficients;
1468
1470 SDL_MATRIX_COEFFICIENTS_IDENTITY;
1471
1473 SDL_MATRIX_COEFFICIENTS_BT709;
1474
1476 SDL_MATRIX_COEFFICIENTS_UNSPECIFIED;
1477
1479 SDL_MATRIX_COEFFICIENTS_FCC;
1480
1486 SDL_MATRIX_COEFFICIENTS_BT470BG;
1487
1489 SDL_MATRIX_COEFFICIENTS_BT601;
1490
1492 SDL_MATRIX_COEFFICIENTS_SMPTE240;
1493
1495 SDL_MATRIX_COEFFICIENTS_YCGCO;
1496
1498 SDL_MATRIX_COEFFICIENTS_BT2020_NCL;
1500
1502 SDL_MATRIX_COEFFICIENTS_BT2020_CL;
1503
1505 SDL_MATRIX_COEFFICIENTS_SMPTE2085;
1506
1508 SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL;
1509
1511 SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL;
1512
1514 SDL_MATRIX_COEFFICIENTS_ICTCP;
1515
1517 SDL_MATRIX_COEFFICIENTS_CUSTOM;
1518
1520
1525
1531using ChromaLocation = SDL_ChromaLocation;
1532
1534 SDL_CHROMA_LOCATION_NONE;
1535
1541constexpr ChromaLocation CHROMA_LOCATION_LEFT = SDL_CHROMA_LOCATION_LEFT;
1542
1548constexpr ChromaLocation CHROMA_LOCATION_CENTER = SDL_CHROMA_LOCATION_CENTER;
1549
1555constexpr ChromaLocation CHROMA_LOCATION_TOPLEFT = SDL_CHROMA_LOCATION_TOPLEFT;
1556
1558
1563
1583{
1584 ColorspaceRaw m_cspace;
1585
1586public:
1592 constexpr Colorspace(ColorspaceRaw cspace = {}) noexcept
1593 : m_cspace(cspace)
1594 {
1595 }
1596
1627 constexpr Colorspace(ColorType type,
1628 ColorRange range,
1629 ColorPrimaries primaries,
1630 TransferCharacteristics transfer,
1631 MatrixCoefficients matrix,
1632 ChromaLocation chroma);
1633
1639 constexpr operator ColorspaceRaw() const noexcept { return m_cspace; }
1640
1650 constexpr ColorType GetType() const;
1651
1661 constexpr ColorRange GetRange() const;
1662
1672 constexpr ChromaLocation GetChroma() const;
1673
1683 constexpr ColorPrimaries GetPrimaries() const;
1684
1694 constexpr TransferCharacteristics GetTransfer() const;
1695
1705 constexpr MatrixCoefficients GetMatrix() const;
1706
1716 constexpr bool IsMatrixBT601() const;
1717
1727 constexpr bool IsMatrixBT709() const;
1728
1738 constexpr bool IsMatrixBT2020_NCL() const;
1739
1749 constexpr bool IsLimitedRange() const;
1750
1760 constexpr bool IsFullRange() const;
1761};
1762
1763constexpr Colorspace COLORSPACE_UNKNOWN = SDL_COLORSPACE_UNKNOWN;
1764
1766constexpr Colorspace COLORSPACE_SRGB = SDL_COLORSPACE_SRGB;
1767
1769constexpr Colorspace COLORSPACE_SRGB_LINEAR = SDL_COLORSPACE_SRGB_LINEAR;
1770
1772constexpr Colorspace COLORSPACE_HDR10 = SDL_COLORSPACE_HDR10;
1773
1775constexpr Colorspace COLORSPACE_JPEG = SDL_COLORSPACE_JPEG;
1776
1778constexpr Colorspace COLORSPACE_BT601_LIMITED = SDL_COLORSPACE_BT601_LIMITED;
1779
1781constexpr Colorspace COLORSPACE_BT601_FULL = SDL_COLORSPACE_BT601_FULL;
1782
1784constexpr Colorspace COLORSPACE_BT709_LIMITED = SDL_COLORSPACE_BT709_LIMITED;
1785
1787constexpr Colorspace COLORSPACE_BT709_FULL = SDL_COLORSPACE_BT709_FULL;
1788
1790constexpr Colorspace COLORSPACE_BT2020_LIMITED = SDL_COLORSPACE_BT2020_LIMITED;
1791
1793constexpr Colorspace COLORSPACE_BT2020_FULL = SDL_COLORSPACE_BT2020_FULL;
1794
1796constexpr Colorspace COLORSPACE_RGB_DEFAULT = SDL_COLORSPACE_RGB_DEFAULT;
1797
1799constexpr Colorspace COLORSPACE_YUV_DEFAULT = SDL_COLORSPACE_YUV_DEFAULT;
1800
1802
1834 ColorRange range,
1835 ColorPrimaries primaries,
1836 TransferCharacteristics transfer,
1837 MatrixCoefficients matrix,
1838 ChromaLocation chroma)
1839{
1840 return Colorspace(type, range, primaries, transfer, matrix, chroma);
1841}
1842
1844 ColorRange range,
1845 ColorPrimaries primaries,
1846 TransferCharacteristics transfer,
1847 MatrixCoefficients matrix,
1848 ChromaLocation chroma)
1849 : m_cspace(ColorspaceRaw(
1850 SDL_DEFINE_COLORSPACE(type, range, primaries, transfer, matrix, chroma)))
1851{
1852}
1853
1865{
1866 return SDL_COLORSPACETYPE(cspace);
1867}
1868
1870{
1871 return SDL::ColorspaceType(m_cspace);
1872}
1873
1885{
1886 return SDL_COLORSPACERANGE(cspace);
1887}
1888
1890{
1891 return SDL::ColorspaceRange(m_cspace);
1892}
1893
1905{
1906 return SDL_COLORSPACECHROMA(cspace);
1907}
1908
1910{
1911 return SDL::ColorspaceChroma(m_cspace);
1912}
1913
1925{
1926 return SDL_COLORSPACEPRIMARIES(cspace);
1927}
1928
1930{
1931 return SDL::ColorspacePrimaries(m_cspace);
1932}
1933
1945{
1946 return SDL_COLORSPACETRANSFER(cspace);
1947}
1948
1950{
1951 return SDL::ColorspaceTransfer(m_cspace);
1952}
1953
1965{
1966 return SDL_COLORSPACEMATRIX(cspace);
1967}
1968
1970{
1971 return SDL::ColorspaceMatrix(m_cspace);
1972}
1973
1989{
1990 return SDL_ISCOLORSPACE_MATRIX_BT601(cspace);
1991}
1992
1993constexpr bool Colorspace::IsMatrixBT601() const
1994{
1995 return SDL::IsColorspaceMatrixBT601(m_cspace);
1996}
1997
2009{
2010 return SDL_ISCOLORSPACE_MATRIX_BT709(cspace);
2011}
2012
2013constexpr bool Colorspace::IsMatrixBT709() const
2014{
2015 return SDL::IsColorspaceMatrixBT709(m_cspace);
2016}
2017
2029{
2030 return SDL_ISCOLORSPACE_MATRIX_BT2020_NCL(cspace);
2031}
2032
2034{
2035 return SDL::IsColorspaceMatrixBT2020_NCL(m_cspace);
2036}
2037
2049{
2050 return SDL_ISCOLORSPACE_LIMITED_RANGE(cspace);
2051}
2052
2053constexpr bool Colorspace::IsLimitedRange() const
2054{
2055 return SDL::IsColorspaceLimitedRange(m_cspace);
2056}
2057
2069{
2070 return SDL_ISCOLORSPACE_FULL_RANGE(cspace);
2071}
2072
2073constexpr bool Colorspace::IsFullRange() const
2074{
2075 return SDL::IsColorspaceFullRange(m_cspace);
2076}
2077
2079constexpr bool operator==(ColorRaw lhs, ColorRaw rhs) noexcept
2080{
2081 return lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b && lhs.a == rhs.a;
2082}
2083
2085constexpr bool operator==(const FColorRaw& lhs, const FColorRaw& rhs) noexcept
2086{
2087 return lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b && lhs.a == rhs.a;
2088}
2089
2091constexpr auto operator<=>(ColorRaw lhs, ColorRaw rhs) noexcept
2092{
2093 if (lhs.r != rhs.r) return lhs.r <=> rhs.r;
2094 if (lhs.g != rhs.g) return lhs.g <=> rhs.g;
2095 if (lhs.b != rhs.b) return lhs.b <=> rhs.b;
2096 return lhs.a <=> rhs.a;
2097}
2098
2100constexpr auto operator<=>(const FColorRaw& lhs, const FColorRaw& rhs) noexcept
2101{
2102 if (lhs.r != rhs.r) return lhs.r <=> rhs.r;
2103 if (lhs.g != rhs.g) return lhs.g <=> rhs.g;
2104 if (lhs.b != rhs.b) return lhs.b <=> rhs.b;
2105 return lhs.a <=> rhs.a;
2106}
2107
2121{
2127 constexpr Color(ColorRaw color = {}) noexcept
2128 : ColorRaw(color)
2129 {
2130 }
2131
2140 constexpr Color(Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255) noexcept
2141 : ColorRaw{r, g, b, a}
2142 {
2143 }
2144
2150 constexpr Uint8 GetR() const noexcept { return r; }
2151
2158 constexpr Color& SetR(Uint8 newR) noexcept
2159 {
2160 r = newR;
2161 return *this;
2162 }
2163
2170 constexpr Uint8 GetG() const noexcept { return g; }
2171
2178 constexpr Color& SetG(Uint8 newG) noexcept
2179 {
2180 g = newG;
2181 return *this;
2182 }
2183
2190 constexpr Uint8 GetB() const noexcept { return b; }
2191
2198 constexpr Color& SetB(Uint8 newB) noexcept
2199 {
2200 b = newB;
2201 return *this;
2202 }
2203
2210 constexpr Uint8 GetA() const noexcept { return a; }
2211
2218 constexpr Color& SetA(Uint8 newA) noexcept
2219 {
2220 a = newA;
2221 return *this;
2222 }
2223
2250 Uint32 Map(const PixelFormatDetails& format, PaletteConstRef palette) const;
2251
2278 static Color Get(Uint32 pixel,
2279 const PixelFormatDetails& format,
2280 PaletteConstRef palette = {});
2281};
2282
2294{
2300 constexpr FColor(const FColorRaw& color = {}) noexcept
2301 : FColorRaw(color)
2302 {
2303 }
2304
2313 constexpr FColor(float r, float g, float b, float a = 1) noexcept
2314 : FColorRaw{r, g, b, a}
2315 {
2316 }
2317
2323 constexpr float GetR() const noexcept { return r; }
2324
2331 constexpr FColor& SetR(float newR) noexcept
2332 {
2333 r = newR;
2334 return *this;
2335 }
2336
2343 constexpr float GetG() const noexcept { return g; }
2344
2351 constexpr FColor& SetG(float newG) noexcept
2352 {
2353 g = newG;
2354 return *this;
2355 }
2356
2363 constexpr float GetB() const noexcept { return b; }
2364
2371 constexpr FColor& SetB(float newB) noexcept
2372 {
2373 b = newB;
2374 return *this;
2375 }
2376
2383 constexpr float GetA() const noexcept { return a; }
2384
2391 constexpr FColor& SetA(float newA) noexcept
2392 {
2393 a = newA;
2394 return *this;
2395 }
2396};
2397
2400{
2401 PaletteRaw m_palette;
2402
2403 int m_index;
2404
2405public:
2407 constexpr PaletteIndex(PaletteRaw palette, int index)
2408 : m_palette{palette}
2409 , m_index{index}
2410 {
2411 }
2412
2414 constexpr explicit operator bool() const
2415 {
2416 return m_palette && m_index >= 0 && m_index < m_palette->ncolors;
2417 }
2418
2420 constexpr operator ColorRaw() const
2421 {
2422 return *this ? m_palette->colors[m_index] : ColorRaw{};
2423 }
2424
2427};
2428
2434struct PaletteBase : ResourceBaseT<PaletteRaw, PaletteRawConst>
2435{
2437
2439 constexpr operator PaletteConstRef() const noexcept { return get(); }
2440
2451 void Destroy();
2452
2454 constexpr const ColorRaw* data() const { return get()->colors; }
2455
2457 constexpr int size() const { return get()->ncolors; }
2458
2460 constexpr ColorRaw operator[](int index) const
2461 {
2462 return get()->colors[index];
2463 }
2464
2466 constexpr PaletteIndex operator[](int index)
2467 {
2468 return PaletteIndex{get(), index};
2469 }
2470
2485 void SetColors(SpanRef<const ColorRaw> colors, int firstcolor = 0);
2486};
2487
2498{
2499 using PaletteBase::PaletteBase;
2500
2508 constexpr explicit Palette(PaletteRaw resource) noexcept
2509 : PaletteBase(resource)
2510 {
2511 }
2512
2514 constexpr Palette(const Palette& other)
2515 : Palette(borrow(other.get()))
2516 {
2517 }
2518
2520 constexpr Palette(Palette&& other) noexcept
2521 : Palette(other.release())
2522 {
2523 }
2524
2542 Palette(int ncolors);
2543
2551 static Palette borrow(PaletteRaw resource)
2552 {
2553 if (resource) {
2554 ++resource->refcount;
2555 return Palette(resource);
2556 }
2557 return {};
2558 }
2559
2561 ~Palette() { SDL_DestroyPalette(get()); }
2562
2564 constexpr Palette& operator=(Palette&& other) noexcept
2565 {
2566 swap(*this, other);
2567 return *this;
2568 }
2569
2572 {
2573 if (get() != other.get()) {
2574 Palette tmp(other);
2575 swap(*this, tmp);
2576 }
2577 return *this;
2578 }
2579};
2580
2592inline const char* GetPixelFormatName(PixelFormatRaw format)
2593{
2594 return SDL_GetPixelFormatName(format);
2595}
2596
2597inline const char* PixelFormat::GetName() const
2598{
2599 return SDL::GetPixelFormatName(m_format);
2600}
2601
2620 int* bpp,
2621 Uint32* Rmask,
2622 Uint32* Gmask,
2623 Uint32* Bmask,
2624 Uint32* Amask)
2625{
2626 CheckError(
2627 SDL_GetMasksForPixelFormat(format, bpp, Rmask, Gmask, Bmask, Amask));
2628}
2629
2630inline void PixelFormat::GetMasks(int* bpp,
2631 Uint32* Rmask,
2632 Uint32* Gmask,
2633 Uint32* Bmask,
2634 Uint32* Amask) const
2635{
2636 SDL::GetMasksForPixelFormat(m_format, bpp, Rmask, Gmask, Bmask, Amask);
2637}
2638
2659 Uint32 Rmask,
2660 Uint32 Gmask,
2661 Uint32 Bmask,
2662 Uint32 Amask)
2663{
2664 return SDL_GetPixelFormatForMasks(bpp, Rmask, Gmask, Bmask, Amask);
2665}
2666
2668 Uint32 Rmask,
2669 Uint32 Gmask,
2670 Uint32 Bmask,
2671 Uint32 Amask)
2672{
2673 return SDL::GetPixelFormatForMasks(bpp, Rmask, Gmask, Bmask, Amask);
2674}
2675
2692{
2693 return *CheckError(SDL_GetPixelFormatDetails(format));
2694}
2695
2697{
2698 return SDL::GetPixelFormatDetails(m_format);
2699}
2700
2701inline PixelFormat::operator const PixelFormatDetails&() const
2702{
2703 return GetDetails();
2704}
2705
2723inline Palette CreatePalette(int ncolors) { return Palette(ncolors); }
2724
2725inline Palette::Palette(int ncolors)
2726 : Palette(CheckError(SDL_CreatePalette(ncolors)))
2727{
2728}
2729
2743inline void SetPaletteColors(PaletteRef palette,
2745 int firstcolor = 0)
2746{
2747 CheckError(SDL_SetPaletteColors(
2748 palette, colors.data(), firstcolor, narrowS32(colors.size())));
2749}
2750
2752 int firstcolor)
2753{
2754 SDL::SetPaletteColors(get(), colors, firstcolor);
2755}
2756
2758{
2759 m_palette->colors[m_index] = color;
2760 return *this;
2761}
2762
2775inline void DestroyPalette(PaletteRaw palette) { SDL_DestroyPalette(palette); }
2776
2778
2814inline Uint32 MapRGB(const PixelFormatDetails& format,
2815 PaletteConstRef palette,
2816 Uint8 r,
2817 Uint8 g,
2818 Uint8 b)
2819{
2820 return SDL_MapRGB(&format, palette, r, g, b);
2821}
2822
2860inline Uint32 MapRGBA(const PixelFormatDetails& format,
2861 Uint8 r,
2862 Uint8 g,
2863 Uint8 b,
2864 Uint8 a,
2865 PaletteConstRef palette = {})
2866{
2867 return SDL_MapRGBA(&format, palette, r, g, b, a);
2868}
2869
2904 ColorRaw c,
2905 PaletteConstRef palette = {})
2906{
2907 return SDL_MapRGBA(&format, palette, c.r, c.g, c.b, c.a);
2908}
2909
2911 PaletteConstRef palette) const
2912{
2913 return MapColor(format, *this, palette);
2914}
2915
2917{
2918 return MapColor(GetDetails(), c, palette);
2919}
2920
2946inline void GetRGB(Uint32 pixelvalue,
2947 const PixelFormatDetails& format,
2948 PaletteConstRef palette,
2949 Uint8* r,
2950 Uint8* g,
2951 Uint8* b)
2952{
2953 SDL_GetRGB(pixelvalue, &format, palette, r, g, b);
2954}
2955
2985inline void GetRGBA(Uint32 pixelvalue,
2986 const PixelFormatDetails& format,
2987 PaletteConstRef palette,
2988 Uint8* r,
2989 Uint8* g,
2990 Uint8* b,
2991 Uint8* a)
2992{
2993 SDL_GetRGBA(pixelvalue, &format, palette, r, g, b, a);
2994}
2995
3023inline Color GetColor(Uint32 pixel,
3024 const PixelFormatDetails& format,
3025 PaletteConstRef palette = {})
3026{
3027 Color c;
3028 GetRGBA(pixel, format, palette, &c.r, &c.g, &c.b, &c.a);
3029 return c;
3030}
3031
3033 const PixelFormatDetails& format,
3034 PaletteConstRef palette)
3035{
3036 return GetColor(pixel, format, palette);
3037}
3038
3039inline Color PixelFormat::Get(Uint32 pixel, PaletteConstRef palette) const
3040{
3041 return GetColor(pixel, GetDetails(), palette);
3042}
3043
3045
3046} // namespace SDL
3047
3048#endif /* SDL3PP_PIXELS_H_ */
Colorspace definitions.
Definition SDL3pp_pixels.h:1583
constexpr Colorspace(ColorspaceRaw cspace={}) noexcept
Wraps Colorspace.
Definition SDL3pp_pixels.h:1592
Auxiliary class for Palette to provide access to specific palette index.
Definition SDL3pp_pixels.h:2400
constexpr PaletteIndex(PaletteRaw palette, int index)
Constructs a PaletteIndex for a specific palette and index.
Definition SDL3pp_pixels.h:2407
Pixel format.
Definition SDL3pp_pixels.h:361
constexpr PixelFormat(PixelFormatRaw format={}) noexcept
Wraps PixelFormat.
Definition SDL3pp_pixels.h:370
constexpr RawPointer release() noexcept
Definition SDL3pp_resource.h:57
friend constexpr void swap(ResourceBaseT &lhs, ResourceBaseT &rhs) noexcept
Definition SDL3pp_resource.h:65
constexpr RawPointer get() const noexcept
Definition SDL3pp_resource.h:54
constexpr ResourceBaseT()=default
Default constructor, creates null/invalid resource.
Const reference wrapper for a given resource,.
Definition SDL3pp_resource.h:115
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:199
constexpr PixelFormat PIXELFORMAT_ABGR1555
ABGR1555.
Definition SDL3pp_pixels.h:772
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_FCC
US FCC Title 47.
Definition SDL3pp_pixels.h:1478
constexpr bool IsMatrixBT709() const
Determine if an Colorspace uses BT709 matrix coefficients.
Definition SDL3pp_pixels.h:2013
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:1303
constexpr PixelFormat PIXELFORMAT_IYUV
Planar mode: Y + U + V (3 planes).
Definition SDL3pp_pixels.h:873
constexpr bool IsPixelFormatArray(PixelFormatRaw format)
A function to determine if an PixelFormat is an array format.
Definition SDL3pp_pixels.h:1178
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_SMPTE240
SMPTE 240M.
Definition SDL3pp_pixels.h:1491
constexpr ColorPrimaries COLOR_PRIMARIES_UNSPECIFIED
COLOR_PRIMARIES_UNSPECIFIED.
Definition SDL3pp_pixels.h:1337
constexpr ColorPrimaries COLOR_PRIMARIES_BT709
ITU-R BT.709-6.
Definition SDL3pp_pixels.h:1334
constexpr PixelFormat PIXELFORMAT_BGRA64
BGRA64.
Definition SDL3pp_pixels.h:830
constexpr PixelType PIXELTYPE_PACKED8
PACKED8.
Definition SDL3pp_pixels.h:181
void DestroyPalette(PaletteRaw palette)
Free a palette created with CreatePalette().
Definition SDL3pp_pixels.h:2775
constexpr PackedLayout PACKEDLAYOUT_1555
1555
Definition SDL3pp_pixels.h:299
constexpr PixelFormat PIXELFORMAT_RGB96_FLOAT
RGB96_FLOAT.
Definition SDL3pp_pixels.h:852
constexpr ChromaLocation ColorspaceChroma(ColorspaceRaw cspace)
A macro to retrieve the chroma sample location of an Colorspace.
Definition SDL3pp_pixels.h:1904
constexpr PixelFormat PIXELFORMAT_P010
Planar mode: Y + U/V interleaved (2 planes).
Definition SDL3pp_pixels.h:891
constexpr int PixelFormatOrder(PixelFormatRaw format)
A function to retrieve the order of an PixelFormat.
Definition SDL3pp_pixels.h:1045
const char * GetName() const
Get the human readable name of a pixel format.
Definition SDL3pp_pixels.h:2597
SDL_ChromaLocation ChromaLocation
Colorspace chroma sample location.
Definition SDL3pp_pixels.h:1531
constexpr PixelFormat PIXELFORMAT_XRGB32
XRGB32.
Definition SDL3pp_pixels.h:913
constexpr ColorPrimaries ColorspacePrimaries(ColorspaceRaw cspace)
A macro to retrieve the primaries of an Colorspace.
Definition SDL3pp_pixels.h:1924
constexpr ColorType GetType() const
Retrieve the type of a Colorspace.
Definition SDL3pp_pixels.h:1869
constexpr PixelType PIXELTYPE_ARRAYF32
ARRAYF32.
Definition SDL3pp_pixels.h:195
SDL_PixelFormat PixelFormatRaw
Alias to raw representation for PixelFormat.
Definition SDL3pp_pixels.h:71
constexpr Uint8 GetFlags() const
Retrieve the flags of an PixelFormat.
Definition SDL3pp_pixels.h:1005
constexpr bool IsPixelFormat10Bit(PixelFormatRaw format)
A function to determine if an PixelFormat is a 10-bit format.
Definition SDL3pp_pixels.h:1198
constexpr PixelFormat PIXELFORMAT_MJPG
Motion JPEG.
Definition SDL3pp_pixels.h:899
static Color Get(Uint32 pixel, const PixelFormatDetails &format, PaletteConstRef palette={})
Get RGBA values from a pixel in the specified format.
Definition SDL3pp_pixels.h:3032
constexpr ColorRange COLOR_RANGE_LIMITED
Narrow range, e.g.
Definition SDL3pp_pixels.h:1311
constexpr ColorType ColorspaceType(ColorspaceRaw cspace)
A macro to retrieve the type of an Colorspace.
Definition SDL3pp_pixels.h:1864
constexpr bool IsColorspaceLimitedRange(ColorspaceRaw cspace)
A macro to determine if an Colorspace has a limited range.
Definition SDL3pp_pixels.h:2048
constexpr PixelFormat PIXELFORMAT_XRGB1555
XRGB1555.
Definition SDL3pp_pixels.h:748
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_SMPTE240
SMPTE ST 240M.
Definition SDL3pp_pixels.h:1412
constexpr PackedLayout PACKEDLAYOUT_1010102
1010102
Definition SDL3pp_pixels.h:310
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT2020_12BIT
ITU-R BT2020 for 12-bit system.
Definition SDL3pp_pixels.h:1436
constexpr ArrayOrder ARRAYORDER_RGB
RGB.
Definition SDL3pp_pixels.h:267
SDL_Color ColorRaw
Alias to raw representation for Color.
Definition SDL3pp_pixels.h:83
constexpr PixelFormat PIXELFORMAT_EXTERNAL_OES
Android video texture format.
Definition SDL3pp_pixels.h:894
SDL_Palette * PaletteRaw
Alias to raw representation for Palette.
Definition SDL3pp_pixels.h:101
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_UNSPECIFIED
MATRIX_COEFFICIENTS_UNSPECIFIED.
Definition SDL3pp_pixels.h:1475
ResourceConstRef< PaletteRaw, PaletteRawConst > PaletteConstRef
Safely wrap Palette for non owning const parameters.
Definition SDL3pp_pixels.h:114
constexpr Uint8 PixelFormatFlags(PixelFormatRaw format)
Retrieve the flags of an PixelFormat.
Definition SDL3pp_pixels.h:1000
constexpr PixelFormat PIXELFORMAT_INDEX1MSB
INDEX1MSB.
Definition SDL3pp_pixels.h:723
constexpr PixelType PIXELTYPE_PACKED32
PACKED32.
Definition SDL3pp_pixels.h:185
constexpr PixelType PIXELTYPE_ARRAYF16
ARRAYF16.
Definition SDL3pp_pixels.h:193
constexpr PixelFormat PIXELFORMAT_ABGR8888
ABGR8888.
Definition SDL3pp_pixels.h:804
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_SMPTE2085
SMPTE ST 2085.
Definition SDL3pp_pixels.h:1504
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_ICTCP
ITU-R BT.2100-0 ICTCP.
Definition SDL3pp_pixels.h:1513
constexpr PixelFormat PIXELFORMAT_NV21
Planar mode: Y + V/U interleaved (2 planes).
Definition SDL3pp_pixels.h:888
constexpr bool IsPixelFormatPacked(PixelFormatRaw format)
A function to determine if an PixelFormat is a packed format.
Definition SDL3pp_pixels.h:1158
const SDL_Palette * PaletteRawConst
Alias to const raw representation for Palette.
Definition SDL3pp_pixels.h:104
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_LOG100
TRANSFER_CHARACTERISTICS_LOG100.
Definition SDL3pp_pixels.h:1418
constexpr ColorType COLOR_TYPE_YCBCR
COLOR_TYPE_YCBCR.
Definition SDL3pp_pixels.h:1287
constexpr PixelFormat PIXELFORMAT_ARGB2101010
ARGB2101010.
Definition SDL3pp_pixels.h:816
constexpr bool IsPixelFormatAlpha(PixelFormatRaw format)
A function to determine if an PixelFormat has an alpha channel.
Definition SDL3pp_pixels.h:1243
constexpr PixelFormat PIXELFORMAT_INDEX4MSB
INDEX4MSB.
Definition SDL3pp_pixels.h:735
constexpr int PixelFormatBytesPerPixel(PixelFormatRaw format)
A function to determine an PixelFormat's bytes per pixel.
Definition SDL3pp_pixels.h:1118
constexpr PixelFormat PIXELFORMAT_UNKNOWN
UNKNOWN.
Definition SDL3pp_pixels.h:717
constexpr ColorPrimaries COLOR_PRIMARIES_UNKNOWN
COLOR_PRIMARIES_UNKNOWN.
Definition SDL3pp_pixels.h:1331
constexpr PixelFormat PIXELFORMAT_ABGR4444
ABGR4444.
Definition SDL3pp_pixels.h:760
constexpr PixelFormat PIXELFORMAT_BGRA64_FLOAT
BGRA64_FLOAT.
Definition SDL3pp_pixels.h:846
constexpr BitmapOrder BITMAPORDER_1234
1234
Definition SDL3pp_pixels.h:217
constexpr PixelFormat PIXELFORMAT_ABGR32
ABGR32.
Definition SDL3pp_pixels.h:909
constexpr PixelFormat PIXELFORMAT_BGRA128_FLOAT
BGRA128_FLOAT.
Definition SDL3pp_pixels.h:864
constexpr PixelFormat PIXELFORMAT_XBGR2101010
XBGR2101010.
Definition SDL3pp_pixels.h:813
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT601
SMPTE ST 170M / ITU-R BT.601-7 525 or 625.
Definition SDL3pp_pixels.h:1408
SDL_PackedOrder PackedOrder
Packed component order, high bit -> low bit.
Definition SDL3pp_pixels.h:231
constexpr ColorRange ColorspaceRange(ColorspaceRaw cspace)
A macro to retrieve the range of an Colorspace.
Definition SDL3pp_pixels.h:1884
constexpr bool IsColorspaceFullRange(ColorspaceRaw cspace)
A macro to determine if an Colorspace has a full range.
Definition SDL3pp_pixels.h:2068
constexpr PackedLayout PACKEDLAYOUT_565
565
Definition SDL3pp_pixels.h:303
const char * GetPixelFormatName(PixelFormatRaw format)
Get the human readable name of a pixel format.
Definition SDL3pp_pixels.h:2592
constexpr PackedOrder PACKEDORDER_BGRA
BGRA.
Definition SDL3pp_pixels.h:249
void SetPaletteColors(PaletteRef palette, SpanRef< const ColorRaw > colors, int firstcolor=0)
Set a range of colors in a palette.
Definition SDL3pp_pixels.h:2743
constexpr PixelFormat PIXELFORMAT_XRGB8888
XRGB8888.
Definition SDL3pp_pixels.h:786
constexpr PixelFormat PIXELFORMAT_BGR96_FLOAT
BGR96_FLOAT.
Definition SDL3pp_pixels.h:855
constexpr bool Is10Bit() const
Determine if this is a 10-bit format.
Definition SDL3pp_pixels.h:1203
constexpr bool IsIndexed() const
Determine if this is an indexed format.
Definition SDL3pp_pixels.h:1143
constexpr PixelFormat PIXELFORMAT_INDEX8
INDEX8.
Definition SDL3pp_pixels.h:738
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL
MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL.
Definition SDL3pp_pixels.h:1510
constexpr MatrixCoefficients ColorspaceMatrix(ColorspaceRaw cspace)
A macro to retrieve the matrix coefficients of an Colorspace.
Definition SDL3pp_pixels.h:1964
constexpr PixelFormat PIXELFORMAT_INDEX1LSB
INDEX1LSB.
Definition SDL3pp_pixels.h:720
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_SMPTE428
SMPTE ST 428-1.
Definition SDL3pp_pixels.h:1443
constexpr TransferCharacteristics GetTransfer() const
Retrieve the transfer characteristics of an Colorspace.
Definition SDL3pp_pixels.h:1949
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:1555
constexpr ChromaLocation GetChroma() const
Retrieve the chroma sample location of an Colorspace.
Definition SDL3pp_pixels.h:1909
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_GAMMA22
ITU-R BT.470-6 System M / ITU-R BT1700 625 PAL & SECAM.
Definition SDL3pp_pixels.h:1402
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT2020_NCL
ITU-R BT.2020-2 non-constant luminance.
Definition SDL3pp_pixels.h:1497
Uint32 MapRGBA(const PixelFormatDetails &format, Uint8 r, Uint8 g, Uint8 b, Uint8 a, PaletteConstRef palette={})
Map an RGBA quadruple to a pixel value for a given pixel format.
Definition SDL3pp_pixels.h:2860
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:1485
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_SRGB
IEC 61966-2-1 (sRGB or sYCC).
Definition SDL3pp_pixels.h:1430
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:1833
Color GetColor(Uint32 pixel, const PixelFormatDetails &format, PaletteConstRef palette={})
Get RGBA values from a pixel in the specified format.
Definition SDL3pp_pixels.h:3023
constexpr PixelFormat PIXELFORMAT_BGRA8888
BGRA8888.
Definition SDL3pp_pixels.h:807
constexpr PixelFormat PIXELFORMAT_RGBX8888
RGBX8888.
Definition SDL3pp_pixels.h:789
constexpr PixelFormat PIXELFORMAT_YVYU
Packed mode: Y0+V0+Y1+U0 (1 plane).
Definition SDL3pp_pixels.h:882
constexpr Uint8 ALPHA_TRANSPARENT
A fully transparent 8-bit alpha value.
Definition SDL3pp_pixels.h:148
constexpr ColorPrimaries COLOR_PRIMARIES_BT470BG
ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625.
Definition SDL3pp_pixels.h:1343
Uint32 Map(const PixelFormatDetails &format, PaletteConstRef palette) const
Map an RGBA quadruple to a pixel value for a given pixel format.
Definition SDL3pp_pixels.h:2910
constexpr ArrayOrder ARRAYORDER_NONE
NONE.
Definition SDL3pp_pixels.h:265
constexpr PackedOrder PACKEDORDER_ARGB
ARGB.
Definition SDL3pp_pixels.h:239
constexpr Uint8 ALPHA_OPAQUE
A fully opaque 8-bit alpha value.
Definition SDL3pp_pixels.h:130
constexpr PackedLayout PixelFormatLayout(PixelFormatRaw format)
A function to retrieve the layout of an PixelFormat.
Definition SDL3pp_pixels.h:1068
constexpr PixelFormat PIXELFORMAT_RGB24
RGB24.
Definition SDL3pp_pixels.h:782
constexpr ColorPrimaries GetPrimaries() const
Retrieve the primaries of an Colorspace.
Definition SDL3pp_pixels.h:1929
constexpr bool operator==(ColorRaw lhs, ColorRaw rhs) noexcept
Comparison operator for Color.
Definition SDL3pp_pixels.h:2079
constexpr Colorspace COLORSPACE_UNKNOWN
UNKNOWN.
Definition SDL3pp_pixels.h:1763
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:1541
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT2020_CL
ITU-R BT.2020-2 constant luminance.
Definition SDL3pp_pixels.h:1501
constexpr Colorspace COLORSPACE_BT601_FULL
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601.
Definition SDL3pp_pixels.h:1781
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:2667
constexpr PixelFormat PIXELFORMAT_ARGB8888
ARGB8888.
Definition SDL3pp_pixels.h:798
constexpr Colorspace COLORSPACE_SRGB_LINEAR
Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709.
Definition SDL3pp_pixels.h:1769
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_HLG
ARIB STD-B67, known as "hybrid log-gamma" (HLG).
Definition SDL3pp_pixels.h:1446
constexpr PackedLayout PACKEDLAYOUT_NONE
NONE.
Definition SDL3pp_pixels.h:293
constexpr PixelFormat PIXELFORMAT_ARGB128_FLOAT
ARGB128_FLOAT.
Definition SDL3pp_pixels.h:861
constexpr PixelType PIXELTYPE_ARRAYU16
ARRAYU16.
Definition SDL3pp_pixels.h:189
constexpr ColorType COLOR_TYPE_UNKNOWN
COLOR_TYPE_UNKNOWN.
Definition SDL3pp_pixels.h:1282
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT709
ITU-R BT.709-6.
Definition SDL3pp_pixels.h:1472
constexpr PixelFormat PIXELFORMAT_RGBX32
RGBX32.
Definition SDL3pp_pixels.h:911
SDL_FColor FColorRaw
Alias to raw representation for FColor.
Definition SDL3pp_pixels.h:89
constexpr PackedOrder PACKEDORDER_RGBX
RGBX.
Definition SDL3pp_pixels.h:237
constexpr Colorspace COLORSPACE_SRGB
Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709.
Definition SDL3pp_pixels.h:1766
constexpr bool IsMatrixBT2020_NCL() const
Determine if an Colorspace uses BT2020_NCL matrix coefficients.
Definition SDL3pp_pixels.h:2033
SDL_TransferCharacteristics TransferCharacteristics
Colorspace transfer characteristics.
Definition SDL3pp_pixels.h:1390
constexpr PackedLayout PACKEDLAYOUT_4444
4444
Definition SDL3pp_pixels.h:297
constexpr PixelFormat PIXELFORMAT_RGBA5551
RGBA5551.
Definition SDL3pp_pixels.h:769
void GetRGBA(Uint32 pixelvalue, const PixelFormatDetails &format, PaletteConstRef palette, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
Get RGBA values from a pixel in the specified format.
Definition SDL3pp_pixels.h:2985
constexpr float ALPHA_TRANSPARENT_FLOAT
A fully transparent floating point alpha value.
Definition SDL3pp_pixels.h:157
SDL_PackedLayout PackedLayout
Packed component layout.
Definition SDL3pp_pixels.h:291
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:968
constexpr PixelFormat PIXELFORMAT_XBGR8888
XBGR8888.
Definition SDL3pp_pixels.h:792
constexpr PixelFormat PIXELFORMAT_BGR48
BGR48.
Definition SDL3pp_pixels.h:824
constexpr PixelType PIXELTYPE_UNKNOWN
UNKNOWN.
Definition SDL3pp_pixels.h:173
constexpr bool IsFloat() const
Determine if this is a floating point format.
Definition SDL3pp_pixels.h:1223
constexpr Colorspace COLORSPACE_BT601_LIMITED
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601.
Definition SDL3pp_pixels.h:1778
constexpr PixelFormat PIXELFORMAT_ARGB1555
ARGB1555.
Definition SDL3pp_pixels.h:766
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT601
ITU-R BT.601-7 525.
Definition SDL3pp_pixels.h:1488
constexpr ColorPrimaries COLOR_PRIMARIES_EBU3213
EBU Tech. 3213-E.
Definition SDL3pp_pixels.h:1370
constexpr PackedOrder PACKEDORDER_ABGR
ABGR.
Definition SDL3pp_pixels.h:247
constexpr bool IsMatrixBT601() const
Determine if a Colorspace uses BT601 (or BT470BG) matrix coefficients.
Definition SDL3pp_pixels.h:1993
constexpr ColorPrimaries COLOR_PRIMARIES_SMPTE240
SMPTE 240M, functionally the same as COLOR_PRIMARIES_BT601.
Definition SDL3pp_pixels.h:1351
constexpr Colorspace COLORSPACE_BT709_LIMITED
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709.
Definition SDL3pp_pixels.h:1784
constexpr BitmapOrder BITMAPORDER_NONE
NONE.
Definition SDL3pp_pixels.h:213
SDL_BitmapOrder BitmapOrder
Bitmap pixel order, high bit -> low bit.
Definition SDL3pp_pixels.h:211
constexpr PixelFormat PIXELFORMAT_ARGB64_FLOAT
ARGB64_FLOAT.
Definition SDL3pp_pixels.h:843
constexpr PixelFormat PIXELFORMAT_XRGB2101010
XRGB2101010.
Definition SDL3pp_pixels.h:810
constexpr BitmapOrder BITMAPORDER_4321
4321
Definition SDL3pp_pixels.h:215
constexpr bool IsPacked() const
Determine if this is a packed format.
Definition SDL3pp_pixels.h:1163
constexpr ColorPrimaries COLOR_PRIMARIES_CUSTOM
COLOR_PRIMARIES_CUSTOM.
Definition SDL3pp_pixels.h:1373
constexpr ColorPrimaries COLOR_PRIMARIES_BT2020
ITU-R BT.2020-2 / ITU-R BT.2100-0.
Definition SDL3pp_pixels.h:1358
SDL_ColorType ColorType
Colorspace color type.
Definition SDL3pp_pixels.h:1280
constexpr ColorType COLOR_TYPE_RGB
COLOR_TYPE_RGB.
Definition SDL3pp_pixels.h:1285
constexpr PixelType PIXELTYPE_INDEX4
INDEX4.
Definition SDL3pp_pixels.h:177
constexpr Colorspace COLORSPACE_BT709_FULL
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709.
Definition SDL3pp_pixels.h:1787
constexpr PixelFormat PIXELFORMAT_XBGR4444
XBGR4444.
Definition SDL3pp_pixels.h:745
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT1361
ITU-R BT1361 Extended Colour Gamut.
Definition SDL3pp_pixels.h:1427
constexpr PixelType PIXELTYPE_PACKED16
PACKED16.
Definition SDL3pp_pixels.h:183
Color Get(Uint32 pixel, PaletteConstRef palette={}) const
Get RGBA values from a pixel in the specified format.
Definition SDL3pp_pixels.h:3039
const PixelFormatDetails & GetPixelFormatDetails(PixelFormatRaw format)
Create an PixelFormatDetails structure corresponding to a pixel format.
Definition SDL3pp_pixels.h:2691
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_YCGCO
MATRIX_COEFFICIENTS_YCGCO.
Definition SDL3pp_pixels.h:1494
constexpr PackedLayout PACKEDLAYOUT_332
332
Definition SDL3pp_pixels.h:295
constexpr PixelFormat PIXELFORMAT_RGBA8888
RGBA8888.
Definition SDL3pp_pixels.h:801
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_PQ
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition SDL3pp_pixels.h:1439
constexpr bool IsColorspaceMatrixBT601(ColorspaceRaw cspace)
A macro to determine if an Colorspace uses BT601 (or BT470BG) matrix coefficients.
Definition SDL3pp_pixels.h:1988
constexpr PackedLayout GetLayout() const
Retrieve the layout.
Definition SDL3pp_pixels.h:1073
SDL_PixelFormatDetails PixelFormatDetails
Details about the format of a pixel.
Definition SDL3pp_pixels.h:121
constexpr PixelFormat PIXELFORMAT_RGBA4444
RGBA4444.
Definition SDL3pp_pixels.h:757
constexpr auto operator<=>(ColorRaw lhs, ColorRaw rhs) noexcept
Spaceship operator for Color.
Definition SDL3pp_pixels.h:2091
constexpr PixelType PIXELTYPE_ARRAYU8
ARRAYU8.
Definition SDL3pp_pixels.h:187
constexpr PixelFormat PIXELFORMAT_ARGB32
ARGB32.
Definition SDL3pp_pixels.h:905
constexpr PixelFormat PIXELFORMAT_INDEX4LSB
INDEX4LSB.
Definition SDL3pp_pixels.h:732
constexpr bool IsPixelFormatFloat(PixelFormatRaw format)
A function to determine if an PixelFormat is a floating point format.
Definition SDL3pp_pixels.h:1218
constexpr ArrayOrder ARRAYORDER_ABGR
ABGR.
Definition SDL3pp_pixels.h:277
constexpr bool IsFourCC() const
Determine if this is a "FourCC" format.
Definition SDL3pp_pixels.h:1270
constexpr PixelFormat PIXELFORMAT_ABGR64_FLOAT
ABGR64_FLOAT.
Definition SDL3pp_pixels.h:849
constexpr bool IsPixelFormatFourCC(PixelFormatRaw format)
A function to determine if an PixelFormat is a "FourCC" format.
Definition SDL3pp_pixels.h:1265
constexpr ColorPrimaries COLOR_PRIMARIES_BT470M
ITU-R BT.470-6 System M.
Definition SDL3pp_pixels.h:1340
constexpr ColorPrimaries COLOR_PRIMARIES_SMPTE431
SMPTE RP 431-2.
Definition SDL3pp_pixels.h:1364
constexpr PixelFormat PIXELFORMAT_ABGR128_FLOAT
ABGR128_FLOAT.
Definition SDL3pp_pixels.h:867
constexpr ColorPrimaries COLOR_PRIMARIES_XYZ
SMPTE ST 428-1.
Definition SDL3pp_pixels.h:1361
constexpr PixelFormat PIXELFORMAT_ABGR2101010
ABGR2101010.
Definition SDL3pp_pixels.h:819
constexpr PixelFormat PIXELFORMAT_BGRX8888
BGRX8888.
Definition SDL3pp_pixels.h:795
SDL_PixelType PixelType
Pixel type.
Definition SDL3pp_pixels.h:171
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL
MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL.
Definition SDL3pp_pixels.h:1507
constexpr float ALPHA_OPAQUE_FLOAT
A fully opaque floating point alpha value.
Definition SDL3pp_pixels.h:139
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_CUSTOM
MATRIX_COEFFICIENTS_CUSTOM.
Definition SDL3pp_pixels.h:1516
constexpr PixelFormat PIXELFORMAT_YV12
Planar mode: Y + V + U (3 planes).
Definition SDL3pp_pixels.h:870
constexpr PixelFormat PIXELFORMAT_BGRX32
BGRX32.
Definition SDL3pp_pixels.h:915
constexpr PixelFormat PIXELFORMAT_BGRA4444
BGRA4444.
Definition SDL3pp_pixels.h:763
constexpr PixelFormat PIXELFORMAT_INDEX2MSB
INDEX2MSB.
Definition SDL3pp_pixels.h:729
constexpr PixelFormat PIXELFORMAT_BGR565
BGR565.
Definition SDL3pp_pixels.h:780
constexpr PixelFormat PIXELFORMAT_RGB48_FLOAT
RGB48_FLOAT.
Definition SDL3pp_pixels.h:834
constexpr PixelFormat PIXELFORMAT_RGB565
RGB565.
Definition SDL3pp_pixels.h:778
constexpr PixelFormat PIXELFORMAT_RGBA32
RGBA32.
Definition SDL3pp_pixels.h:903
constexpr PixelFormat PIXELFORMAT_BGR24
BGR24.
Definition SDL3pp_pixels.h:784
constexpr PackedLayout PACKEDLAYOUT_2101010
2101010
Definition SDL3pp_pixels.h:307
constexpr bool IsColorspaceMatrixBT709(ColorspaceRaw cspace)
A macro to determine if an Colorspace uses BT709 matrix coefficients.
Definition SDL3pp_pixels.h:2008
constexpr int GetOrder() const
Retrieve the order.
Definition SDL3pp_pixels.h:1050
constexpr PixelFormat PIXELFORMAT_NV12
Planar mode: Y + U/V interleaved (2 planes).
Definition SDL3pp_pixels.h:885
constexpr ColorPrimaries COLOR_PRIMARIES_SMPTE432
SMPTE EG 432-1 / DCI P3.
Definition SDL3pp_pixels.h:1367
constexpr Colorspace COLORSPACE_JPEG
Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601.
Definition SDL3pp_pixels.h:1775
constexpr PixelFormat PIXELFORMAT_INDEX2LSB
INDEX2LSB.
Definition SDL3pp_pixels.h:726
constexpr PackedLayout PACKEDLAYOUT_5551
5551
Definition SDL3pp_pixels.h:301
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:1314
constexpr bool IsArray() const
Determine if this is an array format.
Definition SDL3pp_pixels.h:1183
void Destroy()
Free a palette created with CreatePalette().
Definition SDL3pp_pixels.h:2777
constexpr PixelFormat PIXELFORMAT_ABGR64
ABGR64.
Definition SDL3pp_pixels.h:832
constexpr PackedOrder PACKEDORDER_RGBA
RGBA.
Definition SDL3pp_pixels.h:241
SDL_ArrayOrder ArrayOrder
Array component order, low byte -> high byte.
Definition SDL3pp_pixels.h:263
Uint32 MapRGB(const PixelFormatDetails &format, PaletteConstRef 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:2814
void GetRGB(Uint32 pixelvalue, const PixelFormatDetails &format, PaletteConstRef palette, Uint8 *r, Uint8 *g, Uint8 *b)
Get RGB values from a pixel in the specified format.
Definition SDL3pp_pixels.h:2946
Uint32 Map(ColorRaw c, PaletteConstRef palette={}) const
Map an RGBA quadruple to a pixel value for a given pixel format.
Definition SDL3pp_pixels.h:2916
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:2619
constexpr Uint32 DefinePixelFourCC(Uint8 A, Uint8 B, Uint8 C, Uint8 D)
A function for defining custom FourCC pixel formats.
Definition SDL3pp_pixels.h:940
constexpr PixelFormat PIXELFORMAT_RGBA128_FLOAT
RGBA128_FLOAT.
Definition SDL3pp_pixels.h:858
constexpr Colorspace COLORSPACE_BT2020_LIMITED
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020.
Definition SDL3pp_pixels.h:1790
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:2658
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_UNSPECIFIED
TRANSFER_CHARACTERISTICS_UNSPECIFIED.
Definition SDL3pp_pixels.h:1398
constexpr int PixelFormatBitsPerPixel(PixelFormatRaw format)
A function to determine an PixelFormat's bits per pixel.
Definition SDL3pp_pixels.h:1093
ResourceRefT< PaletteBase > PaletteRef
Reference for Palette.
Definition SDL3pp_pixels.h:111
constexpr int GetBytesPerPixel() const
Determine this's bytes per pixel.
Definition SDL3pp_pixels.h:1123
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:1329
constexpr PixelFormat PIXELFORMAT_RGB332
RGB332.
Definition SDL3pp_pixels.h:740
constexpr PixelFormat PIXELFORMAT_BGRA5551
BGRA5551.
Definition SDL3pp_pixels.h:775
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_CUSTOM
TRANSFER_CHARACTERISTICS_CUSTOM.
Definition SDL3pp_pixels.h:1450
constexpr ArrayOrder ARRAYORDER_BGRA
BGRA.
Definition SDL3pp_pixels.h:275
constexpr ColorPrimaries COLOR_PRIMARIES_GENERIC_FILM
Generic film (color filters using Illuminant C).
Definition SDL3pp_pixels.h:1354
constexpr PixelType PIXELTYPE_INDEX2
INDEX2.
Definition SDL3pp_pixels.h:197
constexpr ColorRange COLOR_RANGE_UNKNOWN
COLOR_RANGE_UNKNOWN.
Definition SDL3pp_pixels.h:1305
constexpr ColorPrimaries COLOR_PRIMARIES_BT601
ITU-R BT.601-7 525, SMPTE 170M.
Definition SDL3pp_pixels.h:1347
constexpr bool IsAlpha() const
Determine if this has an alpha channel.
Definition SDL3pp_pixels.h:1248
constexpr MatrixCoefficients GetMatrix() const
Retrieve the matrix coefficients of an Colorspace.
Definition SDL3pp_pixels.h:1969
constexpr PixelFormat PIXELFORMAT_YUY2
Packed mode: Y0+U0+Y1+V0 (1 plane).
Definition SDL3pp_pixels.h:876
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_LINEAR
TRANSFER_CHARACTERISTICS_LINEAR.
Definition SDL3pp_pixels.h:1415
constexpr PixelType PIXELTYPE_ARRAYU32
ARRAYU32.
Definition SDL3pp_pixels.h:191
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_UNKNOWN
TRANSFER_CHARACTERISTICS_UNKNOWN.
Definition SDL3pp_pixels.h:1392
SDL_MatrixCoefficients MatrixCoefficients
Colorspace matrix coefficients.
Definition SDL3pp_pixels.h:1467
constexpr PixelType GetType() const
Retrieve the type.
Definition SDL3pp_pixels.h:1027
constexpr ArrayOrder ARRAYORDER_RGBA
RGBA.
Definition SDL3pp_pixels.h:269
constexpr PixelFormat PIXELFORMAT_RGBA64_FLOAT
RGBA64_FLOAT.
Definition SDL3pp_pixels.h:840
constexpr bool IsColorspaceMatrixBT2020_NCL(ColorspaceRaw cspace)
Determine if an Colorspace uses BT2020_NCL matrix coefficients.
Definition SDL3pp_pixels.h:2028
PaletteIndex & operator=(ColorRaw color)
Assignment operator.
Definition SDL3pp_pixels.h:2757
constexpr PixelFormat PIXELFORMAT_XRGB4444
XRGB4444.
Definition SDL3pp_pixels.h:742
constexpr Colorspace COLORSPACE_BT2020_FULL
Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020.
Definition SDL3pp_pixels.h:1793
constexpr TransferCharacteristics ColorspaceTransfer(ColorspaceRaw cspace)
A macro to retrieve the transfer characteristics of an Colorspace.
Definition SDL3pp_pixels.h:1944
void SetColors(SpanRef< const ColorRaw > colors, int firstcolor=0)
Set a range of colors in a palette.
Definition SDL3pp_pixels.h:2751
constexpr ChromaLocation CHROMA_LOCATION_NONE
RGB, no chroma sampling.
Definition SDL3pp_pixels.h:1533
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT2020_10BIT
ITU-R BT2020 for 10-bit system.
Definition SDL3pp_pixels.h:1433
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:1548
constexpr PixelFormat PIXELFORMAT_RGBA64
RGBA64.
Definition SDL3pp_pixels.h:826
constexpr PixelFormat PIXELFORMAT_UYVY
Packed mode: U0+Y0+V0+Y1 (1 plane).
Definition SDL3pp_pixels.h:879
constexpr Colorspace COLORSPACE_RGB_DEFAULT
The default colorspace for RGB surfaces if no colorspace is specified.
Definition SDL3pp_pixels.h:1796
constexpr PackedOrder PACKEDORDER_NONE
NONE.
Definition SDL3pp_pixels.h:233
constexpr PixelType PixelFormatType(PixelFormatRaw format)
A function to retrieve the type of an PixelFormat.
Definition SDL3pp_pixels.h:1022
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_GAMMA28
ITU-R BT.470-6 System B, G.
Definition SDL3pp_pixels.h:1405
Uint32 MapColor(const PixelFormatDetails &format, ColorRaw c, PaletteConstRef palette={})
Map an RGBA quadruple to a pixel value for a given pixel format.
Definition SDL3pp_pixels.h:2903
constexpr PixelFormat PIXELFORMAT_ARGB4444
ARGB4444.
Definition SDL3pp_pixels.h:754
SDL_Colorspace ColorspaceRaw
Alias to raw representation for Colorspace.
Definition SDL3pp_pixels.h:77
constexpr ArrayOrder ARRAYORDER_BGR
BGR.
Definition SDL3pp_pixels.h:273
constexpr PixelFormat PIXELFORMAT_BGRA32
BGRA32.
Definition SDL3pp_pixels.h:907
constexpr bool IsFullRange() const
A function to determine if an Colorspace has a full range.
Definition SDL3pp_pixels.h:2073
constexpr int GetBitsPerPixel() const
Determine this's bits per pixel.
Definition SDL3pp_pixels.h:1098
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT709
Rec. ITU-R BT.709-6 / ITU-R BT1361.
Definition SDL3pp_pixels.h:1395
constexpr PixelType PIXELTYPE_INDEX1
INDEX1.
Definition SDL3pp_pixels.h:175
constexpr PixelFormat PIXELFORMAT_XBGR32
XBGR32.
Definition SDL3pp_pixels.h:917
constexpr bool IsPixelFormatIndexed(PixelFormatRaw format)
A function to determine if an PixelFormat is an indexed format.
Definition SDL3pp_pixels.h:1138
constexpr ArrayOrder ARRAYORDER_ARGB
ARGB.
Definition SDL3pp_pixels.h:271
constexpr PixelFormat PIXELFORMAT_ARGB64
ARGB64.
Definition SDL3pp_pixels.h:828
constexpr Colorspace COLORSPACE_HDR10
Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020.
Definition SDL3pp_pixels.h:1772
constexpr PackedOrder PACKEDORDER_XRGB
XRGB.
Definition SDL3pp_pixels.h:235
constexpr PackedLayout PACKEDLAYOUT_8888
8888
Definition SDL3pp_pixels.h:305
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:2630
const PixelFormatDetails & GetDetails() const
Create an PixelFormatDetails structure corresponding to a pixel format.
Definition SDL3pp_pixels.h:2696
constexpr PixelFormat PIXELFORMAT_RGB48
RGB48.
Definition SDL3pp_pixels.h:822
constexpr bool IsLimitedRange() const
A function to determine if an Colorspace has a limited range.
Definition SDL3pp_pixels.h:2053
constexpr PixelFormat PIXELFORMAT_XBGR1555
XBGR1555.
Definition SDL3pp_pixels.h:751
constexpr ColorRange GetRange() const
Retrieve the range of a Colorspace.
Definition SDL3pp_pixels.h:1889
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_LOG100_SQRT10
TRANSFER_CHARACTERISTICS_LOG100_SQRT10.
Definition SDL3pp_pixels.h:1421
Palette CreatePalette(int ncolors)
Create a palette structure with the specified number of color entries.
Definition SDL3pp_pixels.h:2723
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_IEC61966
IEC 61966-2-4.
Definition SDL3pp_pixels.h:1424
constexpr PackedOrder PACKEDORDER_BGRX
BGRX.
Definition SDL3pp_pixels.h:245
constexpr Colorspace COLORSPACE_YUV_DEFAULT
The default colorspace for YUV surfaces if no colorspace is specified.
Definition SDL3pp_pixels.h:1799
constexpr PackedOrder PACKEDORDER_XBGR
XBGR.
Definition SDL3pp_pixels.h:243
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_IDENTITY
MATRIX_COEFFICIENTS_IDENTITY.
Definition SDL3pp_pixels.h:1469
constexpr PixelFormat PIXELFORMAT_BGR48_FLOAT
BGR48_FLOAT.
Definition SDL3pp_pixels.h:837
constexpr PixelType PIXELTYPE_INDEX8
INDEX8.
Definition SDL3pp_pixels.h:179
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition SDL3pp_stdinc.h:296
::Uint8 Uint8
An unsigned 8-bit integer type.
Definition SDL3pp_stdinc.h:244
Main include header for the SDL3pp library.
Sint32 narrowS32(T value)
Narrows to Sint32.
Definition SDL3pp_stdinc.h:6262
A structure that represents a color as RGBA components.
Definition SDL3pp_pixels.h:2121
constexpr Uint8 GetG() const noexcept
Get the green component from the color.
Definition SDL3pp_pixels.h:2170
constexpr Uint8 GetA() const noexcept
Get the alpha component from the color.
Definition SDL3pp_pixels.h:2210
constexpr Color & SetB(Uint8 newB) noexcept
Set the blue component from the color.
Definition SDL3pp_pixels.h:2198
constexpr Uint8 GetB() const noexcept
Get the blue component from the color.
Definition SDL3pp_pixels.h:2190
constexpr Color & SetR(Uint8 newR) noexcept
Set the red component from the color.
Definition SDL3pp_pixels.h:2158
constexpr Color(Uint8 r, Uint8 g, Uint8 b, Uint8 a=255) noexcept
Constructs from its fields.
Definition SDL3pp_pixels.h:2140
constexpr Uint8 GetR() const noexcept
Get the red component from the color.
Definition SDL3pp_pixels.h:2150
constexpr Color & SetA(Uint8 newA) noexcept
Set the alpha component from the color.
Definition SDL3pp_pixels.h:2218
constexpr Color & SetG(Uint8 newG) noexcept
Set the green component from the color.
Definition SDL3pp_pixels.h:2178
constexpr Color(ColorRaw color={}) noexcept
Wraps Color.
Definition SDL3pp_pixels.h:2127
The bits of this structure can be directly reinterpreted as a float-packed color which uses the PIXEL...
Definition SDL3pp_pixels.h:2294
constexpr FColor & SetB(float newB) noexcept
Set the blue component from the color.
Definition SDL3pp_pixels.h:2371
constexpr float GetG() const noexcept
Get the green component from the color.
Definition SDL3pp_pixels.h:2343
constexpr FColor(float r, float g, float b, float a=1) noexcept
Constructs from its fields.
Definition SDL3pp_pixels.h:2313
constexpr FColor(const FColorRaw &color={}) noexcept
Wraps FColor.
Definition SDL3pp_pixels.h:2300
constexpr FColor & SetR(float newR) noexcept
Set the red component from the color.
Definition SDL3pp_pixels.h:2331
constexpr float GetB() const noexcept
Get the blue component from the color.
Definition SDL3pp_pixels.h:2363
constexpr FColor & SetG(float newG) noexcept
Set the green component from the color.
Definition SDL3pp_pixels.h:2351
constexpr FColor & SetA(float newA) noexcept
Set the alpha component from the color.
Definition SDL3pp_pixels.h:2391
constexpr float GetR() const noexcept
Get the red component from the color.
Definition SDL3pp_pixels.h:2323
constexpr float GetA() const noexcept
Get the alpha component from the color.
Definition SDL3pp_pixels.h:2383
Base class to Palette.
Definition SDL3pp_pixels.h:2435
constexpr ColorRaw operator[](int index) const
Access specific pallete index.
Definition SDL3pp_pixels.h:2460
constexpr const ColorRaw * data() const
Access specific pallete colors.
Definition SDL3pp_pixels.h:2454
constexpr PaletteIndex operator[](int index)
Change specific pallete index.
Definition SDL3pp_pixels.h:2466
constexpr int size() const
Returns number of colors in the palette.
Definition SDL3pp_pixels.h:2457
constexpr ResourceBaseT()=default
Default constructor, creates null/invalid resource.
A set of indexed colors representing a palette.
Definition SDL3pp_pixels.h:2498
constexpr Palette(Palette &&other) noexcept
Move constructor.
Definition SDL3pp_pixels.h:2520
Palette & operator=(const Palette &other)
Assignment operator.
Definition SDL3pp_pixels.h:2571
static Palette borrow(PaletteRaw resource)
Safely borrows the from PaletteRaw.
Definition SDL3pp_pixels.h:2551
constexpr Palette(const Palette &other)
Copy constructor.
Definition SDL3pp_pixels.h:2514
~Palette()
Destructor.
Definition SDL3pp_pixels.h:2561
constexpr Palette & operator=(Palette &&other) noexcept
Assignment operator.
Definition SDL3pp_pixels.h:2564
constexpr Palette(PaletteRaw resource) noexcept
Constructs from raw Palette.
Definition SDL3pp_pixels.h:2508
A non-owning reference wrapper for a given resource.
Definition SDL3pp_resource.h:93