Convert color to byte value

后端 未结 4 924
南方客
南方客 2021-01-28 15:28

In C#, how can I convert a Color object into a byte value?

For example, the color #FFF would be converted to the value 255

4条回答
  •  星月不相逢
    2021-01-28 16:00

    Try this,

    string colorcode = "#FFFFFF00";
    int argb = Int32.Parse(colorcode.Replace("#", ""), NumberStyles.HexNumber);
    Color clr = Color.FromArgb(argb);
    

    also see this How to get Color from Hexadecimal color code using .NET?

提交回复
热议问题