LEADTOOLS (Leadtools assembly)

RasterColor Structure

Show in webframe
Example 







Members 
Describes a color consisting of relative intensities of alpha, red, green, and blue.
Object Model
Syntax
[SerializableAttribute()]
public struct RasterColor : System.ValueType 
'Declaration
 
<SerializableAttribute()>
Public Structure RasterColor 
   Inherits System.ValueType
'Usage
 
Dim instance As RasterColor
[SerializableAttribute()]
public class RasterColor
@interface LTRasterColor : NSObject<NSCopying>
public final 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:

In the Document and Medical toolkits, the COLORREF value can represent a 16 bit grayscale value if RasterImage is a 12 or 16-bit grayscale bitmap. To avoid confusion with an RGB value, set the COLORREF_GRAY16 mask (0x04000000). In this case (0x0400YYYY), the lower 16 bits (0xYYYY) of the COLORREF value represent the 16-bit grayscale value. (0x0400FFFF is 16-bit white and 0x04000000 is 16-bit black.) This is not a standard Windows value. Therefore, although LEADTOOLS methods will recognize a COLORREF having this format, but Windows methods will not.
Example
Copy Code  
Imports Leadtools

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
using Leadtools;

      
public void Example()
{
   const int A = 128, R = 24, G = 87, B = 134;
   // Create a RasterColor
   RasterColor clr = new RasterColor(A, R, G, B);

   // Make sure the color is correct
   Assert.IsTrue(clr.A == A);
   Assert.IsTrue(clr.R == R);
   Assert.IsTrue(clr.G == G);
   Assert.IsTrue(clr.B == B);

   // 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);
   }
}
using Leadtools;

      
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);
}
using Leadtools;
using Leadtools.Windows.Media;

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);
}
Imports Leadtools
Imports Leadtools.Windows.Media

      
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

See Also

Reference

RasterColor Members
Leadtools Namespace

 

 


Products | Support | Contact Us | Copyright Notices

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