Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a System.Drawing.Color from its hexadecimal RGB string?

I want to create a System.Drawing.Color from a value like #FF00FF or FF00FF without needing to write code for that. There is any .NET built-in parser for that?

like image 726
Jader Dias Avatar asked Dec 16 '09 12:12

Jader Dias


People also ask

How do you convert hex color to RGB?

Get the 2 left digits of the hex color code and convert to decimal value to get the red color level. Get the 2 middle digits of the hex color code and convert to decimal value to get the green color level. Get the 2 right digits of the hex color code and convert to decimal value to get the blue color level.


1 Answers

ColorTranslator.FromHtml("#FF00FF"); 
like image 79
João Angelo Avatar answered Sep 20 '22 20:09

João Angelo