5 out of 13 rated this helpful - Rate this topic

Color Structure

Represents an ARGB (alpha, red, green, blue) color.

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)
[SerializableAttribute]
[TypeConverterAttribute(typeof(ColorConverter))]
public struct Color

The Color type exposes the following members.

  Name Description
Public property Supported by the XNA Framework A Gets the alpha component value of this Color structure.
Public property Static member Supported by the XNA Framework AliceBlue Gets a system-defined color that has an ARGB value of #FFF0F8FF.
Public property Static member Supported by the XNA Framework AntiqueWhite Gets a system-defined color that has an ARGB value of #FFFAEBD7.
Public property Static member Supported by the XNA Framework Aqua Gets a system-defined color that has an ARGB value of #FF00FFFF.
Public property Static member Supported by the XNA Framework Aquamarine Gets a system-defined color that has an ARGB value of #FF7FFFD4.
Public property Static member Supported by the XNA Framework Azure Gets a system-defined color that has an ARGB value of #FFF0FFFF.
Public property Supported by the XNA Framework B Gets the blue component value of this Color structure.
Public property Static member Supported by the XNA Framework Beige Gets a system-defined color that has an ARGB value of #FFF5F5DC.
Public property Static member Supported by the XNA Framework Bisque Gets a system-defined color that has an ARGB value of #FFFFE4C4.
Public property Static member Supported by the XNA Framework Black Gets a system-defined color that has an ARGB value of #FF000000.
Public property Static member Supported by the XNA Framework BlanchedAlmond Gets a system-defined color that has an ARGB value of #FFFFEBCD.
Public property Static member Supported by the XNA Framework Blue Gets a system-defined color that has an ARGB value of #FF0000FF.
Public property Static member Supported by the XNA Framework BlueViolet Gets a system-defined color that has an ARGB value of #FF8A2BE2.
Public property Static member Supported by the XNA Framework Brown Gets a system-defined color that has an ARGB value of #FFA52A2A.
Public property Static member Supported by the XNA Framework BurlyWood Gets a system-defined color that has an ARGB value of #FFDEB887.
Public property Static member Supported by the XNA Framework CadetBlue Gets a system-defined color that has an ARGB value of #FF5F9EA0.
Public property Static member Supported by the XNA Framework Chartreuse Gets a system-defined color that has an ARGB value of #FF7FFF00.
Public property Static member Supported by the XNA Framework Chocolate Gets a system-defined color that has an ARGB value of #FFD2691E.
Public property Static member Supported by the XNA Framework Coral Gets a system-defined color that has an ARGB value of #FFFF7F50.
Public property Static member Supported by the XNA Framework CornflowerBlue Gets a system-defined color that has an ARGB value of #FF6495ED.
Public property Static member Supported by the XNA Framework Cornsilk Gets a system-defined color that has an ARGB value of #FFFFF8DC.
Public property Static member Supported by the XNA Framework Crimson Gets a system-defined color that has an ARGB value of #FFDC143C.
Public property Static member Supported by the XNA Framework Cyan Gets a system-defined color that has an ARGB value of #FF00FFFF.
Public property Static member Supported by the XNA Framework DarkBlue Gets a system-defined color that has an ARGB value of #FF00008B.
Public property Static member Supported by the XNA Framework DarkCyan Gets a system-defined color that has an ARGB value of #FF008B8B.
Public property Static member Supported by the XNA Framework DarkGoldenrod Gets a system-defined color that has an ARGB value of #FFB8860B.
Public property Static member Supported by the XNA Framework DarkGray Gets a system-defined color that has an ARGB value of #FFA9A9A9.
Public property Static member Supported by the XNA Framework DarkGreen Gets a system-defined color that has an ARGB value of #FF006400.
Public property Static member Supported by the XNA Framework DarkKhaki Gets a system-defined color that has an ARGB value of #FFBDB76B.
Public property Static member Supported by the XNA Framework DarkMagenta Gets a system-defined color that has an ARGB value of #FF8B008B.
Public property Static member Supported by the XNA Framework DarkOliveGreen Gets a system-defined color that has an ARGB value of #FF556B2F.
Public property Static member Supported by the XNA Framework DarkOrange Gets a system-defined color that has an ARGB value of #FFFF8C00.
Public property Static member Supported by the XNA Framework DarkOrchid Gets a system-defined color that has an ARGB value of #FF9932CC.
Public property Static member Supported by the XNA Framework DarkRed Gets a system-defined color that has an ARGB value of #FF8B0000.
Public property Static member Supported by the XNA Framework DarkSalmon Gets a system-defined color that has an ARGB value of #FFE9967A.
Public property Static member Supported by the XNA Framework DarkSeaGreen Gets a system-defined color that has an ARGB value of #FF8FBC8F.
Public property Static member Supported by the XNA Framework DarkSlateBlue Gets a system-defined color that has an ARGB value of #FF483D8B.
Public property Static member Supported by the XNA Framework DarkSlateGray Gets a system-defined color that has an ARGB value of #FF2F4F4F.
Public property Static member Supported by the XNA Framework DarkTurquoise Gets a system-defined color that has an ARGB value of #FF00CED1.
Public property Static member Supported by the XNA Framework DarkViolet Gets a system-defined color that has an ARGB value of #FF9400D3.
Public property Static member Supported by the XNA Framework DeepPink Gets a system-defined color that has an ARGB value of #FFFF1493.
Public property Static member Supported by the XNA Framework DeepSkyBlue Gets a system-defined color that has an ARGB value of #FF00BFFF.
Public property Static member Supported by the XNA Framework DimGray Gets a system-defined color that has an ARGB value of #FF696969.
Public property Static member Supported by the XNA Framework DodgerBlue Gets a system-defined color that has an ARGB value of #FF1E90FF.
Public property Static member Supported by the XNA Framework Firebrick Gets a system-defined color that has an ARGB value of #FFB22222.
Public property Static member Supported by the XNA Framework FloralWhite Gets a system-defined color that has an ARGB value of #FFFFFAF0.
Public property Static member Supported by the XNA Framework ForestGreen Gets a system-defined color that has an ARGB value of #FF228B22.
Public property Static member Supported by the XNA Framework Fuchsia Gets a system-defined color that has an ARGB value of #FFFF00FF.
Public property Supported by the XNA Framework G Gets the green component value of this Color structure.
Public property Static member Supported by the XNA Framework Gainsboro Gets a system-defined color that has an ARGB value of #FFDCDCDC.
Public property Static member Supported by the XNA Framework GhostWhite Gets a system-defined color that has an ARGB value of #FFF8F8FF.
Public property Static member Supported by the XNA Framework Gold Gets a system-defined color that has an ARGB value of #FFFFD700.
Public property Static member Supported by the XNA Framework Goldenrod Gets a system-defined color that has an ARGB value of #FFDAA520.
Public property Static member Supported by the XNA Framework Gray Gets a system-defined color that has an ARGB value of #FF808080.
Public property Static member Supported by the XNA Framework Green Gets a system-defined color that has an ARGB value of #FF008000.
Public property Static member Supported by the XNA Framework GreenYellow Gets a system-defined color that has an ARGB value of #FFADFF2F.
Public property Static member Supported by the XNA Framework Honeydew Gets a system-defined color that has an ARGB value of #FFF0FFF0.
Public property Static member Supported by the XNA Framework HotPink Gets a system-defined color that has an ARGB value of #FFFF69B4.
Public property Static member Supported by the XNA Framework IndianRed Gets a system-defined color that has an ARGB value of #FFCD5C5C.
Public property Static member Supported by the XNA Framework Indigo Gets a system-defined color that has an ARGB value of #FF4B0082.
Public property Supported by the XNA Framework IsEmpty Specifies whether this Color structure is uninitialized.
Public property IsKnownColor Gets a value indicating whether this Color structure is a predefined color. Predefined colors are represented by the elements of the KnownColor enumeration.
Public property IsNamedColor Gets a value indicating whether this Color structure is a named color or a member of the KnownColor enumeration.
Public property Supported by the XNA Framework 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.
Public property Static member Supported by the XNA Framework Ivory Gets a system-defined color that has an ARGB value of #FFFFFFF0.
Public property Static member Supported by the XNA Framework Khaki Gets a system-defined color that has an ARGB value of #FFF0E68C.
Public property Static member Supported by the XNA Framework Lavender Gets a system-defined color that has an ARGB value of #FFE6E6FA.
Public property Static member Supported by the XNA Framework LavenderBlush Gets a system-defined color that has an ARGB value of #FFFFF0F5.
Public property Static member Supported by the XNA Framework LawnGreen Gets a system-defined color that has an ARGB value of #FF7CFC00.
Public property Static member Supported by the XNA Framework LemonChiffon Gets a system-defined color that has an ARGB value of #FFFFFACD.
Public property Static member Supported by the XNA Framework LightBlue Gets a system-defined color that has an ARGB value of #FFADD8E6.
Public property Static member Supported by the XNA Framework LightCoral Gets a system-defined color that has an ARGB value of #FFF08080.
Public property Static member Supported by the XNA Framework LightCyan Gets a system-defined color that has an ARGB value of #FFE0FFFF.
Public property Static member Supported by the XNA Framework LightGoldenrodYellow Gets a system-defined color that has an ARGB value of #FFFAFAD2.
Public property Static member Supported by the XNA Framework LightGray Gets a system-defined color that has an ARGB value of #FFD3D3D3.
Public property Static member Supported by the XNA Framework LightGreen Gets a system-defined color that has an ARGB value of #FF90EE90.
Public property Static member Supported by the XNA Framework LightPink Gets a system-defined color that has an ARGB value of #FFFFB6C1.
Public property Static member Supported by the XNA Framework LightSalmon Gets a system-defined color that has an ARGB value of #FFFFA07A.
Public property Static member Supported by the XNA Framework LightSeaGreen Gets a system-defined color that has an ARGB value of #FF20B2AA.
Public property Static member Supported by the XNA Framework LightSkyBlue Gets a system-defined color that has an ARGB value of #FF87CEFA.
Public property Static member Supported by the XNA Framework LightSlateGray Gets a system-defined color that has an ARGB value of #FF778899.
Public property Static member Supported by the XNA Framework LightSteelBlue Gets a system-defined color that has an ARGB value of #FFB0C4DE.
Public property Static member Supported by the XNA Framework LightYellow Gets a system-defined color that has an ARGB value of #FFFFFFE0.
Public property Static member Supported by the XNA Framework Lime Gets a system-defined color that has an ARGB value of #FF00FF00.
Public property Static member Supported by the XNA Framework LimeGreen Gets a system-defined color that has an ARGB value of #FF32CD32.
Public property Static member Supported by the XNA Framework Linen Gets a system-defined color that has an ARGB value of #FFFAF0E6.
Public property Static member Supported by the XNA Framework Magenta Gets a system-defined color that has an ARGB value of #FFFF00FF.
Public property Static member Supported by the XNA Framework Maroon Gets a system-defined color that has an ARGB value of #FF800000.
Public property Static member Supported by the XNA Framework MediumAquamarine Gets a system-defined color that has an ARGB value of #FF66CDAA.
Public property Static member Supported by the XNA Framework MediumBlue Gets a system-defined color that has an ARGB value of #FF0000CD.
Public property Static member Supported by the XNA Framework MediumOrchid Gets a system-defined color that has an ARGB value of #FFBA55D3.
Public property Static member Supported by the XNA Framework MediumPurple Gets a system-defined color that has an ARGB value of #FF9370DB.
Public property Static member Supported by the XNA Framework MediumSeaGreen Gets a system-defined color that has an ARGB value of #FF3CB371.
Public property Static member Supported by the XNA Framework MediumSlateBlue Gets a system-defined color that has an ARGB value of #FF7B68EE.
Public property Static member Supported by the XNA Framework MediumSpringGreen Gets a system-defined color that has an ARGB value of #FF00FA9A.
Public property Static member Supported by the XNA Framework MediumTurquoise Gets a system-defined color that has an ARGB value of #FF48D1CC.
Public property Static member Supported by the XNA Framework MediumVioletRed Gets a system-defined color that has an ARGB value of #FFC71585.
Public property Static member Supported by the XNA Framework MidnightBlue Gets a system-defined color that has an ARGB value of #FF191970.
Public property Static member Supported by the XNA Framework MintCream Gets a system-defined color that has an ARGB value of #FFF5FFFA.
Public property Static member Supported by the XNA Framework MistyRose Gets a system-defined color that has an ARGB value of #FFFFE4E1.
Public property Static member Supported by the XNA Framework Moccasin Gets a system-defined color that has an ARGB value of #FFFFE4B5.
Public property Name Gets the name of this Color.
Public property Static member Supported by the XNA Framework NavajoWhite Gets a system-defined color that has an ARGB value of #FFFFDEAD.
Public property Static member Supported by the XNA Framework Navy Gets a system-defined color that has an ARGB value of #FF000080.
Public property Static member Supported by the XNA Framework OldLace Gets a system-defined color that has an ARGB value of #FFFDF5E6.
Public property Static member Supported by the XNA Framework Olive Gets a system-defined color that has an ARGB value of #FF808000.
Public property Static member Supported by the XNA Framework OliveDrab Gets a system-defined color that has an ARGB value of #FF6B8E23.
Public property Static member Supported by the XNA Framework Orange Gets a system-defined color that has an ARGB value of #FFFFA500.
Public property Static member Supported by the XNA Framework OrangeRed Gets a system-defined color that has an ARGB value of #FFFF4500.
Public property Static member Supported by the XNA Framework Orchid Gets a system-defined color that has an ARGB value of #FFDA70D6.
Public property Static member Supported by the XNA Framework PaleGoldenrod Gets a system-defined color that has an ARGB value of #FFEEE8AA.
Public property Static member Supported by the XNA Framework PaleGreen Gets a system-defined color that has an ARGB value of #FF98FB98.
Public property Static member Supported by the XNA Framework PaleTurquoise Gets a system-defined color that has an ARGB value of #FFAFEEEE.
Public property Static member Supported by the XNA Framework PaleVioletRed Gets a system-defined color that has an ARGB value of #FFDB7093.
Public property Static member Supported by the XNA Framework PapayaWhip Gets a system-defined color that has an ARGB value of #FFFFEFD5.
Public property Static member Supported by the XNA Framework PeachPuff Gets a system-defined color that has an ARGB value of #FFFFDAB9.
Public property Static member Supported by the XNA Framework Peru Gets a system-defined color that has an ARGB value of #FFCD853F.
Public property Static member Supported by the XNA Framework Pink Gets a system-defined color that has an ARGB value of #FFFFC0CB.
Public property Static member Supported by the XNA Framework Plum Gets a system-defined color that has an ARGB value of #FFDDA0DD.
Public property Static member Supported by the XNA Framework PowderBlue Gets a system-defined color that has an ARGB value of #FFB0E0E6.
Public property Static member Supported by the XNA Framework Purple Gets a system-defined color that has an ARGB value of #FF800080.
Public property Supported by the XNA Framework R Gets the red component value of this Color structure.
Public property Static member Supported by the XNA Framework Red Gets a system-defined color that has an ARGB value of #FFFF0000.
Public property Static member Supported by the XNA Framework RosyBrown Gets a system-defined color that has an ARGB value of #FFBC8F8F.
Public property Static member Supported by the XNA Framework RoyalBlue Gets a system-defined color that has an ARGB value of #FF4169E1.
Public property Static member Supported by the XNA Framework SaddleBrown Gets a system-defined color that has an ARGB value of #FF8B4513.
Public property Static member Supported by the XNA Framework Salmon Gets a system-defined color that has an ARGB value of #FFFA8072.
Public property Static member Supported by the XNA Framework SandyBrown Gets a system-defined color that has an ARGB value of #FFF4A460.
Public property Static member Supported by the XNA Framework SeaGreen Gets a system-defined color that has an ARGB value of #FF2E8B57.
Public property Static member Supported by the XNA Framework SeaShell Gets a system-defined color that has an ARGB value of #FFFFF5EE.
Public property Static member Supported by the XNA Framework Sienna Gets a system-defined color that has an ARGB value of #FFA0522D.
Public property Static member Supported by the XNA Framework Silver Gets a system-defined color that has an ARGB value of #FFC0C0C0.
Public property Static member Supported by the XNA Framework SkyBlue Gets a system-defined color that has an ARGB value of #FF87CEEB.
Public property Static member Supported by the XNA Framework SlateBlue Gets a system-defined color that has an ARGB value of #FF6A5ACD.
Public property Static member Supported by the XNA Framework SlateGray Gets a system-defined color that has an ARGB value of #FF708090.
Public property Static member Supported by the XNA Framework Snow Gets a system-defined color that has an ARGB value of #FFFFFAFA.
Public property Static member Supported by the XNA Framework SpringGreen Gets a system-defined color that has an ARGB value of #FF00FF7F.
Public property Static member Supported by the XNA Framework SteelBlue Gets a system-defined color that has an ARGB value of #FF4682B4.
Public property Static member Supported by the XNA Framework Tan Gets a system-defined color that has an ARGB value of #FFD2B48C.
Public property Static member Supported by the XNA Framework Teal Gets a system-defined color that has an ARGB value of #FF008080.
Public property Static member Supported by the XNA Framework Thistle Gets a system-defined color that has an ARGB value of #FFD8BFD8.
Public property Static member Supported by the XNA Framework Tomato Gets a system-defined color that has an ARGB value of #FFFF6347.
Public property Static member Supported by the XNA Framework Transparent Gets a system-defined color.
Public property Static member Supported by the XNA Framework Turquoise Gets a system-defined color that has an ARGB value of #FF40E0D0.
Public property Static member Supported by the XNA Framework Violet Gets a system-defined color that has an ARGB value of #FFEE82EE.
Public property Static member Supported by the XNA Framework Wheat Gets a system-defined color that has an ARGB value of #FFF5DEB3.
Public property Static member Supported by the XNA Framework White Gets a system-defined color that has an ARGB value of #FFFFFFFF.
Public property Static member Supported by the XNA Framework WhiteSmoke Gets a system-defined color that has an ARGB value of #FFF5F5F5.
Public property Static member Supported by the XNA Framework Yellow Gets a system-defined color that has an ARGB value of #FFFFFF00.
Public property Static member Supported by the XNA Framework YellowGreen Gets a system-defined color that has an ARGB value of #FF9ACD32.
Top
  Name Description
