VintaSoftTwain Control v6.0
VintaSoftTwain Object / AcquiredImages_Deskew Method
Zero-based index of image in acquired image collection. Valid values are from 0 to (AcquiredImages_Count-1).
Free space around rotated image will be filled with this color.
Specifies scan interval for X axis. Recommended value is 5.
Specifies scan interval for X axis. Recommended value is 5.
In This Topic
    AcquiredImages_Deskew Method
    In This Topic
    Description
    Deskew an image, i.e. detects correct position of image.
    Syntax
    Visual Basic
    Public Function AcquiredImages_Deskew( _
       ByVal index As Long, _
       ByVal borderColor As enumImageProcessingBorderColor, _
       ByVal scanIntervalX As Integer, _
       ByVal scanIntervalY As Integer _
    ) As Boolean
    Parameters
    index
    Zero-based index of image in acquired image collection. Valid values are from 0 to (AcquiredImages_Count-1).
    borderColor
    ValueDescription
    IMAGEPROCESSINGBORDERCOLOR_AutoDetectFree space around rotated image will be filled with border color of rotated image.
    IMAGEPROCESSINGBORDERCOLOR_BlackFree space around rotated image will be filled with black color.
    IMAGEPROCESSINGBORDERCOLOR_WhiteFree space around rotated image will be filled with white color.
    Free space around rotated image will be filled with this color.
    scanIntervalX
    Specifies scan interval for X axis. Recommended value is 5.
    scanIntervalY
    Specifies scan interval for X axis. Recommended value is 5.
    Return Type
    TRUE (1) if image is processed successfully, FALSE (0) otherwise.
    Remarks
    Here is a "good" sequence of operations for image processing:
    1. Despeckle an image (AcquiredImages_Despeckle method)
    2. Deskew an image (AcquiredImages_Deskew method)
    3. Detect image border (AcquiredImages_DetectBorder method)

    Possible values for scanIntervalX and scanIntervalY parameters: 1 - every column (row) will be scanned, 2 - every second column (row) will be scanned, 3 - every third column (row) will be scanned, and so on. Big values of these parameters may speed up deskewing process, but may worsen results.

    Information about error that occurs during method execution can be get using the Error and ErrorString properties.
    Example
    This example shows how to process scanned image.
    Private VSTwain1 As New VintaSoftTwain()
    
    
    ''' <summary>
    ''' Scans images asynchronously.
    ''' </summary>
    Private Sub StartScan()
        ' open the device manager
        If Not VSTwain1.DeviceManager_Open() Then
            Console.WriteLine(VSTwain1.errorString)
            Exit Sub
        End If
    
        ' select device using standard device selection dialog
        VSTwain1.DeviceManager_ShowDefaultDeviceSelectionDialog()
    
        ' specify that device UI must be shown
        VSTwain1.Device_ShowUI = True
    
        ' subscribe to the device events
        AddHandler VSTwain1.DeviceImageAcquired, AddressOf VSTwain1_ImageAcquired
        AddHandler VSTwain1.DeviceScanCompleted, AddressOf VSTwain1_ScanCompleted
        AddHandler VSTwain1.DeviceScanFailed, AddressOf VSTwain1_ScanFailed
        AddHandler VSTwain1.DeviceScanCanceled, AddressOf VSTwain1_ScanCanceled
    
        ' acquire images asynchronously
        VSTwain1.Device_AcquireImage()
    End Sub
    
    Private Sub VSTwain1_ImageAcquired()
        ' get index of acquired image
        Dim imageIndex As Integer = VSTwain1.AcquiredImages_Count - 1
    
        ' despeckle image
        If Not VSTwain1.AcquiredImages_Despeckle(imageIndex, 8, 25, 30, 400) Then
            Console.WriteLine(VSTwain1.errorString)
        Else
            ' deskew image
            If Not VSTwain1.AcquiredImages_Deskew(imageIndex, IMAGEPROCESSINGBORDERCOLOR.IMAGEPROCESSINGBORDERCOLOR_AutoDetect, 5, 5) Then
                Console.WriteLine(VSTwain1.errorString)
            Else
                ' remove image border
                If Not VSTwain1.AcquiredImages_DetectBorder(imageIndex, 5) Then
                    Console.WriteLine(VSTwain1.errorString)
                End If
            End If
        End If
    End Sub
    
    Private Sub VSTwain1_ScanCompleted()
        Console.WriteLine("Scan is completed.")
    End Sub
    
    Private Sub VSTwain1_ScanFailed(errorString As String)
        Console.WriteLine(String.Format("Scan is failed: {0}.", errorString))
    End Sub
    
    Private Sub VSTwain1_ScanCanceled()
        Console.WriteLine("Scan is canceled.")
    End Sub
    See Also