В этом разделе
Класс, содержащий расширенную информацию о отсканированном изображении.
Объектная модель
Синтаксис
'Declaration
Public NotInheritable Class ExtendedImageInfo
public sealed class ExtendedImageInfo
public __gc __sealed class ExtendedImageInfo
public ref class ExtendedImageInfo sealed
Пример
Вот C#/VB.NET код, который демонстрирует, как получить информацию о штрих-кодах, найденных на полученном изображении.
''' <summary>
''' Synchronously acquires images from TWAIN device and retrieves from TWAIN device information about barcodes recognized on acquired images.
''' </summary>
Public Sub SynchronouslyAcquireImageFromTwainDeviceAndRecognizeBarcodeInAcquiredImages()
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
' specify that device UI must not be used
device.ShowUI = False
' specify that device must be closed after scan
device.DisableAfterAcquire = True
' open the device
device.Open()
' specify that device should recognize barcodes in acquired images
device.BarcodeRecognizer.IsEnabled = True
' 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
' get information about recognized barcodes
Dim recognizedBarcodes As Vintasoft.Twain.TwainBarcodeInfo() = device.BarcodeRecognizer.GetRecognitionResult()
' if barcodes are NOT found
If recognizedBarcodes.Length = 0 Then
System.Console.WriteLine("Barcodes are NOT found.")
Else
' if barcodes are found
System.Console.WriteLine(String.Format("{0} barcodes are found.", recognizedBarcodes.Length))
' for each recognized barcode
For i As Integer = 0 To recognizedBarcodes.Length - 1
' output barcode type
System.Console.Write(String.Format("BarcodeType={0} ", recognizedBarcodes(i).Type))
' output barcode text
System.Console.WriteLine(String.Format("BarcodeText='{0}'", recognizedBarcodes(i).Value))
Next
End If
' if acquired image is present (Native or Memory transfer mode is used)
If device.AcquiredImage IsNot Nothing Then
' dispose the acquired image
device.AcquiredImage.Dispose()
End If
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
/// <summary>
/// Synchronously acquires images from TWAIN device and retrieves from TWAIN device information about barcodes recognized on acquired images.
/// </summary>
public void SynchronouslyAcquireImageFromTwainDeviceAndRecognizeBarcodeInAcquiredImages()
{
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;
// specify that device UI must not be used
device.ShowUI = false;
// specify that device must be closed after scan
device.DisableAfterAcquire = true;
// open the device
device.Open();
// specify that device should recognize barcodes in acquired images
device.BarcodeRecognizer.IsEnabled = true;
// acquire images from device
Vintasoft.Twain.AcquireModalState acquireModalState = Vintasoft.Twain.AcquireModalState.None;
do
{
acquireModalState = device.AcquireModal();
switch (acquireModalState)
{
case Vintasoft.Twain.AcquireModalState.ImageAcquired:
// get information about recognized barcodes
Vintasoft.Twain.TwainBarcodeInfo[] recognizedBarcodes = device.BarcodeRecognizer.GetRecognitionResult();
// if barcodes are NOT found
if (recognizedBarcodes.Length == 0)
{
System.Console.WriteLine("Barcodes are NOT found.");
}
// if barcodes are found
else
{
System.Console.WriteLine(string.Format("{0} barcodes are found.", recognizedBarcodes.Length));
// for each recognized barcode
for (int i = 0; i < recognizedBarcodes.Length; i++)
{
// output barcode type
System.Console.Write(string.Format("BarcodeType={0} ", recognizedBarcodes[i].Type));
// output barcode text
System.Console.WriteLine(string.Format("BarcodeText='{0}'", recognizedBarcodes[i].Value));
}
}
// if acquired image is present (Native or Memory transfer mode is used)
if (device.AcquiredImage != null)
// 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.WinTwain.ExtendedImageInfo
Требования
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
Смотрите также