How do I get the color from a hexadecimal color code using .NET?

前端 未结 16 801
不思量自难忘°
不思量自难忘° 2020-11-22 06:45

How can I get a color from a hexadecimal color code (e.g. #FFDFD991)?

I am reading a file and am getting a hexadecimal color code. I need to create the

16条回答
  •  太阳男子
    2020-11-22 06:53

    If you want to do it with a Windows Store App, following by @Hans Kesting and @Jink answer:

        string colorcode = "#FFEEDDCC";
        int argb = Int32.Parse(colorcode.Replace("#", ""), NumberStyles.HexNumber);
        tData.DefaultData = Color.FromArgb((byte)((argb & -16777216) >> 0x18),
                              (byte)((argb & 0xff0000) >> 0x10),
                              (byte)((argb & 0xff00) >> 8),
                              (byte)(argb & 0xff));
    

提交回复
热议问题