1 /** 2 * @file gdipluscolor.h 3 * Copyright 2012, 2013 MinGW.org project 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the next 13 * paragraph) shall be included in all copies or substantial portions of the 14 * Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 * DEALINGS IN THE SOFTWARE. 23 */ 24 /* Created by Markus Koenig <markus@stber-koenig.de> */ 25 #ifndef __GDIPLUS_COLOR_H 26 #define __GDIPLUS_COLOR_H 27 #pragma GCC system_header 28 #include <_mingw.h> 29 30 /* 31 * GDI+ color 32 */ 33 34 typedef enum ColorChannelFlags { 35 ColorChannelFlagsC = 0, 36 ColorChannelFlagsM = 1, 37 ColorChannelFlagsY = 2, 38 ColorChannelFlagsK = 3, 39 ColorChannelFlagsLast = 4 40 } ColorChannelFlags; 41 42 typedef struct Color 43 { 44 #ifdef __cplusplus 45 private: 46 #endif 47 ARGB Value; 48 49 #ifdef __cplusplus 50 public: 51 friend class Bitmap; 52 friend class Graphics; 53 friend class HatchBrush; 54 friend class PathGradientBrush; 55 friend class Pen; 56 friend class SolidBrush; 57 MakeARGBColor58 static ARGB MakeARGB(BYTE a, BYTE r, BYTE g, BYTE b) 59 { 60 return (ARGB) ((((DWORD) a) << 24) | (((DWORD) r) << 16) 61 | (((DWORD) g) << 8) | ((DWORD) b)); 62 } 63 64 static const ARGB AlphaMask = 0xFF000000UL; 65 66 static const ARGB AliceBlue = 0xFFF0F8FFUL; 67 static const ARGB AntiqueWhite = 0xFFFAEBD7UL; 68 static const ARGB Aqua = 0xFF00FFFFUL; 69 static const ARGB Aquamarine = 0xFF7FFFD4UL; 70 static const ARGB Azure = 0xFFF0FFFFUL; 71 static const ARGB Beige = 0xFFF5F5DCUL; 72 static const ARGB Bisque = 0xFFFFE4C4UL; 73 static const ARGB Black = 0xFF000000UL; 74 static const ARGB BlanchedAlmond = 0xFFFFEBCDUL; 75 static const ARGB Blue = 0xFF0000FFUL; 76 static const ARGB BlueViolet = 0xFF8A2BE2UL; 77 static const ARGB Brown = 0xFFA52A2AUL; 78 static const ARGB BurlyWood = 0xFFDEB887UL; 79 static const ARGB CadetBlue = 0xFF5F9EA0UL; 80 static const ARGB Chartreuse = 0xFF7FFF00UL; 81 static const ARGB Chocolate = 0xFFD2691EUL; 82 static const ARGB Coral = 0xFFFF7F50UL; 83 static const ARGB CornflowerBlue = 0xFF6495EDUL; 84 static const ARGB Cornsilk = 0xFFFFF8DCUL; 85 static const ARGB Crimson = 0xFFDC143CUL; 86 static const ARGB Cyan = 0xFF00FFFFUL; 87 static const ARGB DarkBlue = 0xFF00008BUL; 88 static const ARGB DarkCyan = 0xFF008B8BUL; 89 static const ARGB DarkGoldenrod = 0xFFB8860BUL; 90 static const ARGB DarkGray = 0xFFA9A9A9UL; 91 static const ARGB DarkGreen = 0xFF006400UL; 92 static const ARGB DarkKhaki = 0xFFBDB76BUL; 93 static const ARGB DarkMagenta = 0xFF8B008BUL; 94 static const ARGB DarkOliveGreen = 0xFF556B2FUL; 95 static const ARGB DarkOrange = 0xFFFF8C00UL; 96 static const ARGB DarkOrchid = 0xFF9932CCUL; 97 static const ARGB DarkRed = 0xFF8B0000UL; 98 static const ARGB DarkSalmon = 0xFFE9967AUL; 99 static const ARGB DarkSeaGreen = 0xFF8FBC8FUL; 100 static const ARGB DarkSlateBlue = 0xFF483D8BUL; 101 static const ARGB DarkSlateGray = 0xFF2F4F4FUL; 102 static const ARGB DarkTurquoise = 0xFF00CED1UL; 103 static const ARGB DarkViolet = 0xFF9400D3UL; 104 static const ARGB DeepPink = 0xFFFF1493UL; 105 static const ARGB DeepSkyBlue = 0xFF00BFFFUL; 106 static const ARGB DimGray = 0xFF696969UL; 107 static const ARGB DodgerBlue = 0xFF1E90FFUL; 108 static const ARGB Firebrick = 0xFFB22222UL; 109 static const ARGB FloralWhite = 0xFFFFFAF0UL; 110 static const ARGB ForestGreen = 0xFF228B22UL; 111 static const ARGB Fuchsia = 0xFFFF00FFUL; 112 static const ARGB Gainsboro = 0xFFDCDCDCUL; 113 static const ARGB GhostWhite = 0xFFF8F8FFUL; 114 static const ARGB Gold = 0xFFFFD700UL; 115 static const ARGB Goldenrod = 0xFFDAA520UL; 116 static const ARGB Gray = 0xFF808080UL; 117 static const ARGB Green = 0xFF008000UL; 118 static const ARGB GreenYellow = 0xFFADFF2FUL; 119 static const ARGB Honeydew = 0xFFF0FFF0UL; 120 static const ARGB HotPink = 0xFFFF69B4UL; 121 static const ARGB IndianRed = 0xFFCD5C5CUL; 122 static const ARGB Indigo = 0xFF4B0082UL; 123 static const ARGB Ivory = 0xFFFFFFF0UL; 124 static const ARGB Khaki = 0xFFF0E68CUL; 125 static const ARGB Lavender = 0xFFE6E6FAUL; 126 static const ARGB LavenderBlush = 0xFFFFF0F5UL; 127 static const ARGB LawnGreen = 0xFF7CFC00UL; 128 static const ARGB LemonChiffon = 0xFFFFFACDUL; 129 static const ARGB LightBlue = 0xFFADD8E6UL; 130 static const ARGB LightCoral = 0xFFF08080UL; 131 static const ARGB LightCyan = 0xFFE0FFFFUL; 132 static const ARGB LightGoldenrodYellow = 0xFFFAFAD2UL; 133 static const ARGB LightGray = 0xFFD3D3D3UL; 134 static const ARGB LightGreen = 0xFF90EE90UL; 135 static const ARGB LightPink = 0xFFFFB6C1UL; 136 static const ARGB LightSalmon = 0xFFFFA07AUL; 137 static const ARGB LightSeaGreen = 0xFF20B2AAUL; 138 static const ARGB LightSkyBlue = 0xFF87CEFAUL; 139 static const ARGB LightSlateGray = 0xFF778899UL; 140 static const ARGB LightSteelBlue = 0xFFB0C4DEUL; 141 static const ARGB LightYellow = 0xFFFFFFE0UL; 142 static const ARGB Lime = 0xFF00FF00UL; 143 static const ARGB LimeGreen = 0xFF32CD32UL; 144 static const ARGB Linen = 0xFFFAF0E6UL; 145 static const ARGB Magenta = 0xFFFF00FFUL; 146 static const ARGB Maroon = 0xFF800000UL; 147 static const ARGB MediumAquamarine = 0xFF66CDAAUL; 148 static const ARGB MediumBlue = 0xFF0000CDUL; 149 static const ARGB MediumOrchid = 0xFFBA55D3UL; 150 static const ARGB MediumPurple = 0xFF9370DBUL; 151 static const ARGB MediumSeaGreen = 0xFF3CB371UL; 152 static const ARGB MediumSlateBlue = 0xFF7B68EEUL; 153 static const ARGB MediumSpringGreen = 0xFF00FA9AUL; 154 static const ARGB MediumTurquoise = 0xFF48D1CCUL; 155 static const ARGB MediumVioletRed = 0xFFC71585UL; 156 static const ARGB MidnightBlue = 0xFF191970UL; 157 static const ARGB MintCream = 0xFFF5FFFAUL; 158 static const ARGB MistyRose = 0xFFFFE4E1UL; 159 static const ARGB Moccasin = 0xFFFFE4B5UL; 160 static const ARGB NavajoWhite = 0xFFFFDEADUL; 161 static const ARGB Navy = 0xFF000080UL; 162 static const ARGB OldLace = 0xFFFDF5E6UL; 163 static const ARGB Olive = 0xFF808000UL; 164 static const ARGB OliveDrab = 0xFF6B8E23UL; 165 static const ARGB Orange = 0xFFFFA500UL; 166 static const ARGB OrangeRed = 0xFFFF4500UL; 167 static const ARGB Orchid = 0xFFDA70D6UL; 168 static const ARGB PaleGoldenrod = 0xFFEEE8AAUL; 169 static const ARGB PaleGreen = 0xFF98FB98UL; 170 static const ARGB PaleTurquoise = 0xFFAFEEEEUL; 171 static const ARGB PaleVioletRed = 0xFFDB7093UL; 172 static const ARGB PapayaWhip = 0xFFFFEFD5UL; 173 static const ARGB PeachPuff = 0xFFFFDAB9UL; 174 static const ARGB Peru = 0xFFCD853FUL; 175 static const ARGB Pink = 0xFFFFC0CBUL; 176 static const ARGB Plum = 0xFFDDA0DDUL; 177 static const ARGB PowderBlue = 0xFFB0E0E6UL; 178 static const ARGB Purple = 0xFF800080UL; 179 static const ARGB Red = 0xFFFF0000UL; 180 static const ARGB RosyBrown = 0xFFBC8F8FUL; 181 static const ARGB RoyalBlue = 0xFF4169E1UL; 182 static const ARGB SaddleBrown = 0xFF8B4513UL; 183 static const ARGB Salmon = 0xFFFA8072UL; 184 static const ARGB SandyBrown = 0xFFF4A460UL; 185 static const ARGB SeaGreen = 0xFF2E8B57UL; 186 static const ARGB SeaShell = 0xFFFFF5EEUL; 187 static const ARGB Sienna = 0xFFA0522DUL; 188 static const ARGB Silver = 0xFFC0C0C0UL; 189 static const ARGB SkyBlue = 0xFF87CEEBUL; 190 static const ARGB SlateBlue = 0xFF6A5ACDUL; 191 static const ARGB SlateGray = 0xFF708090UL; 192 static const ARGB Snow = 0xFFFFFAFAUL; 193 static const ARGB SpringGreen = 0xFF00FF7FUL; 194 static const ARGB SteelBlue = 0xFF4682B4UL; 195 static const ARGB Tan = 0xFFD2B48CUL; 196 static const ARGB Teal = 0xFF008080UL; 197 static const ARGB Thistle = 0xFFD8BFD8UL; 198 static const ARGB Tomato = 0xFFFF6347UL; 199 static const ARGB Transparent = 0x00FFFFFFUL; 200 static const ARGB Turquoise = 0xFF40E0D0UL; 201 static const ARGB Violet = 0xFFEE82EEUL; 202 static const ARGB Wheat = 0xFFF5DEB3UL; 203 static const ARGB White = 0xFFFFFFFFUL; 204 static const ARGB WhiteSmoke = 0xFFF5F5F5UL; 205 static const ARGB Yellow = 0xFFFFFF00UL; 206 static const ARGB YellowGreen = 0xFF9ACD32UL; 207 ColorColor208 Color(): Value(0xFF000000) {} ColorColor209 Color(ARGB argb): Value(argb) {} ColorColor210 Color(BYTE r, BYTE g, BYTE b): Value(MakeARGB(0xFF, r, g, b)) {} ColorColor211 Color(BYTE a, BYTE r, BYTE g, BYTE b): Value(MakeARGB(a, r, g, b)) {} 212 GetAColor213 BYTE GetA() const 214 { 215 return (BYTE) (Value >> 24); 216 } GetAlphaColor217 BYTE GetAlpha() const 218 { 219 return (BYTE) (Value >> 24); 220 } GetBColor221 BYTE GetB() const 222 { 223 return (BYTE) Value; 224 } GetBlueColor225 BYTE GetBlue() const 226 { 227 return (BYTE) Value; 228 } GetGColor229 BYTE GetG() const 230 { 231 return (BYTE) (Value >> 8); 232 } GetGreenColor233 BYTE GetGreen() const 234 { 235 return (BYTE) (Value >> 8); 236 } GetRColor237 BYTE GetR() const 238 { 239 return (BYTE) (Value >> 16); 240 } GetRedColor241 BYTE GetRed() const 242 { 243 return (BYTE) (Value >> 16); 244 } GetValueColor245 ARGB GetValue() const 246 { 247 return Value; 248 } SetFromCOLORREFColor249 VOID SetFromCOLORREF(COLORREF rgb) 250 { 251 BYTE r = (BYTE) rgb; 252 BYTE g = (BYTE) (rgb >> 8); 253 BYTE b = (BYTE) (rgb >> 16); 254 Value = MakeARGB(0xFF, r, g, b); 255 } SetValueColor256 VOID SetValue(ARGB argb) 257 { 258 Value = argb; 259 } ToCOLORREFColor260 COLORREF ToCOLORREF() const 261 { 262 return RGB(GetRed(), GetGreen(), GetBlue()); 263 } 264 #endif /* __cplusplus */ 265 } Color; 266 267 #endif /* __GDIPLUS_COLOR_H */ 268