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)]
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 null.

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 #FFF0F8FF.

AntiqueWhite AntiqueWhite AntiqueWhite AntiqueWhite

Gets a system-defined color that has an ARGB value of #FFFAEBD7.

Aqua Aqua Aqua Aqua

Gets a system-defined color that has an ARGB value of #FF00FFFF.

Aquamarine Aquamarine Aquamarine Aquamarine

Gets a system-defined color that has an ARGB value of #FF7FFFD4.

Azure Azure Azure Azure

Gets a system-defined color that has an ARGB value of #FFF0FFFF.

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 #FFF5F5DC.

Bisque Bisque Bisque Bisque

Gets a system-defined color that has an ARGB value of #FFFFE4C4.

Black Black Black Black

Gets a system-defined color that has an ARGB value of #FF000000.

BlanchedAlmond BlanchedAlmond BlanchedAlmond BlanchedAlmond

Gets a system-defined color that has an ARGB value of #FFFFEBCD.

Blue Blue Blue Blue

Gets a system-defined color that has an ARGB value of #FF0000FF.

BlueViolet BlueViolet BlueViolet BlueViolet

Gets a system-defined color that has an ARGB value of #FF8A2BE2.

Brown Brown Brown Brown

Gets a system-defined color that has an ARGB value of #FFA52A2A.

BurlyWood BurlyWood BurlyWood BurlyWood

Gets a system-defined color that has an ARGB value of #FFDEB887.

CadetBlue CadetBlue CadetBlue CadetBlue

Gets a system-defined color that has an ARGB value of #FF5F9EA0.

Chartreuse Chartreuse Chartreuse Chartreuse

Gets a system-defined color that has an ARGB value of #FF7FFF00.

Chocolate Chocolate Chocolate Chocolate

Gets a system-defined color that has an ARGB value of #FFD2691E.

Coral Coral Coral Coral

Gets a system-defined color that has an ARGB value of #FFFF7F50.

CornflowerBlue CornflowerBlue CornflowerBlue CornflowerBlue

Gets a system-defined color that has an ARGB value of #FF6495ED.

Cornsilk Cornsilk Cornsilk Cornsilk

Gets a system-defined color that has an ARGB value of #FFFFF8DC.

Crimson Crimson Crimson Crimson

Gets a system-defined color that has an ARGB value of #FFDC143C.

Cyan Cyan Cyan Cyan

Gets a system-defined color that has an ARGB value of #FF00FFFF.

DarkBlue DarkBlue DarkBlue DarkBlue

Gets a system-defined color that has an ARGB value of #FF00008B.

DarkCyan DarkCyan DarkCyan DarkCyan

Gets a system-defined color that has an ARGB value of #FF008B8B.

DarkGoldenrod DarkGoldenrod DarkGoldenrod DarkGoldenrod

Gets a system-defined color that has an ARGB value of #FFB8860B.

DarkGray DarkGray DarkGray DarkGray

Gets a system-defined color that has an ARGB value of #FFA9A9A9.

DarkGreen DarkGreen DarkGreen DarkGreen

Gets a system-defined color that has an ARGB value of #FF006400.

DarkKhaki DarkKhaki DarkKhaki DarkKhaki

Gets a system-defined color that has an ARGB value of #FFBDB76B.

DarkMagenta DarkMagenta DarkMagenta DarkMagenta

Gets a system-defined color that has an ARGB value of #FF8B008B.

DarkOliveGreen DarkOliveGreen DarkOliveGreen DarkOliveGreen

Gets a system-defined color that has an ARGB value of #FF556B2F.

DarkOrange DarkOrange DarkOrange DarkOrange

Gets a system-defined color that has an ARGB value of #FFFF8C00.

DarkOrchid DarkOrchid DarkOrchid DarkOrchid

Gets a system-defined color that has an ARGB value of #FF9932CC.

DarkRed DarkRed DarkRed DarkRed

Gets a system-defined color that has an ARGB value of #FF8B0000.

DarkSalmon DarkSalmon DarkSalmon DarkSalmon

Gets a system-defined color that has an ARGB value of #FFE9967A.

DarkSeaGreen DarkSeaGreen DarkSeaGreen DarkSeaGreen

Gets a system-defined color that has an ARGB value of #FF8FBC8F.

DarkSlateBlue DarkSlateBlue DarkSlateBlue DarkSlateBlue

