Leadtools.ImageProcessing Namespace : CombineFastCommand Class |
public class CombineFastCommand : RasterCommand, IRasterCommand
'Declaration Public Class CombineFastCommand Inherits RasterCommand Implements IRasterCommand
'Usage Dim instance As CombineFastCommand
public sealed class CombineFastCommand : IRasterCommand
function Leadtools.ImageProcessing.CombineFastCommand()
public ref class CombineFastCommand : public RasterCommand, IRasterCommand
As an example, suppose you use Leadtools.ImageProcessing.Effects.SpatialFilterCommand class to apply an edge detection filter. You can then use this class to combine the resulting image with the original one to produce an image with hard edges.
The CombineFastCommand class works by combining the image in the DestinationImage property with the image passed to the RasterCommand.Run method. The DestinationImage will then hold the result of the combine operation.
The CombineFastCommand flags are divided into four groupings: source (SRC) flags, destination (DST) flags, operation (OP) flags, and resulting image (RES) flags. The flags apply only to the defined rectangles (not necessarily the whole image). The flags are applied in the following order:
You can use a bitwise OR (|) to specify one flag from each group.
Group | Flags |
Flags that define treatment of the source rectangle | None, SourceNot, Source0, Source1 |
Flags that define treatment of the destination rectangle | DestinationNot, Destination0, Destination1 |
Flags that define the operation to use when combining the data | OperationOr, OperationXor, OperationAdd, OperationSubtractSource, OperationSubtractDestination, OperationMultiply, OperationDivideSource, OperationDivideDestination, OperationAverage, OperationMinimum, OperationMaximum |
Flags that define treatment of the resulting image rectangle | ResultNot, Result0, Result1, SourceCopy |
Certain flags when combined have no meaning:
For more options, like specifying the color plane, use Leadtools.ImageProcessing.Effects.CombineCommand.
For more information, refer to Processing an Image.
Public Sub CombineFastCommandExample() Dim codecs As RasterCodecs = New RasterCodecs() Dim srcFileName1 As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp") Dim srcFileName2 As String = Path.Combine(LEAD_VARS.ImagesDir, "Image2.cmp") Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "CombineFastCommand.bmp") ' Load the source images from disk Dim srcImage As RasterImage = codecs.Load(srcFileName1) Dim destImage As RasterImage = codecs.Load(srcFileName2) ' Combine them Dim command As CombineFastCommand = New CombineFastCommand() ' Specify a position in the destination image command.DestinationRectangle = New LeadRect(destImage.Width \ 8, destImage.Height \ 8, destImage.Width, destImage.Height) command.SourcePoint = LeadPoint.Empty command.DestinationImage = destImage command.Flags = CombineFastCommandFlags.OperationAdd Or CombineFastCommandFlags.Destination0 command.Run(srcImage) ' Save it to disk codecs.Save(destImage, destFileName, RasterImageFormat.Bmp, 24) ' Clean Up destImage.Dispose() srcImage.Dispose() End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class
public void CombineFastCommandExample() { RasterCodecs codecs = new RasterCodecs(); string srcFileName1 = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); string srcFileName2 = Path.Combine(LEAD_VARS.ImagesDir, "Image2.cmp"); string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "CombineFastCommand.bmp"); // Load the source images from disk RasterImage srcImage = codecs.Load(srcFileName1); RasterImage destImage = codecs.Load(srcFileName2); // Combine them CombineFastCommand command = new CombineFastCommand(); // Specify a position in the destination image command.DestinationRectangle = new LeadRect( destImage.Width / 8, destImage.Height / 8, destImage.Width, destImage.Height); command.SourcePoint = LeadPoint.Empty; command.DestinationImage = destImage; command.Flags = CombineFastCommandFlags.OperationAdd | CombineFastCommandFlags.Destination0; command.Run(srcImage); // Save it to disk codecs.Save(destImage, destFileName, RasterImageFormat.Bmp, 24); // Clean Up destImage.Dispose(); srcImage.Dispose(); } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; }
RasterCommandExamples.prototype.CombineFastCommandExample = function ( ) { Tools.SetLicense ( ) ; with (Leadtools) { with (Leadtools.Codecs) { with (Leadtools.ImageProcessing) { var codecs = new RasterCodecs(); var srcFileName1 = "Assets\\sample1.cmp"; var srcFileName2 = "Assets\\sample2.cmp"; var destFileName = "CombineFastCommand.bmp"; var srcImage; var destImage; // Load the source images from disk return Tools.AppInstallFolder().getFileAsync(srcFileName1).then(function (loadFile) { return codecs.loadAsync(LeadStreamFactory.create(loadFile)) }) .then(function (img) { srcImage = img; return Tools.AppInstallFolder().getFileAsync(srcFileName2) }) .then(function (loadFile) { return codecs.loadAsync(LeadStreamFactory.create(loadFile)) }) .then(function (destImg) { destImage = destImg; // Combine them var command = new CombineFastCommand(); // Specify a position in the destination image command.destinationRectangle = LeadRectHelper.create( destImage.width / 8, destImage.height / 8, destImage.width, destImage.height); command.sourcePoint = LeadPointHelper.empty; command.destinationImage = destImage; command.flags = CombineFastCommandFlags.operationAdd | CombineFastCommandFlags.destination0; command.run(srcImage); // Save it to disk return Tools.AppLocalFolder().createFileAsync(destFileName) }) .then(function (saveFile) { return codecs.saveAsync(destImage, LeadStreamFactory.create(saveFile), RasterImageFormat.bmp, 24) }) .then(function () { // Clean Up destImage.close(); srcImage.close(); codecs.close(); }); } } } }
[TestMethod] public async Task CombineFastCommandExample() { RasterCodecs codecs = new RasterCodecs(); string srcFileName1 = @"Assets\sample1.cmp"; string srcFileName2 = @"Assets\sample2.cmp"; string destFileName = @"CombineFastCommand.bmp"; // Load the source images from disk StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName1); RasterImage srcImage = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile)); loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName2); RasterImage destImage = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile)); // Combine them CombineFastCommand command = new CombineFastCommand(); // Specify a position in the destination image command.DestinationRectangle = LeadRectHelper.Create( destImage.Width / 8, destImage.Height / 8, destImage.Width, destImage.Height); command.SourcePoint = LeadPointHelper.Empty; command.DestinationImage = destImage; command.Flags = CombineFastCommandFlags.OperationAdd | CombineFastCommandFlags.Destination0; command.Run(srcImage); // Save it to disk StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(destFileName); await codecs.SaveAsync(destImage, LeadStreamFactory.Create(saveFile), RasterImageFormat.Bmp, 24); // Clean Up destImage.Dispose(); srcImage.Dispose(); }
public void CombineFastCommandExample(RasterImage srcImage, RasterImage destImage, Stream destStream) { RasterCodecs codecs = new RasterCodecs(); // Combine them CombineFastCommand command = new CombineFastCommand(); // Specify a position in the destination image command.DestinationRectangle = new LeadRect( destImage.Width / 8, destImage.Height / 8, destImage.Width, destImage.Height); command.SourcePoint = LeadPoint.Empty; command.DestinationImage = destImage; command.Flags = CombineFastCommandFlags.OperationAdd | CombineFastCommandFlags.Destination0; command.Run(srcImage); // Save it to disk codecs.Save(destImage, destStream, RasterImageFormat.Png, 24); // Clean Up destImage.Dispose(); srcImage.Dispose(); }
Public Sub CombineFastCommandExample(ByVal srcImage As RasterImage, ByVal destImage As RasterImage, ByVal destStream As Stream)
Dim codecs As RasterCodecs = New RasterCodecs()
' Combine them
Dim command As CombineFastCommand = New CombineFastCommand()
' Specify a position in the destination image
command.DestinationRectangle = New LeadRect(destImage.Width / 8, destImage.Height / 8, destImage.Width, destImage.Height)
command.SourcePoint = LeadPoint.Empty
command.DestinationImage = destImage
command.Flags = CombineFastCommandFlags.OperationAdd Or CombineFastCommandFlags.Destination0
command.Run(srcImage)
' Save it to disk
codecs.Save(destImage, destStream, RasterImageFormat.Png, 24)
' Clean Up
destImage.Dispose()
srcImage.Dispose()
End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2