SIMIN Posted August 12, 2008 Posted August 12, 2008 Hi, How can I convert a color in a format like: Color [A=255, R=255, G=255, B=255] to a format like: #ffffff ??? Quote
MrPaul Posted August 12, 2008 Posted August 12, 2008 string.Format Ignoring the alpha component: string str = string.Format("#{0:x6}", color.ToArgb() & 0x00ffffff); Or in VB: Dim str As String = String.Format("#{0:x6}", color.ToArgb() And &H00FFFFFF) Good luck :cool: Quote Never trouble another for what you can do for yourself.
SIMIN Posted August 12, 2008 Author Posted August 12, 2008 Well, I think I was unable to clarify myself. I have a color in HTML format, like #ffffff for example. I wanna convert it to standard System.Drawing.Color format. So input is string, but output is NOT, output is RGB color format. Thanks. Quote
MrPaul Posted August 13, 2008 Posted August 13, 2008 Open wide... I wonder how many other people misinterpreted your post... never mind. Assuming the string is exactly the format "#ffffff", then this would work: color = Color.FromArgb(int.Parse(htmlString.Substring(1), System.Globalization.NumberStyles.HexNumber)); Information on all these types and methods are available in the MSDN help, and in the Object Browser. I suggest you use them. Good luck :cool: Quote Never trouble another for what you can do for yourself.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.