More advanced color creation using RGB, alpha and web color settings

Posted by very nice on 7:13 AM with No comments
Creates a Color structure from the specified 8-bit color values (red, green, and blue). The alpha value is implicitly 255 (no transparency).[C#] Color myColor = Color.FromArgb(0, 255,125);
[Visual Basic]
Dim myColor As Color = Color.FromArgb(0, 255,125)
Creates a Color structure from the four ARGB component (alpha, red, green, and blue). Alpha is also known as transparency where 255 is totally solid and 0 is totally transparent.[C#]Color myColor = FromArgb(120, 0, 255,125);
[Visual Basic]
Dim myColor As Color = FromArgb(120, 0, 255,125)
Creates a Color from a 32-bit ARGB value. (alpha, red, green, and blue)[C#]Color myColor = Color.FromArgb(0x78FF0000);
[Visual Basic]
Dim myColor As Color = Color.FromArgb(&H78FF0000)
Creates a Color from the specified Color Name, but with the new specified alpha value, valid alpha values are between 0 through 255.[C#]Color myColor = Color.FromArgb(125,Color.Red);
[Visual Basic]
Dim myColor As Color = Color.FromArgb(125,Color.Red)
For converting a web color:If the color is "bgcolor="#388B7E" , replace # with 0x(for csharp) or &H (for visual basic), and add an alpha value between 0-7F after that, then add the rest. (0x7F388B7E or &H7F388B7E)[C#]Color myColor = Color.FromArgb(0x7F388B7E);
[Visual Basic]
Dim myColor As Color = Color.FromArgb(&H7F388B7E)