29 #define COLOR_NAME_MAP(XX) \
32 XX(DARKGREEN, 0, 128, 0) \
33 XX(DARKCYAN, 0, 128, 128) \
34 XX(MAROON, 128, 0, 0) \
35 XX(PURPLE, 128, 0, 128) \
36 XX(OLIVE, 128, 128, 0) \
37 XX(LIGHTGREY, 192, 192, 192) \
38 XX(DARKGREY, 128, 128, 128) \
40 XX(GREEN, 0, 255, 0) \
41 XX(CYAN, 0, 255, 255) \
43 XX(MAGENTA, 255, 0, 255) \
44 XX(YELLOW, 255, 255, 0) \
45 XX(WHITE, 255, 255, 255) \
46 XX(ORANGE, 255, 165, 0) \
47 XX(GREENYELLOW, 173, 255, 47) \
48 XX(PINK, 255, 192, 203)
71 #define GDIPLUS_COLOR_TABLE(XX) \
72 XX(AliceBlue, 0xFFF0F8FFUL) \
73 XX(AntiqueWhite, 0xFFFAEBD7UL) \
74 XX(Aqua, 0xFF00FFFFUL) \
75 XX(Aquamarine, 0xFF7FFFD4UL) \
76 XX(Azure, 0xFFF0FFFFUL) \
77 XX(Beige, 0xFFF5F5DCUL) \
78 XX(Bisque, 0xFFFFE4C4UL) \
79 XX(Black, 0xFF000000UL) \
80 XX(BlanchedAlmond, 0xFFFFEBCDUL) \
81 XX(Blue, 0xFF0000FFUL) \
82 XX(BlueViolet, 0xFF8A2BE2UL) \
83 XX(Brown, 0xFFA52A2AUL) \
84 XX(BurlyWood, 0xFFDEB887UL) \
85 XX(CadetBlue, 0xFF5F9EA0UL) \
86 XX(Chartreuse, 0xFF7FFF00UL) \
87 XX(Chocolate, 0xFFD2691EUL) \
88 XX(Coral, 0xFFFF7F50UL) \
89 XX(CornflowerBlue, 0xFF6495EDUL) \
90 XX(Cornsilk, 0xFFFFF8DCUL) \
91 XX(Crimson, 0xFFDC143CUL) \
92 XX(Cyan, 0xFF00FFFFUL) \
93 XX(DarkBlue, 0xFF00008BUL) \
94 XX(DarkCyan, 0xFF008B8BUL) \
95 XX(DarkGoldenrod, 0xFFB8860BUL) \
96 XX(DarkGray, 0xFFA9A9A9UL) \
97 XX(DarkGreen, 0xFF006400UL) \
98 XX(DarkKhaki, 0xFFBDB76BUL) \
99 XX(DarkMagenta, 0xFF8B008BUL) \
100 XX(DarkOliveGreen, 0xFF556B2FUL) \
101 XX(DarkOrange, 0xFFFF8C00UL) \
102 XX(DarkOrchid, 0xFF9932CCUL) \
103 XX(DarkRed, 0xFF8B0000UL) \
104 XX(DarkSalmon, 0xFFE9967AUL) \
105 XX(DarkSeaGreen, 0xFF8FBC8FUL) \
106 XX(DarkSlateBlue, 0xFF483D8BUL) \
107 XX(DarkSlateGray, 0xFF2F4F4FUL) \
108 XX(DarkTurquoise, 0xFF00CED1UL) \
109 XX(DarkViolet, 0xFF9400D3UL) \
110 XX(DeepPink, 0xFFFF1493UL) \
111 XX(DeepSkyBlue, 0xFF00BFFFUL) \
112 XX(DimGray, 0xFF696969UL) \
113 XX(DodgerBlue, 0xFF1E90FFUL) \
114 XX(Firebrick, 0xFFB22222UL) \
115 XX(FloralWhite, 0xFFFFFAF0UL) \
116 XX(ForestGreen, 0xFF228B22UL) \
117 XX(Fuchsia, 0xFFFF00FFUL) \
118 XX(Gainsboro, 0xFFDCDCDCUL) \
119 XX(GhostWhite, 0xFFF8F8FFUL) \
120 XX(Gold, 0xFFFFD700UL) \
121 XX(Goldenrod, 0xFFDAA520UL) \
122 XX(Gray, 0xFF808080UL) \
123 XX(Green, 0xFF008000UL) \
124 XX(GreenYellow, 0xFFADFF2FUL) \
125 XX(Honeydew, 0xFFF0FFF0UL) \
126 XX(HotPink, 0xFFFF69B4UL) \
127 XX(IndianRed, 0xFFCD5C5CUL) \
128 XX(Indigo, 0xFF4B0082UL) \
129 XX(Ivory, 0xFFFFFFF0UL) \
130 XX(Khaki, 0xFFF0E68CUL) \
131 XX(Lavender, 0xFFE6E6FAUL) \
132 XX(LavenderBlush, 0xFFFFF0F5UL) \
133 XX(LawnGreen, 0xFF7CFC00UL) \
134 XX(LemonChiffon, 0xFFFFFACDUL) \
135 XX(LightBlue, 0xFFADD8E6UL) \
136 XX(LightCoral, 0xFFF08080UL) \
137 XX(LightCyan, 0xFFE0FFFFUL) \
138 XX(LightGoldenrodYellow, 0xFFFAFAD2UL) \
139 XX(LightGray, 0xFFD3D3D3UL) \
140 XX(LightGreen, 0xFF90EE90UL) \
141 XX(LightPink, 0xFFFFB6C1UL) \
142 XX(LightSalmon, 0xFFFFA07AUL) \
143 XX(LightSeaGreen, 0xFF20B2AAUL) \
144 XX(LightSkyBlue, 0xFF87CEFAUL) \
145 XX(LightSlateGray, 0xFF778899UL) \
146 XX(LightSteelBlue, 0xFFB0C4DEUL) \
147 XX(LightYellow, 0xFFFFFFE0UL) \
148 XX(Lime, 0xFF00FF00UL) \
149 XX(LimeGreen, 0xFF32CD32UL) \
150 XX(Linen, 0xFFFAF0E6UL) \
151 XX(Magenta, 0xFFFF00FFUL) \
152 XX(Maroon, 0xFF800000UL) \
153 XX(MediumAquamarine, 0xFF66CDAAUL) \
154 XX(MediumBlue, 0xFF0000CDUL) \
155 XX(MediumOrchid, 0xFFBA55D3UL) \
156 XX(MediumPurple, 0xFF9370DBUL) \
157 XX(MediumSeaGreen, 0xFF3CB371UL) \
158 XX(MediumSlateBlue, 0xFF7B68EEUL) \
159 XX(MediumSpringGreen, 0xFF00FA9AUL) \
160 XX(MediumTurquoise, 0xFF48D1CCUL) \
161 XX(MediumVioletRed, 0xFFC71585UL) \
162 XX(MidnightBlue, 0xFF191970UL) \
163 XX(MintCream, 0xFFF5FFFAUL) \
164 XX(MistyRose, 0xFFFFE4E1UL) \
165 XX(Moccasin, 0xFFFFE4B5UL) \
166 XX(NavajoWhite, 0xFFFFDEADUL) \
167 XX(Navy, 0xFF000080UL) \
168 XX(OldLace, 0xFFFDF5E6UL) \
169 XX(Olive, 0xFF808000UL) \
170 XX(OliveDrab, 0xFF6B8E23UL) \
171 XX(Orange, 0xFFFFA500UL) \
172 XX(OrangeRed, 0xFFFF4500UL) \
173 XX(Orchid, 0xFFDA70D6UL) \
174 XX(PaleGoldenrod, 0xFFEEE8AAUL) \
175 XX(PaleGreen, 0xFF98FB98UL) \
176 XX(PaleTurquoise, 0xFFAFEEEEUL) \
177 XX(PaleVioletRed, 0xFFDB7093UL) \
178 XX(PapayaWhip, 0xFFFFEFD5UL) \
179 XX(PeachPuff, 0xFFFFDAB9UL) \
180 XX(Peru, 0xFFCD853FUL) \
181 XX(Pink, 0xFFFFC0CBUL) \
182 XX(Plum, 0xFFDDA0DDUL) \
183 XX(PowderBlue, 0xFFB0E0E6UL) \
184 XX(Purple, 0xFF800080UL) \
185 XX(Red, 0xFFFF0000UL) \
186 XX(RosyBrown, 0xFFBC8F8FUL) \
187 XX(RoyalBlue, 0xFF4169E1UL) \
188 XX(SaddleBrown, 0xFF8B4513UL) \
189 XX(Salmon, 0xFFFA8072UL) \
190 XX(SandyBrown, 0xFFF4A460UL) \
191 XX(SeaGreen, 0xFF2E8B57UL) \
192 XX(SeaShell, 0xFFFFF5EEUL) \
193 XX(Sienna, 0xFFA0522DUL) \
194 XX(Silver, 0xFFC0C0C0UL) \
195 XX(SkyBlue, 0xFF87CEEBUL) \
196 XX(SlateBlue, 0xFF6A5ACDUL) \
197 XX(SlateGray, 0xFF708090UL) \
198 XX(Snow, 0xFFFFFAFAUL) \
199 XX(SpringGreen, 0xFF00FF7FUL) \
200 XX(SteelBlue, 0xFF4682B4UL) \
201 XX(Tan, 0xFFD2B48CUL) \
202 XX(Teal, 0xFF008080UL) \
203 XX(Thistle, 0xFFD8BFD8UL) \
204 XX(Tomato, 0xFFFF6347UL) \
205 XX(Transparent, 0x00FFFFFFUL) \
206 XX(Turquoise, 0xFF40E0D0UL) \
207 XX(Violet, 0xFFEE82EEUL) \
208 XX(Wheat, 0xFFF5DEB3UL) \
209 XX(White, 0xFFFFFFFFUL) \
210 XX(WhiteSmoke, 0xFFF5F5F5UL) \
211 XX(Yellow, 0xFFFFFF00UL) \
212 XX(YellowGreen, 0xFF9ACD32UL)
219 inline constexpr uint32_t
getColorValue(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)
221 return (a << 24) | (r << 16) | (g << 8) | b;
229 #define XX(name, r, g, b) name = getColorValue(r, g, b),
233 #define XX(name, argb) name = argb,
241 inline constexpr
Color makeColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)
248 color = (color & 0xffffff) | (alpha << 24);
254 return makeColor(uint32_t(color), alpha);
259 return uint32_t(color) >> 24;
264 return uint32_t(color) >> 16;
269 return uint32_t(color) >> 8;
274 return uint32_t(color);
289 #define PIXEL_FORMAT_MAP(XX) \
290 XX(RGB24, 3, 24, orderRGB, "24-bit RGB") \
291 XX(BGRA32, 4, 32, orderRGB, "32-bit ARGB") \
292 XX(BGR24, 3, 24, orderBGR, "24-bit BGR") \
293 XX(RGB565, 2, 16, orderRGB, "16-bit RGB 5/6/5")
297 #define XX(name, bytes, bpp, colorOrder, desc) name = (bytes - 1) | ((bpp / 2) << 2) | (colorOrder << 7),
326 static_assert(
sizeof(PixelFormatStruct) == 1);
#define GDIPLUS_COLOR_TABLE(XX)
Definition: Colors.h:71
#define PIXEL_FORMAT_MAP(XX)
Definition: Colors.h:289
String toString(Graphics::Color color)
#define COLOR_NAME_MAP(XX)
Definition: Colors.h:29
uint8_t u8
Definition: c_types.h:9
The String class.
Definition: WString.h:137
const char * c_str() const
Get a constant (un-modifiable) pointer to String content.
Definition: WString.h:617
PixelBuffer unpack(PixelBuffer src, PixelFormat format)
Convert packed colour into RGB.
constexpr uint32_t getColorValue(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
Obtain 24-bit colour value from red, green and blue components.
Definition: Colors.h:219
constexpr uint8_t getGreen(Color color)
Definition: Colors.h:267
size_t writeColor(void *buffer, PackedColor color, PixelFormat format)
Store a packed colour value into memory.
constexpr uint8_t getBlue(Color color)
Definition: Colors.h:272
PixelBuffer pack(PixelBuffer src, PixelFormat format)
Convert RGB colour into packed format.
constexpr uint8_t getAlpha(Color color)
Definition: Colors.h:257
constexpr Color makeColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
Function to create a custom colour.
Definition: Colors.h:241
constexpr uint8_t getRed(Color color)
Definition: Colors.h:262
size_t convert(const void *srcData, PixelFormat srcFormat, void *dstBuffer, PixelFormat dstFormat, size_t numPixels)
Convert block of data from one pixel format to another.
bool fromString(const char *s, Color &color)
ColorOrder
Order refers to colour order within bitstream.
Definition: Colors.h:287
@ orderBGR
Definition: Colors.h:287
@ orderRGB
Definition: Colors.h:287
PixelFormat
Definition: Colors.h:295
XX(name, bytes, bpp, colorOrder, desc)
uint8_t getBytesPerPixel(PixelFormat format)
Get number of bytes required to store a pixel in the given format.
Definition: Colors.h:331
Color
Standard colour definitions.
Definition: Colors.h:227
Colour in device pixel format.
Definition: Colors.h:339
uint32_t value
Definition: Colors.h:340
uint32_t alpha
Definition: Colors.h:341
uint8_t r
Definition: Colors.h:371
uint8_t b
Definition: Colors.h:369
uint8_t g
Definition: Colors.h:370
uint8_t b
Definition: Colors.h:354
uint8_t a
Definition: Colors.h:357
uint8_t r
Definition: Colors.h:356
uint8_t g
Definition: Colors.h:355
uint8_t g
Definition: Colors.h:363
uint8_t b
Definition: Colors.h:364
uint8_t r
Definition: Colors.h:362
uint16_t b
Definition: Colors.h:376
uint16_t r
Definition: Colors.h:378
uint16_t g
Definition: Colors.h:377
Structure used to perform pixel format conversions.
Definition: Colors.h:347
RGB24 rgb24
Definition: Colors.h:366
PackedColor packed
Definition: Colors.h:349
BGRA32 bgra32
Definition: Colors.h:359
RGB565 rgb565
Definition: Colors.h:380
BGR24 bgr24
Definition: Colors.h:373
Color color
Definition: Colors.h:348