The 
RasterCommand class implements 
IRasterCommand and is the base class for all LEADTOOLS image processing commands. 
Syntax
| Visual Basic (Declaration) | 
  | 
Public MustInherit Class RasterCommand 
   Implements IRasterCommand   | 
 
| C++/CLI | 
  | 
public ref class RasterCommand abstract : public IRasterCommand    | 
  
Example
This example runs two image processing commands on an image showing the progress percentage.
| Visual Basic | 
 Copy Code | 
Public Sub RasterCommandExample()  RasterCodecs.Startup()  Dim codecs As RasterCodecs = New RasterCodecs()
   Dim srcFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp"  Dim rotatedFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Image1_rotated.bmp"  Dim flippedFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Image1_flipped.bmp"
     Dim image As RasterImage = codecs.Load(srcFileName)
     Dim flip As FlipCommand = New FlipCommand(False)  RunCommand(image, flip)
     codecs.Save(image, flippedFileName, RasterImageFormat.Bmp, 24)
     Dim rotate As RotateCommand = New RotateCommand()  rotate.Angle = 45 * 100  rotate.FillColor = RasterColor.FromGdiPlusColor(Color.White)  rotate.Flags = RotateCommandFlags.Resize  RunCommand(image, rotate)
     codecs.Save(image, rotatedFileName, RasterImageFormat.Bmp, 24)
     image.Dispose()  RasterCodecs.Shutdown()       End Sub
        Private cancelAt50 As Boolean
        Private Sub RunCommand(ByVal image As RasterImage, ByVal command As IRasterCommand)    AddHandler command.Progress, AddressOf command_Progress
     cancelAt50 = TypeOf command Is FlipCommand
     command.Run(image)
   RemoveHandler command.Progress, AddressOf command_Progress       End Sub
        Private Sub command_Progress(ByVal sender As Object, ByVal e As RasterCommandProgressEventArgs)    Console.WriteLine(e.Percent)
     If e.Percent = 50 AndAlso cancelAt50 Then     e.Cancel = True  End If       End Sub | 
 
| C# | 
 Copy Code | 
public void RasterCommandExample()  {     RasterCodecs.Startup();     RasterCodecs codecs = new RasterCodecs();       string srcFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp";     string rotatedFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Image1_rotated.bmp";     string flippedFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Image1_flipped.bmp";       // Load the source image from disk     RasterImage image = codecs.Load(srcFileName);       // flip the image     FlipCommand flip = new FlipCommand(false);     RunCommand(image, flip);       // save the image     codecs.Save(image, flippedFileName, RasterImageFormat.Bmp, 24);       // rotate the image by 45 degrees     RotateCommand rotate = new RotateCommand();     rotate.Angle = 45 * 100;     rotate.FillColor = RasterColor.FromGdiPlusColor(Color.White);     rotate.Flags = RotateCommandFlags.Resize;     RunCommand(image, rotate);       // save the image     codecs.Save(image, rotatedFileName, RasterImageFormat.Bmp, 24);       // clean up     image.Dispose();     RasterCodecs.Shutdown();  }    bool cancelAt50;    void RunCommand(RasterImage image, IRasterCommand command)  {     // subscribe to the progress event of the command     command.Progress += new EventHandler<RasterCommandProgressEventArgs>(command_Progress);       // if this is a flip command, we want to stop at 50 percent     cancelAt50 = command is FlipCommand;       // run the command     command.Run(image);       command.Progress -= new EventHandler<RasterCommandProgressEventArgs>(command_Progress);  }    void command_Progress(object sender, RasterCommandProgressEventArgs e)  {     // show the percentage     Console.WriteLine(e.Percent);       // check if we need to cancel the command at 50%     if(e.Percent == 50 && cancelAt50)        e.Cancel = true;  } | 
  
Remarks
Inheritance Hierarchy
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
 
See Also