LEADTOOLS(Leadtoolsアセンブリ)

フレームを表示

RasterUserMatchTableクラス








メンバ 
ColorResolutionCommand使用時にユーザーパレットでの変換を高速化するよう事前定義されたテーブルを維持します。
オブジェクトモデル
構文
public class RasterUserMatchTable 
'Declaration
 
Public Class RasterUserMatchTable 
'Usage
 
Dim instance As RasterUserMatchTable
public sealed class RasterUserMatchTable 
function Leadtools.ImageProcessing.RasterUserMatchTable()
public ref class RasterUserMatchTable 
解説

ColorResolutionCommandを使うとき、ユーザーパレットで速度変換に事前定義テーブルを作成するために、RasterUserMatchTableクラスを使用します。

以下のシーケンスを使わなければなりません:

  1. RasterUserMatchTableクラスの新しいインスタンスを作成します
  2. テーブルを作成するために、RasterUserMatchTable.Createメソッドを呼び出します。
  3. これを現在のテーブルにするために、RasterUserMatchTable.Useメソッドを呼び出します。(別々のメソッドとしてこれを持っていることは、ファイルでテーブルを保存して、再びそれを作成することなく、必要とするものを取得することができます。)
  4. ColorResolutionCommand.PaletteFlagsプロパティでColorResolutionCommandPaletteFlags.UsePaletteまたはColorResolutionCommandPaletteFlags.FastMatchを設定して、ColorResolutionCommandを実行します。
  5. テーブルがもはや必要でないとき、Unuseメソッドを呼び出します。

完成する表は、整数の32Kの配列です。32ビットシステムの上で、それは128Kのバイトメモリを占有します。テーブルの作成は遅く、メモリ集中プロセスであり、ユーザー独自のパレットを1回以上使用する場合にのみ有用です。たとえば、テーブルを作成してファイルに保存し、そのファイルを自身のアプリケーションをと共に出荷する場合です。

サンプル

このサンプルは、高速カラーマッチングのためにユーザー定義のパレットとマッチテーブルを使用してビットマップのカラー解像度を変更します。

Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core

      
  Public Sub RasterUserMatchTableExample()
   Dim codecs As RasterCodecs = New RasterCodecs()
   Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")
   Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "RasterUserMatchTable.bmp")

   ' Load the image from disk
   Dim image As RasterImage = codecs.Load(srcFileName)

   ' 64-color rainbow palette
   Dim colors As RasterColor() = {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
   Dim userMatchTable As RasterUserMatchTable = 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.

   Dim command As ColorResolutionCommand = New ColorResolutionCommand( _
                                           ColorResolutionCommandMode.InPlace, 8, RasterByteOrder.Rgb, _
                                           RasterDitheringMethod.FloydStein, _
                                           ColorResolutionCommandPaletteFlags.UsePalette Or _
                                           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()
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;

      
public void RasterUserMatchTableExample()
{
   RasterCodecs codecs = new RasterCodecs();
   string srcFileName = Path.Combine(ImagesPath.Path, "Image1.cmp");
   string destFileName = Path.Combine(ImagesPath.Path, "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();
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Examples;
using Leadtools.ImageProcessing;

public void RasterUserMatchTableExample(RasterImage image, Stream destStream)
{
   RasterCodecs codecs = new RasterCodecs();
   // 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, destStream, RasterImageFormat.Bmp, 8);

   // Clean up
   image.Dispose();
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing

Public Sub RasterUserMatchTableExample(ByVal image As RasterImage, ByVal destStream As Stream)
   Dim codecs As RasterCodecs = New RasterCodecs()
   ' 64-color rainbow palette
   Dim colors As RasterColor() = {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
   Dim userMatchTable As RasterUserMatchTable = 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.

   Dim command As ColorResolutionCommand = New ColorResolutionCommand(ColorResolutionCommandMode.InPlace, 8, RasterByteOrder.Rgb, RasterDitheringMethod.FloydStein, ColorResolutionCommandPaletteFlags.UsePalette Or _
         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, destStream, RasterImageFormat.Bmp, 8)

   ' Clean up
   image.Dispose()
End Sub
必要条件

ターゲットプラットホーム

参照

参照

RasterUserMatchTableメンバ
Leadtools.ImageProcessing名前空間