欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

将16进制颜色转换为RGB

最编程 2024-01-13 07:44:41
...

   rgb = "FFFFFF";


            var result = Regex.Matches(rgb, @"\w{2}");


            List<string> re = new List<string>();


            foreach (Match item in result)

            {

                re.Add(item.Value);

            }


            byte r = (byte)Convert.ToByte(re[0], 16);

            byte g = (byte)Convert.ToByte(re[1], 16);

            byte b = (byte)Convert.ToByte(re[2], 16);


            Color32 color = new Color32(r, g, b, 255);


推荐阅读