VintaSoftTwain Control v6.0
VintaSoftTwain Object / Device_AcquireImage Method
In This Topic
    Device_AcquireImage Method
    In This Topic
    Acquires images from the device asynchronously.
    Visual Basic
    Public Function Device_AcquireImage() As Boolean
    Return Type
    TRUE (1) if method is executed successfully, FALSE (0) otherwise.
    Call this method only after DeviceManager_Open method.

    Method is asynchronous and it only starts image acquisition process. Acquired image will be available only when DeviceImageAcquired event occurs.

    Method enables device and shows user interface Device_ShowUI property is set to True. Device user interface settings determines how many images the application wants to acquire from device.

    Method enables device and does NOT show user interface Device_ShowUI property is set to FalseDevice_XferCount property determines how many images the application wants to acquire from device.

    Device user interface will be closed automatically if Device_DisableAfterAcquire property is set to True and image acquisition session is finished.

    The acquired images are stored in the internal images buffer and can be retrieved with the AcquiredImages_GetImage method.

    Information about error that occurs during method execution can be get using the Error and ErrorString properties.
    This example shows how to asynchronously acquire images from the device.
    Private VSTwain1 As New VintaSoftTwain()
    ''' <summary>
    ''' Scans images asynchronously.
    ''' </summary>
    Private Sub ScanImages()
        ' specify name of scanning application
        VSTwain1.DeviceManager_ApplicationProductName = "MyTwainApplication"
        ' open the device manager
        If Not VSTwain1.DeviceManager_Open() Then
            Exit Sub
        End If
        ' select device using standard device selection dialog
        ' open the device
        If Not VSTwain1.Device_Open Then
            Exit Sub
        End If
        ' specify that device UI must be shown
        VSTwain1.Device_ShowUI = True
        ' specify that acquired image must be added to an existing TIFF file
        VSTwain1.TiffEncoder_MultiPage = 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
    End Sub
    Private Sub VSTwain1_ImageAcquired()
        ' get index of acquired image
        Dim imageIndex As Integer = VSTwain1.AcquiredImages_Count - 1
        ' save acquired image to TIFF file
        If Not VSTwain1.AcquiredImages_Save(imageIndex, "test.tif") Then
        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