Gets a system-defined color that has an ARGB value of #FF483D8B.

DarkSlateGray DarkSlateGray DarkSlateGray DarkSlateGray

Gets a system-defined color that has an ARGB value of #FF2F4F4F.

DarkTurquoise DarkTurquoise DarkTurquoise DarkTurquoise

Gets a system-defined color that has an ARGB value of #FF00CED1.

DarkViolet DarkViolet DarkViolet DarkViolet

Gets a system-defined color that has an ARGB value of #FF9400D3.

DeepPink DeepPink DeepPink DeepPink

Gets a system-defined color that has an ARGB value of #FFFF1493.

DeepSkyBlue DeepSkyBlue DeepSkyBlue DeepSkyBlue

Gets a system-defined color that has an ARGB value of #FF00BFFF.

DimGray DimGray DimGray DimGray

Gets a system-defined color that has an ARGB value of #FF696969.

DodgerBlue DodgerBlue DodgerBlue DodgerBlue

Gets a system-defined color that has an ARGB value of #FF1E90FF.

Firebrick Firebrick Firebrick Firebrick

Gets a system-defined color that has an ARGB value of #FFB22222.

FloralWhite FloralWhite FloralWhite FloralWhite

Gets a system-defined color that has an ARGB value of #FFFFFAF0.

ForestGreen ForestGreen ForestGreen ForestGreen

Gets a system-defined color that has an ARGB value of #FF228B22.

Fuchsia Fuchsia Fuchsia Fuchsia

Gets a system-defined color that has an ARGB value of #FFFF00FF.

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 #FFDCDCDC.

GhostWhite GhostWhite GhostWhite GhostWhite

Gets a system-defined color that has an ARGB value of #FFF8F8FF.

Gold Gold Gold Gold

Gets a system-defined color that has an ARGB value of #FFFFD700.

Goldenrod Goldenrod Goldenrod Goldenrod

Gets a system-defined color that has an ARGB value of #FFDAA520.

Gray Gray Gray Gray

Gets a system-defined color that has an ARGB value of #FF808080.

Green Green Green Green

Gets a system-defined color that has an ARGB value of #FF008000.

GreenYellow GreenYellow GreenYellow GreenYellow

Gets a system-defined color that has an ARGB value of #FFADFF2F.

Honeydew Honeydew Honeydew Honeydew

Gets a system-defined color that has an ARGB value of #FFF0FFF0.

HotPink HotPink HotPink HotPink

Gets a system-defined color that has an ARGB value of #FFFF69B4.

IndianRed IndianRed IndianRed IndianRed

Gets a system-defined color that has an ARGB value of #FFCD5C5C.

Indigo Indigo Indigo Indigo

Gets a system-defined color that has an ARGB value of #FF4B0082.

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 #FFFFFFF0.

Khaki Khaki Khaki Khaki

Gets a system-defined color that has an ARGB value of #FFF0E68C.

Lavender Lavender Lavender Lavender

Gets a system-defined color that has an ARGB value of #FFE6E6FA.

LavenderBlush LavenderBlush LavenderBlush LavenderBlush

Gets a system-defined color that has an ARGB value of #FFFFF0F5.

LawnGreen LawnGreen LawnGreen LawnGreen

Gets a system-defined color that has an ARGB value of #FF7CFC00.

LemonChiffon LemonChiffon LemonChiffon LemonChiffon

Gets a system-defined color that has an ARGB value of #FFFFFACD.

LightBlue LightBlue LightBlue LightBlue

Gets a system-defined color that has an ARGB value of #FFADD8E6.

LightCoral LightCoral LightCoral LightCoral

Gets a system-defined color that has an ARGB value of #FFF08080.

LightCyan LightCyan LightCyan LightCyan

Gets a system-defined color that has an ARGB value of #FFE0FFFF.

LightGoldenrodYellow LightGoldenrodYellow LightGoldenrodYellow LightGoldenrodYellow

Gets a system-defined color that has an ARGB value of #FFFAFAD2.

LightGray LightGray LightGray LightGray

Gets a system-defined color that has an ARGB value of #FFD3D3D3.

LightGreen LightGreen LightGreen LightGreen

Gets a system-defined color that has an ARGB value of #FF90EE90.

LightPink LightPink LightPink LightPink

Gets a system-defined color that has an ARGB value of #FFFFB6C1.

LightSalmon LightSalmon LightSalmon LightSalmon

