VintaSoft Twain .NET SDK 14.1: Руководство для .NET разработчика
Vintasoft.WpfTwain Namespace / DeviceImageLayout Class
Члены типа Объект Синтаксис Example Иерархия Требования Смотрите также
В этом разделе
    Класс DeviceImageLayout
    В этом разделе
    Класс, который позволяет управлять компоновкой изображения TWAIN устройства.
    Объектная модель
    DeviceImageLayout
    Синтаксис
    'Declaration
    
    Public NotInheritable Class DeviceImageLayout
    
    
    public sealed class DeviceImageLayout
    
    
    public __gc __sealed class DeviceImageLayout
    
    
    public ref class DeviceImageLayout sealed
    
    
    Пример

    Вот C#/VB.NET код, который демонстрирует, как получить только верхнюю часть страницы.

    
    Private Sub AcquirePartOfImage()
            Using deviceManager As New Vintasoft.Twain.DeviceManager()
                    Try
                            ' open the device manager
                            deviceManager.Open()
    
                            deviceManager.ShowDefaultDeviceSelectionDialog()
    
                            ' get reference to the default device
                            Dim device As Vintasoft.Twain.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 = Vintasoft.Twain.UnitOfMeasure.Inches
                            Dim imageLayout As Vintasoft.Primitives.VintasoftRectF = device.ImageLayout.[Get]()
                            device.ImageLayout.[Set](0, 0, imageLayout.Width, imageLayout.Height / 2)
    
                            Dim tiffFilename As String = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "multipage.tif")
    
                            ' acquire images from device
                            Dim acquireModalState As Vintasoft.Twain.AcquireModalState = Vintasoft.Twain.AcquireModalState.None
                            Do
                                    acquireModalState = device.AcquireModal()
                                    Select Case acquireModalState
                                            Case Vintasoft.Twain.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 acquireModalState <> Vintasoft.Twain.AcquireModalState.None
    
                            ' close the device
                            device.Close()
    
                            ' close the device manager
                            deviceManager.Close()
                    Catch ex As Vintasoft.Twain.TwainException
                            System.Console.WriteLine("Error: " + ex.Message)
                            System.Console.ReadLine()
                    End Try
            End Using
    End Sub
    
    
    
    private void AcquirePartOfImage()
    {
        using (Vintasoft.Twain.DeviceManager deviceManager = new Vintasoft.Twain.DeviceManager())
        {
            try
            {
                // open the device manager
                deviceManager.Open();
    
                deviceManager.ShowDefaultDeviceSelectionDialog();
    
                // get reference to the default device
                Vintasoft.Twain.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 = Vintasoft.Twain.UnitOfMeasure.Inches;
                Vintasoft.Primitives.VintasoftRectF imageLayout = device.ImageLayout.Get();
                device.ImageLayout.Set(0, 0, imageLayout.Width, imageLayout.Height / 2);
    
                string tiffFilename = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "multipage.tif");
    
                // acquire images from device
                Vintasoft.Twain.AcquireModalState acquireModalState = Vintasoft.Twain.AcquireModalState.None;
                do
                {
                    acquireModalState = device.AcquireModal();
                    switch (acquireModalState)
                    {
                        case Vintasoft.Twain.AcquireModalState.ImageAcquired:
                            // save acquired image to multipage TIFF file
                            device.AcquiredImage.Save(tiffFilename);
                            // dispose the acquired image
                            device.AcquiredImage.Dispose();
                            break;
                    }
                }
                while (acquireModalState != Vintasoft.Twain.AcquireModalState.None);
    
                // close the device
                device.Close();
    
                // close the device manager
                deviceManager.Close();
            }
            catch (Vintasoft.Twain.TwainException ex)
            {
                System.Console.WriteLine("Error: " + ex.Message);
                System.Console.ReadLine();
            }
        }
    }
    
    

    Иерархия наследования

    System.Object
       Vintasoft.WpfTwain.DeviceImageLayout

    Требования

    Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    Смотрите также