←Select platform

Create Method

Summary
Creates a table that speeds color conversion when using a palette that you create.
Syntax
C#
C++/CLI
Python
public void Create( 
   RasterColor[] palette 
) 
public: 
void Create(  
   array<RasterColor>^ palette 
)  
def Create(self,] palette): 

Parameters

palette
An array of RasterColor that is your palette.

Remarks

The table is referenced by ColorResolutionCommand.

For more information, refer to RasterUserMatchTable.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
 
 
public void RasterUserMatchTableExample() 
{ 
	RasterCodecs codecs = new RasterCodecs(); 
 
	string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); 
	string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "RasterUserMatchTable.bmp"); 
 
	// Load the image from disk 
	RasterImage image = codecs.Load(srcFileName); 
 
	// 64-color rainbow palette 
	RasterColor[] colors = 
	{ 
	new RasterColor(0, 0, 0), new RasterColor(0, 0, 85), new RasterColor(0, 0, 170), new RasterColor(0, 0, 255), 
	new RasterColor(85, 0, 0), new RasterColor(85, 0, 85), new RasterColor(85, 0, 170), new RasterColor(85, 0, 255), 
	new RasterColor(170, 0, 0), new RasterColor(170, 0, 85), new RasterColor(170, 0, 170), new RasterColor(170, 0, 255), 
	new RasterColor(255, 0, 0), new RasterColor(255, 0, 85), new RasterColor(255, 0, 170), new RasterColor(255, 0, 255), 
	new RasterColor(0, 85, 0), new RasterColor(0, 85, 85), new RasterColor(0, 85, 170), new RasterColor(0, 85, 255), 
	new RasterColor(85, 85, 0), new RasterColor(85, 85, 85), new RasterColor(85, 85, 170), new RasterColor(85, 85, 255), 
	new RasterColor(170, 85, 0), new RasterColor(170, 85, 85), new RasterColor(170, 85, 170), new RasterColor(170, 85, 255), 
	new RasterColor(255, 85, 0), new RasterColor(255, 85, 85), new RasterColor(255, 85, 170), new RasterColor(255, 85, 255), 
	new RasterColor(0, 170, 0), new RasterColor(0, 170, 85), new RasterColor(0, 170, 170), new RasterColor(0, 170, 255), 
	new RasterColor(85, 170, 0), new RasterColor(85, 170, 85), new RasterColor(85, 170, 170), new RasterColor(85, 170, 255), 
	new RasterColor(170, 170, 0), new RasterColor(170, 170, 85), new RasterColor(170, 170, 170), new RasterColor(170, 170, 255), 
	new RasterColor(255, 170, 0), new RasterColor(255, 170, 85), new RasterColor(255, 170, 170), new RasterColor(255, 170, 255), 
	new RasterColor(0, 255, 0), new RasterColor(0, 255, 85), new RasterColor(0, 255, 170), new RasterColor(0, 255, 255), 
	new RasterColor(85, 255, 0), new RasterColor(85, 255, 85), new RasterColor(85, 255, 170), new RasterColor(85, 255, 255), 
	new RasterColor(170, 255, 0), new RasterColor(170, 255, 85), new RasterColor(170, 255, 170), new RasterColor(170, 255, 255), 
	new RasterColor(255, 255, 0), new RasterColor(255, 255, 85), new RasterColor(255, 255, 170), new RasterColor(255, 255, 255) 
 }; 
 
	// Create and set the user match table 
	RasterUserMatchTable userMatchTable = new RasterUserMatchTable(); 
	userMatchTable.Create(colors); 
	userMatchTable.Use(); 
 
	// Change the color resolution using the new palette. Note that the user match table 
	// is makes your code faster only if you use it more than once. It is included here only  
	// to show how it can be coded. 
 
	ColorResolutionCommand command = new ColorResolutionCommand( 
	   ColorResolutionCommandMode.InPlace, 
	   8, 
	   RasterByteOrder.Rgb, 
	   RasterDitheringMethod.FloydStein, 
	   ColorResolutionCommandPaletteFlags.UsePalette | ColorResolutionCommandPaletteFlags.FastMatch, 
	   colors); 
	command.Run(image); 
 
	// Free the user match table when it is no longer needed 
	userMatchTable.Unuse(); 
 
	// Save the image back to disk 
	codecs.Save(image, destFileName, RasterImageFormat.Bmp, 8); 
 
	// Clean up 
	image.Dispose(); 
	codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
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.