Color
Struct · namespace System.Image · Since 0.28
struct Color : IEquatable<Color>, IHashableA color: alpha, red, green and blue, from 0 to 255 each (an alpha of 0 is transparent, 255 opaque).
var red = Color.FromRgb(255, 0, 0);uint32 argb = red.ToArgb(); // 0xFFFF0000var same = Color.FromArgb(argb);Fields
Section titled “Fields”| Name | Description |
|---|---|
A |
Alpha: 0 is transparent, 255 opaque. |
R |
Red. |
G |
Green. |
B |
Blue. |
uint8 AAlpha: 0 is transparent, 255 opaque.
uint8 RRed.
uint8 GGreen.
uint8 BBlue.
Static methods
Section titled “Static methods”| Name | Description |
|---|---|
FromArgb |
A color from its four components (0 to 255 each). |
FromRgb |
An opaque color from red, green and blue (0 to 255 each). |
Transparent |
Transparent white, 0x00FFFFFF (like Color.Transparent of .NET; Image.Create fills with transparent black, 0). |
Black |
Opaque black. |
White |
Opaque white. |
FromArgb
Section titled “FromArgb”static Color FromArgb(int alpha, int red, int green, int blue)A color from its four components (0 to 255 each).
Panics when a component is not 0 to 255.
static Color FromArgb(uint32 argb)A color from a 32-bit value 0xAARRGGBB (the value of Color.ToArgb and of Image.Pixels).
FromRgb
Section titled “FromRgb”static Color FromRgb(int red, int green, int blue)An opaque color from red, green and blue (0 to 255 each).
Panics when a component is not 0 to 255.
Transparent
Section titled “Transparent”static Color Transparent()Transparent white, 0x00FFFFFF (like Color.Transparent of .NET; Image.Create fills with transparent
black, 0).
static Color Black()Opaque black.
static Color White()Opaque white.
Methods
Section titled “Methods”| Name | Description |
|---|---|
ToArgb |
The color as a 32-bit value 0xAARRGGBB. |
Equals |
Whether all four components are the same. |
GetHashCode |
A hash code (the ARGB value). |
ToString |
The color as text: #AARRGGBB. |
ToArgb
Section titled “ToArgb”uint32 ToArgb()The color as a 32-bit value 0xAARRGGBB.
Equals
Section titled “Equals”bool Equals(Color other)Whether all four components are the same.
GetHashCode
Section titled “GetHashCode”int GetHashCode()A hash code (the ARGB value).
ToString
Section titled “ToString”string ToString()The color as text: #AARRGGBB.