问题
I use C# and asp.net 4.
How to convert and Hexadecimal Color in an equivalent RGB Color?
Example: FF0000 to 255,0,0.
My aim is to pass this color to the method FromArgb namespace System.Drawing
FromArgb Method (Int32, Int32, Int32) (Alpha is implicit as opaque)
At the moment I use this code to Clear and Image and apply a opaque flat color:
System.Drawing.Graphics.Clear(System.Drawing.Color.Red));
This works fine with predefined color like "Red", "Black" and so on, but not obviously with a Custom more precise color.
Any ideas? Thanks for your help!
Resource:
http://msdn.microsoft.com/en-us/library/cce5h557.aspx
http://msdn.microsoft.com/en-us/library/system.drawing.color.aspx
回答1:
Why don't you just do this?
System.Drawing.Color myColor = System.Drawing.Color.FromArgb(0xFF0000);
回答2:
This answer may help: C# convert integer to hex and back again
来源:https://stackoverflow.com/questions/5553673/how-to-convert-hexadecimal-color-to-rgb-color-24-bit