LEADTOOLS(Leadtoolsアセンブリ)

フレームを表示

RasterCommandProcessorクラス








メンバ 
バッチは、RasterImageオブジェクトのコレクションの上で、RasterCommandオブジェクトのコレクションを処理します。
オブジェクトモデル
構文
public class RasterCommandProcessor 
'Declaration
 
Public Class RasterCommandProcessor 
'Usage
 
Dim instance As RasterCommandProcessor
public sealed class RasterCommandProcessor 
function Leadtools.ImageProcessing.RasterCommandProcessor()
public ref class RasterCommandProcessor 
解説
一つ以上のコマンドが一つ以上のイメージに関して実行される所で、「バッチ」画像処理を実行するために、RasterCommandProcessorクラスを使用します。
サンプル

このサンプルはディスクから複数イメージをロードして、単一の複数ページのtifファイルに結果を保存する前に、複数イメージ処理コマンドを実行します。

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

      
Public Sub RasterCommandProcessorExample()
   Dim codecs As RasterCodecs = New RasterCodecs()
   Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "RasterCommandProcessor.tif")

   ' create a raster command processor
   Dim processor As RasterCommandProcessor = New RasterCommandProcessor()

   ' add the commands (color-res to 8 then flip)
   processor.Commands.Add(New ColorResolutionCommand( _
                          ColorResolutionCommandMode.InPlace, 8, RasterByteOrder.Rgb, RasterDitheringMethod.None, _
                          ColorResolutionCommandPaletteFlags.Optimized, Nothing))
   processor.Commands.Add(New FlipCommand(False))

   ' load the images
   Const imageCount As Integer = 2
   For i As Integer = 0 To imageCount - 1
      Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, String.Format("Image{0}.cmp", i + 1))
      processor.Images.Add(codecs.Load(srcFileName))
   Next i

   ' run the commands
   AddHandler processor.Progress, AddressOf processor_Progress
   processor.Run()
   RemoveHandler processor.Progress, AddressOf processor_Progress

   ' save the result image as multi-page tif file
   If File.Exists(destFileName) Then
      File.Delete(destFileName)
   End If

   For i As Integer = 0 To imageCount - 1
      codecs.Save(processor.Images(i), destFileName, RasterImageFormat.Tif, 8, 1, 1, -1, CodecsSavePageMode.Append)
   Next i

   ' clean up
   For i As Integer = 0 To imageCount - 1
      processor.Images(i).Dispose()
   Next i

End Sub

Private Sub processor_Progress(ByVal sender As Object, ByVal e As RasterCommandProcessorProgressEventArgs)
   ' show information about the command
   Console.Write("Running command {0} ({1}) of {2}, ", e.CommandNumber, e.Command, e.TotalCommands)
   Console.Write("On image {0} ({1} by {2} pixels) of {3}, ", e.ImageNumber, e.Image.Width, e.Image.Height, e.TotalImages)
   Console.WriteLine("{0}% done", e.Percent)
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;

      
public void RasterCommandProcessorExample()
{
   RasterCodecs codecs = new RasterCodecs();
   string destFileName = Path.Combine(ImagesPath.Path, "RasterCommandProcessor.tif");

   // create a raster command processor
   RasterCommandProcessor processor = new RasterCommandProcessor();

   // add the commands (color-res to 8 then flip)
   processor.Commands.Add(new ColorResolutionCommand(
      ColorResolutionCommandMode.InPlace,
      8,
      RasterByteOrder.Rgb,
      RasterDitheringMethod.None,
      ColorResolutionCommandPaletteFlags.Optimized,
      null));
   processor.Commands.Add(new FlipCommand(false));

   // load the images
   const int imageCount = 4;
   for(int i = 0; i < imageCount; i++)
   {
      string srcFileName = Path.Combine(ImagesPath.Path, string.Format("Image{0}.cmp", (i + 1)%2+1));
      processor.Images.Add(codecs.Load(srcFileName));
   }

   // run the commands
   processor.Progress += new EventHandler<RasterCommandProcessorProgressEventArgs>(processor_Progress);
   processor.Run();
   processor.Progress -= new EventHandler<RasterCommandProcessorProgressEventArgs>(processor_Progress);

   // save the result image as multi-page tif file
   if(File.Exists(destFileName))
      File.Delete(destFileName);

   for(int i = 0; i < imageCount; i++)
      codecs.Save(
         processor.Images[i],
         destFileName,
         RasterImageFormat.Tif,
         8,
         1,
         1,
         -1,
         CodecsSavePageMode.Append);

   // clean up
   for(int i = 0; i < imageCount; i++)
      processor.Images[i].Dispose();
}

