Skip to content

Instantly share code, notes, and snippets.


MichaC MichaCo

Block or report user

Report or block MichaCo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
MichaCo / ColorCodeTransform
Created May 6, 2015
The code transforms color codes which are 3 digits like "#000", 8 digits (with opacity) or named colors to a valid 6 digit hex code, using System.Drawing
View ColorCodeTransform
public static string ToHexadecimalColorCode(string color)
Color baseColor = ColorTranslator.FromHtml(color);
// if its a named color we can use the argb value to transform it to a hex
var argb = baseColor.ToArgb();
return ColorTranslator.ToHtml(Color.FromArgb(argb));
You can’t perform that action at this time.