【发布时间】:2016-02-19 20:46:57
【问题描述】:
来自answer,我想知道是否有一种简单的方法可以扭转这种方法
public static System.ConsoleColor FromColor(System.Drawing.Color c)
{
int index = (c.R > 128 | c.G > 128 | c.B > 128) ? 8 : 0; // Bright bit
index |= (c.R > 64) ? 4 : 0; // Red bit
index |= (c.G > 64) ? 2 : 0; // Green bit
index |= (c.B > 64) ? 1 : 0; // Blue bit
return (System.ConsoleColor)index;
}
进入
public static System.Drawing.Color FromColor( System.ConsoleColor c)
{
// ??
}
【问题讨论】:
-
你检查过这个吗:stackoverflow.com/questions/21092421/… 虽然它在 VB.NET 但应该给你一个线索!