void processor_Progress(object sender, RasterCommandProcessorProgressEventArgs e)
{
   // show information about the command
   Console.Write("Running command {0} ({1}) of {2}, ", e.CommandNumber, e.Command, e.TotalCommands);
   Console.Write("On image {0} ({1} by {2} pixels) of {3}, ", e.ImageNumber, e.Image.Width, e.Image.Height, e.TotalImages);
   Console.WriteLine("{0}% done", e.Percent);
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Examples;
using Leadtools.ImageProcessing;
using Leadtools.Windows.Media;

public void RasterCommandProcessorExample(RasterImage image1, RasterImage image2, RasterImage image3, Stream destStream)
{
   RasterCodecs codecs = new RasterCodecs();
   // create a raster command processor
   RasterCommandProcessor processor = new RasterCommandProcessor();

   // add the commands (color-res to 8 then flip)
   processor.Commands.Add(new ColorResolutionCommand(
      ColorResolutionCommandMode.InPlace,
      8,
      RasterByteOrder.Rgb,
      RasterDitheringMethod.None,
      ColorResolutionCommandPaletteFlags.Optimized,
      null));
   processor.Commands.Add(new FlipCommand(false));

   // add the images
   processor.Images.Add(image1);
   processor.Images.Add(image2);
   processor.Images.Add(image3);

   // run the commands
   processor.Progress += new EventHandler<RasterCommandProcessorProgressEventArgs>(processor_Progress);
   processor.Run();
   processor.Progress -= new EventHandler<RasterCommandProcessorProgressEventArgs>(processor_Progress);

   // save the result image as multi-page tif file
   for(int i = 0; i < 3; i++)
      codecs.Save(
         processor.Images[i],
         destStream,
         RasterImageFormat.Tif,
         8,
         1,
         1,
         -1,
         CodecsSavePageMode.Append);

   // clean up
   for(int i = 0; i < 3; i++)
      processor.Images[i].Dispose();
}

void processor_Progress(object sender, RasterCommandProcessorProgressEventArgs e)
{
   // show information about the command
   Console.Write("Running command {0} ({1}) of {2}, ", e.CommandNumber, e.Command, e.TotalCommands);
   Console.Write("On image {0} ({1} by {2} pixels) of {3}, ", e.ImageNumber, e.Image.Width, e.Image.Height, e.TotalImages);
   Debug.WriteLine("{0}% done", e.Percent);
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.Windows.Media

Public Sub RasterCommandProcessorExample(ByVal image1 As RasterImage, ByVal image2 As RasterImage, ByVal image3 As RasterImage, ByVal destStream As Stream)
   Dim codecs As RasterCodecs = New RasterCodecs()
   ' create a raster command processor
   Dim processor As RasterCommandProcessor = New RasterCommandProcessor()

   ' add the commands (color-res to 8 then flip)
   processor.Commands.Add(New ColorResolutionCommand(ColorResolutionCommandMode.InPlace, 8, RasterByteOrder.Rgb, RasterDitheringMethod.None, ColorResolutionCommandPaletteFlags.Optimized, Nothing))
   processor.Commands.Add(New FlipCommand(False))

   ' add the images
   processor.Images.Add(image1)
   processor.Images.Add(image2)
   processor.Images.Add(image3)

   ' run the commands
   AddHandler processor.Progress, AddressOf processor_Progress
   processor.Run()
   RemoveHandler processor.Progress, AddressOf processor_Progress

   ' save the result image as multi-page tif file
   For i As Integer = 0 To 2
      codecs.Save(processor.Images(i), destStream, RasterImageFormat.Tif, 8, 1, 1, -1, CodecsSavePageMode.Append)
   Next i

   ' clean up
   For i As Integer = 0 To 2
      processor.Images(i).Dispose()
   Next i
End Sub

Private Sub processor_Progress(ByVal sender As Object, ByVal e As RasterCommandProcessorProgressEventArgs)
   ' show information about the command
   Console.Write("Running command {0} ({1}) of {2}, ", e.CommandNumber, e.Command, e.TotalCommands)
   Console.Write("On image {0} ({1} by {2} pixels) of {3}, ", e.ImageNumber, e.Image.Width, e.Image.Height, e.TotalImages)
   Debug.WriteLine("{0}% done", e.Percent)
End Sub
必要条件

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

参照

参照

RasterCommandProcessorメンバ
Leadtools.ImageProcessing名前空間