LEADTOOLSカラー変換

フレームを表示

LEADカラー変換ツールキットは、その変換メソッドの1つとして、エミュレーションテーブルを提供します。しかし、このメソッドは、以下の変換に対してだけ用意されています:

エミュレーションテーブルのメソッドは、組み込みでカスタムオプションをサポートします。組み込みエミュレーションテーブルのために、ConversionMethodFlags.UseEmulationTablesオプションを使います。カスタムエミュレーションテーブルのオプションであるConversionMethodFlags.UseCustomEmulationTablesを使用すると、ライブラリに付属するソース画像を任意のツールを使用して変換したユーザー定義の画像を使用して、カスタムの変換を実行できます。

変換 ソース 変換します
CMYK to RGB src_cmyk_image.tif RGB image(すなわちdst_cmyk2rgb_image.tif)
LabへのRGB src_rgb_image.tif Lab image(すなわちdst_rgb2lab_image.tif)
RGBへのLab src_lab_image.tif RGB image(すなわちdst_lab2rgb_image.tif)

一組のイメージ(すでに変換されて、使用(dst_cmyk2rgb_image.tif、dst_rgb2lab_image.tifとdst_lab2rgb_image.tif)の準備ができている)は、提供されます。ただし、これらの変換済み画像と組み込みのエミュレーションテーブルのどちらを使用しても、結果は同じです。

[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;
                   }
             
© 1991-2016のLEAD Technologies, Inc. All Rights Reserved.