Color 结构
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示一种 ARGB 颜色(alpha、红色、绿色、蓝色)。
public value class Color : IEquatable<System::Drawing::Color>
public value class Color
[System.ComponentModel.TypeConverter("System.Drawing.ColorConverter, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public readonly struct Color : IEquatable<System.Drawing.Color>
public struct Color : IEquatable<System.Drawing.Color>
public readonly struct Color : IEquatable<System.Drawing.Color>
[System.ComponentModel.TypeConverter(typeof(System.Drawing.ColorConverter))]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public struct Color
[System.ComponentModel.TypeConverter(typeof(System.Drawing.ColorConverter))]
[System.Serializable]
public struct Color
public struct Color
[<System.ComponentModel.TypeConverter("System.Drawing.ColorConverter, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
type Color = struct
type Color = struct
[<System.ComponentModel.TypeConverter(typeof(System.Drawing.ColorConverter))>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type Color = struct
[<System.ComponentModel.TypeConverter(typeof(System.Drawing.ColorConverter))>]
[<System.Serializable>]
type Color = struct
Public Structure Color
Implements IEquatable(Of Color)
Public Structure Color
- 继承
- 属性
- 实现
示例
下面的代码示例演示 了 A和 成员的 Color、R、 GB 和 Implicit 属性。
此示例旨在与 Windows 窗体一起使用。 将代码粘贴到窗体中, ShowPropertiesOfSlateBlue 并从窗体的事件 Paint 处理方法调用 方法,作为 ePaintEventArgs传递。
void ShowPropertiesOfSlateBlue( PaintEventArgs^ e )
{
Color slateBlue = Color::FromName( "SlateBlue" );
Byte g = slateBlue.G;
Byte b = slateBlue.B;
Byte r = slateBlue.R;
Byte a = slateBlue.A;
array<Object^>^temp0 = {a,r,g,b};
String^ text = String::Format( "Slate Blue has these ARGB values: Alpha:{0}, "
"red:{1}, green: {2}, blue {3}", temp0 );
e->Graphics->DrawString( text, gcnew System::Drawing::Font( this->Font,FontStyle::Italic ), gcnew SolidBrush( slateBlue ), RectangleF(PointF(0.0F,0.0F),this->Size) );
}
private void ShowPropertiesOfSlateBlue(PaintEventArgs e)
{
Color slateBlue = Color.FromName("SlateBlue");
byte g = slateBlue.G;
byte b = slateBlue.B;
byte r = slateBlue.R;
byte a = slateBlue.A;
string text = String.Format("Slate Blue has these ARGB values: Alpha:{0}, " +
"red:{1}, green: {2}, blue {3}", new object[]{a, r, g, b});
e.Graphics.DrawString(text,
new Font(this.Font, FontStyle.Italic),
new SolidBrush(slateBlue),
new RectangleF(new PointF(0.0F, 0.0F), this.Size));
}
Private Sub ShowPropertiesOfSlateBlue(ByVal e As PaintEventArgs)
Dim slateBlue As Color = Color.FromName("SlateBlue")
Dim g As Byte = slateBlue.G
Dim b As Byte = slateBlue.B
Dim r As Byte = slateBlue.R
Dim a As Byte = slateBlue.A
Dim text As String = _
String.Format("Slate Blue has these ARGB values: Alpha:{0}, " _
& "red:{1}, green: {2}, blue {3}", New Object() {a, r, g, b})
e.Graphics.DrawString(text, New Font(Me.Font, FontStyle.Italic), _
New SolidBrush(slateBlue), _
New RectangleF(New PointF(0.0F, 0.0F), _
Size.op_Implicit(Me.Size)))
End Sub
注解
命名颜色通过使用 结构的属性 Color 来表示。
每个像素的颜色表示为 32 位数字:alpha、红色、绿色和蓝色各 8 位, (ARGB) 。 四个分量中的每一个都是一个从 0 到 255 的数字,其中 0 表示无强度,而 255 表示全强度。 Alpha 分量指定颜色的透明度:0 表示完全透明,255 表示完全不透明。 若要确定颜色的 alpha、红色、绿色或蓝色分量,请分别使用 A、 R、 G或 B 属性。 可以使用方法之 FromArgb 一创建自定义颜色。
有关这些颜色的详细信息,请参阅 按名称列出的颜色。
字段
| Empty |
表示值为 |
属性
| A |
获取此 Color 结构的 alpha 组件值。 |
| AliceBlue |
获取 ARGB 值为 的系统 |
| AntiqueWhite |
获取 ARGB 值为 的系统 |
| Aqua |
获取 ARGB 值为 的系统 |
| Aquamarine |
获取 ARGB 值为 的系统 |
| Azure |
获取 ARGB 值为 的系统 |
| B |
获取此 Color 结构的蓝色组件值。 |
| Beige |
获取 ARGB 值为 的系统 |
| Bisque |
获取 ARGB 值为 的系统 |
| Black |
获取 ARGB 值为 的系统 |
| BlanchedAlmond |
获取 ARGB 值为 的系统 |
| Blue |
获取 ARGB 值为 的系统 |
| BlueViolet |
获取 ARGB 值为 的系统 |
| Brown |
获取 ARGB 值为 的系统 |
| BurlyWood |
获取 ARGB 值为 的系统 |
| CadetBlue |
获取 ARGB 值为 的系统 |
| Chartreuse |
获取 ARGB 值为 的系统 |
| Chocolate |
获取 ARGB 值为 的系统 |
| Coral |
获取 ARGB 值为 的系统 |
| CornflowerBlue |
获取 ARGB 值为 的系统 |
| Cornsilk |
获取 ARGB 值为 的系统 |
| Crimson |
获取 ARGB 值为 的系统 |
| Cyan |
获取 ARGB 值为 的系统 |
| DarkBlue |
获取 ARGB 值为 的系统 |
| DarkCyan |
获取 ARGB 值为 的系统 |
| DarkGoldenrod |
获取 ARGB 值为 的系统 |
| DarkGray |
获取 ARGB 值为 的系统 |
| DarkGreen |
获取 ARGB 值为 的系统 |
| DarkKhaki |
获取 ARGB 值为 的系统 |
| DarkMagenta |
获取 ARGB 值为 的系统 |
| DarkOliveGreen |
获取 ARGB 值为 的系统 |
| DarkOrange |
获取 ARGB 值为 的系统 |
| DarkOrchid |
获取 ARGB 值为 的系统 |
| DarkRed |
获取 ARGB 值为 的系统 |
| DarkSalmon |
获取 ARGB 值为 的系统 |
| DarkSeaGreen |
获取 ARGB 值为 的系统 |
| DarkSlateBlue |
获取 ARGB 值为 的系统 |
| DarkSlateGray |
获取 ARGB 值为 的系统 |
| DarkTurquoise |
获取 ARGB 值为 的系统 |
| DarkViolet |
获取 ARGB 值为 的系统 |
| DeepPink |
获取 ARGB 值为 的系统 |
| DeepSkyBlue |
获取 ARGB 值为 的系统 |
| DimGray |
获取 ARGB 值为 的系统 |
| DodgerBlue |
获取 ARGB 值为 的系统 |
| Firebrick |
获取 ARGB 值为 的系统 |
| FloralWhite |
获取 ARGB 值为 的系统 |
| ForestGreen |
获取 ARGB 值为 的系统 |
| Fuchsia |
获取 ARGB 值为 的系统 |
| G |
获取此 Color 结构的绿色组件值。 |
| Gainsboro |
获取 ARGB 值为 的系统 |
| GhostWhite |
获取 ARGB 值为 的系统 |
| Gold |
获取 ARGB 值为 的系统 |
| Goldenrod |
获取 ARGB 值为 的系统 |
| Gray |
获取 ARGB 值为 的系统 |
| Green |
获取 ARGB 值为 的系统 |
| GreenYellow |
获取 ARGB 值为 的系统 |
| Honeydew |
获取 ARGB 值为 的系统 |
| HotPink |
获取 ARGB 值为 的系统 |
| IndianRed |
获取 ARGB 值为 的系统 |
| Indigo |
获取 ARGB 值为 的系统 |
| IsEmpty |
指定是否取消初始化此 Color 结构。 |
| IsKnownColor |
获取指示此 Color 结构是否为预定义颜色的值。 预定义颜色由 KnownColor 枚举的元素表示。 |
| IsNamedColor |
获取指示此 Color 结构是命名颜色还是 KnownColor 枚举成员的值。 |
| IsSystemColor |
获取指示此 Color 结构是否为系统颜色的值。 系统颜色是指 Windows 显示元素中使用的颜色。 系统颜色由 KnownColor 枚举的元素来表示。 |
| Ivory |
获取 ARGB 值为 的系统 |
| Khaki |
获取 ARGB 值为 的系统 |
| Lavender |
获取 ARGB 值为 的系统 |
| LavenderBlush |
获取 ARGB 值为 的系统 |
| LawnGreen |
获取 ARGB 值为 的系统 |
| LemonChiffon |
获取 ARGB 值为 的系统 |
| LightBlue |
获取 ARGB 值为 的系统 |
| LightCoral |
获取 ARGB 值为 的系统 |
| LightCyan |
获取 ARGB 值为 的系统 |
| LightGoldenrodYellow |
获取 ARGB 值为 的系统 |
| LightGray |
获取 ARGB 值为 的系统 |
| LightGreen |
获取 ARGB 值为 的系统 |
| LightPink |
获取 ARGB 值为 的系统 |
| LightSalmon |
获取 ARGB 值为 的系统 |
| LightSeaGreen |
获取 ARGB 值为 的系统 |
| LightSkyBlue |
获取 ARGB 值为 的系统 |
| LightSlateGray |
获取 ARGB 值为 的系统 |
| LightSteelBlue |
获取 ARGB 值为 的系统 |
| LightYellow |
获取 ARGB 值为 的系统 |
| Lime |
获取 ARGB 值为 的系统 |
| LimeGreen |
获取 ARGB 值为 的系统 |
| Linen |
获取 ARGB 值为 的系统 |
| Magenta |
获取 ARGB 值为 的系统 |
| Maroon |
获取 ARGB 值为 的系统 |
| MediumAquamarine |
获取 ARGB 值为 的系统 |
| MediumBlue |
获取 ARGB 值为 的系统 |
| MediumOrchid |
获取 ARGB 值为 的系统 |
| MediumPurple |
获取 ARGB 值为 的系统 |
| MediumSeaGreen |
获取 ARGB 值为 的系统 |
| MediumSlateBlue |
获取 ARGB 值为 的系统 |
| MediumSpringGreen |
获取 ARGB 值为 的系统 |
| MediumTurquoise |
获取 ARGB 值为 的系统 |
| MediumVioletRed |
获取 ARGB 值为 的系统 |
| MidnightBlue |
获取 ARGB 值为 的系统 |
| MintCream |
获取 ARGB 值为 的系统 |
| MistyRose |
获取 ARGB 值为 的系统 |
| Moccasin |
获取 ARGB 值为 的系统 |
| Name |
获取此 Color 的名称。 |
| NavajoWhite |
获取 ARGB 值为 的系统 |
| Navy |
获取 ARGB 值为 的系统 |
| OldLace |
获取 ARGB 值为 的系统 |
| Olive |
获取 ARGB 值为 的系统 |
| OliveDrab |
获取 ARGB 值为 的系统 |
| Orange |
获取 ARGB 值为 的系统 |
| OrangeRed |
获取 ARGB 值为 的系统 |
| Orchid |
获取 ARGB 值为 的系统 |
| PaleGoldenrod |
获取 ARGB 值为 的系统 |
| PaleGreen |
获取 ARGB 值为 的系统 |
| PaleTurquoise |
获取 ARGB 值为 的系统 |
| PaleVioletRed |
获取 ARGB 值为 的系统 |
| PapayaWhip |
获取 ARGB 值为 的系统 |
| PeachPuff |
获取 ARGB 值为 的系统 |
| Peru |
获取 ARGB 值为 的系统 |
| Pink |
获取 ARGB 值为 的系统 |
| Plum |
获取 ARGB 值为 的系统 |
| PowderBlue |
获取 ARGB 值为 的系统 |
| Purple |
获取 ARGB 值为 的系统 |
| R |
获取此 Color 结构的红色组件值。 |
| RebeccaPurple |
获取 ARGB 值为 的系统 |
| Red |
获取 ARGB 值为 的系统 |
| RosyBrown |
获取 ARGB 值为 的系统 |
| RoyalBlue |
获取 ARGB 值为 的系统 |
| SaddleBrown |
获取 ARGB 值为 的系统 |
| Salmon |
获取 ARGB 值为 的系统 |
| SandyBrown |
获取 ARGB 值为 的系统 |
| SeaGreen |
获取 ARGB 值为 的系统 |
| SeaShell |
获取 ARGB 值为 的系统 |
| Sienna |
获取 ARGB 值为 的系统 |
| Silver |
获取 ARGB 值为 的系统 |
| SkyBlue |
获取 ARGB 值为 的系统 |
| SlateBlue |
获取 ARGB 值为 的系统 |
| SlateGray |
获取 ARGB 值为 的系统 |
| Snow |
获取 ARGB 值为 的系统 |
| SpringGreen |
获取 ARGB 值为 的系统 |
| SteelBlue |
获取 ARGB 值为 的系统 |
| Tan |
获取 ARGB 值为 的系统 |
| Teal |
获取 ARGB 值为 的系统 |
| Thistle |
获取 ARGB 值为 的系统 |
| Tomato |
获取 ARGB 值为 的系统 |
| Transparent |
获取系统定义的颜色。 |
| Turquoise |
获取 ARGB 值为 的系统 |
| Violet |
获取 ARGB 值为 的系统 |
| Wheat |
获取 ARGB 值为 的系统 |
| White |
获取 ARGB 值为 的系统 |
| WhiteSmoke |
获取 ARGB 值为 的系统 |
| Yellow |
获取 ARGB 值为 的系统 |
| YellowGreen |
获取 ARGB 值为 的系统 |
方法
| Equals(Color) |
指示当前对象是否等于同一类型的另一个对象。 |
| Equals(Object) | |
| FromArgb(Int32) |
基于一个 32 位 ARGB 值创建 Color 结构。 |
| FromArgb(Int32, Color) |
从指定的 Color 结构创建 Color 结构,但要使用新指定的 alpha 值。 尽管此方法允许为 alpha 值传递 32 位值,但该值仅限于 8 位。 |
| FromArgb(Int32, Int32, Int32) |
基于指定的 8 位颜色值(红色、绿色和蓝色)创建 Color 结构。 隐式的 alpha 值为 255(完全不透明)。 尽管此方法允许为每个颜色组件传递 32 位值,但每个组件的值仅限于 8 位。 |
| FromArgb(Int32, Int32, Int32, Int32) |
基于四个 ARGB 组件(alpha、红色、绿色和蓝色)值创建 Color 结构。 尽管此方法允许为每个组件传递 32 位值,但每个组件的值仅限于 8 位。 |
| FromKnownColor(KnownColor) |
基于指定的预定义颜色创建 Color 结构。 |
| FromName(String) |
基于预定义颜色的指定名称创建 Color 结构。 |
| GetBrightness() |
获取此 Color 结构的“色调-饱和度-亮度”(HSL) 的亮度值。 |
| GetHashCode() |
返回此 Color 结构的哈希代码。 |
| GetHue() |
获取此 Color 结构的“色调-饱和度-亮度”(HSL) 的色调值,以度为单位。 |
| GetSaturation() |
获取此 Color 结构的“色调-饱和度-亮度”(HSL) 的饱和度值。 |
| ToArgb() |
获取此 Color 结构的 32 位 ARGB 值。 |
| ToKnownColor() |
获取此 Color 结构的 KnownColor 值。 |
| ToString() |
将此 Color 结构转换为用户可读的字符串。 |
运算符
| Equality(Color, Color) |
测试两个指定的 Color 结构是否等效。 |
| Inequality(Color, Color) |
测试两个指定的 Color 结构是否不同。 |