Colors: Hex to RGB

G

Gene

I've been reading the documentation on Colors in .NET (System.Drawing.Color,
System.Drawing.ColorConverter, System.Drawing.ColorTranslator), and so far
have found nothing that lets us use the hex value of a color (e.g.,
#FF00FF); rather, it appears to me that all Color members use or require
individual RGB decimal values. I'm happy to write something that converts
the hex values to the corresponding RGB values - but do I really have to
"roll my own" on this? Have I missed something - or can we really use hex
values or have some base class do the translation?

Thanks.
 
P

Paul E Collins

Gene said:
[using hex colour codes]

System.Web.UI.WebControls.WebColorConverter

From VS.NET Help:
"You can also specify a custom color by using a hexadecimal number, preceded
by the pound character (#), in the form #RRGGBB. RR, GG, and BB represent
hexadecimal values from 0 to 255 that indicate the red, green, and blue
components of a color, respectively."

P.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top