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 Palette;
96
98using PaletteRaw = SDL_Palette*;
99
101using PaletteRawConst = const SDL_Palette*;
102
109
112
118using PixelFormatDetails = SDL_PixelFormatDetails;
119
127constexpr Uint8 ALPHA_OPAQUE = SDL_ALPHA_OPAQUE;
128
136constexpr float ALPHA_OPAQUE_FLOAT = SDL_ALPHA_OPAQUE_FLOAT;
137
145constexpr Uint8 ALPHA_TRANSPARENT = SDL_ALPHA_TRANSPARENT;
146
154constexpr float ALPHA_TRANSPARENT_FLOAT = SDL_ALPHA_TRANSPARENT_FLOAT;
155
162
168using PixelType = SDL_PixelType;
169
170constexpr PixelType PIXELTYPE_UNKNOWN = SDL_PIXELTYPE_UNKNOWN;
171
172constexpr PixelType PIXELTYPE_INDEX1 = SDL_PIXELTYPE_INDEX1;
173
174constexpr PixelType PIXELTYPE_INDEX4 = SDL_PIXELTYPE_INDEX4;
175
176constexpr PixelType PIXELTYPE_INDEX8 = SDL_PIXELTYPE_INDEX8;
177
178constexpr PixelType PIXELTYPE_PACKED8 = SDL_PIXELTYPE_PACKED8;
179
180constexpr PixelType PIXELTYPE_PACKED16 = SDL_PIXELTYPE_PACKED16;
181
182constexpr PixelType PIXELTYPE_PACKED32 = SDL_PIXELTYPE_PACKED32;
183
184constexpr PixelType PIXELTYPE_ARRAYU8 = SDL_PIXELTYPE_ARRAYU8;
185
186constexpr PixelType PIXELTYPE_ARRAYU16 = SDL_PIXELTYPE_ARRAYU16;
187
188constexpr PixelType PIXELTYPE_ARRAYU32 = SDL_PIXELTYPE_ARRAYU32;
189
190constexpr PixelType PIXELTYPE_ARRAYF16 = SDL_PIXELTYPE_ARRAYF16;
191
192constexpr PixelType PIXELTYPE_ARRAYF32 = SDL_PIXELTYPE_ARRAYF32;
193
194constexpr PixelType PIXELTYPE_INDEX2 = SDL_PIXELTYPE_INDEX2;
195
197
202
208using BitmapOrder = SDL_BitmapOrder;
209
210constexpr BitmapOrder BITMAPORDER_NONE = SDL_BITMAPORDER_NONE;
211
212constexpr BitmapOrder BITMAPORDER_4321 = SDL_BITMAPORDER_4321;
213
214constexpr BitmapOrder BITMAPORDER_1234 = SDL_BITMAPORDER_1234;
215
217
222
228using PackedOrder = SDL_PackedOrder;
229
230constexpr PackedOrder PACKEDORDER_NONE = SDL_PACKEDORDER_NONE;
231
232constexpr PackedOrder PACKEDORDER_XRGB = SDL_PACKEDORDER_XRGB;
233
234constexpr PackedOrder PACKEDORDER_RGBX = SDL_PACKEDORDER_RGBX;
235
236constexpr PackedOrder PACKEDORDER_ARGB = SDL_PACKEDORDER_ARGB;
237
238constexpr PackedOrder PACKEDORDER_RGBA = SDL_PACKEDORDER_RGBA;
239
240constexpr PackedOrder PACKEDORDER_XBGR = SDL_PACKEDORDER_XBGR;
241
242constexpr PackedOrder PACKEDORDER_BGRX = SDL_PACKEDORDER_BGRX;
243
244constexpr PackedOrder PACKEDORDER_ABGR = SDL_PACKEDORDER_ABGR;
245
246constexpr PackedOrder PACKEDORDER_BGRA = SDL_PACKEDORDER_BGRA;
247
249
254
260using ArrayOrder = SDL_ArrayOrder;
261
262constexpr ArrayOrder ARRAYORDER_NONE = SDL_ARRAYORDER_NONE;
263
264constexpr ArrayOrder ARRAYORDER_RGB = SDL_ARRAYORDER_RGB;
265
266constexpr ArrayOrder ARRAYORDER_RGBA = SDL_ARRAYORDER_RGBA;
267
268constexpr ArrayOrder ARRAYORDER_ARGB = SDL_ARRAYORDER_ARGB;
269
270constexpr ArrayOrder ARRAYORDER_BGR = SDL_ARRAYORDER_BGR;
271
272constexpr ArrayOrder ARRAYORDER_BGRA = SDL_ARRAYORDER_BGRA;
273
274constexpr ArrayOrder ARRAYORDER_ABGR = SDL_ARRAYORDER_ABGR;
275
277
282
288using PackedLayout = SDL_PackedLayout;
289
290constexpr PackedLayout PACKEDLAYOUT_NONE = SDL_PACKEDLAYOUT_NONE;
291
292constexpr PackedLayout PACKEDLAYOUT_332 = SDL_PACKEDLAYOUT_332;
293
294constexpr PackedLayout PACKEDLAYOUT_4444 = SDL_PACKEDLAYOUT_4444;
295
296constexpr PackedLayout PACKEDLAYOUT_1555 = SDL_PACKEDLAYOUT_1555;
297
298constexpr PackedLayout PACKEDLAYOUT_5551 = SDL_PACKEDLAYOUT_5551;
299
300constexpr PackedLayout PACKEDLAYOUT_565 = SDL_PACKEDLAYOUT_565;
301
302constexpr PackedLayout PACKEDLAYOUT_8888 = SDL_PACKEDLAYOUT_8888;
303
305 SDL_PACKEDLAYOUT_2101010;
306
308 SDL_PACKEDLAYOUT_1010102;
309
311
316
358{
359 PixelFormatRaw m_format;
360
361public:
367 constexpr PixelFormat(PixelFormatRaw format = {}) noexcept
368 : m_format(format)
369 {
370 }
371
395 constexpr PixelFormat(PixelType type,
396 int order,
397 PackedLayout layout,
398 int bits,
399 int bytes);
400
406 constexpr operator PixelFormatRaw() const noexcept { return m_format; }
407
427 static PixelFormat ForMasks(int bpp,
428 Uint32 Rmask,
429 Uint32 Gmask,
430 Uint32 Bmask,
431 Uint32 Amask);
432
445 constexpr Uint8 GetFlags() const;
446
456 constexpr PixelType GetType() const;
457
470 constexpr int GetOrder() const;
471
484 constexpr PackedLayout GetLayout() const;
485
500 constexpr int GetBitsPerPixel() const;
501
519 constexpr int GetBytesPerPixel() const;
520
530 constexpr bool IsIndexed() const;
531
541 constexpr bool IsPacked() const;
542
552 constexpr bool IsArray() const;
553
563 constexpr bool Is10Bit() const;
564
574 constexpr bool IsFloat() const;
575
585 constexpr bool IsAlpha() const;
586
598 constexpr bool IsFourCC() const;
599
610 const char* GetName() const;
611
628 void GetMasks(int* bpp,
629 Uint32* Rmask,
630 Uint32* Gmask,
631 Uint32* Bmask,
632 Uint32* Amask) const;
633
648 const PixelFormatDetails& GetDetails() const;
649
651 operator const PixelFormatDetails&() const;
652
685 Uint32 Map(ColorRaw c, PaletteConstRef palette = {}) const;
686
711 Color Get(Uint32 pixel, PaletteConstRef palette = {}) const;
712};
713
715 SDL_PIXELFORMAT_UNKNOWN;
716
718 SDL_PIXELFORMAT_INDEX1LSB;
719
721 SDL_PIXELFORMAT_INDEX1MSB;
722
724 SDL_PIXELFORMAT_INDEX2LSB;
725
727 SDL_PIXELFORMAT_INDEX2MSB;
728
730 SDL_PIXELFORMAT_INDEX4LSB;
731
733 SDL_PIXELFORMAT_INDEX4MSB;
734
735constexpr PixelFormat PIXELFORMAT_INDEX8 = SDL_PIXELFORMAT_INDEX8;
736
737constexpr PixelFormat PIXELFORMAT_RGB332 = SDL_PIXELFORMAT_RGB332;
738
740 SDL_PIXELFORMAT_XRGB4444;
741
743 SDL_PIXELFORMAT_XBGR4444;
744
746 SDL_PIXELFORMAT_XRGB1555;
747
749 SDL_PIXELFORMAT_XBGR1555;
750
752 SDL_PIXELFORMAT_ARGB4444;
753
755 SDL_PIXELFORMAT_RGBA4444;
756
758 SDL_PIXELFORMAT_ABGR4444;
759
761 SDL_PIXELFORMAT_BGRA4444;
762
764 SDL_PIXELFORMAT_ARGB1555;
765
767 SDL_PIXELFORMAT_RGBA5551;
768
770 SDL_PIXELFORMAT_ABGR1555;
771
773 SDL_PIXELFORMAT_BGRA5551;
774
775constexpr PixelFormat PIXELFORMAT_RGB565 = SDL_PIXELFORMAT_RGB565;
776
777constexpr PixelFormat PIXELFORMAT_BGR565 = SDL_PIXELFORMAT_BGR565;
778
779constexpr PixelFormat PIXELFORMAT_RGB24 = SDL_PIXELFORMAT_RGB24;
780
781constexpr PixelFormat PIXELFORMAT_BGR24 = SDL_PIXELFORMAT_BGR24;
782
784 SDL_PIXELFORMAT_XRGB8888;
785
787 SDL_PIXELFORMAT_RGBX8888;
788
790 SDL_PIXELFORMAT_XBGR8888;
791
793 SDL_PIXELFORMAT_BGRX8888;
794
796 SDL_PIXELFORMAT_ARGB8888;
797
799 SDL_PIXELFORMAT_RGBA8888;
800
802 SDL_PIXELFORMAT_ABGR8888;
803
805 SDL_PIXELFORMAT_BGRA8888;
806
808 SDL_PIXELFORMAT_XRGB2101010;
809
811 SDL_PIXELFORMAT_XBGR2101010;
812
814 SDL_PIXELFORMAT_ARGB2101010;
815
817 SDL_PIXELFORMAT_ABGR2101010;
818
819constexpr PixelFormat PIXELFORMAT_RGB48 = SDL_PIXELFORMAT_RGB48;
820
821constexpr PixelFormat PIXELFORMAT_BGR48 = SDL_PIXELFORMAT_BGR48;
822
823constexpr PixelFormat PIXELFORMAT_RGBA64 = SDL_PIXELFORMAT_RGBA64;
824
825constexpr PixelFormat PIXELFORMAT_ARGB64 = SDL_PIXELFORMAT_ARGB64;
826
827constexpr PixelFormat PIXELFORMAT_BGRA64 = SDL_PIXELFORMAT_BGRA64;
828
829constexpr PixelFormat PIXELFORMAT_ABGR64 = SDL_PIXELFORMAT_ABGR64;
830
832 SDL_PIXELFORMAT_RGB48_FLOAT;
833
835 SDL_PIXELFORMAT_BGR48_FLOAT;
836
838 SDL_PIXELFORMAT_RGBA64_FLOAT;
839
841 SDL_PIXELFORMAT_ARGB64_FLOAT;
842
844 SDL_PIXELFORMAT_BGRA64_FLOAT;
845
847 SDL_PIXELFORMAT_ABGR64_FLOAT;
848
850 SDL_PIXELFORMAT_RGB96_FLOAT;
851
853 SDL_PIXELFORMAT_BGR96_FLOAT;
854
856 SDL_PIXELFORMAT_RGBA128_FLOAT;
857
859 SDL_PIXELFORMAT_ARGB128_FLOAT;
860
862 SDL_PIXELFORMAT_BGRA128_FLOAT;
863
865 SDL_PIXELFORMAT_ABGR128_FLOAT;
866
868 SDL_PIXELFORMAT_YV12;
869
871 SDL_PIXELFORMAT_IYUV;
872
874 SDL_PIXELFORMAT_YUY2;
875
877 SDL_PIXELFORMAT_UYVY;
878
880 SDL_PIXELFORMAT_YVYU;
881
883 SDL_PIXELFORMAT_NV12;
884
886 SDL_PIXELFORMAT_NV21;
887
889 SDL_PIXELFORMAT_P010;
890
892 SDL_PIXELFORMAT_EXTERNAL_OES;
893
894#if SDL_VERSION_ATLEAST(3, 2, 10)
895
896constexpr PixelFormat PIXELFORMAT_MJPG = SDL_PIXELFORMAT_MJPG;
897
898#endif // SDL_VERSION_ATLEAST(3, 2, 10)
899
900constexpr PixelFormat PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_RGBA32;
901
902constexpr PixelFormat PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_ARGB32;
903
904constexpr PixelFormat PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_BGRA32;
905
906constexpr PixelFormat PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_ABGR32;
907
908constexpr PixelFormat PIXELFORMAT_RGBX32 = SDL_PIXELFORMAT_RGBX32;
909
910constexpr PixelFormat PIXELFORMAT_XRGB32 = SDL_PIXELFORMAT_XRGB32;
911
912constexpr PixelFormat PIXELFORMAT_BGRX32 = SDL_PIXELFORMAT_BGRX32;
913
914constexpr PixelFormat PIXELFORMAT_XBGR32 = SDL_PIXELFORMAT_XBGR32;
915
917
938{
939 return SDL_DEFINE_PIXELFOURCC(A, B, C, D);
940}
941
966 int order,
967 PackedLayout layout,
968 int bits,
969 int bytes)
970{
971 return PixelFormat(type, order, layout, bits, bytes);
972}
973
975 int order,
976 PackedLayout layout,
977 int bits,
978 int bytes)
979 : m_format(
980 PixelFormatRaw(SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes)))
981{
982}
983
998{
999 return SDL_PIXELFLAG(format);
1000}
1001
1003{
1004 return SDL::PixelFormatFlags(m_format);
1005}
1006
1020{
1021 return PixelType(SDL_PIXELTYPE(format));
1022}
1023
1025{
1026 return SDL::PixelFormatType(m_format);
1027}
1028
1043{
1044 return SDL_PIXELORDER(format);
1045}
1046
1047constexpr int PixelFormat::GetOrder() const
1048{
1049 return SDL::PixelFormatOrder(m_format);
1050}
1051
1066{
1067 return PackedLayout(SDL_PIXELLAYOUT(format));
1068}
1069
1071{
1072 return SDL::PixelFormatLayout(m_format);
1073}
1074
1094{
1095 return SDL_BITSPERPIXEL(format);
1096}
1097
1098constexpr int PixelFormat::GetBitsPerPixel() const
1099{
1100 return SDL::PixelFormatBitsPerPixel(m_format);
1101}
1102
1122{
1123 return SDL_BYTESPERPIXEL(format);
1124}
1125
1127{
1128 return SDL::PixelFormatBytesPerPixel(m_format);
1129}
1130
1145{
1146 return SDL_ISPIXELFORMAT_INDEXED(format);
1147}
1148
1149constexpr bool PixelFormat::IsIndexed() const
1150{
1151 return SDL::IsPixelFormatIndexed(m_format);
1152}
1153
1168{
1169 return SDL_ISPIXELFORMAT_PACKED(format);
1170}
1171
1172constexpr bool PixelFormat::IsPacked() const
1173{
1174 return SDL::IsPixelFormatPacked(m_format);
1175}
1176
1191{
1192 return SDL_ISPIXELFORMAT_ARRAY(format);
1193}
1194
1195constexpr bool PixelFormat::IsArray() const
1196{
1197 return SDL::IsPixelFormatArray(m_format);
1198}
1199
1214{
1215 return SDL_ISPIXELFORMAT_10BIT(format);
1216}
1217
1218constexpr bool PixelFormat::Is10Bit() const
1219{
1220 return SDL::IsPixelFormat10Bit(m_format);
1221}
1222
1237{
1238 return SDL_ISPIXELFORMAT_FLOAT(format);
1239}
1240
1241constexpr bool PixelFormat::IsFloat() const
1242{
1243 return SDL::IsPixelFormatFloat(m_format);
1244}
1245
1250
1265{
1266 return SDL_ISPIXELFORMAT_ALPHA(format);
1267}
1268
1269constexpr bool PixelFormat::IsAlpha() const
1270{
1271 return SDL::IsPixelFormatAlpha(m_format);
1272}
1273
1290{
1291 return SDL_ISPIXELFORMAT_FOURCC(format);
1292}
1293
1294constexpr bool PixelFormat::IsFourCC() const
1295{
1296 return SDL::IsPixelFormatFourCC(m_format);
1297}
1298
1304using ColorType = SDL_ColorType;
1305
1307 SDL_COLOR_TYPE_UNKNOWN;
1308
1309constexpr ColorType COLOR_TYPE_RGB = SDL_COLOR_TYPE_RGB;
1310
1312 SDL_COLOR_TYPE_YCBCR;
1313
1315
1320
1327using ColorRange = SDL_ColorRange;
1328
1330 SDL_COLOR_RANGE_UNKNOWN;
1331
1335constexpr ColorRange COLOR_RANGE_LIMITED = SDL_COLOR_RANGE_LIMITED;
1336
1338constexpr ColorRange COLOR_RANGE_FULL = SDL_COLOR_RANGE_FULL;
1339
1341
1346
1353using ColorPrimaries = SDL_ColorPrimaries;
1354
1356 SDL_COLOR_PRIMARIES_UNKNOWN;
1357
1359 SDL_COLOR_PRIMARIES_BT709;
1360
1362 SDL_COLOR_PRIMARIES_UNSPECIFIED;
1363
1365 SDL_COLOR_PRIMARIES_BT470M;
1366
1368 SDL_COLOR_PRIMARIES_BT470BG;
1370
1372 SDL_COLOR_PRIMARIES_BT601;
1373
1376 SDL_COLOR_PRIMARIES_SMPTE240;
1377
1379 SDL_COLOR_PRIMARIES_GENERIC_FILM;
1381
1383 SDL_COLOR_PRIMARIES_BT2020;
1384
1386 SDL_COLOR_PRIMARIES_XYZ;
1387
1389 SDL_COLOR_PRIMARIES_SMPTE431;
1390
1392 SDL_COLOR_PRIMARIES_SMPTE432;
1393
1395 SDL_COLOR_PRIMARIES_EBU3213;
1396
1398 SDL_COLOR_PRIMARIES_CUSTOM;
1399
1401
1406
1414using TransferCharacteristics = SDL_TransferCharacteristics;
1415
1417 SDL_TRANSFER_CHARACTERISTICS_UNKNOWN;
1418
1420 SDL_TRANSFER_CHARACTERISTICS_BT709;
1421
1423 SDL_TRANSFER_CHARACTERISTICS_UNSPECIFIED;
1424
1427 SDL_TRANSFER_CHARACTERISTICS_GAMMA22;
1428
1430 SDL_TRANSFER_CHARACTERISTICS_GAMMA28;
1431
1433 SDL_TRANSFER_CHARACTERISTICS_BT601;
1435
1437 SDL_TRANSFER_CHARACTERISTICS_SMPTE240;
1438
1440 SDL_TRANSFER_CHARACTERISTICS_LINEAR;
1441
1443 SDL_TRANSFER_CHARACTERISTICS_LOG100;
1444
1446 SDL_TRANSFER_CHARACTERISTICS_LOG100_SQRT10;
1447
1449 SDL_TRANSFER_CHARACTERISTICS_IEC61966;
1450
1452 SDL_TRANSFER_CHARACTERISTICS_BT1361;
1453
1455 SDL_TRANSFER_CHARACTERISTICS_SRGB;
1456
1458 SDL_TRANSFER_CHARACTERISTICS_BT2020_10BIT;
1459
1461 SDL_TRANSFER_CHARACTERISTICS_BT2020_12BIT;
1462
1464 SDL_TRANSFER_CHARACTERISTICS_PQ;
1466
1468 SDL_TRANSFER_CHARACTERISTICS_SMPTE428;
1469
1471 SDL_TRANSFER_CHARACTERISTICS_HLG;
1473
1475 SDL_TRANSFER_CHARACTERISTICS_CUSTOM;
1476
1478
1483
1491using MatrixCoefficients = SDL_MatrixCoefficients;
1492
1494 SDL_MATRIX_COEFFICIENTS_IDENTITY;
1495
1497 SDL_MATRIX_COEFFICIENTS_BT709;
1498
1500 SDL_MATRIX_COEFFICIENTS_UNSPECIFIED;
1501
1503 SDL_MATRIX_COEFFICIENTS_FCC;
1504
1510 SDL_MATRIX_COEFFICIENTS_BT470BG;
1511
1513 SDL_MATRIX_COEFFICIENTS_BT601;
1514
1516 SDL_MATRIX_COEFFICIENTS_SMPTE240;
1517
1519 SDL_MATRIX_COEFFICIENTS_YCGCO;
1520
1522 SDL_MATRIX_COEFFICIENTS_BT2020_NCL;
1524
1526 SDL_MATRIX_COEFFICIENTS_BT2020_CL;
1527
1529 SDL_MATRIX_COEFFICIENTS_SMPTE2085;
1530
1532 SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL;
1533
1535 SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL;
1536
1538 SDL_MATRIX_COEFFICIENTS_ICTCP;
1539
1541 SDL_MATRIX_COEFFICIENTS_CUSTOM;
1542
1544
1549
1555using ChromaLocation = SDL_ChromaLocation;
1556
1558 SDL_CHROMA_LOCATION_NONE;
1559
1565constexpr ChromaLocation CHROMA_LOCATION_LEFT = SDL_CHROMA_LOCATION_LEFT;
1566
1572constexpr ChromaLocation CHROMA_LOCATION_CENTER = SDL_CHROMA_LOCATION_CENTER;
1573
1579constexpr ChromaLocation CHROMA_LOCATION_TOPLEFT = SDL_CHROMA_LOCATION_TOPLEFT;
1580
1582
1587
1607{
1608 ColorspaceRaw m_cspace;
1609
1610public:
1616 constexpr Colorspace(ColorspaceRaw cspace = {}) noexcept
1617 : m_cspace(cspace)
1618 {
1619 }
1620
1651 constexpr Colorspace(ColorType type,
1652 ColorRange range,
1653 ColorPrimaries primaries,
1654 TransferCharacteristics transfer,
1655 MatrixCoefficients matrix,
1656 ChromaLocation chroma);
1657
1663 constexpr operator ColorspaceRaw() const noexcept { return m_cspace; }
1664
1674 constexpr ColorType GetType() const;
1675
1685 constexpr ColorRange GetRange() const;
1686
1696 constexpr ChromaLocation GetChroma() const;
1697
1707 constexpr ColorPrimaries GetPrimaries() const;
1708
1718 constexpr TransferCharacteristics GetTransfer() const;
1719
1729 constexpr MatrixCoefficients GetMatrix() const;
1730
1740 constexpr bool IsMatrixBT601() const;
1741
1751 constexpr bool IsMatrixBT709() const;
1752
1762 constexpr bool IsMatrixBT2020_NCL() const;
1763
1773 constexpr bool IsLimitedRange() const;
1774
1784 constexpr bool IsFullRange() const;
1785};
1786
1787constexpr Colorspace COLORSPACE_UNKNOWN = SDL_COLORSPACE_UNKNOWN;
1788
1790constexpr Colorspace COLORSPACE_SRGB = SDL_COLORSPACE_SRGB;
1791
1793constexpr Colorspace COLORSPACE_SRGB_LINEAR = SDL_COLORSPACE_SRGB_LINEAR;
1794
1796constexpr Colorspace COLORSPACE_HDR10 = SDL_COLORSPACE_HDR10;
1797
1799constexpr Colorspace COLORSPACE_JPEG = SDL_COLORSPACE_JPEG;
1800
1802constexpr Colorspace COLORSPACE_BT601_LIMITED = SDL_COLORSPACE_BT601_LIMITED;
1803
1805constexpr Colorspace COLORSPACE_BT601_FULL = SDL_COLORSPACE_BT601_FULL;
1806
1808constexpr Colorspace COLORSPACE_BT709_LIMITED = SDL_COLORSPACE_BT709_LIMITED;
1809
1811constexpr Colorspace COLORSPACE_BT709_FULL = SDL_COLORSPACE_BT709_FULL;
1812
1814constexpr Colorspace COLORSPACE_BT2020_LIMITED = SDL_COLORSPACE_BT2020_LIMITED;
1815
1817constexpr Colorspace COLORSPACE_BT2020_FULL = SDL_COLORSPACE_BT2020_FULL;
1818
1820constexpr Colorspace COLORSPACE_RGB_DEFAULT = SDL_COLORSPACE_RGB_DEFAULT;
1821
1823constexpr Colorspace COLORSPACE_YUV_DEFAULT = SDL_COLORSPACE_YUV_DEFAULT;
1824
1826
1858 ColorRange range,
1859 ColorPrimaries primaries,
1860 TransferCharacteristics transfer,
1861 MatrixCoefficients matrix,
1862 ChromaLocation chroma)
1863{
1864 return Colorspace(type, range, primaries, transfer, matrix, chroma);
1865}
1866
1868 ColorRange range,
1869 ColorPrimaries primaries,
1870 TransferCharacteristics transfer,
1871 MatrixCoefficients matrix,
1872 ChromaLocation chroma)
1873 : m_cspace(ColorspaceRaw(
1874 SDL_DEFINE_COLORSPACE(type, range, primaries, transfer, matrix, chroma)))
1875{
1876}
1877
1889{
1890 return SDL_COLORSPACETYPE(cspace);
1891}
1892
1894{
1895 return SDL::ColorspaceType(m_cspace);
1896}
1897
1909{
1910 return SDL_COLORSPACERANGE(cspace);
1911}
1912
1914{
1915 return SDL::ColorspaceRange(m_cspace);
1916}
1917
1929{
1930 return SDL_COLORSPACECHROMA(cspace);
1931}
1932
1934{
1935 return SDL::ColorspaceChroma(m_cspace);
1936}
1937
1949{
1950 return SDL_COLORSPACEPRIMARIES(cspace);
1951}
1952
1954{
1955 return SDL::ColorspacePrimaries(m_cspace);
1956}
1957
1969{
1970 return SDL_COLORSPACETRANSFER(cspace);
1971}
1972
1974{
1975 return SDL::ColorspaceTransfer(m_cspace);
1976}
1977
1989{
1990 return SDL_COLORSPACEMATRIX(cspace);
1991}
1992
1994{
1995 return SDL::ColorspaceMatrix(m_cspace);
1996}
1997
2013{
2014 return SDL_ISCOLORSPACE_MATRIX_BT601(cspace);
2015}
2016
2017constexpr bool Colorspace::IsMatrixBT601() const
2018{
2019 return SDL::IsColorspaceMatrixBT601(m_cspace);
2020}
2021
2033{
2034 return SDL_ISCOLORSPACE_MATRIX_BT709(cspace);
2035}
2036
2037constexpr bool Colorspace::IsMatrixBT709() const
2038{
2039 return SDL::IsColorspaceMatrixBT709(m_cspace);
2040}
2041
2053{
2054 return SDL_ISCOLORSPACE_MATRIX_BT2020_NCL(cspace);
2055}
2056
2058{
2059 return SDL::IsColorspaceMatrixBT2020_NCL(m_cspace);
2060}
2061
2073{
2074 return SDL_ISCOLORSPACE_LIMITED_RANGE(cspace);
2075}
2076
2077constexpr bool Colorspace::IsLimitedRange() const
2078{
2079 return SDL::IsColorspaceLimitedRange(m_cspace);
2080}
2081
2093{
2094 return SDL_ISCOLORSPACE_FULL_RANGE(cspace);
2095}
2096
2097constexpr bool Colorspace::IsFullRange() const
2098{
2099 return SDL::IsColorspaceFullRange(m_cspace);
2100}
2101
2103constexpr bool operator==(ColorRaw lhs, ColorRaw rhs) noexcept
2104{
2105 return lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b && lhs.a == rhs.a;
2106}
2107
2109constexpr bool operator==(const FColorRaw& lhs, const FColorRaw& rhs) noexcept
2110{
2111 return lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b && lhs.a == rhs.a;
2112}
2113
2115constexpr auto operator<=>(ColorRaw lhs, ColorRaw rhs) noexcept
2116{
2117 if (lhs.r != rhs.r) return lhs.r <=> rhs.r;
2118 if (lhs.g != rhs.g) return lhs.g <=> rhs.g;
2119 if (lhs.b != rhs.b) return lhs.b <=> rhs.b;
2120 return lhs.a <=> rhs.a;
2121}
2122
2124constexpr auto operator<=>(const FColorRaw& lhs, const FColorRaw& rhs) noexcept
2125{
2126 if (lhs.r != rhs.r) return lhs.r <=> rhs.r;
2127 if (lhs.g != rhs.g) return lhs.g <=> rhs.g;
2128 if (lhs.b != rhs.b) return lhs.b <=> rhs.b;
2129 return lhs.a <=> rhs.a;
2130}
2131
2145{
2151 constexpr Color(ColorRaw color = {}) noexcept
2152 : ColorRaw(color)
2153 {
2154 }
2155
2164 constexpr Color(Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255) noexcept
2165 : ColorRaw{r, g, b, a}
2166 {
2167 }
2168
2174 constexpr Uint8 GetR() const noexcept { return r; }
2175
2182 constexpr Color& SetR(Uint8 newR) noexcept
2183 {
2184 r = newR;
2185 return *this;
2186 }
2187
2194 constexpr Uint8 GetG() const noexcept { return g; }
2195
2202 constexpr Color& SetG(Uint8 newG) noexcept
2203 {
2204 g = newG;
2205 return *this;
2206 }
2207
2214 constexpr Uint8 GetB() const noexcept { return b; }
2215
2222 constexpr Color& SetB(Uint8 newB) noexcept
2223 {
2224 b = newB;
2225 return *this;
2226 }
2227
2234 constexpr Uint8 GetA() const noexcept { return a; }
2235
2242 constexpr Color& SetA(Uint8 newA) noexcept
2243 {
2244 a = newA;
2245 return *this;
2246 }
2247
2274 Uint32 Map(const PixelFormatDetails& format, PaletteConstRef palette) const;
2275
2302 static Color Get(Uint32 pixel,
2303 const PixelFormatDetails& format,
2304 PaletteConstRef palette = {});
2305};
2306
2318{
2324 constexpr FColor(const FColorRaw& color = {}) noexcept
2325 : FColorRaw(color)
2326 {
2327 }
2328
2337 constexpr FColor(float r, float g, float b, float a = 1) noexcept
2338 : FColorRaw{r, g, b, a}
2339 {
2340 }
2341
2347 constexpr float GetR() const noexcept { return r; }
2348
2355 constexpr FColor& SetR(float newR) noexcept
2356 {
2357 r = newR;
2358 return *this;
2359 }
2360
2367 constexpr float GetG() const noexcept { return g; }
2368
2375 constexpr FColor& SetG(float newG) noexcept
2376 {
2377 g = newG;
2378 return *this;
2379 }
2380
2387 constexpr float GetB() const noexcept { return b; }
2388
2395 constexpr FColor& SetB(float newB) noexcept
2396 {
2397 b = newB;
2398 return *this;
2399 }
2400
2407 constexpr float GetA() const noexcept { return a; }
2408
2415 constexpr FColor& SetA(float newA) noexcept
2416 {
2417 a = newA;
2418 return *this;
2419 }
2420};
2421
2424{
2425 PaletteRaw m_palette;
2426
2427 int m_index;
2428
2429public:
2431 constexpr PaletteIndex(PaletteRaw palette, int index)
2432 : m_palette{palette}
2433 , m_index{index}
2434 {
2435 }
2436
2438 constexpr explicit operator bool() const
2439 {
2440 return m_palette && m_index >= 0 && m_index < m_palette->ncolors;
2441 }
2442
2444 constexpr operator ColorRaw() const
2445 {
2446 return *this ? m_palette->colors[m_index] : ColorRaw{};
2447 }
2448
2451};
2452
2462struct Palette : ResourceBase<PaletteRaw, PaletteRawConst>
2463{
2465
2473 constexpr explicit Palette(PaletteRaw resource) noexcept
2474 : ResourceBase(resource)
2475 {
2476 }
2477
2479 constexpr Palette(const Palette& other)
2480 : Palette(other.get())
2481 {
2482 if (auto res = get()) ++res->refcount;
2483 }
2484
2486 constexpr Palette(Palette&& other) noexcept
2487 : Palette(other.release())
2488 {
2489 }
2490
2508 Palette(int ncolors);
2509
2517 static Palette Borrow(PaletteRaw resource)
2518 {
2519 if (resource) {
2520 ++resource->refcount;
2521 return Palette(resource);
2522 }
2523 return {};
2524 }
2525
2527 constexpr operator PaletteConstRef() const noexcept { return get(); }
2528
2530 ~Palette() { SDL_DestroyPalette(get()); }
2531
2533 constexpr Palette& operator=(Palette&& other) noexcept
2534 {
2535 swap(*this, other);
2536 return *this;
2537 }
2538
2541 {
2542 if (get() != other.get()) {
2543 Palette tmp(other);
2544 swap(*this, tmp);
2545 }
2546 return *this;
2547 }
2548
2559 void Destroy();
2560
2562 constexpr const ColorRaw* data() const { return get()->colors; }
2563
2565 constexpr int size() const { return get()->ncolors; }
2566
2568 constexpr ColorRaw operator[](int index) const
2569 {
2570 return get()->colors[index];
2571 }
2572
2574 constexpr PaletteIndex operator[](int index)
2575 {
2576 return PaletteIndex{get(), index};
2577 }
2578
2593 void SetColors(SpanRef<const ColorRaw> colors, int firstcolor = 0);
2594};
2595
2607inline const char* GetPixelFormatName(PixelFormatRaw format)
2608{
2609 return SDL_GetPixelFormatName(format);
2610}
2611
2612inline const char* PixelFormat::GetName() const
2613{
2614 return SDL::GetPixelFormatName(m_format);
2615}
2616
2635 int* bpp,
2636 Uint32* Rmask,
2637 Uint32* Gmask,
2638 Uint32* Bmask,
2639 Uint32* Amask)
2640{
2641 CheckError(
2642 SDL_GetMasksForPixelFormat(format, bpp, Rmask, Gmask, Bmask, Amask));
2643}
2644
2645inline void PixelFormat::GetMasks(int* bpp,
2646 Uint32* Rmask,
2647 Uint32* Gmask,
2648 Uint32* Bmask,
2649 Uint32* Amask) const
2650{
2651 SDL::GetMasksForPixelFormat(m_format, bpp, Rmask, Gmask, Bmask, Amask);
2652}
2653
2674 Uint32 Rmask,
2675 Uint32 Gmask,
2676 Uint32 Bmask,
2677 Uint32 Amask)
2678{
2679 return SDL_GetPixelFormatForMasks(bpp, Rmask, Gmask, Bmask, Amask);
2680}
2681
2683 Uint32 Rmask,
2684 Uint32 Gmask,
2685 Uint32 Bmask,
2686 Uint32 Amask)
2687{
2688 return SDL::GetPixelFormatForMasks(bpp, Rmask, Gmask, Bmask, Amask);
2689}
2690
2707{
2708 return *CheckError(SDL_GetPixelFormatDetails(format));
2709}
2710
2712{
2713 return SDL::GetPixelFormatDetails(m_format);
2714}
2715
2716inline PixelFormat::operator const PixelFormatDetails&() const
2717{
2718 return GetDetails();
2719}
2720
2738inline Palette CreatePalette(int ncolors) { return Palette(ncolors); }
2739
2740inline Palette::Palette(int ncolors)
2741 : Palette(CheckError(SDL_CreatePalette(ncolors)))
2742{
2743}
2744
2758inline void SetPaletteColors(PaletteRef palette,
2760 int firstcolor = 0)
2761{
2762 CheckError(SDL_SetPaletteColors(
2763 palette, colors.data(), firstcolor, narrowS32(colors.size())));
2764}
2765
2766inline void Palette::SetColors(SpanRef<const ColorRaw> colors, int firstcolor)
2767{
2768 SDL::SetPaletteColors(get(), colors, firstcolor);
2769}
2770
2772{
2773 m_palette->colors[m_index] = color;
2774 return *this;
2775}
2776
2789inline void DestroyPalette(PaletteRaw palette) { SDL_DestroyPalette(palette); }
2790
2792
2828inline Uint32 MapRGB(const PixelFormatDetails& format,
2829 PaletteConstRef palette,
2830 Uint8 r,
2831 Uint8 g,
2832 Uint8 b)
2833{
2834 return SDL_MapRGB(&format, palette, r, g, b);
2835}
2836
2874inline Uint32 MapRGBA(const PixelFormatDetails& format,
2875 Uint8 r,
2876 Uint8 g,
2877 Uint8 b,
2878 Uint8 a,
2879 PaletteConstRef palette = {})
2880{
2881 return SDL_MapRGBA(&format, palette, r, g, b, a);
2882}
2883
2918 ColorRaw c,
2919 PaletteConstRef palette = {})
2920{
2921 return SDL_MapRGBA(&format, palette, c.r, c.g, c.b, c.a);
2922}
2923
2925 PaletteConstRef palette) const
2926{
2927 return MapColor(format, *this, palette);
2928}
2929
2931{
2932 return MapColor(GetDetails(), c, palette);
2933}
2934
2960inline void GetRGB(Uint32 pixelvalue,
2961 const PixelFormatDetails& format,
2962 PaletteConstRef palette,
2963 Uint8* r,
2964 Uint8* g,
2965 Uint8* b)
2966{
2967 SDL_GetRGB(pixelvalue, &format, palette, r, g, b);
2968}
2969
2999inline void GetRGBA(Uint32 pixelvalue,
3000 const PixelFormatDetails& format,
3001 PaletteConstRef palette,
3002 Uint8* r,
3003 Uint8* g,
3004 Uint8* b,
3005 Uint8* a)
3006{
3007 SDL_GetRGBA(pixelvalue, &format, palette, r, g, b, a);
3008}
3009
3037inline Color GetColor(Uint32 pixel,
3038 const PixelFormatDetails& format,
3039 PaletteConstRef palette = {})
3040{
3041 Color c;
3042 GetRGBA(pixel, format, palette, &c.r, &c.g, &c.b, &c.a);
3043 return c;
3044}
3045
3047 const PixelFormatDetails& format,
3048 PaletteConstRef palette)
3049{
3050 return GetColor(pixel, format, palette);
3051}
3052
3053inline Color PixelFormat::Get(Uint32 pixel, PaletteConstRef palette) const
3054{
3055 return GetColor(pixel, GetDetails(), palette);
3056}
3057
3059
3060} // namespace SDL
3061
3062#endif /* SDL3PP_PIXELS_H_ */
Colorspace definitions.
Definition SDL3pp_pixels.h:1607
constexpr Colorspace(ColorspaceRaw cspace={}) noexcept
Wraps Colorspace.
Definition SDL3pp_pixels.h:1616
Auxiliary class for Palette to provide access to specific palette index.
Definition SDL3pp_pixels.h:2424
constexpr PaletteIndex(PaletteRaw palette, int index)
Constructs a PaletteIndex for a specific palette and index.
Definition SDL3pp_pixels.h:2431
Pixel format.
Definition SDL3pp_pixels.h:358
constexpr PixelFormat(PixelFormatRaw format={}) noexcept
Wraps PixelFormat.
Definition SDL3pp_pixels.h:367
constexpr RawPointer get() const noexcept
Definition SDL3pp_resource.h:53
constexpr RawPointer release() noexcept
Definition SDL3pp_resource.h:56
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
Const reference wrapper for a given resource,.
Definition SDL3pp_resource.h:111
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:769
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_FCC
US FCC Title 47.
Definition SDL3pp_pixels.h:1502
constexpr bool IsMatrixBT709() const
Determine if an Colorspace uses BT709 matrix coefficients.
Definition SDL3pp_pixels.h:2037
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:1327
constexpr PixelFormat PIXELFORMAT_IYUV
Planar mode: Y + U + V (3 planes).
Definition SDL3pp_pixels.h:870
constexpr bool IsPixelFormatArray(PixelFormatRaw format)
A macro to determine if an PixelFormat is an array format.
Definition SDL3pp_pixels.h:1190
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_SMPTE240
SMPTE 240M.
Definition SDL3pp_pixels.h:1515
constexpr ColorPrimaries COLOR_PRIMARIES_UNSPECIFIED
COLOR_PRIMARIES_UNSPECIFIED.
Definition SDL3pp_pixels.h:1361
constexpr ColorPrimaries COLOR_PRIMARIES_BT709
ITU-R BT.709-6.
Definition SDL3pp_pixels.h:1358
constexpr PixelFormat PIXELFORMAT_BGRA64
BGRA64.
Definition SDL3pp_pixels.h:827
constexpr PixelType PIXELTYPE_PACKED8
PACKED8.
Definition SDL3pp_pixels.h:178
void DestroyPalette(PaletteRaw palette)
Free a palette created with CreatePalette().
Definition SDL3pp_pixels.h:2789
constexpr PackedLayout PACKEDLAYOUT_1555
1555
Definition SDL3pp_pixels.h:296
constexpr PixelFormat PIXELFORMAT_RGB96_FLOAT
RGB96_FLOAT.
Definition SDL3pp_pixels.h:849
constexpr ChromaLocation ColorspaceChroma(ColorspaceRaw cspace)
A macro to retrieve the chroma sample location of an Colorspace.
Definition SDL3pp_pixels.h:1928
constexpr PixelFormat PIXELFORMAT_P010
Planar mode: Y + U/V interleaved (2 planes).
Definition SDL3pp_pixels.h:888
constexpr int PixelFormatOrder(PixelFormatRaw format)
A macro to retrieve the order of an PixelFormat.
Definition SDL3pp_pixels.h:1042
const char * GetName() const
Get the human readable name of a pixel format.
Definition SDL3pp_pixels.h:2612
SDL_ChromaLocation ChromaLocation
Colorspace chroma sample location.
Definition SDL3pp_pixels.h:1555
constexpr PixelFormat PIXELFORMAT_XRGB32
XRGB32.
Definition SDL3pp_pixels.h:910
constexpr ColorPrimaries ColorspacePrimaries(ColorspaceRaw cspace)
A macro to retrieve the primaries of an Colorspace.
Definition SDL3pp_pixels.h:1948
constexpr ColorType GetType() const
Retrieve the type of a Colorspace.
Definition SDL3pp_pixels.h:1893
constexpr PixelType PIXELTYPE_ARRAYF32
ARRAYF32.
Definition SDL3pp_pixels.h:192
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:1002
constexpr bool IsPixelFormat10Bit(PixelFormatRaw format)
A macro to determine if an PixelFormat is a 10-bit format.
Definition SDL3pp_pixels.h:1213
constexpr PixelFormat PIXELFORMAT_MJPG
Motion JPEG.
Definition SDL3pp_pixels.h:896
static Color Get(Uint32 pixel, const PixelFormatDetails &format, PaletteConstRef palette={})
Get RGBA values from a pixel in the specified format.
Definition SDL3pp_pixels.h:3046
constexpr ColorRange COLOR_RANGE_LIMITED
Narrow range, e.g.
Definition SDL3pp_pixels.h:1335
constexpr ColorType ColorspaceType(ColorspaceRaw cspace)
A macro to retrieve the type of an Colorspace.
Definition SDL3pp_pixels.h:1888
constexpr bool IsColorspaceLimitedRange(ColorspaceRaw cspace)
A macro to determine if an Colorspace has a limited range.
Definition SDL3pp_pixels.h:2072
constexpr PixelFormat PIXELFORMAT_XRGB1555
XRGB1555.
Definition SDL3pp_pixels.h:745
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_SMPTE240
SMPTE ST 240M.
Definition SDL3pp_pixels.h:1436
constexpr PackedLayout PACKEDLAYOUT_1010102
1010102
Definition SDL3pp_pixels.h:307
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT2020_12BIT
ITU-R BT2020 for 12-bit system.
Definition SDL3pp_pixels.h:1460
constexpr ArrayOrder ARRAYORDER_RGB
RGB.
Definition SDL3pp_pixels.h:264
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:891
SDL_Palette * PaletteRaw
Alias to raw representation for Palette.
Definition SDL3pp_pixels.h:98
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_UNSPECIFIED
MATRIX_COEFFICIENTS_UNSPECIFIED.
Definition SDL3pp_pixels.h:1499
ResourceConstRef< PaletteRaw, PaletteRawConst > PaletteConstRef
Safely wrap Palette for non owning const parameters.
Definition SDL3pp_pixels.h:111
constexpr Uint8 PixelFormatFlags(PixelFormatRaw format)
Retrieve the flags of an PixelFormat.
Definition SDL3pp_pixels.h:997
constexpr PixelFormat PIXELFORMAT_INDEX1MSB
INDEX1MSB.
Definition SDL3pp_pixels.h:720
constexpr PixelType PIXELTYPE_PACKED32
PACKED32.
Definition SDL3pp_pixels.h:182
constexpr PixelType PIXELTYPE_ARRAYF16
ARRAYF16.
Definition SDL3pp_pixels.h:190
constexpr PixelFormat PIXELFORMAT_ABGR8888
ABGR8888.
Definition SDL3pp_pixels.h:801
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_SMPTE2085
SMPTE ST 2085.
Definition SDL3pp_pixels.h:1528
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_ICTCP
ITU-R BT.2100-0 ICTCP.
Definition SDL3pp_pixels.h:1537
void Destroy()
Free a palette created with CreatePalette().
Definition SDL3pp_pixels.h:2791
constexpr PixelFormat PIXELFORMAT_NV21
Planar mode: Y + V/U interleaved (2 planes).
Definition SDL3pp_pixels.h:885
constexpr bool IsPixelFormatPacked(PixelFormatRaw format)
A macro to determine if an PixelFormat is a packed format.
Definition SDL3pp_pixels.h:1167
const SDL_Palette * PaletteRawConst
Alias to const raw representation for Palette.
Definition SDL3pp_pixels.h:101
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_LOG100
TRANSFER_CHARACTERISTICS_LOG100.
Definition SDL3pp_pixels.h:1442
constexpr ColorType COLOR_TYPE_YCBCR
COLOR_TYPE_YCBCR.
Definition SDL3pp_pixels.h:1311
constexpr PixelFormat PIXELFORMAT_ARGB2101010
ARGB2101010.
Definition SDL3pp_pixels.h:813
constexpr bool IsPixelFormatAlpha(PixelFormatRaw format)
A macro to determine if an PixelFormat has an alpha channel.
Definition SDL3pp_pixels.h:1264
constexpr PixelFormat PIXELFORMAT_INDEX4MSB
INDEX4MSB.
Definition SDL3pp_pixels.h:732
constexpr int PixelFormatBytesPerPixel(PixelFormatRaw format)
A macro to determine an PixelFormat's bytes per pixel.
Definition SDL3pp_pixels.h:1121
constexpr PixelFormat PIXELFORMAT_UNKNOWN
UNKNOWN.
Definition SDL3pp_pixels.h:714
constexpr ColorPrimaries COLOR_PRIMARIES_UNKNOWN
COLOR_PRIMARIES_UNKNOWN.
Definition SDL3pp_pixels.h:1355
constexpr PixelFormat PIXELFORMAT_ABGR4444
ABGR4444.
Definition SDL3pp_pixels.h:757
constexpr PixelFormat PIXELFORMAT_BGRA64_FLOAT
BGRA64_FLOAT.
Definition SDL3pp_pixels.h:843
constexpr BitmapOrder BITMAPORDER_1234
1234
Definition SDL3pp_pixels.h:214
constexpr PixelFormat PIXELFORMAT_ABGR32
ABGR32.
Definition SDL3pp_pixels.h:906
constexpr PixelFormat PIXELFORMAT_BGRA128_FLOAT
BGRA128_FLOAT.
Definition SDL3pp_pixels.h:861
constexpr PixelFormat PIXELFORMAT_XBGR2101010
XBGR2101010.
Definition SDL3pp_pixels.h:810
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT601
SMPTE ST 170M / ITU-R BT.601-7 525 or 625.
Definition SDL3pp_pixels.h:1432
SDL_PackedOrder PackedOrder
Packed component order, high bit -> low bit.
Definition SDL3pp_pixels.h:228
constexpr ColorRange ColorspaceRange(ColorspaceRaw cspace)
A macro to retrieve the range of an Colorspace.
Definition SDL3pp_pixels.h:1908
constexpr bool IsColorspaceFullRange(ColorspaceRaw cspace)
A macro to determine if an Colorspace has a full range.
Definition SDL3pp_pixels.h:2092
constexpr PackedLayout PACKEDLAYOUT_565
565
Definition SDL3pp_pixels.h:300
const char * GetPixelFormatName(PixelFormatRaw format)
Get the human readable name of a pixel format.
Definition SDL3pp_pixels.h:2607
constexpr PackedOrder PACKEDORDER_BGRA
BGRA.
Definition SDL3pp_pixels.h:246
void SetPaletteColors(PaletteRef palette, SpanRef< const ColorRaw > colors, int firstcolor=0)
Set a range of colors in a palette.
Definition SDL3pp_pixels.h:2758
constexpr PixelFormat PIXELFORMAT_XRGB8888
XRGB8888.
Definition SDL3pp_pixels.h:783
constexpr PixelFormat PIXELFORMAT_BGR96_FLOAT
BGR96_FLOAT.
Definition SDL3pp_pixels.h:852
constexpr bool Is10Bit() const
Determine if this is a 10-bit format.
Definition SDL3pp_pixels.h:1218
constexpr bool IsIndexed() const
Determine if this is an indexed format.
Definition SDL3pp_pixels.h:1149
constexpr PixelFormat PIXELFORMAT_INDEX8
INDEX8.
Definition SDL3pp_pixels.h:735
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL
MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL.
Definition SDL3pp_pixels.h:1534
constexpr MatrixCoefficients ColorspaceMatrix(ColorspaceRaw cspace)
A macro to retrieve the matrix coefficients of an Colorspace.
Definition SDL3pp_pixels.h:1988
constexpr PixelFormat PIXELFORMAT_INDEX1LSB
INDEX1LSB.
Definition SDL3pp_pixels.h:717
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_SMPTE428
SMPTE ST 428-1.
Definition SDL3pp_pixels.h:1467
constexpr TransferCharacteristics GetTransfer() const
Retrieve the transfer characteristics of an Colorspace.
Definition SDL3pp_pixels.h:1973
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:1579
constexpr ChromaLocation GetChroma() const
Retrieve the chroma sample location of an Colorspace.
Definition SDL3pp_pixels.h:1933
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_GAMMA22
ITU-R BT.470-6 System M / ITU-R BT1700 625 PAL & SECAM.
Definition SDL3pp_pixels.h:1426
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT2020_NCL
ITU-R BT.2020-2 non-constant luminance.
Definition SDL3pp_pixels.h:1521
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:2874
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:1509
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_SRGB
IEC 61966-2-1 (sRGB or sYCC).
Definition SDL3pp_pixels.h:1454
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:1857
Color GetColor(Uint32 pixel, const PixelFormatDetails &format, PaletteConstRef palette={})
Get RGBA values from a pixel in the specified format.
Definition SDL3pp_pixels.h:3037
constexpr PixelFormat PIXELFORMAT_BGRA8888
BGRA8888.
Definition SDL3pp_pixels.h:804
constexpr PixelFormat PIXELFORMAT_RGBX8888
RGBX8888.
Definition SDL3pp_pixels.h:786
constexpr PixelFormat PIXELFORMAT_YVYU
Packed mode: Y0+V0+Y1+U0 (1 plane).
Definition SDL3pp_pixels.h:879
constexpr Uint8 ALPHA_TRANSPARENT
A fully transparent 8-bit alpha value.
Definition SDL3pp_pixels.h:145
constexpr ColorPrimaries COLOR_PRIMARIES_BT470BG
ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625.
Definition SDL3pp_pixels.h:1367
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:2924
constexpr ArrayOrder ARRAYORDER_NONE
NONE.
Definition SDL3pp_pixels.h:262
constexpr PackedOrder PACKEDORDER_ARGB
ARGB.
Definition SDL3pp_pixels.h:236
constexpr Uint8 ALPHA_OPAQUE
A fully opaque 8-bit alpha value.
Definition SDL3pp_pixels.h:127
constexpr PackedLayout PixelFormatLayout(PixelFormatRaw format)
A macro to retrieve the layout of an PixelFormat.
Definition SDL3pp_pixels.h:1065
constexpr PixelFormat PIXELFORMAT_RGB24
RGB24.
Definition SDL3pp_pixels.h:779
constexpr ColorPrimaries GetPrimaries() const
Retrieve the primaries of an Colorspace.
Definition SDL3pp_pixels.h:1953
constexpr bool operator==(ColorRaw lhs, ColorRaw rhs) noexcept
Comparison operator for Color.
Definition SDL3pp_pixels.h:2103
constexpr Colorspace COLORSPACE_UNKNOWN
UNKNOWN.
Definition SDL3pp_pixels.h:1787
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:1565
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT2020_CL
ITU-R BT.2020-2 constant luminance.
Definition SDL3pp_pixels.h:1525
constexpr Colorspace COLORSPACE_BT601_FULL
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601.
Definition SDL3pp_pixels.h:1805
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:2682
constexpr PixelFormat PIXELFORMAT_ARGB8888
ARGB8888.
Definition SDL3pp_pixels.h:795
constexpr Colorspace COLORSPACE_SRGB_LINEAR
Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709.
Definition SDL3pp_pixels.h:1793
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_HLG
ARIB STD-B67, known as "hybrid log-gamma" (HLG).
Definition SDL3pp_pixels.h:1470
constexpr PackedLayout PACKEDLAYOUT_NONE
NONE.
Definition SDL3pp_pixels.h:290
constexpr PixelFormat PIXELFORMAT_ARGB128_FLOAT
ARGB128_FLOAT.
Definition SDL3pp_pixels.h:858
constexpr PixelType PIXELTYPE_ARRAYU16
ARRAYU16.
Definition SDL3pp_pixels.h:186
constexpr ColorType COLOR_TYPE_UNKNOWN
COLOR_TYPE_UNKNOWN.
Definition SDL3pp_pixels.h:1306
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT709
ITU-R BT.709-6.
Definition SDL3pp_pixels.h:1496
constexpr PixelFormat PIXELFORMAT_RGBX32
RGBX32.
Definition SDL3pp_pixels.h:908
SDL_FColor FColorRaw
Alias to raw representation for FColor.
Definition SDL3pp_pixels.h:89
constexpr PackedOrder PACKEDORDER_RGBX
RGBX.
Definition SDL3pp_pixels.h:234
constexpr Colorspace COLORSPACE_SRGB
Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709.
Definition SDL3pp_pixels.h:1790
constexpr bool IsMatrixBT2020_NCL() const
Determine if an Colorspace uses BT2020_NCL matrix coefficients.
Definition SDL3pp_pixels.h:2057
SDL_TransferCharacteristics TransferCharacteristics
Colorspace transfer characteristics.
Definition SDL3pp_pixels.h:1414
constexpr PackedLayout PACKEDLAYOUT_4444
4444
Definition SDL3pp_pixels.h:294
constexpr PixelFormat PIXELFORMAT_RGBA5551
RGBA5551.
Definition SDL3pp_pixels.h:766
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:2999
constexpr float ALPHA_TRANSPARENT_FLOAT
A fully transparent floating point alpha value.
Definition SDL3pp_pixels.h:154
SDL_PackedLayout PackedLayout
Packed component layout.
Definition SDL3pp_pixels.h:288
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:965
constexpr PixelFormat PIXELFORMAT_XBGR8888
XBGR8888.
Definition SDL3pp_pixels.h:789
constexpr PixelFormat PIXELFORMAT_BGR48
BGR48.
Definition SDL3pp_pixels.h:821
constexpr PixelType PIXELTYPE_UNKNOWN
UNKNOWN.
Definition SDL3pp_pixels.h:170
constexpr bool IsFloat() const
Determine if this is a floating point format.
Definition SDL3pp_pixels.h:1241
constexpr Colorspace COLORSPACE_BT601_LIMITED
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601.
Definition SDL3pp_pixels.h:1802
constexpr PixelFormat PIXELFORMAT_ARGB1555
ARGB1555.
Definition SDL3pp_pixels.h:763
void SetColors(SpanRef< const ColorRaw > colors, int firstcolor=0)
Set a range of colors in a palette.
Definition SDL3pp_pixels.h:2766
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_BT601
ITU-R BT.601-7 525.
Definition SDL3pp_pixels.h:1512
constexpr ColorPrimaries COLOR_PRIMARIES_EBU3213
EBU Tech. 3213-E.
Definition SDL3pp_pixels.h:1394
constexpr PackedOrder PACKEDORDER_ABGR
ABGR.
Definition SDL3pp_pixels.h:244
constexpr bool IsMatrixBT601() const
Determine if a Colorspace uses BT601 (or BT470BG) matrix coefficients.
Definition SDL3pp_pixels.h:2017
constexpr ColorPrimaries COLOR_PRIMARIES_SMPTE240
SMPTE 240M, functionally the same as COLOR_PRIMARIES_BT601.
Definition SDL3pp_pixels.h:1375
constexpr Colorspace COLORSPACE_BT709_LIMITED
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709.
Definition SDL3pp_pixels.h:1808
constexpr BitmapOrder BITMAPORDER_NONE
NONE.
Definition SDL3pp_pixels.h:210
SDL_BitmapOrder BitmapOrder
Bitmap pixel order, high bit -> low bit.
Definition SDL3pp_pixels.h:208
constexpr PixelFormat PIXELFORMAT_ARGB64_FLOAT
ARGB64_FLOAT.
Definition SDL3pp_pixels.h:840
constexpr PixelFormat PIXELFORMAT_XRGB2101010
XRGB2101010.
Definition SDL3pp_pixels.h:807
constexpr BitmapOrder BITMAPORDER_4321
4321
Definition SDL3pp_pixels.h:212
constexpr bool IsPacked() const
Determine if this is a packed format.
Definition SDL3pp_pixels.h:1172
constexpr ColorPrimaries COLOR_PRIMARIES_CUSTOM
COLOR_PRIMARIES_CUSTOM.
Definition SDL3pp_pixels.h:1397
constexpr ColorPrimaries COLOR_PRIMARIES_BT2020
ITU-R BT.2020-2 / ITU-R BT.2100-0.
Definition SDL3pp_pixels.h:1382
SDL_ColorType ColorType
Colorspace color type.
Definition SDL3pp_pixels.h:1304
constexpr ColorType COLOR_TYPE_RGB
COLOR_TYPE_RGB.
Definition SDL3pp_pixels.h:1309
constexpr PixelType PIXELTYPE_INDEX4
INDEX4.
Definition SDL3pp_pixels.h:174
constexpr Colorspace COLORSPACE_BT709_FULL
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709.
Definition SDL3pp_pixels.h:1811
constexpr PixelFormat PIXELFORMAT_XBGR4444
XBGR4444.
Definition SDL3pp_pixels.h:742
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT1361
ITU-R BT1361 Extended Colour Gamut.
Definition SDL3pp_pixels.h:1451
constexpr PixelType PIXELTYPE_PACKED16
PACKED16.
Definition SDL3pp_pixels.h:180
Color Get(Uint32 pixel, PaletteConstRef palette={}) const
Get RGBA values from a pixel in the specified format.
Definition SDL3pp_pixels.h:3053
const PixelFormatDetails & GetPixelFormatDetails(PixelFormatRaw format)
Create an PixelFormatDetails structure corresponding to a pixel format.
Definition SDL3pp_pixels.h:2706
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_YCGCO
MATRIX_COEFFICIENTS_YCGCO.
Definition SDL3pp_pixels.h:1518
constexpr PackedLayout PACKEDLAYOUT_332
332
Definition SDL3pp_pixels.h:292
constexpr PixelFormat PIXELFORMAT_RGBA8888
RGBA8888.
Definition SDL3pp_pixels.h:798
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_PQ
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition SDL3pp_pixels.h:1463
constexpr bool IsColorspaceMatrixBT601(ColorspaceRaw cspace)
A macro to determine if an Colorspace uses BT601 (or BT470BG) matrix coefficients.
Definition SDL3pp_pixels.h:2012
constexpr PackedLayout GetLayout() const
Retrieve the layout.
Definition SDL3pp_pixels.h:1070
SDL_PixelFormatDetails PixelFormatDetails
Details about the format of a pixel.
Definition SDL3pp_pixels.h:118
constexpr PixelFormat PIXELFORMAT_RGBA4444
RGBA4444.
Definition SDL3pp_pixels.h:754
ResourceRef< Palette > PaletteRef
Reference for Palette.
Definition SDL3pp_pixels.h:108
constexpr auto operator<=>(ColorRaw lhs, ColorRaw rhs) noexcept
Spaceship operator for Color.
Definition SDL3pp_pixels.h:2115
constexpr PixelType PIXELTYPE_ARRAYU8
ARRAYU8.
Definition SDL3pp_pixels.h:184
constexpr PixelFormat PIXELFORMAT_ARGB32
ARGB32.
Definition SDL3pp_pixels.h:902
constexpr PixelFormat PIXELFORMAT_INDEX4LSB
INDEX4LSB.
Definition SDL3pp_pixels.h:729
constexpr bool IsPixelFormatFloat(PixelFormatRaw format)
A macro to determine if an PixelFormat is a floating point format.
Definition SDL3pp_pixels.h:1236
constexpr ArrayOrder ARRAYORDER_ABGR
ABGR.
Definition SDL3pp_pixels.h:274
constexpr bool IsFourCC() const
Determine if this is a "FourCC" format.
Definition SDL3pp_pixels.h:1294
constexpr PixelFormat PIXELFORMAT_ABGR64_FLOAT
ABGR64_FLOAT.
Definition SDL3pp_pixels.h:846
constexpr bool IsPixelFormatFourCC(PixelFormatRaw format)
A macro to determine if an PixelFormat is a "FourCC" format.
Definition SDL3pp_pixels.h:1289
constexpr ColorPrimaries COLOR_PRIMARIES_BT470M
ITU-R BT.470-6 System M.
Definition SDL3pp_pixels.h:1364
constexpr ColorPrimaries COLOR_PRIMARIES_SMPTE431
SMPTE RP 431-2.
Definition SDL3pp_pixels.h:1388
constexpr PixelFormat PIXELFORMAT_ABGR128_FLOAT
ABGR128_FLOAT.
Definition SDL3pp_pixels.h:864
constexpr ColorPrimaries COLOR_PRIMARIES_XYZ
SMPTE ST 428-1.
Definition SDL3pp_pixels.h:1385
constexpr PixelFormat PIXELFORMAT_ABGR2101010
ABGR2101010.
Definition SDL3pp_pixels.h:816
constexpr PixelFormat PIXELFORMAT_BGRX8888
BGRX8888.
Definition SDL3pp_pixels.h:792
SDL_PixelType PixelType
Pixel type.
Definition SDL3pp_pixels.h:168
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL
MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL.
Definition SDL3pp_pixels.h:1531
constexpr float ALPHA_OPAQUE_FLOAT
A fully opaque floating point alpha value.
Definition SDL3pp_pixels.h:136
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_CUSTOM
MATRIX_COEFFICIENTS_CUSTOM.
Definition SDL3pp_pixels.h:1540
constexpr PixelFormat PIXELFORMAT_YV12
Planar mode: Y + V + U (3 planes).
Definition SDL3pp_pixels.h:867
constexpr PixelFormat PIXELFORMAT_BGRX32
BGRX32.
Definition SDL3pp_pixels.h:912
constexpr PixelFormat PIXELFORMAT_BGRA4444
BGRA4444.
Definition SDL3pp_pixels.h:760
constexpr PixelFormat PIXELFORMAT_INDEX2MSB
INDEX2MSB.
Definition SDL3pp_pixels.h:726
constexpr PixelFormat PIXELFORMAT_BGR565
BGR565.
Definition SDL3pp_pixels.h:777
constexpr PixelFormat PIXELFORMAT_RGB48_FLOAT
RGB48_FLOAT.
Definition SDL3pp_pixels.h:831
constexpr PixelFormat PIXELFORMAT_RGB565
RGB565.
Definition SDL3pp_pixels.h:775
constexpr PixelFormat PIXELFORMAT_RGBA32
RGBA32.
Definition SDL3pp_pixels.h:900
constexpr PixelFormat PIXELFORMAT_BGR24
BGR24.
Definition SDL3pp_pixels.h:781
constexpr PackedLayout PACKEDLAYOUT_2101010
2101010
Definition SDL3pp_pixels.h:304
constexpr bool IsColorspaceMatrixBT709(ColorspaceRaw cspace)
A macro to determine if an Colorspace uses BT709 matrix coefficients.
Definition SDL3pp_pixels.h:2032
constexpr int GetOrder() const
Retrieve the order.
Definition SDL3pp_pixels.h:1047
constexpr PixelFormat PIXELFORMAT_NV12
Planar mode: Y + U/V interleaved (2 planes).
Definition SDL3pp_pixels.h:882
constexpr ColorPrimaries COLOR_PRIMARIES_SMPTE432
SMPTE EG 432-1 / DCI P3.
Definition SDL3pp_pixels.h:1391
constexpr Colorspace COLORSPACE_JPEG
Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601.
Definition SDL3pp_pixels.h:1799
constexpr PixelFormat PIXELFORMAT_INDEX2LSB
INDEX2LSB.
Definition SDL3pp_pixels.h:723
constexpr PackedLayout PACKEDLAYOUT_5551
5551
Definition SDL3pp_pixels.h:298
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:1338
constexpr bool IsArray() const
Determine if this is an array format.
Definition SDL3pp_pixels.h:1195
constexpr PixelFormat PIXELFORMAT_ABGR64
ABGR64.
Definition SDL3pp_pixels.h:829
constexpr PackedOrder PACKEDORDER_RGBA
RGBA.
Definition SDL3pp_pixels.h:238
SDL_ArrayOrder ArrayOrder
Array component order, low byte -> high byte.
Definition SDL3pp_pixels.h:260
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:2828
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:2960
Uint32 Map(ColorRaw c, PaletteConstRef palette={}) const
Map an RGBA quadruple to a pixel value for a given pixel format.
Definition SDL3pp_pixels.h:2930
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:2634
constexpr Uint32 DefinePixelFourCC(Uint8 A, Uint8 B, Uint8 C, Uint8 D)
A function for defining custom FourCC pixel formats.
Definition SDL3pp_pixels.h:937
constexpr PixelFormat PIXELFORMAT_RGBA128_FLOAT
RGBA128_FLOAT.
Definition SDL3pp_pixels.h:855
constexpr Colorspace COLORSPACE_BT2020_LIMITED
Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020.
Definition SDL3pp_pixels.h:1814
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:2673
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_UNSPECIFIED
TRANSFER_CHARACTERISTICS_UNSPECIFIED.
Definition SDL3pp_pixels.h:1422
constexpr int PixelFormatBitsPerPixel(PixelFormatRaw format)
A macro to determine an PixelFormat's bits per pixel.
Definition SDL3pp_pixels.h:1093
constexpr int GetBytesPerPixel() const
Determine this's bytes per pixel.
Definition SDL3pp_pixels.h:1126
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:1353
constexpr PixelFormat PIXELFORMAT_RGB332
RGB332.
Definition SDL3pp_pixels.h:737
constexpr PixelFormat PIXELFORMAT_BGRA5551
BGRA5551.
Definition SDL3pp_pixels.h:772
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_CUSTOM
TRANSFER_CHARACTERISTICS_CUSTOM.
Definition SDL3pp_pixels.h:1474
constexpr ArrayOrder ARRAYORDER_BGRA
BGRA.
Definition SDL3pp_pixels.h:272
constexpr ColorPrimaries COLOR_PRIMARIES_GENERIC_FILM
Generic film (color filters using Illuminant C).
Definition SDL3pp_pixels.h:1378
constexpr PixelType PIXELTYPE_INDEX2
INDEX2.
Definition SDL3pp_pixels.h:194
constexpr ColorRange COLOR_RANGE_UNKNOWN
COLOR_RANGE_UNKNOWN.
Definition SDL3pp_pixels.h:1329
constexpr ColorPrimaries COLOR_PRIMARIES_BT601
ITU-R BT.601-7 525, SMPTE 170M.
Definition SDL3pp_pixels.h:1371
constexpr bool IsAlpha() const
Determine if this has an alpha channel.
Definition SDL3pp_pixels.h:1269
constexpr MatrixCoefficients GetMatrix() const
Retrieve the matrix coefficients of an Colorspace.
Definition SDL3pp_pixels.h:1993
constexpr PixelFormat PIXELFORMAT_YUY2
Packed mode: Y0+U0+Y1+V0 (1 plane).
Definition SDL3pp_pixels.h:873
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_LINEAR
TRANSFER_CHARACTERISTICS_LINEAR.
Definition SDL3pp_pixels.h:1439
constexpr PixelType PIXELTYPE_ARRAYU32
ARRAYU32.
Definition SDL3pp_pixels.h:188
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_UNKNOWN
TRANSFER_CHARACTERISTICS_UNKNOWN.
Definition SDL3pp_pixels.h:1416
SDL_MatrixCoefficients MatrixCoefficients
Colorspace matrix coefficients.
Definition SDL3pp_pixels.h:1491
constexpr PixelType GetType() const
Retrieve the type.
Definition SDL3pp_pixels.h:1024
constexpr ArrayOrder ARRAYORDER_RGBA
RGBA.
Definition SDL3pp_pixels.h:266
constexpr PixelFormat PIXELFORMAT_RGBA64_FLOAT
RGBA64_FLOAT.
Definition SDL3pp_pixels.h:837
constexpr bool IsColorspaceMatrixBT2020_NCL(ColorspaceRaw cspace)
Determine if an Colorspace uses BT2020_NCL matrix coefficients.
Definition SDL3pp_pixels.h:2052
PaletteIndex & operator=(ColorRaw color)
Assignment operator.
Definition SDL3pp_pixels.h:2771
constexpr PixelFormat PIXELFORMAT_XRGB4444
XRGB4444.
Definition SDL3pp_pixels.h:739
constexpr Colorspace COLORSPACE_BT2020_FULL
Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020.
Definition SDL3pp_pixels.h:1817
constexpr TransferCharacteristics ColorspaceTransfer(ColorspaceRaw cspace)
A macro to retrieve the transfer characteristics of an Colorspace.
Definition SDL3pp_pixels.h:1968
constexpr ChromaLocation CHROMA_LOCATION_NONE
RGB, no chroma sampling.
Definition SDL3pp_pixels.h:1557
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_BT2020_10BIT
ITU-R BT2020 for 10-bit system.
Definition SDL3pp_pixels.h:1457
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:1572
constexpr PixelFormat PIXELFORMAT_RGBA64
RGBA64.
Definition SDL3pp_pixels.h:823
constexpr PixelFormat PIXELFORMAT_UYVY
Packed mode: U0+Y0+V0+Y1 (1 plane).
Definition SDL3pp_pixels.h:876
constexpr Colorspace COLORSPACE_RGB_DEFAULT
The default colorspace for RGB surfaces if no colorspace is specified.
Definition SDL3pp_pixels.h:1820
constexpr PackedOrder PACKEDORDER_NONE
NONE.
Definition SDL3pp_pixels.h:230
constexpr PixelType PixelFormatType(PixelFormatRaw format)
A macro to retrieve the type of an PixelFormat.
Definition SDL3pp_pixels.h:1019
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_GAMMA28
ITU-R BT.470-6 System B, G.
Definition SDL3pp_pixels.h:1429
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:2917
constexpr PixelFormat PIXELFORMAT_ARGB4444
ARGB4444.
Definition SDL3pp_pixels.h:751
SDL_Colorspace ColorspaceRaw
Alias to raw representation for Colorspace.
Definition SDL3pp_pixels.h:77
constexpr ArrayOrder ARRAYORDER_BGR
BGR.
Definition SDL3pp_pixels.h:270
constexpr PixelFormat PIXELFORMAT_BGRA32
BGRA32.
Definition SDL3pp_pixels.h:904
constexpr bool IsFullRange() const
A function to determine if an Colorspace has a full range.
Definition SDL3pp_pixels.h:2097
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:1419
constexpr PixelType PIXELTYPE_INDEX1
INDEX1.
Definition SDL3pp_pixels.h:172
constexpr PixelFormat PIXELFORMAT_XBGR32
XBGR32.
Definition SDL3pp_pixels.h:914
constexpr bool IsPixelFormatIndexed(PixelFormatRaw format)
A macro to determine if an PixelFormat is an indexed format.
Definition SDL3pp_pixels.h:1144
constexpr ArrayOrder ARRAYORDER_ARGB
ARGB.
Definition SDL3pp_pixels.h:268
constexpr PixelFormat PIXELFORMAT_ARGB64
ARGB64.
Definition SDL3pp_pixels.h:825
constexpr Colorspace COLORSPACE_HDR10
Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020.
Definition SDL3pp_pixels.h:1796
constexpr PackedOrder PACKEDORDER_XRGB
XRGB.
Definition SDL3pp_pixels.h:232
constexpr PackedLayout PACKEDLAYOUT_8888
8888
Definition SDL3pp_pixels.h:302
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:2645
const PixelFormatDetails & GetDetails() const
Create an PixelFormatDetails structure corresponding to a pixel format.
Definition SDL3pp_pixels.h:2711
constexpr PixelFormat PIXELFORMAT_RGB48
RGB48.
Definition SDL3pp_pixels.h:819
constexpr bool IsLimitedRange() const
A function to determine if an Colorspace has a limited range.
Definition SDL3pp_pixels.h:2077
constexpr PixelFormat PIXELFORMAT_XBGR1555
XBGR1555.
Definition SDL3pp_pixels.h:748
constexpr ColorRange GetRange() const
Retrieve the range of a Colorspace.
Definition SDL3pp_pixels.h:1913
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_LOG100_SQRT10
TRANSFER_CHARACTERISTICS_LOG100_SQRT10.
Definition SDL3pp_pixels.h:1445
Palette CreatePalette(int ncolors)
Create a palette structure with the specified number of color entries.
Definition SDL3pp_pixels.h:2738
constexpr TransferCharacteristics TRANSFER_CHARACTERISTICS_IEC61966
IEC 61966-2-4.
Definition SDL3pp_pixels.h:1448
constexpr PackedOrder PACKEDORDER_BGRX
BGRX.
Definition SDL3pp_pixels.h:242
constexpr Colorspace COLORSPACE_YUV_DEFAULT
The default colorspace for YUV surfaces if no colorspace is specified.
Definition SDL3pp_pixels.h:1823
constexpr PackedOrder PACKEDORDER_XBGR
XBGR.
Definition SDL3pp_pixels.h:240
constexpr MatrixCoefficients MATRIX_COEFFICIENTS_IDENTITY
MATRIX_COEFFICIENTS_IDENTITY.
Definition SDL3pp_pixels.h:1493
constexpr PixelFormat PIXELFORMAT_BGR48_FLOAT
BGR48_FLOAT.
Definition SDL3pp_pixels.h:834
constexpr PixelType PIXELTYPE_INDEX8
INDEX8.
Definition SDL3pp_pixels.h:176
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition SDL3pp_stdinc.h:290
::Uint8 Uint8
An unsigned 8-bit integer type.
Definition SDL3pp_stdinc.h:238
Main include header for the SDL3pp library.
Sint32 narrowS32(T value)
Narrows to Sint32.
Definition SDL3pp_stdinc.h:6257
A structure that represents a color as RGBA components.
Definition SDL3pp_pixels.h:2145
constexpr Uint8 GetG() const noexcept
Get the green component from the color.
Definition SDL3pp_pixels.h:2194
constexpr Uint8 GetA() const noexcept
Get the alpha component from the color.
Definition SDL3pp_pixels.h:2234
constexpr Color & SetB(Uint8 newB) noexcept
Set the blue component from the color.
Definition SDL3pp_pixels.h:2222
constexpr Uint8 GetB() const noexcept
Get the blue component from the color.
Definition SDL3pp_pixels.h:2214
constexpr Color & SetR(Uint8 newR) noexcept
Set the red component from the color.
Definition SDL3pp_pixels.h:2182
constexpr Color(Uint8 r, Uint8 g, Uint8 b, Uint8 a=255) noexcept
Constructs from its fields.
Definition SDL3pp_pixels.h:2164
constexpr Uint8 GetR() const noexcept
Get the red component from the color.
Definition SDL3pp_pixels.h:2174
constexpr Color & SetA(Uint8 newA) noexcept
Set the alpha component from the color.
Definition SDL3pp_pixels.h:2242
constexpr Color & SetG(Uint8 newG) noexcept
Set the green component from the color.
Definition SDL3pp_pixels.h:2202
constexpr Color(ColorRaw color={}) noexcept
Wraps Color.
Definition SDL3pp_pixels.h:2151
The bits of this structure can be directly reinterpreted as a float-packed color which uses the PIXEL...
Definition SDL3pp_pixels.h:2318
constexpr FColor & SetB(float newB) noexcept
Set the blue component from the color.
Definition SDL3pp_pixels.h:2395
constexpr float GetG() const noexcept
Get the green component from the color.
Definition SDL3pp_pixels.h:2367
constexpr FColor(float r, float g, float b, float a=1) noexcept
Constructs from its fields.
Definition SDL3pp_pixels.h:2337
constexpr FColor(const FColorRaw &color={}) noexcept
Wraps FColor.
Definition SDL3pp_pixels.h:2324
constexpr FColor & SetR(float newR) noexcept
Set the red component from the color.
Definition SDL3pp_pixels.h:2355
constexpr float GetB() const noexcept
Get the blue component from the color.
Definition SDL3pp_pixels.h:2387
constexpr FColor & SetG(float newG) noexcept
Set the green component from the color.
Definition SDL3pp_pixels.h:2375
constexpr FColor & SetA(float newA) noexcept
Set the alpha component from the color.
Definition SDL3pp_pixels.h:2415
constexpr float GetR() const noexcept
Get the red component from the color.
Definition SDL3pp_pixels.h:2347
constexpr float GetA() const noexcept
Get the alpha component from the color.
Definition SDL3pp_pixels.h:2407
A set of indexed colors representing a palette.
Definition SDL3pp_pixels.h:2463
constexpr Palette(Palette &&other) noexcept
Move constructor.
Definition SDL3pp_pixels.h:2486
constexpr PaletteIndex operator[](int index)
Change specific pallete index.
Definition SDL3pp_pixels.h:2574
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
Palette & operator=(const Palette &other)
Assignment operator.
Definition SDL3pp_pixels.h:2540
constexpr Palette(const Palette &other)
Copy constructor.
Definition SDL3pp_pixels.h:2479
~Palette()
Destructor.
Definition SDL3pp_pixels.h:2530
constexpr Palette & operator=(Palette &&other) noexcept
Assignment operator.
Definition SDL3pp_pixels.h:2533
constexpr Palette(PaletteRaw resource) noexcept
Constructs from raw Palette.
Definition SDL3pp_pixels.h:2473
constexpr int size() const
Returns number of colors in the palette.
Definition SDL3pp_pixels.h:2565
constexpr ColorRaw operator[](int index) const
Access specific pallete index.
Definition SDL3pp_pixels.h:2568
static Palette Borrow(PaletteRaw resource)
Safely borrows the from PaletteRaw.
Definition SDL3pp_pixels.h:2517
constexpr const ColorRaw * data() const
Access specific pallete colors.
Definition SDL3pp_pixels.h:2562
A non-owning reference wrapper for a given resource.
Definition SDL3pp_resource.h:156