Describes a color consisting of relative intensities of alpha, red, green, and blue.
Supported in Silverlight, Windows Phone 7
Object Model
Syntax
Visual Basic (Usage) | Copy Code |
---|
Dim instance As RasterColor |
Example
Converts a .NET color to a RasterColor and back.
Visual Basic | Copy Code |
---|
Public Sub Example()
' Create a RasterColor
Dim clr As New RasterColor(128, 24, 87, 134)
' Make sure the color is correct
Debug.Assert(clr.A = 128)
Debug.Assert(clr.R = 24)
Debug.Assert(clr.G = 87)
Debug.Assert(clr.B = 134)
' Show its value
Console.WriteLine(clr)
' Show the A, R, G and B values
Console.WriteLine("Alpha value: " + clr.A.ToString())
Console.WriteLine("Red value: " + clr.R.ToString())
Console.WriteLine("Green value: " + clr.G.ToString())
Console.WriteLine("Blue value: " + clr.B.ToString())
End Sub |
C# | Copy Code |
---|
public void Example()
{
// Create a RasterColor
RasterColor clr = new RasterColor(128, 24, 87, 134);
// Make sure the color is correct
Debug.Assert(clr.A == 128);
Debug.Assert(clr.R == 24);
Debug.Assert(clr.G == 87);
Debug.Assert(clr.B == 134);
// Show its value
Console.WriteLine(clr);
// Show the A, R, G and B values
Console.WriteLine("Alpha value: " + clr.A);
Console.WriteLine("Red value: " + clr.R);
Console.WriteLine("Green value: " + clr.G);
Console.WriteLine("Blue value: " + clr.B);
} |
SilverlightCSharp | Copy Code |
---|
[TestMethod]
public void Example()
{
Random rand = new Random();
// Create a random .NET color
Color clr1 = Color.FromArgb((byte)rand.Next(256), (byte)rand.Next(256), (byte)rand.Next(256), (byte)rand.Next(256));
// Convert this color to a LEADTOOLS color
RasterColor clr2 = RasterColorConverter.FromColor(clr1);
// Make sure both colors are equal
Debug.Assert(clr1.A == clr2.A);
Debug.Assert(clr1.R == clr2.R);
Debug.Assert(clr1.G == clr2.G);
Debug.Assert(clr1.B == clr2.B);
// Convert the LEADTOOLS color back to .NET
clr1 = RasterColorConverter.ToColor(clr2);
// Make sure both colors are equal
Debug.Assert(clr1.A == clr2.A);
Debug.Assert(clr1.R == clr2.R);
Debug.Assert(clr1.G == clr2.G);
Debug.Assert(clr1.B == clr2.B);
} |
SilverlightVB | Copy Code |
---|
<TestMethod> _
Public Sub Example()
Dim rand As Random = New Random()
' Create a random .NET color
Dim clr1 As Color = Color.FromArgb(CByte(rand.Next(256)), CByte(rand.Next(256)), CByte(rand.Next(256)), CByte(rand.Next(256)))
' Convert this color to a LEADTOOLS color
Dim clr2 As RasterColor = RasterColorConverter.FromColor(clr1)
' Make sure both colors are equal
Debug.Assert(clr1.A = clr2.A)
Debug.Assert(clr1.R = clr2.R)
Debug.Assert(clr1.G = clr2.G)
Debug.Assert(clr1.B = clr2.B)
' Convert the LEADTOOLS color back to .NET
clr1 = RasterColorConverter.ToColor(clr2)
' Make sure both colors are equal
Debug.Assert(clr1.A = clr2.A)
Debug.Assert(clr1.R = clr2.R)
Debug.Assert(clr1.G = clr2.G)
Debug.Assert(clr1.B = clr2.B)
End Sub |
Remarks
Inheritance Hierarchy
Requirements
Target Platforms: Silverlight, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only), Windows Phone 7
See Also