Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Color.FromScRgb Method

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

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

public static Color FromScRgb(
	float a,
	float r,
	float g,
	float b
You cannot use methods in XAML.


Type: System.Single

The ScRGB alpha channel, ScA, of the new color.

Type: System.Single

The ScRGB red channel, ScR, of the new color.

Type: System.Single

The ScRGB green channel, ScG, of the new color.

Type: System.Single

The ScRGB blue channel, ScB, of the new color.

Return Value

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

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

The sRGB channels (A, R, G, B) and the ScRGB channels (ScA, ScR, ScG, ScB) of the Color structure are synchronized properties. For example, when R, the sRGB red channel, is modified the ScRGB red channel, ScR, is transformed to the equivalent value.

The following example shows how to use the FromScRgb method to create a Color structure.

private Color FromScRgbExample()
    // Create a blue color using the FromScRgb static method.
    Color myScRgbColor = new Color();
    myScRgbColor = Color.FromScRgb(1, 0, 0, 1);
    return myScRgbColor;

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5, 3.0

Community Additions

© 2016 Microsoft