Color Color Color Color Struct
Definition
Represents an ARGB (alpha, red, green, blue) color.
public value class Color
[System.ComponentModel.TypeConverter(typeof(System.Drawing.ColorConverter))]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public struct Color
type Color = struct
Public Structure Color
- Inheritance
- Attributes
Examples
The following code example demonstrates the A, R, G, and B properties of a Color, and the Implicit member.
This example is designed to be used with a Windows Form. Paste the code into the form and call the ShowPropertiesOfSlateBlue
method from the form's Paint event-handling method, passing e
as PaintEventArgs.
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
Remarks
Named colors are represented by using the properties of the Color structure. For more information about these colors, see Colors by Name.
The color of each pixel is represented as a 32-bit number: 8 bits each for alpha, red, green, and blue (ARGB). Each of the four components is a number from 0 through 255, with 0 representing no intensity and 255 representing full intensity. The alpha component specifies the transparency of the color: 0 is fully transparent, and 255 is fully opaque. To determine the alpha, red, green, or blue component of a color, use the A, R, G, or B property, respectively. You can create a custom color by using one of the FromArgb methods.
Fields
Empty Empty Empty Empty |
Represents a color that is |
Properties
A A A A |
Gets the alpha component value of this Color structure. |
AliceBlue AliceBlue AliceBlue AliceBlue |
Gets a system-defined color that has an ARGB value of |
AntiqueWhite AntiqueWhite AntiqueWhite AntiqueWhite |
Gets a system-defined color that has an ARGB value of |
Aqua Aqua Aqua Aqua |
Gets a system-defined color that has an ARGB value of |
Aquamarine Aquamarine Aquamarine Aquamarine |
Gets a system-defined color that has an ARGB value of |
Azure Azure Azure Azure |
Gets a system-defined color that has an ARGB value of |
B B B B |
Gets the blue component value of this Color structure. |
Beige Beige Beige Beige |
Gets a system-defined color that has an ARGB value of |
Bisque Bisque Bisque Bisque |
Gets a system-defined color that has an ARGB value of |
Black Black Black Black |
Gets a system-defined color that has an ARGB value of |
BlanchedAlmond BlanchedAlmond BlanchedAlmond BlanchedAlmond |
Gets a system-defined color that has an ARGB value of |
Blue Blue Blue Blue |
Gets a system-defined color that has an ARGB value of |
BlueViolet BlueViolet BlueViolet BlueViolet |
Gets a system-defined color that has an ARGB value of |
Brown Brown Brown Brown |
Gets a system-defined color that has an ARGB value of |
BurlyWood BurlyWood BurlyWood BurlyWood |
Gets a system-defined color that has an ARGB value of |
CadetBlue CadetBlue CadetBlue CadetBlue |
Gets a system-defined color that has an ARGB value of |
Chartreuse Chartreuse Chartreuse Chartreuse |
Gets a system-defined color that has an ARGB value of |
Chocolate Chocolate Chocolate Chocolate |
Gets a system-defined color that has an ARGB value of |
Coral Coral Coral Coral |
Gets a system-defined color that has an ARGB value of |
CornflowerBlue CornflowerBlue CornflowerBlue CornflowerBlue |
Gets a system-defined color that has an ARGB value of |
Cornsilk Cornsilk Cornsilk Cornsilk |
Gets a system-defined color that has an ARGB value of |
Crimson Crimson Crimson Crimson |
Gets a system-defined color that has an ARGB value of |
Cyan Cyan Cyan Cyan |
Gets a system-defined color that has an ARGB value of |
DarkBlue DarkBlue DarkBlue DarkBlue |
Gets a system-defined color that has an ARGB value of |
DarkCyan DarkCyan DarkCyan DarkCyan |
Gets a system-defined color that has an ARGB value of |
DarkGoldenrod DarkGoldenrod DarkGoldenrod DarkGoldenrod |
Gets a system-defined color that has an ARGB value of |
DarkGray DarkGray DarkGray DarkGray |
Gets a system-defined color that has an ARGB value of |
DarkGreen DarkGreen DarkGreen DarkGreen |
Gets a system-defined color that has an ARGB value of |
DarkKhaki DarkKhaki DarkKhaki DarkKhaki |
Gets a system-defined color that has an ARGB value of |
DarkMagenta DarkMagenta DarkMagenta DarkMagenta |
Gets a system-defined color that has an ARGB value of |
DarkOliveGreen DarkOliveGreen DarkOliveGreen DarkOliveGreen |
Gets a system-defined color that has an ARGB value of |
DarkOrange DarkOrange DarkOrange DarkOrange |
Gets a system-defined color that has an ARGB value of |
DarkOrchid DarkOrchid DarkOrchid DarkOrchid |
Gets a system-defined color that has an ARGB value of |
DarkRed DarkRed DarkRed DarkRed |
Gets a system-defined color that has an ARGB value of |
DarkSalmon DarkSalmon DarkSalmon DarkSalmon |
Gets a system-defined color that has an ARGB value of |
DarkSeaGreen DarkSeaGreen DarkSeaGreen DarkSeaGreen |
Gets a system-defined color that has an ARGB value of |
DarkSlateBlue DarkSlateBlue DarkSlateBlue DarkSlateBlue |
Gets a system-defined color that has an ARGB value of |
DarkSlateGray DarkSlateGray DarkSlateGray DarkSlateGray |
Gets a system-defined color that has an ARGB value of |
DarkTurquoise DarkTurquoise DarkTurquoise DarkTurquoise |
Gets a system-defined color that has an ARGB value of |
DarkViolet DarkViolet DarkViolet DarkViolet |
Gets a system-defined color that has an ARGB value of |
DeepPink DeepPink DeepPink DeepPink |
Gets a system-defined color that has an ARGB value of |
DeepSkyBlue DeepSkyBlue DeepSkyBlue DeepSkyBlue |
Gets a system-defined color that has an ARGB value of |
DimGray DimGray DimGray DimGray |
Gets a system-defined color that has an ARGB value of |
DodgerBlue DodgerBlue DodgerBlue DodgerBlue |
Gets a system-defined color that has an ARGB value of |
Firebrick Firebrick Firebrick Firebrick |
Gets a system-defined color that has an ARGB value of |
FloralWhite FloralWhite FloralWhite FloralWhite |
Gets a system-defined color that has an ARGB value of |
ForestGreen ForestGreen ForestGreen ForestGreen |
Gets a system-defined color that has an ARGB value of |
Fuchsia Fuchsia Fuchsia Fuchsia |
Gets a system-defined color that has an ARGB value of |
G G G G |
Gets the green component value of this Color structure. |
Gainsboro Gainsboro Gainsboro Gainsboro |
Gets a system-defined color that has an ARGB value of |
GhostWhite GhostWhite GhostWhite GhostWhite |
Gets a system-defined color that has an ARGB value of |
Gold Gold Gold Gold |
Gets a system-defined color that has an ARGB value of |
Goldenrod Goldenrod Goldenrod Goldenrod |
Gets a system-defined color that has an ARGB value of |
Gray Gray Gray Gray |
Gets a system-defined color that has an ARGB value of |
Green Green Green Green |
Gets a system-defined color that has an ARGB value of |
GreenYellow GreenYellow GreenYellow GreenYellow |
Gets a system-defined color that has an ARGB value of |
Honeydew Honeydew Honeydew Honeydew |
Gets a system-defined color that has an ARGB value of |
HotPink HotPink HotPink HotPink |
Gets a system-defined color that has an ARGB value of |
IndianRed IndianRed IndianRed IndianRed |
Gets a system-defined color that has an ARGB value of |
Indigo Indigo Indigo Indigo |
Gets a system-defined color that has an ARGB value of |
IsEmpty IsEmpty IsEmpty IsEmpty |
Specifies whether this Color structure is uninitialized. |
IsKnownColor IsKnownColor IsKnownColor IsKnownColor |
Gets a value indicating whether this Color structure is a predefined color. Predefined colors are represented by the elements of the KnownColor enumeration. |
IsNamedColor IsNamedColor IsNamedColor IsNamedColor |
Gets a value indicating whether this Color structure is a named color or a member of the KnownColor enumeration. |
IsSystemColor IsSystemColor IsSystemColor IsSystemColor |
Gets a value indicating whether this Color structure is a system color. A system color is a color that is used in a Windows display element. System colors are represented by elements of the KnownColor enumeration. |
Ivory Ivory Ivory Ivory |
Gets a system-defined color that has an ARGB value of |
Khaki Khaki Khaki Khaki |
Gets a system-defined color that has an ARGB value of |
Lavender Lavender Lavender Lavender |
Gets a system-defined color that has an ARGB value of |
LavenderBlush LavenderBlush LavenderBlush LavenderBlush |
Gets a system-defined color that has an ARGB value of |
LawnGreen LawnGreen LawnGreen LawnGreen |
Gets a system-defined color that has an ARGB value of |
LemonChiffon LemonChiffon LemonChiffon LemonChiffon |
Gets a system-defined color that has an ARGB value of |
LightBlue LightBlue LightBlue LightBlue |
Gets a system-defined color that has an ARGB value of |
LightCoral LightCoral LightCoral LightCoral |
Gets a system-defined color that has an ARGB value of |
LightCyan LightCyan LightCyan LightCyan |
Gets a system-defined color that has an ARGB value of |
LightGoldenrodYellow LightGoldenrodYellow LightGoldenrodYellow LightGoldenrodYellow |
Gets a system-defined color that has an ARGB value of |
LightGray LightGray LightGray LightGray |
Gets a system-defined color that has an ARGB value of |
LightGreen LightGreen LightGreen LightGreen |
Gets a system-defined color that has an ARGB value of |
LightPink LightPink LightPink LightPink |
Gets a system-defined color that has an ARGB value of |
LightSalmon LightSalmon LightSalmon LightSalmon |
Gets a system-defined color that has an ARGB value of |
LightSeaGreen LightSeaGreen LightSeaGreen LightSeaGreen |
Gets a system-defined color that has an ARGB value of |
LightSkyBlue LightSkyBlue LightSkyBlue LightSkyBlue |
Gets a system-defined color that has an ARGB value of |
LightSlateGray LightSlateGray LightSlateGray LightSlateGray |
Gets a system-defined color that has an ARGB value of |
LightSteelBlue LightSteelBlue LightSteelBlue LightSteelBlue |
Gets a system-defined color that has an ARGB value of |
LightYellow LightYellow LightYellow LightYellow |
Gets a system-defined color that has an ARGB value of |
Lime Lime Lime Lime |
Gets a system-defined color that has an ARGB value of |
LimeGreen LimeGreen LimeGreen LimeGreen |
Gets a system-defined color that has an ARGB value of |
Linen Linen Linen Linen |
Gets a system-defined color that has an ARGB value of |
Magenta Magenta Magenta Magenta |
Gets a system-defined color that has an ARGB value of |
Maroon Maroon Maroon Maroon |
Gets a system-defined color that has an ARGB value of |
MediumAquamarine MediumAquamarine MediumAquamarine MediumAquamarine |
Gets a system-defined color that has an ARGB value of |
MediumBlue MediumBlue MediumBlue MediumBlue |
Gets a system-defined color that has an ARGB value of |
MediumOrchid MediumOrchid MediumOrchid MediumOrchid |
Gets a system-defined color that has an ARGB value of |
MediumPurple MediumPurple MediumPurple MediumPurple |
Gets a system-defined color that has an ARGB value of |
MediumSeaGreen MediumSeaGreen MediumSeaGreen MediumSeaGreen |
Gets a system-defined color that has an ARGB value of |
MediumSlateBlue MediumSlateBlue MediumSlateBlue MediumSlateBlue |
Gets a system-defined color that has an ARGB value of |
MediumSpringGreen MediumSpringGreen MediumSpringGreen MediumSpringGreen |
Gets a system-defined color that has an ARGB value of |
MediumTurquoise MediumTurquoise MediumTurquoise MediumTurquoise |
Gets a system-defined color that has an ARGB value of |
MediumVioletRed MediumVioletRed MediumVioletRed MediumVioletRed |
Gets a system-defined color that has an ARGB value of |
MidnightBlue MidnightBlue MidnightBlue MidnightBlue |
Gets a system-defined color that has an ARGB value of |
MintCream MintCream MintCream MintCream |
Gets a system-defined color that has an ARGB value of |
MistyRose MistyRose MistyRose MistyRose |
Gets a system-defined color that has an ARGB value of |
Moccasin Moccasin Moccasin Moccasin |
Gets a system-defined color that has an ARGB value of |
Name Name Name Name |
Gets the name of this Color. |
NavajoWhite NavajoWhite NavajoWhite NavajoWhite |
Gets a system-defined color that has an ARGB value of |
Navy Navy Navy Navy |
Gets a system-defined color that has an ARGB value of |
OldLace OldLace OldLace OldLace |
Gets a system-defined color that has an ARGB value of |
Olive Olive Olive Olive |
Gets a system-defined color that has an ARGB value of |
OliveDrab OliveDrab OliveDrab OliveDrab |
Gets a system-defined color that has an ARGB value of |
Orange Orange Orange Orange |
Gets a system-defined color that has an ARGB value of |
OrangeRed OrangeRed OrangeRed OrangeRed |
Gets a system-defined color that has an ARGB value of |
Orchid Orchid Orchid Orchid |
Gets a system-defined color that has an ARGB value of |
PaleGoldenrod PaleGoldenrod PaleGoldenrod PaleGoldenrod |
Gets a system-defined color that has an ARGB value of |
PaleGreen PaleGreen PaleGreen PaleGreen |
Gets a system-defined color that has an ARGB value of |
PaleTurquoise PaleTurquoise PaleTurquoise PaleTurquoise |
Gets a system-defined color that has an ARGB value of |
PaleVioletRed PaleVioletRed PaleVioletRed PaleVioletRed |
Gets a system-defined color that has an ARGB value of |
PapayaWhip PapayaWhip PapayaWhip PapayaWhip |
Gets a system-defined color that has an ARGB value of |
PeachPuff PeachPuff PeachPuff PeachPuff |
Gets a system-defined color that has an ARGB value of |
Peru Peru Peru Peru |
Gets a system-defined color that has an ARGB value of |
Pink Pink Pink Pink |
Gets a system-defined color that has an ARGB value of |
Plum Plum Plum Plum |
Gets a system-defined color that has an ARGB value of |
PowderBlue PowderBlue PowderBlue PowderBlue |
Gets a system-defined color that has an ARGB value of |
Purple Purple Purple Purple |
Gets a system-defined color that has an ARGB value of |
R R R R |
Gets the red component value of this Color structure. |
Red Red Red Red |
Gets a system-defined color that has an ARGB value of |
RosyBrown RosyBrown RosyBrown RosyBrown |
Gets a system-defined color that has an ARGB value of |
RoyalBlue RoyalBlue RoyalBlue RoyalBlue |
Gets a system-defined color that has an ARGB value of |
SaddleBrown SaddleBrown SaddleBrown SaddleBrown |
Gets a system-defined color that has an ARGB value of |
Salmon Salmon Salmon Salmon |
Gets a system-defined color that has an ARGB value of |
SandyBrown SandyBrown SandyBrown SandyBrown |
Gets a system-defined color that has an ARGB value of |
SeaGreen SeaGreen SeaGreen SeaGreen |
Gets a system-defined color that has an ARGB value of |
SeaShell SeaShell SeaShell SeaShell |
Gets a system-defined color that has an ARGB value of |
Sienna Sienna Sienna Sienna |
Gets a system-defined color that has an ARGB value of |
Silver Silver Silver Silver |
Gets a system-defined color that has an ARGB value of |
SkyBlue SkyBlue SkyBlue SkyBlue |
Gets a system-defined color that has an ARGB value of |
SlateBlue SlateBlue SlateBlue SlateBlue |
Gets a system-defined color that has an ARGB value of |
SlateGray SlateGray SlateGray SlateGray |
Gets a system-defined color that has an ARGB value of |
Snow Snow Snow Snow |
Gets a system-defined color that has an ARGB value of |
SpringGreen SpringGreen SpringGreen SpringGreen |
Gets a system-defined color that has an ARGB value of |
SteelBlue SteelBlue SteelBlue SteelBlue |
Gets a system-defined color that has an ARGB value of |
Tan Tan Tan Tan |
Gets a system-defined color that has an ARGB value of |
Teal Teal Teal Teal |
Gets a system-defined color that has an ARGB value of |
Thistle Thistle Thistle Thistle |
Gets a system-defined color that has an ARGB value of |
Tomato Tomato Tomato Tomato |
Gets a system-defined color that has an ARGB value of |
Transparent Transparent Transparent Transparent |
Gets a system-defined color. |
Turquoise Turquoise Turquoise Turquoise |
Gets a system-defined color that has an ARGB value of |
Violet Violet Violet Violet |
Gets a system-defined color that has an ARGB value of |
Wheat Wheat Wheat Wheat |
Gets a system-defined color that has an ARGB value of |
White White White White |
Gets a system-defined color that has an ARGB value of |
WhiteSmoke WhiteSmoke WhiteSmoke WhiteSmoke |
Gets a system-defined color that has an ARGB value of |
Yellow Yellow Yellow Yellow |
Gets a system-defined color that has an ARGB value of |
YellowGreen YellowGreen YellowGreen YellowGreen |
Gets a system-defined color that has an ARGB value of |
Methods
Equals(Color) Equals(Color) Equals(Color) Equals(Color) | |
Equals(Object) Equals(Object) Equals(Object) Equals(Object) |
Tests whether the specified object is a Color structure and is equivalent to this Color structure. |
FromArgb(Int32, Int32, Int32, Int32) FromArgb(Int32, Int32, Int32, Int32) FromArgb(Int32, Int32, Int32, Int32) FromArgb(Int32, Int32, Int32, Int32) |
Creates a Color structure from the four ARGB component (alpha, red, green, and blue) values. Although this method allows a 32-bit value to be passed for each component, the value of each component is limited to 8 bits. |
FromArgb(Int32, Int32, Int32) FromArgb(Int32, Int32, Int32) FromArgb(Int32, Int32, Int32) FromArgb(Int32, Int32, Int32) |
Creates a Color structure from the specified 8-bit color values (red, green, and blue). The alpha value is implicitly 255 (fully opaque). Although this method allows a 32-bit value to be passed for each color component, the value of each component is limited to 8 bits. |
FromArgb(Int32, Color) FromArgb(Int32, Color) FromArgb(Int32, Color) FromArgb(Int32, Color) |
Creates a Color structure from the specified Color structure, but with the new specified alpha value. Although this method allows a 32-bit value to be passed for the alpha value, the value is limited to 8 bits. |
FromArgb(Int32) FromArgb(Int32) FromArgb(Int32) FromArgb(Int32) |
Creates a Color structure from a 32-bit ARGB value. |
FromKnownColor(KnownColor) FromKnownColor(KnownColor) FromKnownColor(KnownColor) FromKnownColor(KnownColor) |
Creates a Color structure from the specified predefined color. |
FromName(String) FromName(String) FromName(String) FromName(String) |
Creates a Color structure from the specified name of a predefined color. |
GetBrightness() GetBrightness() GetBrightness() GetBrightness() |
Gets the hue-saturation-lightness (HSL) lightness value for this Color structure. |
GetHashCode() GetHashCode() GetHashCode() GetHashCode() |
Returns a hash code for this Color structure. |
GetHue() GetHue() GetHue() GetHue() |
Gets the hue-saturation-lightness (HSL) hue value, in degrees, for this Color structure. |
GetSaturation() GetSaturation() GetSaturation() GetSaturation() |
Gets the hue-saturation-lightness (HSL) saturation value for this Color structure. |
ToArgb() ToArgb() ToArgb() ToArgb() |
Gets the 32-bit ARGB value of this Color structure. |
ToKnownColor() ToKnownColor() ToKnownColor() ToKnownColor() |
Gets the KnownColor value of this Color structure. |
ToString() ToString() ToString() ToString() |
Converts this Color structure to a human-readable string. |
Operators
Equality(Color, Color) Equality(Color, Color) Equality(Color, Color) Equality(Color, Color) |
Tests whether two specified Color structures are equivalent. |
Inequality(Color, Color) Inequality(Color, Color) Inequality(Color, Color) Inequality(Color, Color) |
Tests whether two specified Color structures are different. |
Applies to
See also
Feedback
We'd love to hear your thoughts. Choose the type you'd like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.
Loading feedback...