Initializes a new AutoCropRectangleCommand class object with explicit parameters.
Syntax
Visual Basic (Declaration) | |
---|
Public Function New( _
ByVal threshold As Integer _
) |
Parameters
- threshold
- Delta value for detecting blank space.
Starting at each edge of the image and evaluating toward the center,
any change in intensity that is less than or equal to this
parameter is considered blank space. Valid values are 0 to 255.
Example
Run the AutoCropRectangleCommand on an image to get the AutoCrop Rectangle.
Visual Basic | Copy Code |
---|
Public Sub AutoCropRectangleConstructorExample()
RasterCodecs.Startup()
Dim codecs As New RasterCodecs()
codecs.ThrowExceptionsOnInvalidImages = True
Dim leadImage As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Master.jpg")
Dim threshold As Integer = 0
Try
Dim command As AutoCropRectangleCommand
command = New AutoCropRectangleCommand(threshold)
command.Run(leadImage)
MessageBox.Show("Left = " + command.Rectangle.Left.ToString() + Chr(13) + "Top = " + command.Rectangle.Top.ToString() + Chr(13) + "Right = " + command.Rectangle.Right.ToString() + Chr(13) + "Bottom = " + command.Rectangle.Bottom.ToString())
Catch e As Exception
MessageBox.Show(e.Message)
End Try
RasterCodecs.Shutdown()
End Sub |
C# | Copy Code |
---|
public void AutoCropRectangleConstructorExample() { // Load an image RasterCodecs.Startup(); RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; RasterImage image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Master.jpg"); // Prepare the command int threshold = 0; try { AutoCropRectangleCommand command = new AutoCropRectangleCommand(threshold); // Get the Rectangle for AutoCrop with tolerance = threshold passes by the user. command.Run(image); MessageBox.Show("Left = " + command.Rectangle.Left.ToString() + "\n" + "Top = " + command.Rectangle.Top.ToString() + "\n" + "Right = " + command.Rectangle.Right.ToString() + "\n" + "Bottom = " + command.Rectangle.Bottom.ToString()); } catch(Exception exception) { MessageBox.Show(exception.Message); } RasterCodecs.Shutdown(); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also