How can I get a color from a hexadecimal color code (e.g. #FFDFD991
)?
I am reading a file and am getting a hexadecimal color code. I need to create the
Assuming you mean the HTML type RGB codes (called Hex codes, such as #FFCC66), use the ColorTranslator class:
System.Drawing.Color col = System.Drawing.ColorTranslator.FromHtml("#FFCC66");
If, however you are using an ARGB hex code, you can use the ColorConverter class from the System.Windows.Media namespace:
Color col = ColorConverter.ConvertFromString("#FFDFD991") as Color;
//or = (Color) ColorConverter.ConvertFromString("#FFCC66") ;