xref: /reactos/sdk/include/psdk/gdipluscolor.h (revision 1674307f)
1 /*
2  * Copyright (C) 2008 Google (Lei Zhang)
3  *               2015 Benedikt Freisen
4  *               2019 Katayama Hirofumi MZ
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 
21 #ifndef _GDIPLUSCOLOR_H
22 #define _GDIPLUSCOLOR_H
23 
24 typedef enum ColorChannelFlags
25 {
26     ColorChannelFlagsC,
27     ColorChannelFlagsM,
28     ColorChannelFlagsY,
29     ColorChannelFlagsK,
30     ColorChannelFlagsLast
31 } ColorChannelFlags;
32 
33 #ifdef __cplusplus
34 
35 class Color
36 {
37   public:
Color()38     Color() : Argb(0xff000000)
39     {
40     }
41 
Color(ARGB argb)42     Color(ARGB argb) : Argb(argb)
43     {
44     }
45 
Color(BYTE r,BYTE g,BYTE b)46     Color(BYTE r, BYTE g, BYTE b) : Argb(MakeARGB(0xFF, r, g, b))
47     {
48     }
49 
Color(BYTE a,BYTE r,BYTE g,BYTE b)50     Color(BYTE a, BYTE r, BYTE g, BYTE b) : Argb(MakeARGB(a, r, g, b))
51     {
52     }
53 
54     BYTE
GetA()55     GetA() const
56     {
57         return (BYTE)(Argb >> 24);
58     }
59 
60     BYTE
GetAlpha()61     GetAlpha() const
62     {
63         return (BYTE)(Argb >> 24);
64     }
65 
66     BYTE
GetB()67     GetB() const
68     {
69         return (BYTE)Argb;
70     }
71 
72     BYTE
GetBlue()73     GetBlue() const
74     {
75         return (BYTE)Argb;
76     }
77 
78     BYTE
GetG()79     GetG() const
80     {
81         return (BYTE)(Argb >> 8);
82     }
83 
84     BYTE
GetGreen()85     GetGreen() const
86     {
87         return (BYTE)(Argb >> 8);
88     }
89 
90     BYTE
GetR()91     GetR() const
92     {
93         return (BYTE)(Argb >> 16);
94     }
95 
96     BYTE
GetRed()97     GetRed() const
98     {
99         return (BYTE)(Argb >> 16);
100     }
101 
102     ARGB
GetValue()103     GetValue() const
104     {
105         return Argb;
106     }
107 
108     static ARGB
MakeARGB(BYTE a,BYTE r,BYTE g,BYTE b)109     MakeARGB(BYTE a, BYTE r, BYTE g, BYTE b)
110     {
111         ARGB a0 = a, r0 = r, g0 = g, b0 = b;
112         return (a0 << AlphaShift) | (r0 << RedShift) | (g0 << GreenShift) | (b0 << BlueShift);
113     }
114 
115     VOID
SetFromCOLORREF(COLORREF rgb)116     SetFromCOLORREF(COLORREF rgb)
117     {
118         Argb = MakeARGB(0xFF, GetRValue(rgb), GetGValue(rgb), GetBValue(rgb));
119     }
120 
121     VOID
SetValue(ARGB argb)122     SetValue(ARGB argb)
123     {
124         Argb = argb;
125     }
126 
127     COLORREF
ToCOLORREF()128     ToCOLORREF() const
129     {
130         return RGB(GetRed(), GetGreen(), GetBlue());
131     }
132 
133     enum
134     {
135         AlphaShift = 24,
136         RedShift = 16,
137         GreenShift = 8,
138         BlueShift = 0
139     };
140 
141     enum
142     {
143         AlphaMask = 0xFF000000,
144         RedMask = 0x00FF0000,
145         GreenMask = 0x0000FF00,
146         BlueMask = 0x000000FF
147     };
148 
149     enum
150     {
151         AliceBlue = 0xFFF0F8FF,
152         AntiqueWhite = 0xFFFAEBD7,
153         Aqua = 0xFF00FFFF,
154         Aquamarine = 0xFF7FFFD4,
155         Azure = 0xFFF0FFFF,
156         Beige = 0xFFF5F5DC,
157         Bisque = 0xFFFFE4C4,
158         Black = 0xFF000000,
159         BlanchedAlmond = 0xFFFFEBCD,
160         Blue = 0xFF0000FF,
161         BlueViolet = 0xFF8A2BE2,
162         Brown = 0xFFA52A2A,
163         BurlyWood = 0xFFDEB887,
164         CadetBlue = 0xFF5F9EA0,
165         Chartreuse = 0xFF7FFF00,
166         Chocolate = 0xFFD2691E,
167         Coral = 0xFFFF7F50,
168         CornflowerBlue = 0xFF6495ED,
169         Cornsilk = 0xFFFFF8DC,
170         Crimson = 0xFFDC143C,
171         Cyan = 0xFF00FFFF,
172         DarkBlue = 0xFF00008B,
173         DarkCyan = 0xFF008B8B,
174         DarkGoldenrod = 0xFFB8860B,
175         DarkGray = 0xFFA9A9A9,
176         DarkGreen = 0xFF006400,
177         DarkKhaki = 0xFFBDB76B,
178         DarkMagenta = 0xFF8B008B,
179         DarkOliveGreen = 0xFF556B2F,
180         DarkOrange = 0xFFFF8C00,
181         DarkOrchid = 0xFF9932CC,
182         DarkRed = 0xFF8B0000,
183         DarkSalmon = 0xFFE9967A,
184         DarkSeaGreen = 0xFF8FBC8F,
185         DarkSlateBlue = 0xFF483D8B,
186         DarkSlateGray = 0xFF2F4F4F,
187         DarkTurquoise = 0xFF00CED1,
188         DarkViolet = 0xFF9400D3,
189         DeepPink = 0xFFFF1493,
190         DeepSkyBlue = 0xFF00BFFF,
191         DimGray = 0xFF696969,
192         DodgerBlue = 0xFF1E90FF,
193         Firebrick = 0xFFB22222,
194         FloralWhite = 0xFFFFFAF0,
195         ForestGreen = 0xFF228B22,
196         Fuchsia = 0xFFFF00FF,
197         Gainsboro = 0xFFDCDCDC,
198         GhostWhite = 0xFFF8F8FF,
199         Gold = 0xFFFFD700,
200         Goldenrod = 0xFFDAA520,
201         Gray = 0xFF808080,
202         Green = 0xFF008000,
203         GreenYellow = 0xFFADFF2F,
204         Honeydew = 0xFFF0FFF0,
205         HotPink = 0xFFFF69B4,
206         IndianRed = 0xFFCD5C5C,
207         Indigo = 0xFF4B0082,
208         Ivory = 0xFFFFFFF0,
209         Khaki = 0xFFF0E68C,
210         Lavender = 0xFFE6E6FA,
211         LavenderBlush = 0xFFFFF0F5,
212         LawnGreen = 0xFF7CFC00,
213         LemonChiffon = 0xFFFFFACD,
214         LightBlue = 0xFFADD8E6,
215         LightCoral = 0xFFF08080,
216         LightCyan = 0xFFE0FFFF,
217         LightGoldenrodYellow = 0xFFFAFAD2,
218         LightGray = 0xFFD3D3D3,
219         LightGreen = 0xFF90EE90,
220         LightPink = 0xFFFFB6C1,
221         LightSalmon = 0xFFFFA07A,
222         LightSeaGreen = 0xFF20B2AA,
223         LightSkyBlue = 0xFF87CEFA,
224         LightSlateGray = 0xFF778899,
225         LightSteelBlue = 0xFFB0C4DE,
226         LightYellow = 0xFFFFFFE0,
227         Lime = 0xFF00FF00,
228         LimeGreen = 0xFF32CD32,
229         Linen = 0xFFFAF0E6,
230         Magenta = 0xFFFF00FF,
231         Maroon = 0xFF800000,
232         MediumAquamarine = 0xFF66CDAA,
233         MediumBlue = 0xFF0000CD,
234         MediumOrchid = 0xFFBA55D3,
235         MediumPurple = 0xFF9370DB,
236         MediumSeaGreen = 0xFF3CB371,
237         MediumSlateBlue = 0xFF7B68EE,
238         MediumSpringGreen = 0xFF00FA9A,
239         MediumTurquoise = 0xFF48D1CC,
240         MediumVioletRed = 0xFFC71585,
241         MidnightBlue = 0xFF191970,
242         MintCream = 0xFFF5FFFA,
243         MistyRose = 0xFFFFE4E1,
244         Moccasin = 0xFFFFE4B5,
245         NavajoWhite = 0xFFFFDEAD,
246         Navy = 0xFF000080,
247         OldLace = 0xFFFDF5E6,
248         Olive = 0xFF808000,
249         OliveDrab = 0xFF6B8E23,
250         Orange = 0xFFFFA500,
251         OrangeRed = 0xFFFF4500,
252         Orchid = 0xFFDA70D6,
253         PaleGoldenrod = 0xFFEEE8AA,
254         PaleGreen = 0xFF98FB98,
255         PaleTurquoise = 0xFFAFEEEE,
256         PaleVioletRed = 0xFFDB7093,
257         PapayaWhip = 0xFFFFEFD5,
258         PeachPuff = 0xFFFFDAB9,
259         Peru = 0xFFCD853F,
260         Pink = 0xFFFFC0CB,
261         Plum = 0xFFDDA0DD,
262         PowderBlue = 0xFFB0E0E6,
263         Purple = 0xFF800080,
264         Red = 0xFFFF0000,
265         RosyBrown = 0xFFBC8F8F,
266         RoyalBlue = 0xFF4169E1,
267         SaddleBrown = 0xFF8B4513,
268         Salmon = 0xFFFA8072,
269         SandyBrown = 0xFFF4A460,
270         SeaGreen = 0xFF2E8B57,
271         SeaShell = 0xFFFFF5EE,
272         Sienna = 0xFFA0522D,
273         Silver = 0xFFC0C0C0,
274         SkyBlue = 0xFF87CEEB,
275         SlateBlue = 0xFF6A5ACD,
276         SlateGray = 0xFF708090,
277         Snow = 0xFFFFFAFA,
278         SpringGreen = 0xFF00FF7F,
279         SteelBlue = 0xFF4682B4,
280         Tan = 0xFFD2B48C,
281         Teal = 0xFF008080,
282         Thistle = 0xFFD8BFD8,
283         Tomato = 0xFFFF6347,
284         Transparent = 0x00FFFFFF,
285         Turquoise = 0xFF40E0D0,
286         Violet = 0xFFEE82EE,
287         Wheat = 0xFFF5DEB3,
288         White = 0xFFFFFFFF,
289         WhiteSmoke = 0xFFF5F5F5,
290         Yellow = 0xFFFFFF00,
291         YellowGreen = 0xFF9ACD32
292     };
293 
294   protected:
295     ARGB Argb;
296 };
297 
298 #else /* end of c++ typedefs */
299 
300 typedef struct Color
301 {
302     ARGB Argb;
303 } Color;
304 
305 #endif /* end of c typedefs */
306 
307 #endif /* _GDIPLUSCOLOR_H */
308