←Select platform

FromKnownColor Method

Summary
Creates a new RasterColor structure from a known color.
Syntax
C#
C++/CLI
Java
Python
[CLSCompliantAttribute(false)] 
public static RasterColor FromKnownColor( 
   RasterKnownColor knownColor 
) 
public static RasterColor fromKnownColor( 
   long longValue 
); 
[CLSCompliantAttribute(false)] 
public: 
static RasterColor FromKnownColor(  
   RasterKnownColor knownColor 
)  
def FromKnownColor(self,knownColor): 

Parameters

knownColor
One of the RasterKnownColor enumeration members.

Return Value

The new RasterColor object.

Remarks

You can use the RasterKnownColor enumeration to construct RasterColor objects from colors known by name.

Example
C#
Java
using Leadtools; 
 
 
public void FromKnownColorExample() 
{ 
	// Create a yellow color (R = 255, G = 255, B = 0) 
	RasterColor clr1 = new RasterColor(255, 255, 0); 
 
	// Now create the same color using the "Yellow" known color 
	RasterColor clr2 = RasterColor.FromKnownColor(RasterKnownColor.Yellow); 
 
	// Make sure both colors have the same value 
	Assert.IsTrue(clr1.A == clr2.A); 
	Assert.IsTrue(clr1.R == clr2.R); 
	Assert.IsTrue(clr1.G == clr2.G); 
	Assert.IsTrue(clr1.B == clr2.B); 
} 
 
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 rasterColorFromKnownColorExample() { 
   // Create a yellow color (R = 255, G = 255, B = 0) 
   RasterColor clr1 = new RasterColor(255, 255, 0); 
 
   // Now create the same color using the "Yellow" known color 
   RasterColor clr2 = RasterColor.fromKnownColor(RasterKnownColor.YELLOW); 
 
   // Make sure both colors have the same value 
   assertTrue(clr1.a() == clr2.a()); 
   assertTrue(clr1.r() == clr2.r()); 
   assertTrue(clr1.g() == clr2.g()); 
   assertTrue(clr1.b() == clr2.b()); 
} 
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.