Export (0) Print
Expand All

Color.FromArgb Method

Creates a new Color structure by using the specified sRGB alpha channel and color channel values.

Namespace:  System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)

public static Color FromArgb(
	byte a,
	byte r,
	byte g,
	byte b
)

Parameters

a
Type: System.Byte

The alpha channel, A, of the new color.

r
Type: System.Byte

The red channel, R, of the new color.

g
Type: System.Byte

The green channel, G, of the new color.

b
Type: System.Byte

The blue channel, B, of the new color.

Return Value

Type: System.Windows.Media.Color
A Color structure with the specified values.

The FromArgb method allows you to specify the alpha channel; the FromRgb method uses a default value of 255 for the alpha channel.

The alpha channel of a color determines the amount of transparency of the color. An alpha value of 255 indicates that the color is completely opaque, and a value of 0 indicates that the color is completely transparent.

private Color FromArgbExample()
{
    // Create a blue color using the FromArgb static method.
    Color myArgbColor = new Color();
    myArgbColor = Color.FromArgb(255, 0, 255, 0);
    return myArgbColor;
}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft