LEADTOOLS Image Processing (Leadtools.ImageProcessing.Effects assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
CombineCommand Class
See Also  Members  
Leadtools.ImageProcessing.Effects Namespace : CombineCommand Class



Combines image data from two images (source and destination), letting you specify the areas to be combined, the operations to be performed when combining the data, and which color planes (R or G or B or R, G, and B) are used. Supported in Silverlight, Windows Phone 7

Object Model

CombineCommand Class

Syntax

Visual Basic (Declaration) 
Public Class CombineCommand 
   Inherits Leadtools.ImageProcessing.RasterCommand
   Implements IRasterCommand 
Visual Basic (Usage)Copy Code
Dim instance As CombineCommand
C# 
public class CombineCommand : Leadtools.ImageProcessing.RasterCommand, IRasterCommand  
C++/CLI 
public ref class CombineCommand : public Leadtools.ImageProcessing.RasterCommand, IRasterCommand  

Example

Run the Leadtools.ImageProcessing.Effects.CombineCommand on an image.

Visual BasicCopy Code
Public Sub CombineCommandExample()
   Dim codecs As New RasterCodecs()
   codecs.ThrowExceptionsOnInvalidImages = True

   Dim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg"))

   ' Prepare the command
   Dim command As CombineCommand = New CombineCommand
   command.SourceImage = leadImage.Clone()
   command.DestinationRectangle = New LeadRect(leadImage.Width \ 8, leadImage.Height \ 8, leadImage.Width, leadImage.Height)
   command.SourcePoint = New LeadPoint(0, 0)
   command.Flags = CombineCommandFlags.OperationAdd Or CombineCommandFlags.Destination0 Or CombineCommandFlags.SourceRed Or CombineCommandFlags.DestinationGreen Or CombineCommandFlags.ResultBlue
   command.Run(leadImage)
   codecs.Save(leadImage, Path.Combine(LEAD_VARS.ImagesDir, "Result.jpg"), RasterImageFormat.Jpeg, 24)

End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
C#Copy Code
public void CombineCommandExample()
   {
      // Load an image
      RasterCodecs codecs = new RasterCodecs();
      codecs.ThrowExceptionsOnInvalidImages = true;

      RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg"));

      // Prepare the command
      CombineCommand command = new CombineCommand();
      command.SourceImage = image.Clone();
      command.DestinationRectangle = new LeadRect(image.Width / 8, image.Height / 8, image.Width, image.Height);
      command.SourcePoint = new LeadPoint(0, 0);
      command.Flags = CombineCommandFlags.OperationAdd | CombineCommandFlags.Destination0 | CombineCommandFlags.SourceRed | CombineCommandFlags.DestinationGreen | CombineCommandFlags.ResultBlue;
      command.Run(image);
      codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Result.jpg"), RasterImageFormat.Jpeg, 24);

   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
SilverlightCSharpCopy Code
public void CombineCommandExample(RasterImage image, Stream outStream)
{
   // Prepare the command
   CombineCommand command = new CombineCommand();
   command.SourceImage = image.Clone();
   command.DestinationRectangle = new LeadRect(image.Width / 8, image.Height / 8, image.Width, image.Height);
   command.SourcePoint = new LeadPoint(0, 0);
   command.Flags = CombineCommandFlags.OperationAdd | CombineCommandFlags.Destination0 | CombineCommandFlags.SourceRed | CombineCommandFlags.DestinationGreen | CombineCommandFlags.ResultBlue;
   command.Run(image);
   // Save result image
   RasterCodecs codecs = new RasterCodecs();
   codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24);
   image.Dispose();
}
SilverlightVBCopy Code
Public Sub CombineCommandExample(ByVal image As RasterImage, ByVal outStream As Stream)
   ' Prepare the command
   Dim command As CombineCommand = New CombineCommand()
   command.SourceImage = image.Clone()
   command.DestinationRectangle = New LeadRect(image.Width / 8, image.Height / 8, image.Width, image.Height)
   command.SourcePoint = New LeadPoint(0, 0)
   command.Flags = CombineCommandFlags.OperationAdd Or CombineCommandFlags.Destination0 Or CombineCommandFlags.SourceRed Or CombineCommandFlags.DestinationGreen Or CombineCommandFlags.ResultBlue
   command.Run(image)
   ' Save result image
   Dim codecs As RasterCodecs = New RasterCodecs()
   codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24)
   image.Dispose()
End Sub

Remarks

  • For example, suppose you use the Leadtools.ImageProcessing.Effects.SpatialFilterCommand to apply an edge detection filter. You can then use this command to combine the resulting image with the original one to produce an image with hard edges.
  • This method combines the data byte-by-byte. The two images can be any color resolution. Images that are 24-bits per pixel are the easiest and fastest to combine. This command uses Windows-style coordinates (with a top-left origin) to specify the areas to be combined.
  • If the channel setting for one of the images is the master channel (CombineCommandFlags.SourceMaster, CombineCommandFlags.DestinationMaster, or CombineCommandFlags.ResultMaster) the settings for all the images will be set to master.
  • If a region is defined for either the source or destination image, or both images, the combine applies only to the intersection of regions.
  • For example, assume CombineCommandFlags.SourceRed is passed for the source image, CombineCommandFlags.DestinationBlue is passed for the destination image and CombineCommandFlags.ResultGreen is passed for the resulting image. In this case, the green channel of the resulting image is calculated as the result of the operations applied to the red channel of the source image and the blue channel of the destination image. The other channels of the resulting image are unchanged.
  • This command supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available only in the Document/Medical toolkits.
  • This command does not support 32-bit grayscale images.
  • All images must be either signed or unsigned.
For more information, refer to Detecting and Enhancing Edges and Lines.
For more information, refer to Removing Noise.

Inheritance Hierarchy

System.Object
   Leadtools.ImageProcessing.RasterCommand
      Leadtools.ImageProcessing.Effects.CombineCommand

Requirements

Target Platforms: Silverlight 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)

See Also