2

I imagine those System.Drawing.Brushes.SomeColor can eventually break down to some numbers, or vectors perhaps, such as 0 is black and 255 is white in a 8-bit gray scale representation.

So I am wondering is there any chance an integer can be converted to System.Drawing.Brushes.SomeColor? Or perhaps an integer array like (a,a,a), where int a = someNumber;

Thanks.

4

2 回答 2

4

您可以使用 Color.ToArgb 和 Color.FromArgb 将颜色值转换为整数:

int blueInt = System.Drawing.Color.Blue.ToArgb();
var colorBlue = System.Drawing.Color.FromArgb(blueInt);

您可以从如下颜色创建实心画笔:

SolidBrush sb = new SolidBrush(blueColor);
于 2014-08-19T20:48:41.013 回答
1

您不能直接转换整数,但可以从 RGB 集中创建一个:

Color.FromArgb( MSDN )

如您所料,将采用一组整数,一个用于红色,一个用于绿色,一个用于蓝色。该方法的不同重载允许您指定 alpha 值。

然后从颜色创建一个画笔:

Brush myBrush = new SolidBrush(myColor);

( MSDN )

于 2014-08-19T20:46:14.153 回答