The RasterCommand class implements IRasterCommand and is the base class for all LEADTOOLS image processing commands.
public abstract class RasterCommand : IRasterCommand Public MustInherit Class RasterCommandImplements Leadtools.Imageprocessing.IRasterCommand
public sealed class RasterCommand : Leadtools.Imageprocessing.IRasterCommand @interface LTRasterCommand : NSObject public abstract class RasterCommand implements IRasterCommand function Leadtools.ImageProcessing.RasterCommand() public ref class RasterCommand abstract : public Leadtools.Imageprocessing.IRasterCommand The RasterCommand class is the base class for all LEADTOOLS image processing commands.
This class contains functionality for dealing with running an image processing command, including progress status of the command.
This example runs two image processing commands on an image showing the progress percentage.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using LeadtoolsExamples.Common;public void RasterCommandExample(){RasterCodecs codecs = new RasterCodecs();string srcFileName = Path.Combine(ImagesPath.Path, "Image1.cmp");string rotatedFileName = Path.Combine(ImagesPath.Path, "Image1_rotated.bmp");string flippedFileName = Path.Combine(ImagesPath.Path, "Image1_flipped.bmp");// Load the source image from diskRasterImage image = codecs.Load(srcFileName);// flip the imageFlipCommand flip = new FlipCommand(false);RunCommand(image, flip);// save the imagecodecs.Save(image, flippedFileName, RasterImageFormat.Bmp, 24);// rotate the image by 45 degreesRotateCommand rotate = new RotateCommand();rotate.Angle = 45 * 100;rotate.FillColor = RasterColor.FromKnownColor(RasterKnownColor.White);rotate.Flags = RotateCommandFlags.Resize;RunCommand(image, rotate);// save the imagecodecs.Save(image, rotatedFileName, RasterImageFormat.Bmp, 24);// clean upimage.Dispose();codecs.Dispose();}bool cancelAt50;void RunCommand(RasterImage image, IRasterCommand command){// subscribe to the progress event of the commandcommand.Progress += new EventHandler<RasterCommandProgressEventArgs>(command_Progress);// if this is a flip command, we want to stop at 50 percentcancelAt50 = command is FlipCommand;// run the commandcommand.Run(image);command.Progress -= new EventHandler<RasterCommandProgressEventArgs>(command_Progress);}void command_Progress(object sender, RasterCommandProgressEventArgs e){// show the percentageConsole.WriteLine(e.Percent);// check if we need to cancel the command at 50%if (e.Percent == 50 && cancelAt50)e.Cancel = true;}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingPublic Sub RasterCommandExample()Dim codecs As RasterCodecs = New RasterCodecs()Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")Dim rotatedFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1_rotated.bmp")Dim flippedFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1_flipped.bmp")' Load the source image from diskDim image As RasterImage = codecs.Load(srcFileName)' flip the imageDim flip As FlipCommand = New FlipCommand(False)RunCommand(image, flip)' save the imagecodecs.Save(image, flippedFileName, RasterImageFormat.Bmp, 24)' rotate the image by 45 degreesDim rotate As RotateCommand = New RotateCommand()rotate.Angle = 45 * 100rotate.FillColor = RasterColor.FromKnownColor(RasterKnownColor.White)rotate.Flags = RotateCommandFlags.ResizeRunCommand(image, rotate)' save the imagecodecs.Save(image, rotatedFileName, RasterImageFormat.Bmp, 24)' clean upimage.Dispose()End SubPrivate cancelAt50 As BooleanPrivate Sub RunCommand(ByVal image As RasterImage, ByVal command As IRasterCommand)' subscribe to the progress event of the commandAddHandler command.Progress, AddressOf command_Progress' if this is a flip command, we want to stop at 50 percentcancelAt50 = TypeOf command Is FlipCommand' run the commandcommand.Run(image)RemoveHandler command.Progress, AddressOf command_ProgressEnd SubPrivate Sub command_Progress(ByVal sender As Object, ByVal e As RasterCommandProgressEventArgs)' show the percentageConsole.WriteLine(e.Percent)' check if we need to cancel the command at 50%If e.Percent = 50 AndAlso cancelAt50 Thene.Cancel = TrueEnd IfEnd SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
using Leadtools;using Leadtools.Codecs;using Leadtools.Examples;using Leadtools.ImageProcessing;using Leadtools.Windows.Media;public void RasterCommandExample(RasterImage image, Stream flippedStream, Stream rotatedStream){RasterCodecs codecs = new RasterCodecs();// flip the imageFlipCommand flip = new FlipCommand(false);RunCommand(image, flip);// save the imagecodecs.Save(image, flippedStream, RasterImageFormat.Png, 24);// rotate the image by 45 degreesRotateCommand rotate = new RotateCommand();rotate.Angle = 45 * 100;rotate.FillColor = RasterColorConverter.FromColor(Colors.White);rotate.Flags = RotateCommandFlags.Resize;RunCommand(image, rotate);// save the imagecodecs.Save(image, rotatedStream, RasterImageFormat.Png, 24);// clean upimage.Dispose();}bool cancelAt50;void RunCommand(RasterImage image, IRasterCommand command){// subscribe to the progress event of the commandcommand.Progress += new EventHandler<RasterCommandProgressEventArgs>(command_Progress);// if this is a flip command, we want to stop at 50 percentcancelAt50 = command is FlipCommand;// run the commandcommand.Run(image);command.Progress -= new EventHandler<RasterCommandProgressEventArgs>(command_Progress);}void command_Progress(object sender, RasterCommandProgressEventArgs e){// show the percentageDebug.WriteLine(e.Percent);// check if we need to cancel the command at 50%if (e.Percent == 50 && cancelAt50)e.Cancel = true;}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.Windows.MediaPublic Sub RasterCommandExample(ByVal image As RasterImage, ByVal flippedStream As Stream, ByVal rotatedStream As Stream)Dim codecs As RasterCodecs = New RasterCodecs()' flip the imageDim flip As FlipCommand = New FlipCommand(False)RunCommand(image, flip)' save the imagecodecs.Save(image, flippedStream, RasterImageFormat.Png, 24)' rotate the image by 45 degreesDim rotate As RotateCommand = New RotateCommand()rotate.Angle = 45 * 100rotate.FillColor = RasterColorConverter.FromColor(Colors.White)rotate.Flags = RotateCommandFlags.ResizeRunCommand(image, rotate)' save the imagecodecs.Save(image, rotatedStream, RasterImageFormat.Png, 24)' clean upimage.Dispose()End SubPrivate cancelAt50 As BooleanPrivate Sub RunCommand(ByVal image As RasterImage, ByVal command As IRasterCommand)' subscribe to the progress event of the commandAddHandler command.Progress, AddressOf command_Progress' if this is a flip command, we want to stop at 50 percentcancelAt50 = TypeOf command Is FlipCommand' run the commandcommand.Run(image)RemoveHandler command.Progress, AddressOf command_ProgressEnd SubPrivate Sub command_Progress(ByVal sender As Object, ByVal e As RasterCommandProgressEventArgs)' show the percentageDebug.WriteLine(e.Percent)' check if we need to cancel the command at 50%If e.Percent = 50 AndAlso cancelAt50 Thene.Cancel = TrueEnd IfEnd Sub
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
