相关疑难解决方法(0)

将颜色转换为ConsoleColor?

将a转换System.Drawing.Color为类似的最佳方法是什么System.ConsoleColor

c# console colors system.drawing.color

19
推荐指数
3
解决办法
2万
查看次数

C#将System.ConsoleColor转换为System.Drawing.Color

从这个答案我想知道是否有一种简单的方法来扭转这种方法

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;
}
Run Code Online (Sandbox Code Playgroud)

进入

public static System.Drawing.Color FromColor( System.ConsoleColor c)
{
    // ??
}
Run Code Online (Sandbox Code Playgroud)

c# colors

1
推荐指数
1
解决办法
1481
查看次数

标签 统计

c# ×2

colors ×2

console ×1

system.drawing.color ×1