Gets a system-defined color that has an ARGB value of #FFFFA07A.

LightSeaGreen LightSeaGreen LightSeaGreen LightSeaGreen

Gets a system-defined color that has an ARGB value of #FF20B2AA.

LightSkyBlue LightSkyBlue LightSkyBlue LightSkyBlue

Gets a system-defined color that has an ARGB value of #FF87CEFA.

LightSlateGray LightSlateGray LightSlateGray LightSlateGray

Gets a system-defined color that has an ARGB value of #FF778899.

LightSteelBlue LightSteelBlue LightSteelBlue LightSteelBlue

Gets a system-defined color that has an ARGB value of #FFB0C4DE.

LightYellow LightYellow LightYellow LightYellow

Gets a system-defined color that has an ARGB value of #FFFFFFE0.

Lime Lime Lime Lime

Gets a system-defined color that has an ARGB value of #FF00FF00.

LimeGreen LimeGreen LimeGreen LimeGreen

Gets a system-defined color that has an ARGB value of #FF32CD32.

Linen Linen Linen Linen

Gets a system-defined color that has an ARGB value of #FFFAF0E6.

Magenta Magenta Magenta Magenta

Gets a system-defined color that has an ARGB value of #FFFF00FF.

Maroon Maroon Maroon Maroon

Gets a system-defined color that has an ARGB value of #FF800000.

MediumAquamarine MediumAquamarine MediumAquamarine MediumAquamarine

Gets a system-defined color that has an ARGB value of #FF66CDAA.

MediumBlue MediumBlue MediumBlue MediumBlue

Gets a system-defined color that has an ARGB value of #FF0000CD.

MediumOrchid MediumOrchid MediumOrchid MediumOrchid

Gets a system-defined color that has an ARGB value of #FFBA55D3.

MediumPurple MediumPurple MediumPurple MediumPurple

Gets a system-defined color that has an ARGB value of #FF9370DB.

MediumSeaGreen MediumSeaGreen MediumSeaGreen MediumSeaGreen

Gets a system-defined color that has an ARGB value of #FF3CB371.

MediumSlateBlue MediumSlateBlue MediumSlateBlue MediumSlateBlue

Gets a system-defined color that has an ARGB value of #FF7B68EE.

MediumSpringGreen MediumSpringGreen MediumSpringGreen MediumSpringGreen

Gets a system-defined color that has an ARGB value of #FF00FA9A.

MediumTurquoise MediumTurquoise MediumTurquoise MediumTurquoise

Gets a system-defined color that has an ARGB value of #FF48D1CC.

MediumVioletRed MediumVioletRed MediumVioletRed MediumVioletRed

Gets a system-defined color that has an ARGB value of #FFC71585.

MidnightBlue MidnightBlue MidnightBlue MidnightBlue

Gets a system-defined color that has an ARGB value of #FF191970.

MintCream MintCream MintCream MintCream

Gets a system-defined color that has an ARGB value of #FFF5FFFA.

MistyRose MistyRose MistyRose MistyRose

Gets a system-defined color that has an ARGB value of #FFFFE4E1.

Moccasin Moccasin Moccasin Moccasin

Gets a system-defined color that has an ARGB value of #FFFFE4B5.

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 #FFFFDEAD.

Navy Navy Navy Navy

Gets a system-defined color that has an ARGB value of #FF000080.

OldLace OldLace OldLace OldLace

Gets a system-defined color that has an ARGB value of #FFFDF5E6.

Olive Olive Olive Olive

Gets a system-defined color that has an ARGB value of #FF808000.

OliveDrab OliveDrab OliveDrab OliveDrab

Gets a system-defined color that has an ARGB value of #FF6B8E23.

Orange Orange Orange Orange

Gets a system-defined color that has an ARGB value of #FFFFA500.

OrangeRed OrangeRed OrangeRed OrangeRed

Gets a system-defined color that has an ARGB value of #FFFF4500.

Orchid Orchid Orchid Orchid

Gets a system-defined color that has an ARGB value of #FFDA70D6.

PaleGoldenrod PaleGoldenrod PaleGoldenrod PaleGoldenrod

Gets a system-defined color that has an ARGB value of #FFEEE8AA.

PaleGreen PaleGreen PaleGreen PaleGreen

Gets a system-defined color that has an ARGB value of #FF98FB98.

