Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.6.28
|
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
@interface LTCombineFastCommand : LTRasterCommand
public class CombineFastCommand extends RasterCommand
function Leadtools.ImageProcessing.CombineFastCommand()
public ref class CombineFastCommand : public RasterCommand, IRasterCommand
As an example, suppose you use 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 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 CombineCommand.
For more information, refer to Processing an Image.
The following example loads two images and combines them using an "AND" operation.
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.ImageProcessing 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
using Leadtools; using Leadtools.Codecs; using Leadtools.ImageProcessing; public void CombineFastCommandExample() { RasterCodecs codecs = new RasterCodecs(); string srcFileName1 = Path.Combine(ImagesPath.Path, "Image1.cmp"); string srcFileName2 = Path.Combine(ImagesPath.Path, "Image2.cmp"); string destFileName = Path.Combine(ImagesPath.Path, "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(); codecs.Dispose(); }
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(); }); } } } }
using Leadtools; using Leadtools.Codecs; using Leadtools.ImageProcessing; 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(); }
using Leadtools; using Leadtools.Codecs; using Leadtools.Examples; using Leadtools.ImageProcessing; using Leadtools.Windows.Media; 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(); }
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.ImageProcessing Imports Leadtools.Windows.Media 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