C# Color值转换为unit

 

   由于C#没有RGB函数,所以在需要的时候我们该如何把想要的Color值转换成对应的unit值呢?

   RGB原理:RGB = R + G * 256 + B * 256 * 256

   根据该原理可以很简单的把color转换成unit值。

   在此为大家提供一个更高效的方法:

   C# Color值转换为unit_c#uint ParseRGB(Color color)
C# Color值转换为unit_c#_02C# Color值转换为unit_c#_03C# Color值转换为unit_c#_03{
C# Color值转换为unit_c#_05    return (uint)(((uint)color.B << 16) | (ushort)(((ushort)color.G << 8) | color.R));
C# Color值转换为unit_c#_06 }

    好了,就这样了!希望可以帮到大家!

 

Color.ToArgb()