Public method Supported by the XNA Framework Equals Tests whether the specified object is a Color structure and is equivalent to this Color structure. (Overrides ValueType.Equals(Object).)
Protected method Supported by the XNA Framework Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method Static member Supported by the XNA Framework FromArgb(Int32) Creates a Color structure from a 32-bit ARGB value.
Public method Static member 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.
Public method Static member Supported by the XNA Framework 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.
Public method Static member 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.
Public method Static member FromKnownColor Creates a Color structure from the specified predefined color.
Public method Static member FromName Creates a Color structure from the specified name of a predefined color.
Public method GetBrightness Gets the hue-saturation-brightness (HSB) brightness value for this Color structure.
Public method Supported by the XNA Framework GetHashCode Returns a hash code for this Color structure. (Overrides ValueType.GetHashCode().)
Public method GetHue Gets the hue-saturation-brightness (HSB) hue value, in degrees, for this Color structure.
Public method GetSaturation Gets the hue-saturation-brightness (HSB) saturation value for this Color structure.
Public method Supported by the XNA Framework GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method Supported by the XNA Framework MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Supported by the XNA Framework ToArgb Gets the 32-bit ARGB value of this Color structure.
Public method ToKnownColor Gets the KnownColor value of this Color structure.
Public method Supported by the XNA Framework ToString Converts this Color structure to a human-readable string. (Overrides ValueType.ToString().)

In XNA Framework 3.0, this member is inherited from Object.ToString().
Top
  Name Description
Public operator Static member Supported by the XNA Framework Equality Tests whether two specified Color structures are equivalent.
Public operator Static member Supported by the XNA Framework Inequality Tests whether two specified Color structures are different.
Top
  Name Description
Public field Static member Supported by the XNA Framework Empty Represents a color that is null.
Top

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.

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.


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));
}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
XmlSerializer will not save/restore instance of color.
XmlSerializater class will not succesfully de/serialize instance of System.Drawing.Color. Workaround for this can be found e.g. here: http://stackoverflow.com/questions/376234/net-best-solution-for-xmlserializer-and-system-drawing-color
from color to double
can we convert the type color to type double(in c#)??? $0if we can how we will do this?????$0