Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.11.10
|
The LEAD Color Conversion toolkit provides emulation tables as one of its conversion methods. This method however is provided only for the following conversions:
The Emulation tables' method supports both built-in and custom options. For built-in emulation tables, use the ConversionMethodFlags.UseEmulationTables option. The custom emulation tables' option, ConversionMethodFlags.UseCustomEmulationTables, provides custom conversion using user-supplied images, converted from the source images distributed with the library, by any tool, as follows:
Conversion | Source | Convert to |
---|---|---|
CMYK to RGB | src_cmyk_image.tif | RGB image (i.e. dst_cmyk2rgb_image.tif) |
RGB to Lab | src_rgb_image.tif | Lab image (i.e. dst_rgb2lab_image.tif) |
Lab to RGB | src_lab_image.tif | RGB image (i.e. dst_lab2rgb_image.tif) |
A set of images, already converted and ready for use (dst_cmyk2rgb_image.tif, dst_rgb2lab_image.tif, and dst_lab2rgb_image.tif), is provided. However, using the provided set of converted images will produce the same results as the built-in emulation tables.
[Visual Basic]
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.ColorConversion Private Function BuiltInTablesConvertCmykToRgb(ByVal cmykBuffer As Byte(), ByVal width As Integer, ByVal height As Integer) As Byte() ' StartUp the ColorConversion. RasterColorConverter.Startup() ' Initialize the Rgb buffer array Dim rgbBuffer As Byte() = New Byte(cmykBuffer.Length - 1){} ' Initialize a new ConversionParameters class object. Dim convParams As ConversionParameters = New ConversionParameters() ' Conversion with options. ' The conversion will be done with the options specified in the ' convParams variable ' We want to use built-in emulation tables convParams.Method = ConversionMethodFlags.UseEmulationTables ' Set the quantization to 8 convParams.Quantization = 8 ' set the active conversion method convParams.ActiveMethod = ConversionMethodFlags.UseEmulationTables ' Initialize a new Converter object Dim converter As RasterColorConverter = New RasterColorConverter() Try ' Initialize the color conversion converter.Start(ConversionColorFormat.Cmyk, ConversionColorFormat.Rgb, convParams) ' Convert the image buffer converter.Convert(cmykBuffer, 0, rgbBuffer, 0, width, height, 0, 0) ' Stop the conversion converter.Stop() Catch ex As Exception MessageBox.Show(ex.Message) rgbBuffer = Nothing End Try ' Shutdown the ColorConversion. RasterColorConverter.Shutdown() ' return the converted buffer. Return rgbBuffer End Function[C#]
using Leadtools; using Leadtools.Codecs; using Leadtools.ColorConversion; private byte[] BuiltInTablesConvertCmykToRgb(byte[] cmykBuffer, int width, int height) { // StartUp the ColorConversion. RasterColorConverter.Startup(); // Initialize the Rgb buffer array byte[] rgbBuffer = new byte[cmykBuffer.Length]; // Initialize a new ConversionParameters class object. ConversionParameters convParams = new ConversionParameters(); // Conversion with options. // The conversion will be done with the options specified in the // convParams variable // We want to use built-in emulation tables convParams.Method = ConversionMethodFlags.UseEmulationTables; // set the active conversion method convParams.ActiveMethod = ConversionMethodFlags.UseEmulationTables; // set the quantization to 8 convParams.Quantization = 8; // Initialize a new Converter object RasterColorConverter converter = new RasterColorConverter(); try { // Initialize the color conversion converter.Start(ConversionColorFormat.Cmyk, ConversionColorFormat.Rgb, convParams); // Convert the image buffer converter.Convert(cmykBuffer, 0, rgbBuffer, 0, width, height, 0, 0); // Stop the conversion converter.Stop(); } catch (Exception ex) { MessageBox.Show(ex.Message); rgbBuffer = null; } // Shutdown the ColorConversion. RasterColorConverter.Shutdown(); // return the converted buffer. return rgbBuffer; }
[Visual Basic]
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.ColorConversion Private Function UserTablesConvertCmykToRgb(ByVal cmykBuffer As Byte(), ByVal width As Integer, ByVal height As Integer) As Byte() ' StartUp the ColorConversion. RasterColorConverter.Startup() ' Initialize the Rgb buffer array Dim rgbBuffer As Byte() = New Byte(cmykBuffer.Length - 1){} ' Initialize a new ConversionParameters class object. Dim convParams As ConversionParameters = New ConversionParameters() ' Conversion with options. ' The conversion will be done with the options specified in the ' params(variable) ' we want to use custom emulation tables convParams.Method = ConversionMethodFlags.UseCustomEmulationTables ' set the active conversion method convParams.ActiveMethod = ConversionMethodFlags.UseCustomEmulationTables ' set the emulation tables convParams.DestinationInputTable = "C:\Users\Public\Documents\LEADTOOLS Images\ET\src_rgb_image.tif" ' Initialize a new Converter object Dim converter As RasterColorConverter = New RasterColorConverter() Try ' Initialize the color conversion converter.Start(ConversionColorFormat.Cmyk, ConversionColorFormat.Rgb, convParams) ' Convert the image buffer converter.Convert(cmykBuffer, 0, rgbBuffer, 0, width, height, 0, 0) ' Stop the conversion converter.Stop() Catch ex As Exception MessageBox.Show(ex.Message) rgbBuffer = Nothing End Try ' Shutdown the ColorConversion. RasterColorConverter.Shutdown() ' return the converted buffer. Return rgbBuffer End Function[C#]
using Leadtools; using Leadtools.Codecs; using Leadtools.ColorConversion; private byte[] UserTablesConvertCmykToRgb(byte[] cmykBuffer, int width, int height) { // StartUp the ColorConversion. RasterColorConverter.Startup(); // Initialize the Rgb buffer array byte[] rgbBuffer = new byte[cmykBuffer.Length]; // Initialize a new ConversionParameters class object. ConversionParameters convParams = new ConversionParameters(); // Conversion with options. // The conversion will be done with the options specified in the // params(variable) // we want to use custom emulation tables convParams.Method = ConversionMethodFlags.UseCustomEmulationTables; // set the active conversion method convParams.ActiveMethod = ConversionMethodFlags.UseCustomEmulationTables; // set the emulation tables convParams.DestinationInputTable = @"C:\Users\Public\Documents\LEADTOOLS Images\ET\src_rgb_image.tif"; // Initialize a new Converter object RasterColorConverter converter = new RasterColorConverter(); try { // Initialize the color conversion converter.Start(ConversionColorFormat.Cmyk, ConversionColorFormat.Rgb, convParams); // Convert the image buffer converter.Convert(cmykBuffer, 0, rgbBuffer, 0, width, height, 0, 0); // Stop the conversion converter.Stop(); } catch (Exception ex) { MessageBox.Show(ex.Message); rgbBuffer = null; } // Shutdown the ColorConversion. RasterColorConverter.Shutdown(); // return the converted buffer. return rgbBuffer; }