[PSDK][GDIPLUS]
[reactos.git] / reactos / sdk / include / psdk / gdipluscolor.h
1 /*
2 * Copyright (C) 2008 Google (Lei Zhang)
3 * 2015 Benedikt Freisen
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20 #ifndef _GDIPLUSCOLOR_H
21 #define _GDIPLUSCOLOR_H
22
23 enum ColorChannelFlags
24 {
25 ColorChannelFlagsC,
26 ColorChannelFlagsM,
27 ColorChannelFlagsY,
28 ColorChannelFlagsK,
29 ColorChannelFlagsLast
30 };
31
32 #ifdef __cplusplus
33
34 class Color
35 {
36 public:
37 Color(VOID)
38 {
39 Argb = 0xff000000;
40 }
41
42 Color(ARGB argb)
43 {
44 Argb = argb;
45 }
46
47 Color(BYTE r, BYTE g, BYTE b)
48 {
49 Argb = 0xff << 24 | r << 16 | g << 8 | b;
50 }
51
52 Color(BYTE a, BYTE r, BYTE g, BYTE b)
53 {
54 Argb = a << 24 | r << 16 | g << 8 | b;
55 }
56
57 BYTE GetA(VOID) const
58 {
59 return (Argb >> 24) & 0xff;
60 }
61
62 BYTE GetAlpha(VOID) const
63 {
64 return (Argb >> 24) & 0xff;
65 }
66
67 BYTE GetB(VOID) const
68 {
69 return Argb & 0xff;
70 }
71
72 BYTE GetBlue(VOID) const
73 {
74 return Argb & 0xff;
75 }
76
77 BYTE GetG(VOID) const
78 {
79 return (Argb >> 8) & 0xff;
80 }
81
82 BYTE GetGreen(VOID) const
83 {
84 return (Argb >> 8) & 0xff;
85 }
86
87 BYTE GetR(VOID) const
88 {
89 return (Argb >> 16) & 0xff;
90 }
91
92 BYTE GetRed(VOID) const
93 {
94 return (Argb >> 16) & 0xff;
95 }
96
97 ARGB GetValue(VOID) const
98 {
99 return Argb;
100 }
101
102 static ARGB MakeARGB(BYTE a, BYTE r, BYTE g, BYTE b)
103 {
104 return a << 24 | r << 16 | g << 8 | b;
105 }
106
107 VOID SetFromCOLORREF(COLORREF rgb)
108 {
109 Argb = 0xff000000 | (rgb & 0x000000ff) << 16 | (rgb & 0x0000ff00) | (rgb & 0x00ff0000) >> 16;
110 }
111
112 VOID SetValue(ARGB argb)
113 {
114 Argb = argb;
115 }
116
117 COLORREF ToCOLORREF(VOID) const
118 {
119 return (Argb & 0x000000ff) << 16 | (Argb & 0x0000ff00) | (Argb & 0x00ff0000) >> 16;
120 }
121
122 protected:
123 ARGB Argb;
124 };
125
126 #else /* end of c++ typedefs */
127
128 typedef struct Color
129 {
130 ARGB Argb;
131 } Color;
132
133 typedef enum ColorChannelFlags ColorChannelFlags;
134
135 #endif /* end of c typedefs */
136
137 #endif /* _GDIPLUSCOLOR_H */