RasterCommandsList Class
Syntax
C#
VB
Objective-C
C++
Java
Public Class RasterCommandsList
Implements System.Collections.Generic.IList(Of RasterCommand)
@interface LTRasterCommandsList : NSMutableArray<LTRasterCommand *>
public class RasterCommandsList implements List<IRasterCommand>
public ref class RasterCommandsList : System.Collections.Generic.IList<RasterCommand>
Example
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Kernel;
public void RasterCommandsListExample()
{
using (RasterCodecs codecs = new RasterCodecs())
{
// Load an image
using (RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")))
{
//Prepare the list
RasterCommandsList commandsList = new RasterCommandsList();
commandsList.CommandCompleted += new EventHandler<RasterCommandCompletedEventArgs>(CommandCompleted);
commandsList.Add(new Leadtools.ImageProcessing.Kernel.CropCommand(new LeadRect(100, 100, image.Width - 100, image.Height - 100)));
commandsList.Add(new InvertCommand());
// Run the command and save the result
commandsList.Run(image);
// Check the result image created, otherwise use the input image
if (commandsList.ResultImage != null)
{
codecs.Save(commandsList.ResultImage, Path.Combine(LEAD_VARS.ImagesDir, "Result.bmp"), RasterImageFormat.Bmp, 24);
commandsList.ResultImage.Dispose();
}
else
{
codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Result.bmp"), RasterImageFormat.Bmp, 24);
}
}
}
}
private void CommandCompleted(object sender, RasterCommandCompletedEventArgs e)
{
Console.WriteLine(e.Command.ToString());
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing.Kernel
Public Sub RasterCommandsListExample()
Using codecs As RasterCodecs = New RasterCodecs()
Using image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg"))
' Prepare the list
Dim commandsList As RasterCommandsList = New RasterCommandsList()
AddHandler commandsList.CommandCompleted, AddressOf CommandCompleted
commandsList.Add(New CropCommand(New LeadRect(100, 100, image.Width - 100, image.Height - 100)))
commandsList.Add(New InvertCommand())
' Run the command And save the result
commandsList.Run(image)
' Check the result image created, otherwise use the input image
If commandsList.ResultImage IsNot Nothing Then
codecs.Save(commandsList.ResultImage, Path.Combine(LEAD_VARS.ImagesDir, "Result.bmp"), RasterImageFormat.Bmp, 24)
commandsList.ResultImage.Dispose()
Else
codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Result.bmp"), RasterImageFormat.Bmp, 24)
End If
End Using
End Using
End Sub
Private Sub CommandCompleted(ByVal sender As Object, ByVal e As RasterCommandCompletedEventArgs)
Console.WriteLine(e.Command.ToString())
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class