VintaSoftTwain Control v6.0
VintaSoftTwain Object / Device_SetImageLayout Method
Left (X) coordinate of image layout.
Top (Y) coordinate of image layout.
Right (X) coordinate of image layout.
Bottom (Y) coordinate of image layout.
In This Topic
    Device_SetImageLayout Method
    In This Topic
    Description
    Sets an image layout for current scan session.
    Syntax
    Visual Basic
    Public Function Device_SetImageLayout( _
       ByVal left As Single, _
       ByVal top As Single, _
       ByVal right As Single, _
       ByVal bottom As Single _
    ) As Boolean
    Parameters
    left
    Left (X) coordinate of image layout.
    top
    Top (Y) coordinate of image layout.
    right
    Right (X) coordinate of image layout.
    bottom
    Bottom (Y) coordinate of image layout.
    Return Type
    TRUE (1) if image layout is set successfully, FALSE (0) otherwise.
    Remarks
    The image layout rectangle defines what portion of the device's scanning area will be acquired.

    Call this method only when device is opened (Device_State == enumDevice_State.DeviceOpened).

    This method has effect only if user interface is not shown (Device_ShowUI == False).

    Information about error that occurs during method execution can be get using the Error and ErrorString properties.
    Example
    This example shows how to set image layout for before image scan.
    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
            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
    
        ' set units of measure
        VSTwain1.Device_UnitOfMeasure = UNITOFMEASURE.UNITOFMEASURE_Inches
        ' set the image layout
        VSTwain1.Device_SetImageLayout(1, 1, 5, 5)
    
        ' 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
    
        ' save acquired image to TIFF file
        If Not VSTwain1.AcquiredImages_Save(imageIndex, "test.tif") Then
            Console.WriteLine(VSTwain1.errorString)
        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