LEADTOOLS (Leadtools assembly)
LEAD Technologies, Inc

RasterColor Structure

Example 





Members 
Describes a color consisting of relative intensities of alpha, red, green, and blue. .NET support Silverlight support
Object Model
RasterColor StructureRasterColor StructureRasterColor Structure
Syntax
[SerializableAttribute()]
public struct RasterColor : System.ValueType 
'Declaration
 
<SerializableAttribute()>
Public Structure RasterColor 
   Inherits System.ValueType
'Usage
 
Dim instance As RasterColor
[SerializableAttribute()]
public class RasterColor
JAVASCRIPT_NOSTRUCTS
[SerializableAttribute()]
public value class RasterColor : public System.ValueType 
Remarks

The LEADTOOLS RasterColor class provides a platform independent representation of an ARGB color that can be used in any platform supported by LEADTOOLS such as GDI, GDI+, WPF and Silverlight.

To convert a LEADTOOLS RasterColor object to/from a device dependent color, you can either use the various properties of methods of this class (such as the A, R, G, B properties and the RasterColor(int alpha, int red, int green, int blue) constructor) directly, or use the following helper classes:

Example
 
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
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);
}
function RasterColorExamples()
{
   with (Leadtools) {
      // Create a RasterColor
      var clr = RasterColorHelper.create(128, 24, 87, 134);

      // Make sure the color is correct
      console.assert(clr.a === 128, "clr.a == 128");
      console.assert(clr.r === 24, "clr.r == 24");
      console.assert(clr.g === 87, "clr.g == 87");
      console.assert(clr.b === 134, "clr.b == 134");

      // Show its value
      console.log(clr);

      // Show the A, R, G and B values
      console.log("Alpha value: " + clr.a);
      console.log("Red value: " + clr.r);
      console.log("Green value: " + clr.g);
      console.log("Blue value: " + clr.b);
   }
}
[TestMethod]
public void RasterColorExample()
{
   // Create a RasterColor
   RasterColor clr = RasterColorHelper.Create(128, 24, 87, 134);
   // Make sure the color is correct
   Assert.IsTrue(clr.A == 128);
   Assert.IsTrue(clr.R == 24);
   Assert.IsTrue(clr.G == 87);
   Assert.IsTrue(clr.B == 134);

   // Show its value
   Debug.WriteLine(clr);

   // Show the A, R, G and B values
   Debug.WriteLine("Alpha value: " + clr.A);
   Debug.WriteLine("Red value: " + clr.R);
   Debug.WriteLine("Green value: " + clr.G);
   Debug.WriteLine("Blue value: " + clr.B);
}
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);
}
<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
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

RasterColor Members
Leadtools Namespace

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.