Tag: system.drawing.color

设置System.Drawing.Color值

您好如何在System.Drawing.Color.G设置RGB值? 这就像System.Drawing.Color.G=255; 不允许,因为它只读 Property or indexer 'System.Drawing.Color.G' cannot be assigned toit is read only 我只需要通过分配自定义RGB值来创build一个Color对象

如何从它的hexRGBstring创build一个System.Drawing.Color?

我想从像#FF00FF或FF00FF这样的值创build一个System.Drawing.Color ,而不需要为此编写代码。 有任何.NET内置的parsing器呢?

如何反转颜色/颜色?

我知道这不会直接颠倒一种颜色,只会“反对”它。 我想知道是否有人知道一个简单的方法(几行代码)来反转任何给定颜色的颜色? 目前,我有这个(这不完全是一个倒置的定义,因为如果我通过它灰色/灰色,它会返回一些非常相似的东西,例如127,127,127): const int RGBMAX = 255; Color InvertMeAColour(Color ColourToInvert) { return Color.FromArgb(RGBMAX – ColourToInvert.R, RGBMAX – ColourToInvert.G, RGBMAX – ColourToInvert.B); }

将System.Drawing.Color转换为RGB和hex值

使用C#我试图发展以下两个。 我这样做的方式可能会有一些问题,需要您的build议。 此外,我不知道是否有任何现有的方法来做同样的事情。 private static String HexConverter(System.Drawing.Color c) { String rtn = String.Empty; try { rtn = "#" + cRToString("X2") + cGToString("X2") + cBToString("X2"); } catch (Exception ex) { //doing nothing } return rtn; } private static String RGBConverter(System.Drawing.Color c) { String rtn = String.Empty; try { rtn = "RGB(" + cRToString() + "," + […]