Share via


ColorHelper.FromArgb(Byte, Byte, Byte, Byte) Method

Definition

Generates a Color structure, based on discrete Byte values for ARGB components. C# and Microsoft Visual Basic code should use Color.FromArgb instead.

public:
 static Color FromArgb(byte a, byte r, byte g, byte b);
 static Color FromArgb(byte const& a, byte const& r, byte const& g, byte const& b);
public static Color FromArgb(byte a, byte r, byte g, byte b);
function fromArgb(a, r, g, b)
Public Shared Function FromArgb (a As Byte, r As Byte, g As Byte, b As Byte) As Color

Parameters

a
Byte

byte

The A (transparency) component of the desired color. Range is 0-255.

r
Byte

byte

The R component of the desired color. Range is 0-255.

g
Byte

byte

The G component of the desired color. Range is 0-255.

b
Byte

byte

The B component of the desired color. Range is 0-255.

Returns

The generated Color value.

Examples

This example shows how to create a Color.

Windows::UI::Color orangeColor{ Windows::UI::ColorHelper::FromArgb(255, 255, 128, 0) };
auto orangeColor = Windows::UI::ColorHelper::FromArgb(255, 255, 128, 0);

This example shows how to create a SolidColorBrush with the specified Color.

Windows::UI::Xaml::Media::SolidColorBrush greenBrush{
    Windows::UI::ColorHelper::FromArgb(255, 90, 200, 90) };
auto greenBrush = ref new SolidColorBrush(Windows::UI::ColorHelper::FromArgb(255, 90, 200, 90));

Remarks

C#/Visual Basic The ColorHelper class is available for use from C# and Visual Basic code but it's not commonly used. The FromArgb method that's available as a static method of the Color structure has exactly the same functionality, and you also have other API there that's more convenient to use from Color itself rather than using the ColorHelper class. ColorHelper is mainly intended for C++ code, which doesn't have access to the nondata API of the Color structure.

The most common reason for creating a Color value is to use it as an argument for the SolidColorBrush constructor, then assign that brush to a XAML UI property.

Applies to

See also