How To convert HexaDecimal Color Code To Color Name

Posted by Hemanth.Sutapalli under C# on 11/19/2012 | Points: 10 | Views : 20082 | Status : [Member] | Replies : 2
Hi all,
Please Explain How To convert HexaDecimal Color Code To Color Name
Ex:#000000 to Black like that using C# Language..

Thanks&&Regards,
S.Hemanth




Responses

Posted by: Sandhyab on: 11/19/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
If you require color object from hex value use this code
protected void Page_Load(object sender, EventArgs e)

{
string hex="#FFFFFF";
Color color = System.Drawing.ColorTranslator.FromHtml(hex);
Response.Write(color);


}

Or, If You exactly want color name,Get all the color names, and put them in a dictionary using their hex value as the key. Check the dictionary to see if the hex value you are working with exists. If it does, get the value out of the dictionary and you have your color name.
Thanks & Regards

Hemanth.Sutapalli, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hemanth.Sutapalli on: 11/19/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Sandhyab ,
I want to get color name Like (Black color), above code output shows like this: Color [A=255, R=255, G=255, B=255]

Hemanth.Sutapalli, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response