←Select platform

FromRgb Method

Summary
Creates a RasterColor from an rgb value.
Syntax
C#
C++/CLI
Java
Python
public static RasterColor FromRgb( 
   int rgb 
) 
public static RasterColor fromRgb( 
   int rgb 
); 
public: 
static RasterColor FromRgb(  
   int rgb 
)  
def FromRgb(self,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.

C#
Java
using Leadtools; 
 
 
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++) 
	{ 
		Assert.IsTrue(colors[i].ToRgb() == i); 
	} 
} 
 
import java.io.File; 
import java.io.IOException; 
import java.util.Random; 
 
import org.junit.*; 
import org.junit.Test; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
 
 
public void rasterColorFromRgbExample() { 
   RasterColor[] colors = new RasterColor[RasterColor.MAXIMUM_COMPONENT - RasterColor.MINIMUM_COMPONENT + 1]; 
   for (int i = RasterColor.MINIMUM_COMPONENT; i < RasterColor.MAXIMUM_COMPONENT; i++) { 
      colors[i] = RasterColor.fromRgb(i); 
   } 
 
   for (int i = RasterColor.MINIMUM_COMPONENT; i < RasterColor.MAXIMUM_COMPONENT; i++) { 
      assertTrue(colors[i].toRgb() == i); 
   } 
} 
Requirements

Target Platforms

Help Version 23.0.2024.5.22
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.