VintaSoftTwain Control v6.0
VintaSoftTwain Object / AcquiredImagesImageProcessingProgress Event
Gets the progress, in percents, of current action.
Indicates that current action can be canceled.
Indicates that current action must be canceled.
In This Topic
    AcquiredImagesImageProcessingProgress Event
    In This Topic
    Description
    Occurs when progress of image processing is changed.
    Syntax
    Visual Basic
    Public Event AcquiredImagesImageProcessingProgress( _
       ByVal progress As Integer, _
       ByVal canCancel As Boolean, _
       ByRef cancel As Boolean _
    )
    Parameters
    progress
    Gets the progress, in percents, of current action.
    canCancel
    Indicates that current action can be canceled.
    cancel
    Indicates that current action must be canceled.
    Example
    This example shows how to process scanned image with progress indication.
    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)
        End If
    
        ' select device using standard device selection dialog
        VSTwain1.DeviceManager_ShowDefaultDeviceSelectionDialog()
    
        ' open the device
        If Not VSTwain1.Device_Open Then
            Console.WriteLine(VSTwain1.errorString)
            Exit Sub
        End If
    
        ' 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()
        ' subscribe to the progress event
        AddHandler VSTwain1.AcquiredImagesImageProcessingProgress, AddressOf VSTwain1_AcquiredImagesImageProcessingProgress
    
        ' 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
    
        ' unsubscribe from the progress event
        RemoveHandler VSTwain1.AcquiredImagesImageProcessingProgress, AddressOf VSTwain1_AcquiredImagesImageProcessingProgress
    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
    
    Public Sub VSTwain1_AcquiredImagesImageProcessingProgress(progress As Short, canCancel As Boolean, ByRef cancel As Boolean)
        Console.Write(String.Format("{0} ", progress))
    End Sub
    See Also