VintaSoft Imaging .NET SDK 15.1: Documentation for .NET developer
Vintasoft.Imaging.UI.VisualTools Namespace / CropSelectionTool Class
Members Object Syntax Remarks Example Hierarchy Requirements SeeAlso
In This Topic
CropSelectionTool Class
In This Topic
A visual tool for cropping an image in image viewer.
Object Model
IInteractionController IInteractionController RectangularObjectTransformer IObjectClipboard ImageViewer CropSelectionTool
Syntax
'Declaration

Public Class CropSelectionTool
   Inherits RectangularSelectionTool

public class CropSelectionTool : RectangularSelectionTool

Remarks

Rectangular region of image in image viewer can be cropped as follows:

  • place the mouse to the desired position
  • press the action button (ActionButton) and select the "crop" region by holding the action button
  • press the action button inside the "crop" region for cropping of image; press any mouse button outside of the "crop" region for canceling cropping of image

If ActionButton is set to right mouse button, context menu during action can be disabled with the DisableContextMenu property.

Example

This C#/VB.NET code shows how to programmatically crop an image.


Class CropSelectionToolExample
    ''' <summary>
    ''' Programmatically crops an image in image viewer.
    ''' </summary>
    ''' <param name="viewer">Image viewer.</param>
    Public Sub ProgrammaticallyCropImageInViewer(viewer As Vintasoft.Imaging.UI.ImageViewer)
        ' create an instance of CropSelectionTool class
        Dim cropSelectionTool As New Vintasoft.Imaging.UI.VisualTools.CropSelectionTool()

        ' set the tool as the current tool of the ImageViewer
        viewer.VisualTool = cropSelectionTool

        ' set the region of interest on image
        cropSelectionTool.Rectangle = New System.Drawing.Rectangle(50, 50, 250, 150)
        ' crop an image
        cropSelectionTool.Crop()
    End Sub
End Class


class CropSelectionToolExample
{
    /// <summary>
    /// Programmatically crops an image in image viewer.
    /// </summary>
    /// <param name="viewer">Image viewer.</param>
    public void ProgrammaticallyCropImageInViewer(Vintasoft.Imaging.UI.ImageViewer viewer)
    {
        // create an instance of CropSelectionTool class
        Vintasoft.Imaging.UI.VisualTools.CropSelectionTool cropSelectionTool = 
            new Vintasoft.Imaging.UI.VisualTools.CropSelectionTool();

        // set the tool as the current tool of the ImageViewer
        viewer.VisualTool = cropSelectionTool;
        
        // set the region of interest on image
        cropSelectionTool.Rectangle = new System.Drawing.Rectangle(50, 50, 250, 150);
        // crop an image
        cropSelectionTool.Crop();
    }
}

Inheritance Hierarchy
Requirements

Target Platforms: .NET 10; .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

See Also