Leadtools Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
RasterColor Structure
See Also  Members   Example
Leadtools Namespace : RasterColor Structure



Describes a color consisting of relative intensities of alpha, red, green, and blue.

Syntax

Visual Basic (Declaration)  
<SerializableAttribute()>
Public Structure RasterColor 
   Inherits ValueType
Visual Basic (Usage) Copy Code
Dim instance As RasterColor
C#  
[SerializableAttribute()]
public struct RasterColor : ValueType 
C++/CLI  
[SerializableAttribute()]
public value class RasterColor : public ValueType 

Example

Converts a .NET color to a RasterColor and back.

Visual Basic Copy Code
Public Sub Example()
 Dim rand As Random = New Random()

 ' Create a random .NET color
 Dim clr1 As Color = Color.FromArgb(rand.Next(256), rand.Next(256), rand.Next(256), rand.Next(256))

 ' Convert this color to a LEADTOOLS color
 Dim clr2 As RasterColor = RasterColor.FromGdiPlusColor(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 = clr2.ToGdiPlusColor()

 ' 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
C# Copy Code
public void Example() 

   Random rand = new Random(); 
 
   // Create a random .NET color 
   Color clr1 = Color.FromArgb(rand.Next(256), rand.Next(256), rand.Next(256), rand.Next(256)); 
 
   // Convert this color to a LEADTOOLS color 
   RasterColor clr2 = RasterColor.FromGdiPlusColor(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 = clr2.ToGdiPlusColor(); 
 
   // 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); 
}

Remarks

You can use RasterColor.FromGdiPlusColor to convert a System.Drawing.Color object to RasterColor and RasterColor.ToGdiPlusColor to convert a RasterColor object to a System.Drawing.Color.

Inheritance Hierarchy

System.Object
   System.ValueType
      Leadtools.RasterColor

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also