1 /* 2 * gdipluscolor.h 3 * 4 * GDI+ color 5 * 6 * This file is part of the w32api package. 7 * 8 * Contributors: 9 * Created by Markus Koenig <markus (at) stber-koenig.de> 10 * 11 * THIS SOFTWARE IS NOT COPYRIGHTED 12 * 13 * This source code is offered for use in the public domain. You may 14 * use, modify or distribute it freely. 15 * 16 * This code is distributed in the hope that it will be useful but 17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 * DISCLAIMED. This includes but is not limited to warranties of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 * 21 */ 22 23 #ifndef __GDIPLUS_COLOR_H 24 #define __GDIPLUS_COLOR_H 25 #if __GNUC__ >=3 26 #pragma GCC system_header 27 #endif 28 29 typedef enum ColorChannelFlags { 30 ColorChannelFlagsC = 0, 31 ColorChannelFlagsM = 1, 32 ColorChannelFlagsY = 2, 33 ColorChannelFlagsK = 3, 34 ColorChannelFlagsLast = 4 35 } ColorChannelFlags; 36 37 typedef struct Color 38 { 39 #ifdef __cplusplus 40 private: 41 #endif 42 ARGB Value; 43 44 #ifdef __cplusplus 45 public: 46 friend class Bitmap; 47 friend class Graphics; 48 friend class HatchBrush; 49 friend class PathGradientBrush; 50 friend class Pen; 51 friend class SolidBrush; 52 53 static ARGB MakeARGB(BYTE a, BYTE r, BYTE g, BYTE b) 54 { 55 return (ARGB) ((((DWORD) a) << 24) | (((DWORD) r) << 16) 56 | (((DWORD) g) << 8) | ((DWORD) b)); 57 } 58 59 static const ARGB AlphaMask = 0xFF000000; 60 61 static const ARGB AliceBlue = 0xFFF0F8FF; 62 static const ARGB AntiqueWhite = 0xFFFAEBD7; 63 static const ARGB Aqua = 0xFF00FFFF; 64 static const ARGB Aquamarine = 0xFF7FFFD4; 65 static const ARGB Azure = 0xFFF0FFFF; 66 static const ARGB Beige = 0xFFF5F5DC; 67 static const ARGB Bisque = 0xFFFFE4C4; 68 static const ARGB Black = 0xFF000000; 69 static const ARGB BlanchedAlmond = 0xFFFFEBCD; 70 static const ARGB Blue = 0xFF0000FF; 71 static const ARGB BlueViolet = 0xFF8A2BE2; 72 static const ARGB Brown = 0xFFA52A2A; 73 static const ARGB BurlyWood = 0xFFDEB887; 74 static const ARGB CadetBlue = 0xFF5F9EA0; 75 static const ARGB Chartreuse = 0xFF7FFF00; 76 static const ARGB Chocolate = 0xFFD2691E; 77 static const ARGB Coral = 0xFFFF7F50; 78 static const ARGB CornflowerBlue = 0xFF6495ED; 79 static const ARGB Cornsilk = 0xFFFFF8DC; 80 static const ARGB Crimson = 0xFFDC143C; 81 static const ARGB Cyan = 0xFF00FFFF; 82 static const ARGB DarkBlue = 0xFF00008B; 83 static const ARGB DarkCyan = 0xFF008B8B; 84 static const ARGB DarkGoldenrod = 0xFFB8860B; 85 static const ARGB DarkGray = 0xFFA9A9A9; 86 static const ARGB DarkGreen = 0xFF006400; 87 static const ARGB DarkKhaki = 0xFFBDB76B; 88 static const ARGB DarkMagenta = 0xFF8B008B; 89 static const ARGB DarkOliveGreen = 0xFF556B2F; 90 static const ARGB DarkOrange = 0xFFFF8C00; 91 static const ARGB DarkOrchid = 0xFF9932CC; 92 static const ARGB DarkRed = 0xFF8B0000; 93 static const ARGB DarkSalmon = 0xFFE9967A; 94 static const ARGB DarkSeaGreen = 0xFF8FBC8F; 95 static const ARGB DarkSlateBlue = 0xFF483D8B; 96 static const ARGB DarkSlateGray = 0xFF2F4F4F; 97 static const ARGB DarkTurquoise = 0xFF00CED1; 98 static const ARGB DarkViolet = 0xFF9400D3; 99 static const ARGB DeepPink = 0xFFFF1493; 100 static const ARGB DeepSkyBlue = 0xFF00BFFF; 101 static const ARGB DimGray = 0xFF696969; 102 static const ARGB DodgerBlue = 0xFF1E90FF; 103 static const ARGB Firebrick = 0xFFB22222; 104 static const ARGB FloralWhite = 0xFFFFFAF0; 105 static const ARGB ForestGreen = 0xFF228B22; 106 static const ARGB Fuchsia = 0xFFFF00FF; 107 static const ARGB Gainsboro = 0xFFDCDCDC; 108 static const ARGB GhostWhite = 0xFFF8F8FF; 109 static const ARGB Gold = 0xFFFFD700; 110 static const ARGB Goldenrod = 0xFFDAA520; 111 static const ARGB Gray = 0xFF808080; 112 static const ARGB Green = 0xFF008000; 113 static const ARGB GreenYellow = 0xFFADFF2F; 114 static const ARGB Honeydew = 0xFFF0FFF0; 115 static const ARGB HotPink = 0xFFFF69B4; 116 static const ARGB IndianRed = 0xFFCD5C5C; 117 static const ARGB Indigo = 0xFF4B0082; 118 static const ARGB Ivory = 0xFFFFFFF0; 119 static const ARGB Khaki = 0xFFF0E68C; 120 static const ARGB Lavender = 0xFFE6E6FA; 121 static const ARGB LavenderBlush = 0xFFFFF0F5; 122 static const ARGB LawnGreen = 0xFF7CFC00; 123 static const ARGB LemonChiffon = 0xFFFFFACD; 124 static const ARGB LightBlue = 0xFFADD8E6; 125 static const ARGB LightCoral = 0xFFF08080; 126 static const ARGB LightCyan = 0xFFE0FFFF; 127 static const ARGB LightGoldenrodYellow = 0xFFFAFAD2; 128 static const ARGB LightGray = 0xFFD3D3D3; 129 static const ARGB LightGreen = 0xFF90EE90; 130 static const ARGB LightPink = 0xFFFFB6C1; 131 static const ARGB LightSalmon = 0xFFFFA07A; 132 static const ARGB LightSeaGreen = 0xFF20B2AA; 133 static const ARGB LightSkyBlue = 0xFF87CEFA; 134 static const ARGB LightSlateGray = 0xFF778899; 135 static const ARGB LightSteelBlue = 0xFFB0C4DE; 136 static const ARGB LightYellow = 0xFFFFFFE0; 137 static const ARGB Lime = 0xFF00FF00; 138 static const ARGB LimeGreen = 0xFF32CD32; 139 static const ARGB Linen = 0xFFFAF0E6; 140 static const ARGB Magenta = 0xFFFF00FF; 141 static const ARGB Maroon = 0xFF800000; 142 static const ARGB MediumAquamarine = 0xFF66CDAA; 143 static const ARGB MediumBlue = 0xFF0000CD; 144 static const ARGB MediumOrchid = 0xFFBA55D3; 145 static const ARGB MediumPurple = 0xFF9370DB; 146 static const ARGB MediumSeaGreen = 0xFF3CB371; 147 static const ARGB MediumSlateBlue = 0xFF7B68EE; 148 static const ARGB MediumSpringGreen = 0xFF00FA9A; 149 static const ARGB MediumTurquoise = 0xFF48D1CC; 150 static const ARGB MediumVioletRed = 0xFFC71585; 151 static const ARGB MidnightBlue = 0xFF191970; 152 static const ARGB MintCream = 0xFFF5FFFA; 153 static const ARGB MistyRose = 0xFFFFE4E1; 154 static const ARGB Moccasin = 0xFFFFE4B5; 155 static const ARGB NavajoWhite = 0xFFFFDEAD; 156 static const ARGB Navy = 0xFF000080; 157 static const ARGB OldLace = 0xFFFDF5E6; 158 static const ARGB Olive = 0xFF808000; 159 static const ARGB OliveDrab = 0xFF6B8E23; 160 static const ARGB Orange = 0xFFFFA500; 161 static const ARGB OrangeRed = 0xFFFF4500; 162 static const ARGB Orchid = 0xFFDA70D6; 163 static const ARGB PaleGoldenrod = 0xFFEEE8AA; 164 static const ARGB PaleGreen = 0xFF98FB98; 165 static const ARGB PaleTurquoise = 0xFFAFEEEE; 166 static const ARGB PaleVioletRed = 0xFFDB7093; 167 static const ARGB PapayaWhip = 0xFFFFEFD5; 168 static const ARGB PeachPuff = 0xFFFFDAB9; 169 static const ARGB Peru = 0xFFCD853F; 170 static const ARGB Pink = 0xFFFFC0CB; 171 static const ARGB Plum = 0xFFDDA0DD; 172 static const ARGB PowderBlue = 0xFFB0E0E6; 173 static const ARGB Purple = 0xFF800080; 174 static const ARGB Red = 0xFFFF0000; 175 static const ARGB RosyBrown = 0xFFBC8F8F; 176 static const ARGB RoyalBlue = 0xFF4169E1; 177 static const ARGB SaddleBrown = 0xFF8B4513; 178 static const ARGB Salmon = 0xFFFA8072; 179 static const ARGB SandyBrown = 0xFFF4A460; 180 static const ARGB SeaGreen = 0xFF2E8B57; 181 static const ARGB SeaShell = 0xFFFFF5EE; 182 static const ARGB Sienna = 0xFFA0522D; 183 static const ARGB Silver = 0xFFC0C0C0; 184 static const ARGB SkyBlue = 0xFF87CEEB; 185 static const ARGB SlateBlue = 0xFF6A5ACD; 186 static const ARGB SlateGray = 0xFF708090; 187 static const ARGB Snow = 0xFFFFFAFA; 188 static const ARGB SpringGreen = 0xFF00FF7F; 189 static const ARGB SteelBlue = 0xFF4682B4; 190 static const ARGB Tan = 0xFFD2B48C; 191 static const ARGB Teal = 0xFF008080; 192 static const ARGB Thistle = 0xFFD8BFD8; 193 static const ARGB Tomato = 0xFFFF6347; 194 static const ARGB Transparent = 0x00FFFFFF; 195 static const ARGB Turquoise = 0xFF40E0D0; 196 static const ARGB Violet = 0xFFEE82EE; 197 static const ARGB Wheat = 0xFFF5DEB3; 198 static const ARGB White = 0xFFFFFFFF; 199 static const ARGB WhiteSmoke = 0xFFF5F5F5; 200 static const ARGB Yellow = 0xFFFFFF00; 201 static const ARGB YellowGreen = 0xFF9ACD32; 202 203 Color(): Value(0xFF000000) {} 204 Color(ARGB argb): Value(argb) {} 205 Color(BYTE r, BYTE g, BYTE b): Value(MakeARGB(0xFF, r, g, b)) {} 206 Color(BYTE a, BYTE r, BYTE g, BYTE b): Value(MakeARGB(a, r, g, b)) {} 207 208 BYTE GetA() const 209 { 210 return (BYTE) (Value >> 24); 211 } 212 BYTE GetAlpha() const 213 { 214 return (BYTE) (Value >> 24); 215 } 216 BYTE GetB() const 217 { 218 return (BYTE) Value; 219 } 220 BYTE GetBlue() const 221 { 222 return (BYTE) Value; 223 } 224 BYTE GetG() const 225 { 226 return (BYTE) (Value >> 8); 227 } 228 BYTE GetGreen() const 229 { 230 return (BYTE) (Value >> 8); 231 } 232 BYTE GetR() const 233 { 234 return (BYTE) (Value >> 16); 235 } 236 BYTE GetRed() const 237 { 238 return (BYTE) (Value >> 16); 239 } 240 ARGB GetValue() const 241 { 242 return Value; 243 } 244 VOID SetFromCOLORREF(COLORREF rgb) 245 { 246 BYTE r = (BYTE) rgb; 247 BYTE g = (BYTE) (rgb >> 8); 248 BYTE b = (BYTE) (rgb >> 16); 249 Value = MakeARGB(0xFF, r, g, b); 250 } 251 VOID SetValue(ARGB argb) 252 { 253 Value = argb; 254 } 255 COLORREF ToCOLORREF() const 256 { 257 return RGB(GetRed(), GetGreen(), GetBlue()); 258 } 259 #endif /* __cplusplus */ 260 } Color; 261 262 #endif /* __GDIPLUS_COLOR_H */ 263