Color Struktura
Definicja
Przedstawia Kolor ARGB (alfa, czerwony, zielony, niebieski).Represents an ARGB (alpha, red, green, blue) color.
public value class Color : IEquatable<System::Drawing::Color>
public value class Color
public 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
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
- Dziedziczenie
- Atrybuty
- Implementuje
Przykłady
Poniższy przykład kodu demonstruje właściwości, A , R G , i B Color Implicit elementu członkowskiego.The following code example demonstrates the A, R, G, and B properties of a Color, and the Implicit member.
Ten przykład został zaprojektowany do użycia z formularzem systemu Windows.This example is designed to be used with a Windows Form. Wklej kod do formularza i Wywołaj ShowPropertiesOfSlateBlue
metodę z Paint metody obsługi zdarzeń formularza, przekazując e
jako PaintEventArgs .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
Uwagi
Nazwane kolory są reprezentowane przy użyciu właściwości Color struktury.Named colors are represented by using the properties of the Color structure. Aby uzyskać więcej informacji na temat tych kolorów, zobacz kolory według nazwy.For more information about these colors, see Colors by Name.
Kolor każdego piksela jest reprezentowany jako numer 32-bitowy: 8 bitów dla alfa, czerwony, zielony i niebieski (ARGB).The color of each pixel is represented as a 32-bit number: 8 bits each for alpha, red, green, and blue (ARGB). Każdy z czterech składników jest liczbą z przenoszącą od 0 do 255, a wartość 0 oznacza brak intensywności i 255 reprezentującą pełne intensywność.Each of the four components is a number from 0 through 255, with 0 representing no intensity and 255 representing full intensity. Składnik alfa Określa przezroczystość koloru: 0 jest w pełni przezroczysty, a 255 jest całkowicie nieprzezroczysty.The alpha component specifies the transparency of the color: 0 is fully transparent, and 255 is fully opaque. Aby określić składnik koloru alfa, czerwony, zielony lub niebieski, użyj A R odpowiednio właściwości,, G lub B .To determine the alpha, red, green, or blue component of a color, use the A, R, G, or B property, respectively. Kolor niestandardowy można utworzyć przy użyciu jednej z FromArgb metod.You can create a custom color by using one of the FromArgb methods.
Pola
Empty |
Reprezentuje kolor |
Właściwości
A |
Pobiera wartość składnika alfa tej Color struktury.Gets the alpha component value of this Color structure. |
AliceBlue |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
AntiqueWhite |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Aqua |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Aquamarine |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Azure |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
B |
Pobiera wartość niebieską składnika tej Color struktury.Gets the blue component value of this Color structure. |
Beige |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Bisque |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Black |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
BlanchedAlmond |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Blue |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
BlueViolet |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Brown |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
BurlyWood |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
CadetBlue |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Chartreuse |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Chocolate |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Coral |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
CornflowerBlue |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Cornsilk |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Crimson |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Cyan |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DarkBlue |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DarkCyan |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DarkGoldenrod |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DarkGray |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DarkGreen |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DarkKhaki |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DarkMagenta |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DarkOliveGreen |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DarkOrange |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DarkOrchid |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DarkRed |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DarkSalmon |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DarkSeaGreen |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DarkSlateBlue |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DarkSlateGray |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DarkTurquoise |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DarkViolet |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DeepPink |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DeepSkyBlue |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DimGray |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
DodgerBlue |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Firebrick |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
FloralWhite |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
ForestGreen |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Fuchsia |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
G |
Pobiera zieloną wartość składnika tej Color struktury.Gets the green component value of this Color structure. |
Gainsboro |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
GhostWhite |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Gold |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Goldenrod |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Gray |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Green |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
GreenYellow |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Honeydew |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
HotPink |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
IndianRed |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Indigo |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
IsEmpty |
Określa, czy ta Color Struktura nie została zainicjowana.Specifies whether this Color structure is uninitialized. |
IsKnownColor |
Pobiera wartość wskazującą, czy ta Color Struktura jest wstępnie zdefiniowanym kolorem.Gets a value indicating whether this Color structure is a predefined color. Wstępnie zdefiniowane kolory są reprezentowane przez elementy KnownColor wyliczenia.Predefined colors are represented by the elements of the KnownColor enumeration. |
IsNamedColor |
Pobiera wartość wskazującą, czy ta Color Struktura jest kolorem nazwanym czy elementem członkowskim KnownColor wyliczenia.Gets a value indicating whether this Color structure is a named color or a member of the KnownColor enumeration. |
IsSystemColor |
Pobiera wartość wskazującą, czy ta Color Struktura jest kolorem systemu.Gets a value indicating whether this Color structure is a system color. Kolor systemu jest kolorem używanym w elemencie wyświetlanym systemu Windows.A system color is a color that is used in a Windows display element. Kolory systemowe są reprezentowane przez elementy KnownColor wyliczenia.System colors are represented by elements of the KnownColor enumeration. |
Ivory |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Khaki |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Lavender |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
LavenderBlush |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
LawnGreen |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
LemonChiffon |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
LightBlue |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
LightCoral |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
LightCyan |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
LightGoldenrodYellow |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
LightGray |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
LightGreen |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
LightPink |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
LightSalmon |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
LightSeaGreen |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
LightSkyBlue |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
LightSlateGray |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
LightSteelBlue |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
LightYellow |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Lime |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
LimeGreen |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Linen |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Magenta |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Maroon |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
MediumAquamarine |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
MediumBlue |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
MediumOrchid |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
MediumPurple |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
MediumSeaGreen |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
MediumSlateBlue |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
MediumSpringGreen |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
MediumTurquoise |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
MediumVioletRed |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
MidnightBlue |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
MintCream |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
MistyRose |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Moccasin |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Name |
Pobiera nazwę tego elementu Color .Gets the name of this Color. |
NavajoWhite |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Navy |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
OldLace |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Olive |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
OliveDrab |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Orange |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
OrangeRed |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Orchid |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
PaleGoldenrod |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
PaleGreen |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
PaleTurquoise |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
PaleVioletRed |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
PapayaWhip |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
PeachPuff |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Peru |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Pink |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Plum |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
PowderBlue |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Purple |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
R |
Pobiera wartość czerwoną składnika tej Color struktury.Gets the red component value of this Color structure. |
Red |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
RosyBrown |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
RoyalBlue |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
SaddleBrown |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Salmon |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
SandyBrown |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
SeaGreen |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
SeaShell |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Sienna |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Silver |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
SkyBlue |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
SlateBlue |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
SlateGray |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Snow |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
SpringGreen |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
SteelBlue |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Tan |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Teal |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Thistle |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Tomato |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Transparent |
Pobiera kolor zdefiniowany przez system.Gets a system-defined color. |
Turquoise |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Violet |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Wheat |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
White |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
WhiteSmoke |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Yellow |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
YellowGreen |
Pobiera kolor zdefiniowany przez system, który ma wartość ARGB |
Metody
Equals(Color) |
Wskazuje, czy bieżący obiekt jest równy innemu obiektowi tego samego typu.Indicates whether the current object is equal to another object of the same type. |
Equals(Object) |
Testuje, czy określony obiekt jest Color strukturą i jest równoważny z tą Color strukturą.Tests whether the specified object is a Color structure and is equivalent to this Color structure. |
FromArgb(Int32) |
Tworzy Color strukturę z 32-bitowej wartości ARGB.Creates a Color structure from a 32-bit ARGB value. |
FromArgb(Int32, Color) |
Tworzy Color strukturę z określonej Color struktury, ale z nową określoną wartością alfa.Creates a Color structure from the specified Color structure, but with the new specified alpha value. Chociaż ta metoda umożliwia przekazanie wartości 32-bitowej dla wartości alfa, wartość jest ograniczona do 8 bitów.Although this method allows a 32-bit value to be passed for the alpha value, the value is limited to 8 bits. |
FromArgb(Int32, Int32, Int32) |
Tworzy Color strukturę z określonych wartości 8-bitowych kolorów (czerwony, zielony i niebieski).Creates a Color structure from the specified 8-bit color values (red, green, and blue). Wartość alfa jest niejawnie 255 (w pełni nieprzezroczysty).The alpha value is implicitly 255 (fully opaque). Chociaż ta metoda umożliwia przekazywanie wartości 32-bitowych dla każdego składnika koloru, wartość każdego składnika jest ograniczona do 8 bitów.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, Int32, Int32, Int32) |
Tworzy Color strukturę na podstawie wartości czterech składników ARGB (alfa, czerwony, zielony i niebieski).Creates a Color structure from the four ARGB component (alpha, red, green, and blue) values. Chociaż ta metoda umożliwia przekazywanie wartości 32-bitowych dla każdego składnika, wartość każdego składnika jest ograniczona do 8 bitów.Although this method allows a 32-bit value to be passed for each component, the value of each component is limited to 8 bits. |
FromKnownColor(KnownColor) |
Tworzy Color strukturę na podstawie określonego wstępnie zdefiniowanego koloru.Creates a Color structure from the specified predefined color. |
FromName(String) |
Tworzy Color strukturę na podstawie określonej nazwy wstępnie zdefiniowanego koloru.Creates a Color structure from the specified name of a predefined color. |
GetBrightness() |
Pobiera wartość rozjaśnienia barwy nasycenia (HSL) dla tej Color struktury.Gets the hue-saturation-lightness (HSL) lightness value for this Color structure. |
GetHashCode() |
Zwraca kod skrótu dla tej Color struktury.Returns a hash code for this Color structure. |
GetHue() |
Pobiera wartość odcienia barwy nasycenia — jasność (HSL) (w stopniach) dla tej Color struktury.Gets the hue-saturation-lightness (HSL) hue value, in degrees, for this Color structure. |
GetSaturation() |
Pobiera wartość nasycenia Barwa-Nasycenie (HSL) dla tej Color struktury.Gets the hue-saturation-lightness (HSL) saturation value for this Color structure. |
ToArgb() |
Pobiera 32-bitową wartość ARGB tej Color struktury.Gets the 32-bit ARGB value of this Color structure. |
ToKnownColor() |
Pobiera KnownColor wartość tej Color struktury.Gets the KnownColor value of this Color structure. |
ToString() |
Konwertuje tę Color strukturę na ciąg czytelny dla człowieka.Converts this Color structure to a human-readable string. |
Operatory
Equality(Color, Color) |
Testuje, czy dwie określone Color struktury są równoważne.Tests whether two specified Color structures are equivalent. |
Inequality(Color, Color) |
Testuje, czy dwie określone Color struktury są różne.Tests whether two specified Color structures are different. |