VintaSoft Twain .NET SDK v10.2
DeviceImageLayout Class
Members  Example 




Vintasoft.Twain Namespace : DeviceImageLayout Class
Class that allows to manipulate the image layout of TWAIN device.
Object Model
DeviceImageLayout Class
Syntax
'Declaration
 
Public NotInheritable Class DeviceImageLayout 
'Usage
 
Dim instance As DeviceImageLayout
public sealed class DeviceImageLayout 
public __gc __sealed class DeviceImageLayout 
public ref class DeviceImageLayout sealed 
Example
This example shows how to acquire only the top part of page.
Private Sub AcquirePartOfImage()
    Using deviceManager As New DeviceManager()
        Try
            ' open the device manager
            deviceManager.Open()
            
            deviceManager.ShowDefaultDeviceSelectionDialog()
            
            ' get reference to the default device
            Dim device As Device = deviceManager.DefaultDevice
            
            device.ShowUI = False
            device.DisableAfterAcquire = True
            
            ' open the device
            device.Open()
            
            ' set image layout (get only the top half of the page)
            device.UnitOfMeasure = UnitOfMeasure.Inches
            Dim imageLayout As RectangleF = device.ImageLayout.[Get]()
            device.ImageLayout.[Set](0, 0, imageLayout.Width, imageLayout.Height / 2)
            
            Dim tiffFilename As String = Path.Combine(Directory.GetCurrentDirectory(), "multipage.tif")
            
            ' acquire images from device
            Dim acquireModalState1 As AcquireModalState = AcquireModalState.None
            Do
                acquireModalState1 = device.AcquireModal()
                Select Case acquireModalState1
                    Case AcquireModalState.ImageAcquired
                        ' save acquired image to multipage TIFF file
                        device.AcquiredImage.Save(tiffFilename)
                        ' dispose the acquired image
                        device.AcquiredImage.Dispose()
                        Exit Select
                End Select
            Loop While acquireModalState1 <> AcquireModalState.None
            
            ' close the device
            device.Close()
            
            ' close the device manager
            deviceManager.Close()
        Catch ex As TwainException
            Console.WriteLine("Error: " + ex.Message)
            Console.ReadLine()
        End Try
    End Using
End Sub
private void AcquirePartOfImage()
{
    using (DeviceManager deviceManager = new DeviceManager())
    {
        try
        {
            // open the device manager
            deviceManager.Open();
            
            deviceManager.ShowDefaultDeviceSelectionDialog();
            
            // get reference to the default device
            Device device = deviceManager.DefaultDevice;
            
            device.ShowUI = false;
            device.DisableAfterAcquire = true;
            
            // open the device
            device.Open();
            
            // set image layout (get only the top half of the page)
            device.UnitOfMeasure = UnitOfMeasure.Inches;
            RectangleF imageLayout = device.ImageLayout.Get();
            device.ImageLayout.Set(0, 0, imageLayout.Width, imageLayout.Height / 2);
            
            string tiffFilename = Path.Combine(Directory.GetCurrentDirectory(), "multipage.tif");
            
            // acquire images from device
            AcquireModalState acquireModalState = AcquireModalState.None;
            do
            {
                acquireModalState = device.AcquireModal();
                switch (acquireModalState)
                {
                    case AcquireModalState.ImageAcquired:
                        // save acquired image to multipage TIFF file
                        device.AcquiredImage.Save(tiffFilename);
                        // dispose the acquired image
                        device.AcquiredImage.Dispose();
                        break;
                }
            }
            while (acquireModalState != AcquireModalState.None);
            
            // close the device
            device.Close();
            
            // close the device manager
            deviceManager.Close();
        }
        catch (TwainException ex)
        {
            Console.WriteLine("Error: " + ex.Message);
            Console.ReadLine();
        }
    }
}
Inheritance Hierarchy

System.Object
   Vintasoft.Twain.DeviceImageLayout

Requirements

Target Platforms: Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

See Also

Reference

DeviceImageLayout Members
Vintasoft.Twain Namespace