ITPub博客

首页 > Linux操作系统 > Linux操作系统 > C#,silverlight中 将颜色字符串的RRGGBB转换成为颜色

C#,silverlight中 将颜色字符串的RRGGBB转换成为颜色

原创 Linux操作系统 作者:iDotNetSpace 时间:2010-03-24 13:12:46 0 删除 编辑
private Color ReturnColorFromString(string color)
        {
            
string alpha = color.Substring(0, 2);
            
string red = color.Substring(2, 2);
            
string green = color.Substring(4, 2);
            
string blue = color.Substring(6, 2);

            
byte alphaByte = Convert.ToByte(alpha, 16);
            
byte redByte = Convert.ToByte(red, 16);
            
byte greenByte = Convert.ToByte(green, 16);
            
byte blueByte = Convert.ToByte(blue, 16);
            
return Color.FromArgb(alphaByte, redByte, greenByte, blueByte);
        }

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12639172/viewspace-630293/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-01-04

  • 博文量
    2376
  • 访问量
    5769027