Creates a
RasterColor from an rgb value.
Syntax
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 Basic |
Copy 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