PixelArtUpscaler.Image.SVGDocument.String2Color C# (CSharp) Method

String2Color() private method

private String2Color ( string sColor ) : Color
sColor string
return Color
        internal Color String2Color(string sColor)
        {
            Color c;

            if (sColor.Length == 7 && sColor[0] == '#')
            {
                string s1 = sColor.Substring(1, 2);
                string s2 = sColor.Substring(3, 2);
                string s3 = sColor.Substring(5, 2);

                byte r = 0;
                byte g = 0;
                byte b = 0;

                try
                {
                    r = Convert.ToByte(s1, 16);
                    g = Convert.ToByte(s2, 16);
                    b = Convert.ToByte(s3, 16);
                }
                catch
                {
                }

                c = Color.FromArgb(r, g, b);
            }
            else
            {
                c = Color.FromName(sColor);
            }

            return c;
        }