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



rgb
The rgb value.
Creates a RasterColor from an rgb value.

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); 
   } 
}

Requirements

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

See Also