VintaSoftTwain Control v6.0
VintaSoftTwain Object / Device_AcquireImageModal Method
In This Topic
    Device_AcquireImageModal Method
    In This Topic
    Description
    Acquires images from the device synchronously.
    Syntax
    Visual Basic
    Public Function Device_AcquireImageModal() As enumAcquireModalState
    Return Type
    State of the modal acquisition process.
    Remarks
    Important: This method must be called in a loop while it does not return the enumAcquireModalState.None value.

    Call this method only after DeviceManager_Open method.

    Method is synchronous. Acquired image will be available when method is finished.

    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.

    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.
    Example
    This example shows how to synchronously acquire images from the device.
    Private VSTwain1 As New VintaSoftTwain()
    
    
    ''' <summary>
    ''' Scans images synchronously.
    ''' </summary>
    Public Sub ScanImages()
        ' specify name of scanning application
        VSTwain1.DeviceManager_ApplicationProductName = "MyTwainApplication"
        ' 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()
    
        ' 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
    
        ' specify that acquired image must be added to an existing TIFF file
        VSTwain1.TiffEncoder_MultiPage = True
    
        ' run synchronous image acquisition
        Dim acquireModalState1 As VSTwainLib.ACQUIREMODALSTATE = ACQUIREMODALSTATE.AcquireModalState_None
        Do
            acquireModalState1 = VSTwain1.Device_AcquireImageModal()
            Select Case acquireModalState1
                Case ACQUIREMODALSTATE.AcquireModalState_ImageAcquired
                    Console.WriteLine("Image is acquired.")
    
                    ' save acquired image to TIFF file
                    If Not VSTwain1.AcquiredImages_Save(0, "test.tif") Then
                        Console.WriteLine(VSTwain1.errorString)
                    End If
    
                    ' delete image from internal image buffer
                    VSTwain1.AcquiredImages_Clear()
                    Exit Select
    
                Case ACQUIREMODALSTATE.AcquireModalState_ScanCompleted
                    Console.WriteLine("Scan is completed.")
                    Exit Select
    
                Case ACQUIREMODALSTATE.AcquireModalState_ScanCanceled
                    Console.WriteLine("Scan is canceled.")
                    Exit Select
    
                Case ACQUIREMODALSTATE.AcquireModalState_ScanFailed
                    Console.WriteLine(String.Format("Scan is failed: {0}.", VSTwain1.errorString))
                    Exit Select
            End Select
        Loop While acquireModalState1 <> ACQUIREMODALSTATE.AcquireModalState_None
    End Sub
    See Also