您的位置:首页 > 其它

string 至 Color 转换演示示例:

2015-07-10 14:33 218 查看
string colorstr = "#FF4D4D4D";string hex = colorstr.ToString().Replace("#", "");byte alpha;byte pos = 0;if (hex.Length == 8){ alpha = System.Convert.ToByte(hex.Substring(pos, 2), 16); pos = 2;}else{ alpha = System.Convert.ToByte("ff", 16);}byte red = System.Convert.ToByte(hex.Substring(pos,
2), 16);pos += 2;byte green = System.Convert.ToByte(hex.Substring(pos, 2), 16);pos += 2;byte blue = System.Convert.ToByte(hex.Substring(pos, 2), 16);Color color = Color.FromArgb(alpha, red, green, blue);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: