Converts between LEADTOOLS
Leadtools.RasterColor and Windows Presentation Foundation (WPF) or Silverlight
System.Windows.Media.Color objects.
Supported in Silverlight, Windows Phone 7
Object Model
Syntax
Visual Basic (Declaration) | |
---|
Public MustInherit NotInheritable Class RasterColorConverter |
C# | |
---|
public static class RasterColorConverter |
C++/CLI | |
---|
public ref class RasterColorConverter abstract sealed |
Example
Visual Basic | Copy Code |
---|
Public Sub RasterColorConverterExample()
' Create a WPF color
Dim wpfColor As System.Windows.Media.Color = System.Windows.Media.Colors.Bisque
' Convert it to a LEADTOOLS RasterColor
Dim leadColor As RasterColor = RasterColorConverter.FromColor(wpfColor)
' Show both colors
Console.WriteLine("wpfColor = {0} - leadColor = {1}", wpfColor, leadColor)
' Make sure both colors are the same
Debug.Assert( _
wpfColor.A = leadColor.A AndAlso _
wpfColor.R = leadColor.R AndAlso _
wpfColor.G = leadColor.G AndAlso _
wpfColor.B = leadColor.B)
' Create the LEAD color
leadColor = New RasterColor(128, 24, 35, 67)
' Convert it to a WPF color
wpfColor = RasterColorConverter.ToColor(leadColor)
' Show both colors
Console.WriteLine("wpfColor = {0} - leadColor = {1}", wpfColor, leadColor)
' Make sure both colors are the same
Debug.Assert( _
wpfColor.A = leadColor.A AndAlso _
wpfColor.R = leadColor.R AndAlso _
wpfColor.G = leadColor.G AndAlso _
wpfColor.B = leadColor.B)
End Sub |
C# | Copy Code |
---|
public void RasterColorConverterExample()
{
// Create a WPF color
System.Windows.Media.Color wpfColor = System.Windows.Media.Colors.Bisque;
// Convert it to a LEADTOOLS RasterColor
Leadtools.RasterColor leadColor = RasterColorConverter.FromColor(wpfColor);
// Show both colors
Console.WriteLine("wpfColor = {0} - leadColor = {1}", wpfColor, leadColor);
// Make sure both colors are the same
Debug.Assert(
wpfColor.A == leadColor.A &&
wpfColor.R == leadColor.R &&
wpfColor.G == leadColor.G &&
wpfColor.B == leadColor.B);
// Create the LEAD color
leadColor = new RasterColor(128, 24, 35, 67);
// Convert it to a WPF color
wpfColor = RasterColorConverter.ToColor(leadColor);
// Show both colors
Console.WriteLine("wpfColor = {0} - leadColor = {1}", wpfColor, leadColor);
// Make sure both colors are the same
Debug.Assert(
wpfColor.A == leadColor.A &&
wpfColor.R == leadColor.R &&
wpfColor.G == leadColor.G &&
wpfColor.B == leadColor.B);
} |
SilverlightCSharp | Copy Code |
---|
[TestMethod]
public void RasterColorConverterExample()
{
// Create a WPF color
System.Windows.Media.Color wpfColor = System.Windows.Media.Colors.DarkGray;
// Convert it to a LEADTOOLS RasterColor
Leadtools.RasterColor leadColor = RasterColorConverter.FromColor(wpfColor);
// Show both colors
Console.WriteLine("wpfColor = {0} - leadColor = {1}", wpfColor, leadColor);
// Make sure both colors are the same
Debug.Assert(
wpfColor.A == leadColor.A &&
wpfColor.R == leadColor.R &&
wpfColor.G == leadColor.G &&
wpfColor.B == leadColor.B);
// Create the LEAD color
leadColor = new RasterColor(128, 24, 35, 67);
// Convert it to a WPF color
wpfColor = RasterColorConverter.ToColor(leadColor);
// Show both colors
Console.WriteLine("wpfColor = {0} - leadColor = {1}", wpfColor, leadColor);
// Make sure both colors are the same
Debug.Assert(
wpfColor.A == leadColor.A &&
wpfColor.R == leadColor.R &&
wpfColor.G == leadColor.G &&
wpfColor.B == leadColor.B);
} |
SilverlightVB | Copy Code |
---|
<TestMethod> _
Public Sub RasterColorConverterExample()
' Create a WPF color
Dim wpfColor As System.Windows.Media.Color = System.Windows.Media.Colors.DarkGray
' Convert it to a LEADTOOLS RasterColor
Dim leadColor As RasterColor = RasterColorConverter.FromColor(wpfColor)
' Show both colors
Console.WriteLine("wpfColor = {0} - leadColor = {1}", wpfColor, leadColor)
' Make sure both colors are the same
Debug.Assert(wpfColor.A = leadColor.A AndAlso wpfColor.R = leadColor.R AndAlso wpfColor.G = leadColor.G AndAlso wpfColor.B = leadColor.B)
' Create the LEAD color
leadColor = New RasterColor(128, 24, 35, 67)
' Convert it to a WPF color
wpfColor = RasterColorConverter.ToColor(leadColor)
' Show both colors
Console.WriteLine("wpfColor = {0} - leadColor = {1}", wpfColor, leadColor)
' Make sure both colors are the same
Debug.Assert(wpfColor.A = leadColor.A AndAlso wpfColor.R = leadColor.R AndAlso wpfColor.G = leadColor.G AndAlso wpfColor.B = leadColor.B)
End Sub |
Remarks
Inheritance Hierarchy
Requirements
Target Platforms: Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also