PaleTurquoise PaleTurquoise PaleTurquoise PaleTurquoise

Gets a system-defined color that has an ARGB value of #FFAFEEEE.

PaleVioletRed PaleVioletRed PaleVioletRed PaleVioletRed

Gets a system-defined color that has an ARGB value of #FFDB7093.

PapayaWhip PapayaWhip PapayaWhip PapayaWhip

Gets a system-defined color that has an ARGB value of #FFFFEFD5.

PeachPuff PeachPuff PeachPuff PeachPuff

Gets a system-defined color that has an ARGB value of #FFFFDAB9.

Peru Peru Peru Peru

Gets a system-defined color that has an ARGB value of #FFCD853F.

Pink Pink Pink Pink

Gets a system-defined color that has an ARGB value of #FFFFC0CB.

Plum Plum Plum Plum

Gets a system-defined color that has an ARGB value of #FFDDA0DD.

PowderBlue PowderBlue PowderBlue PowderBlue

Gets a system-defined color that has an ARGB value of #FFB0E0E6.

Purple Purple Purple Purple

Gets a system-defined color that has an ARGB value of #FF800080.

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 #FFFF0000.

RosyBrown RosyBrown RosyBrown RosyBrown

Gets a system-defined color that has an ARGB value of #FFBC8F8F.

RoyalBlue RoyalBlue RoyalBlue RoyalBlue

Gets a system-defined color that has an ARGB value of #FF4169E1.

SaddleBrown SaddleBrown SaddleBrown SaddleBrown

Gets a system-defined color that has an ARGB value of #FF8B4513.

Salmon Salmon Salmon Salmon

Gets a system-defined color that has an ARGB value of #FFFA8072.

SandyBrown SandyBrown SandyBrown SandyBrown

Gets a system-defined color that has an ARGB value of #FFF4A460.

SeaGreen SeaGreen SeaGreen SeaGreen

Gets a system-defined color that has an ARGB value of #FF2E8B57.

SeaShell SeaShell SeaShell SeaShell

Gets a system-defined color that has an ARGB value of #FFFFF5EE.

Sienna Sienna Sienna Sienna

Gets a system-defined color that has an ARGB value of #FFA0522D.

Silver Silver Silver Silver

Gets a system-defined color that has an ARGB value of #FFC0C0C0.

SkyBlue SkyBlue SkyBlue SkyBlue

Gets a system-defined color that has an ARGB value of #FF87CEEB.

SlateBlue SlateBlue SlateBlue SlateBlue

Gets a system-defined color that has an ARGB value of #FF6A5ACD.

SlateGray SlateGray SlateGray SlateGray

Gets a system-defined color that has an ARGB value of #FF708090.

Snow Snow Snow Snow

Gets a system-defined color that has an ARGB value of #FFFFFAFA.

SpringGreen SpringGreen SpringGreen SpringGreen

Gets a system-defined color that has an ARGB value of #FF00FF7F.

SteelBlue SteelBlue SteelBlue SteelBlue

Gets a system-defined color that has an ARGB value of #FF4682B4.

Tan Tan Tan Tan

Gets a system-defined color that has an ARGB value of #FFD2B48C.

Teal Teal Teal Teal

Gets a system-defined color that has an ARGB value of #FF008080.

Thistle Thistle Thistle Thistle

Gets a system-defined color that has an ARGB value of #FFD8BFD8.

Tomato Tomato Tomato Tomato

Gets a system-defined color that has an ARGB value of #FFFF6347.

Transparent Transparent Transparent Transparent

Gets a system-defined color.

Turquoise Turquoise Turquoise Turquoise

Gets a system-defined color that has an ARGB value of #FF40E0D0.

Violet Violet Violet Violet

Gets a system-defined color that has an ARGB value of #FFEE82EE.

Wheat Wheat Wheat Wheat

Gets a system-defined color that has an ARGB value of #FFF5DEB3.

White White White White

Gets a system-defined color that has an ARGB value of #FFFFFFFF.

WhiteSmoke WhiteSmoke WhiteSmoke WhiteSmoke

Gets a system-defined color that has an ARGB value of #FFF5F5F5.

Yellow Yellow Yellow Yellow

Gets a system-defined color that has an ARGB value of #FFFFFF00.

YellowGreen YellowGreen YellowGreen YellowGreen

Gets a system-defined color that has an ARGB value of #FF9ACD32.

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