LEADTOOLS (Leadtools assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
FromRgb Method
See Also 
Leadtools Namespace > RasterColor Structure : FromRgb Method



rgb
The rgb value.
rgb
The rgb value.
Creates a RasterColor from an rgb value. Supported in Silverlight, Windows Phone 7

Syntax

Visual Basic (Declaration) 
Public Shared Function FromRgb( _
   ByVal rgb As Integer _
) As RasterColor
Visual Basic (Usage)Copy Code
Dim rgb As Integer
Dim value As RasterColor
 
value = RasterColor.FromRgb(rgb)
C# 
public static RasterColor FromRgb( 
   int rgb
)
C++/CLI 
public:
static RasterColor FromRgb( 
   int rgb
) 

Parameters

rgb
The rgb value.

Return Value

The RasterColor structure that this method creates.

Example

This example will create an array of RasterColor containing 256 shades of gray.

Visual BasicCopy Code
Public Sub FromRgbExample()
   Dim colors As RasterColor() = New RasterColor(RasterColor.MaximumComponent - RasterColor.MinimumComponent) {}
   Dim i As Integer = RasterColor.MinimumComponent
   Do While i < RasterColor.MaximumComponent
      colors(i) = RasterColor.FromRgb(i)
      i += 1
   Loop

   i = RasterColor.MinimumComponent
   Do While i < RasterColor.MaximumComponent
      Debug.Assert(colors(i).ToRgb() = i)
      i += 1
   Loop
End Sub
C#Copy Code
public void FromRgbExample()
{
   RasterColor[] colors = new RasterColor[RasterColor.MaximumComponent - RasterColor.MinimumComponent + 1];
   for(int i = RasterColor.MinimumComponent; i < RasterColor.MaximumComponent; i++)
   {
      colors[i] = RasterColor.FromRgb(i);
   }

   for(int i = RasterColor.MinimumComponent; i < RasterColor.MaximumComponent; i++)
   {
      Debug.Assert(colors[i].ToRgb() == i);
   }
}
SilverlightCSharpCopy Code
[TestMethod]
public void FromRgbExample()
{
   RasterColor[] colors = new RasterColor[RasterColor.MaximumComponent - RasterColor.MinimumComponent + 1];
   for(int i = RasterColor.MinimumComponent; i < RasterColor.MaximumComponent; i++)
   {
      colors[i] = RasterColor.FromRgb(i);
   }
   for(int i = RasterColor.MinimumComponent; i < RasterColor.MaximumComponent; i++)
   {
      Debug.Assert(colors[i].ToRgb() == i);
   }
}
SilverlightVBCopy Code
<TestMethod> _
Public Sub FromRgbExample()
   Dim colors As RasterColor() = New RasterColor(RasterColor.MaximumComponent - RasterColor.MinimumComponent){}
   Dim i As Integer = RasterColor.MinimumComponent
   Do While i < RasterColor.MaximumComponent
      colors(i) = RasterColor.FromRgb(i)
      i += 1
   Loop
   i = RasterColor.MinimumComponent
   Do While i < RasterColor.MaximumComponent
      Debug.Assert(colors(i).ToRgb() = i)
      i += 1
   Loop
End Sub

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