LEADTOOLS Image Processing (Leadtools.ImageProcessing.Core assembly)
LEAD Technologies, Inc

SliceCommandEventArgs Class

Example 





Members 
Handles each slice segment found by SliceCommand. .NET support WinRT support
Object Model
SliceCommandEventArgs Class
Syntax
public class SliceCommandEventArgs : System.EventArgs 
'Declaration
 
Public Class SliceCommandEventArgs 
   Inherits System.EventArgs
'Usage
 
Dim instance As SliceCommandEventArgs
public sealed class SliceCommandEventArgs : ~Remove~ 
function Leadtools.ImageProcessing.Core.SliceCommandEventArgs()
public ref class SliceCommandEventArgs : public System.EventArgs 
Example
 
Public WithEvents sliceEventExample_S2 As SliceCommand
Public Sub SliceCommandEventArgsExample()
   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 cmd As SliceCommand = New SliceCommand(40, New RasterColor(0, 0, 0), SliceCommandFlags.Bicubic Or SliceCommandFlags.CutSlices Or SliceCommandFlags.DeskewImage)

   ' Apply the slice command on the image.
   cmd.Run(leadImage)

   ' Print out the deskew amount.
   Console.WriteLine("Deskew Angle = {0}", cmd.DeskewAngle)

End Sub

Private Sub SliceEventExample_SliceCommand(ByVal sender As Object, ByVal e As SliceCommandEventArgs) Handles sliceEventExample_S2.Slice
   e.Image.AddPage(e.SliceImage)
   e.Cancel = True
End Sub

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

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

      // Prepare the command
      SliceCommand cmd = new SliceCommand(40, new RasterColor(0, 0, 0), SliceCommandFlags.Bicubic | SliceCommandFlags.CutSlices | SliceCommandFlags.DeskewImage);
      cmd.Slice += new EventHandler<SliceCommandEventArgs>(SliceEventExample_S2);

      // Apply the slice command on the image.
      cmd.Run(image);

      // Print out the deskew amount.
      Console.WriteLine("Deskew Angle = {0}", cmd.DeskewAngle);

   }

   private void SliceEventExample_S2(object sender, SliceCommandEventArgs e)
   {
      e.Image.AddPage(e.SliceImage);
      e.Cancel = true;
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
function SliceCommandEventArgsExample()
{
   var codecs = new Leadtools.Codecs.RasterCodecs();
   codecs.throwExceptionsOnInvalidImages = true;

   // Load the image
   var srcFileName = "Assets\\Image1.cmp";
   var processedImage;
   return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) {
      return codecs.loadAsync(Leadtools.LeadStreamFactory.create(loadFile));
   }).then(function (image) {
      // Prepare the command
      with (Leadtools.ImageProcessing.Core) {
         var cmd = new SliceCommand(40, Leadtools.RasterColorHelper.create(0, 0, 0), SliceCommandFlags.bicubic | SliceCommandFlags.cutSlices | SliceCommandFlags.deskewImage);
         cmd.addEventListener("slice", SliceEventExample_S2);

         // Apply the slice command on the image.
         cmd.run(image);

         // Print out the deskew amount.
         console.error("Deskew Angle = {0}", cmd.deskewAngle);
      }
   });
}

function SliceEventExample_S2(e)
{
   e.image.addPage(e.sliceImage);
   e.cancel = true;
}
[TestMethod]
public async Task SliceCommandEventArgsExample()
{
   // Load an image
   RasterCodecs codecs = new RasterCodecs();
   codecs.ThrowExceptionsOnInvalidImages = true;
   // Load the image
   string srcFileName = @"Assets\Image1.cmp";
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile));

   // Prepare the command
   SliceCommand cmd = new SliceCommand(40, RasterColorHelper.Create(0, 0, 0), SliceCommandFlags.Bicubic | SliceCommandFlags.CutSlices | SliceCommandFlags.DeskewImage);
   cmd.Slice += new EventHandler<SliceCommandEventArgs>(SliceEventExample_S2);

   // Apply the slice command on the image.
   cmd.Run(image);

   // Print out the deskew amount.
   Debug.WriteLine("Deskew Angle = {0}", cmd.DeskewAngle);

}

private void SliceEventExample_S2(object sender, SliceCommandEventArgs e)
{
   e.Image.AddPage(e.SliceImage);
   e.Cancel = true;
}
Requirements

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

See Also

Reference

SliceCommandEventArgs Members
Leadtools.ImageProcessing.Core Namespace

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.