Class BarCodeReader

Class BarCodeReader

Namespace: Aspose.BarCode.BarCodeRecognition
Assembly: Aspose.BarCode.dll (25.1.0)

BarCodeReader инкапсулирует изображение, которое может содержать один или несколько штрих-кодов, затем он может выполнить операцию ReadBarCodes для обнаружения штрих-кодов.

[XmlSerialization(Name = "Aspose.BarCode.Reader.Properties")]
public class BarCodeReader : IDisposable

Наследование

objectBarCodeReader

Реализует

IDisposable

Унаследованные члены

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Примеры

Этот пример показывает, как обнаружить штрих-коды Code39 и Code128.

using (BarCodeReader reader = new BarCodeReader(@"c:\test.png", DecodeType.Code39, DecodeType.Code128))
{
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName);
        Console.WriteLine("Текст штрих-кода: " + result.CodeText);
    }
}
Using reader As New BarCodeReader("c:\test.png", DecodeType.Code39, DecodeType.Code128)
    For Each result As BarCodeResult In reader.ReadBarCodes()
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName)
        Console.WriteLine("Текст штрих-кода: " + result.CodeText)
    Next
End Using

Конструкторы

BarCodeReader()

Инициализирует новый экземпляр класса Aspose.BarCode.BarCodeRecognition.BarCodeReader с значениями по умолчанию. Необходимо установить изображение (SetBitmapImage()), прежде чем вызывать метод ReadBarCodes().

public BarCodeReader()

Примеры

Этот пример показывает, как обнаружить штрих-коды Code39 и Code128.

using (BarCodeReader reader = new BarCodeReader())
{
    reader.SetBarCodeReadType(DecodeType.Code39, DecodeType.Code128);
    reader.SetBarCodeImage(@"c:\test.png");
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName);
        Console.WriteLine("Текст штрих-кода: " + result.CodeText);
    }
}
Using reader As New BarCodeReader()
    reader.SetBarCodeReadType(DecodeType.Code39, DecodeType.Code128)
    reader.SetBarCodeImage("c:\test.png")
    For Each result As BarCodeResult In reader.ReadBarCodes()
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName)
        Console.WriteLine("Текст штрих-кода: " + result.CodeText)
    Next
End Using

BarCodeReader(Bitmap)

public BarCodeReader(Bitmap image)

Параметры

image Bitmap

BarCodeReader(Bitmap, params BaseDecodeType[])

public BarCodeReader(Bitmap image, params BaseDecodeType[] decodeTypes)

Параметры

image Bitmap

decodeTypes BaseDecodeType[]

BarCodeReader(Bitmap, BaseDecodeType)

public BarCodeReader(Bitmap image, BaseDecodeType type)

Параметры

image Bitmap

type BaseDecodeType

BarCodeReader(Bitmap, Rectangle, params BaseDecodeType[])

public BarCodeReader(Bitmap image, Rectangle area, params BaseDecodeType[] decodeTypes)

Параметры

image Bitmap

area Rectangle

decodeTypes BaseDecodeType[]

BarCodeReader(Bitmap, Rectangle, BaseDecodeType)

public BarCodeReader(Bitmap image, Rectangle area, BaseDecodeType type)

Параметры

image Bitmap

area Rectangle

type BaseDecodeType

BarCodeReader(Bitmap, Rectangle[], params BaseDecodeType[])

public BarCodeReader(Bitmap image, Rectangle[] areas, params BaseDecodeType[] decodeTypes)

Параметры

image Bitmap

areas Rectangle[]

decodeTypes BaseDecodeType[]

BarCodeReader(Bitmap, Rectangle[], BaseDecodeType)

public BarCodeReader(Bitmap image, Rectangle[] areas, BaseDecodeType type)

Параметры

image Bitmap

areas Rectangle[]

type BaseDecodeType

BarCodeReader(string)

Инициализирует новый экземпляр класса Aspose.BarCode.BarCodeRecognition.BarCodeReader из файла.

public BarCodeReader(string filename)

Параметры

filename string

Имя файла.

Примеры

Этот пример показывает, как обнаружить штрих-коды Code39 и Code128.

using (BarCodeReader reader = new BarCodeReader(@"c:\test.png"))
{
    reader.SetBarCodeReadType(DecodeType.Code39, DecodeType.Code128);
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName);
        Console.WriteLine("Текст штрих-кода: " + result.CodeText);
    }
}
Using reader As New BarCodeReader("c:\test.png")
    reader.SetBarCodeReadType(DecodeType.Code39, DecodeType.Code128)
    For Each result As BarCodeResult In reader.ReadBarCodes()
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName)
        Console.WriteLine("Текст штрих-кода: " + result.CodeText)
    Next
End Using

BarCodeReader(string, params BaseDecodeType[])

Инициализирует новый экземпляр класса Aspose.BarCode.BarCodeRecognition.BarCodeReader.

public BarCodeReader(string filename, params BaseDecodeType[] decodeTypes)

Параметры

filename string

Имя файла.

decodeTypes BaseDecodeType[]

Типы декодирования.

Примеры

Этот пример показывает, как обнаружить штрих-коды Code39 и Code128.

using (BarCodeReader reader = new BarCodeReader(@"c:\test.png", DecodeType.Code39, DecodeType.Code128))
{
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName);
        Console.WriteLine("Текст штрих-кода: " + result.CodeText);
    }
}
Using reader As New BarCodeReader("c:\test.png", DecodeType.Code39, DecodeType.Code128)
    For Each result As BarCodeResult In reader.ReadBarCodes()
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName)
        Console.WriteLine("Текст штрих-кода: " + result.CodeText)
    Next
End Using

BarCodeReader(string, BaseDecodeType)

Инициализирует новый экземпляр класса Aspose.BarCode.BarCodeRecognition.BarCodeReader.

public BarCodeReader(string filename, BaseDecodeType type)

Параметры

filename string

Имя файла.

type BaseDecodeType

Тип декодирования.

Примеры

Этот пример показывает, как обнаружить штрих-коды Code39 и Code128.

using (BarCodeReader reader = new BarCodeReader(@"c:\test.png", new MultyDecodeType(DecodeType.Code39, DecodeType.Code128)))
{
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName);
        Console.WriteLine("Текст штрих-кода: " + result.CodeText);
    }
}
Using reader As New BarCodeReader("c:\test.png", New MultyDecodeType(DecodeType.Code39, DecodeType.Code128))
    For Each result As BarCodeResult In reader.ReadBarCodes()
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName)
        Console.WriteLine("Текст штрих-кода: " + result.CodeText)
    Next
End Using

BarCodeReader(Stream)

Инициализирует новый экземпляр класса Aspose.BarCode.BarCodeRecognition.BarCodeReader.

public BarCodeReader(Stream stream)

Параметры

stream Stream

Поток.

Примеры

Этот пример показывает, как обнаружить штрих-коды Code39 и Code128.

using (FileStream fstr = new FileStream(@"c:\test.png", FileMode.Open))
using (BarCodeReader reader = new BarCodeReader(fstr))
{
    reader.SetBarCodeReadType(DecodeType.Code39, DecodeType.Code128);
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName);
        Console.WriteLine("Текст штрих-кода: " + result.CodeText);
    }
}
Using fstr = New FileStream("c:\test.png", FileMode.Open)
    Using reader As New BarCodeReader(fstr)
        reader.SetBarCodeReadType(DecodeType.Code39, DecodeType.Code128)
        For Each result As BarCodeResult In reader.ReadBarCodes()
            Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName)
            Console.WriteLine("Текст штрих-кода: " + result.CodeText)
        Next
    End Using
End Using

BarCodeReader(Stream, BaseDecodeType)

Инициализирует новый экземпляр класса Aspose.BarCode.BarCodeRecognition.BarCodeReader.

public BarCodeReader(Stream stream, BaseDecodeType type)

Параметры

stream Stream

Поток.

type BaseDecodeType

Тип декодирования.

Примеры

Этот пример показывает, как обнаружить штрих-коды Code39 и Code128.

using (FileStream fstr = new FileStream(@"c:\test.png", FileMode.Open))
using (BarCodeReader reader = new BarCodeReader(fstr, new MultyDecodeType(DecodeType.Code39, DecodeType.Code128)))
{
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName);
        Console.WriteLine("Текст штрих-кода: " + result.CodeText);
    }
}
Using fstr = New FileStream("c:\test.png", FileMode.Open)
    Using reader As New BarCodeReader(fstr, New MultyDecodeType(DecodeType.Code39, DecodeType.Code128))
        For Each result As BarCodeResult In reader.ReadBarCodes()
            Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName)
            Console.WriteLine("Текст штрих-кода: " + result.CodeText)
        Next
    End Using
End Using

BarCodeReader(Stream, params BaseDecodeType[])

Инициализирует новый экземпляр класса Aspose.BarCode.BarCodeRecognition.BarCodeReader.

public BarCodeReader(Stream stream, params BaseDecodeType[] decodeTypes)

Параметры

stream Stream

Поток.

decodeTypes BaseDecodeType[]

Типы декодирования.

Примеры

Этот пример показывает, как обнаружить штрих-коды Code39 и Code128.

using (FileStream fstr = new FileStream(@"c:\test.png", FileMode.Open))
using (BarCodeReader reader = new BarCodeReader(fstr, DecodeType.Code39, DecodeType.Code128))
{
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName);
        Console.WriteLine("Текст штрих-кода: " + result.CodeText);
    }
}
Using fstr = New FileStream("c:\test.png", FileMode.Open)
    Using reader As New BarCodeReader(fstr, DecodeType.Code39, DecodeType.Code128)
        For Each result As BarCodeResult In reader.ReadBarCodes()
            Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName)
            Console.WriteLine("Текст штрих-кода: " + result.CodeText)
        Next
    End Using
End Using

Свойства

BarcodeSettings

Основные параметры декодирования штрих-кода. Содержит параметры, которые влияют на распознанные данные.

[XmlSerialization(Type = XmlSerializationType.Element)]
public BarcodeSettings BarcodeSettings { get; }

Значение свойства

BarcodeSettings

FoundBarCodes

Получает массив распознанных Aspose.BarCode.BarCodeRecognition.BarCodeResults.

public BarCodeResult[] FoundBarCodes { get; }

Значение свойства

BarCodeResult[]

Примеры

Этот пример показывает, как читать штрих-коды с помощью BarCodeReader.

using (BarCodeReader reader = new BarCodeReader(@"c:\test.png", DecodeType.Code39, DecodeType.Code128))
{
    reader.ReadBarCodes();
    for(int i = 0; reader.FoundCount > i; ++i)
        Console.WriteLine("Текст штрих-кода: " + reader.FoundBarCodes[i].CodeText);
}
Using reader As New BarCodeReader("c:\test.png", DecodeType.Code39, DecodeType.Code128)
    reader.ReadBarCodes()
    For i As Integer = 0 To reader.FoundCount - 1 Step 1
        Console.WriteLine("Текст штрих-кода: " + reader.FoundBarCodes(i).CodeText)
    Next
End Using

FoundCount

Получает количество распознанных штрих-кодов.

public int FoundCount { get; }

Значение свойства

int

Примеры

Этот пример показывает, как читать штрих-коды с помощью BarCodeReader.

using (BarCodeReader reader = new BarCodeReader(@"c:\test.png", DecodeType.Code39, DecodeType.Code128))
{
    reader.ReadBarCodes();
    for(int i = 0; reader.FoundCount > i; ++i)
        Console.WriteLine("Текст штрих-кода: " + reader.FoundBarCodes[i].CodeText);
}
Using reader As New BarCodeReader("c:\test.png", DecodeType.Code39, DecodeType.Code128)
    reader.ReadBarCodes()
    For i As Integer = 0 To reader.FoundCount - 1 Step 1
        Console.WriteLine("Текст штрих-кода: " + reader.FoundBarCodes(i).CodeText)
    Next
End Using

ProcessorSettings

Получает настройки использования процессорных ядер.

public static ProcessorSettings ProcessorSettings { get; }

Значение свойства

ProcessorSettings

Примеры

Этот пример показывает, как использовать ProcessorSettings для добавления максимальной многопоточной производительности.

//это позволяет использовать все ядра для одного вызова BarCodeReader
BarCodeReader.ProcessorSettings.UseAllCores = true;
//это позволяет использовать текущее количество ядер
BarCodeReader.ProcessorSettings.UseAllCores = false;
BarCodeReader.ProcessorSettings.UseOnlyThisCoresCount = Math.Max(1, Environment.ProcessorCount / 2);
'это позволяет использовать все ядра для одного вызова BarCodeReader
BarCodeReader.ProcessorSettings.UseAllCores = True
'это позволяет использовать текущее количество ядер
BarCodeReader.ProcessorSettings.UseAllCores = False
BarCodeReader.ProcessorSettings.UseOnlyThisCoresCount = Math.Max(1, Environment.ProcessorCount / 2)

QualitySettings

QualitySettings позволяет вручную настроить качество и скорость распознавания. Вы можете быстро настроить QualitySettings с помощью встроенных предустановок: HighPerformance, NormalQuality, HighQuality, MaxBarCodes или вы можете вручную настроить отдельные параметры. Значение по умолчанию для QualitySettings — NormalQuality.

[XmlSerialization(Type = XmlSerializationType.Element)]
public QualitySettings QualitySettings { get; set; }

Значение свойства

QualitySettings

Примеры

Этот пример показывает, как использовать QualitySettings с BarCodeReader.

using (BarCodeReader reader = new BarCodeReader(@"c:\test.png", DecodeType.Code39, DecodeType.Code128))
{
   //установить режим высокой производительности
   reader.QualitySettings = QualitySettings.HighPerformance;
   foreach (BarCodeResult result in reader.ReadBarCodes())
      Console.WriteLine("Текст штрих-кода: " + result.CodeText);
}
using (BarCodeReader reader = new BarCodeReader(@"c:\test.png", DecodeType.Code39, DecodeType.Code128))
{
   //нормальный режим качества установлен по умолчанию
   foreach (BarCodeResult result in reader.ReadBarCodes())
      Console.WriteLine("Текст штрих-кода: " + result.CodeText);
}
using (BarCodeReader reader = new BarCodeReader(@"c:\test.png", DecodeType.Code39, DecodeType.Code128))
{
   //установить режим высокой производительности
   reader.QualitySettings = QualitySettings.HighPerformance;
   //установить отдельные параметры
   reader.QualitySettings.AllowMedianSmoothing = true;
   reader.QualitySettings.MedianSmoothingWindowSize = 5;
   foreach (BarCodeResult result in reader.ReadBarCodes())
      Console.WriteLine("Текст штрих-кода: " + result.CodeText);
}
Using reader As New BarCodeReader("c:\test.png", DecodeType.Code39, DecodeType.Code128)
    'установить режим высокой производительности
    reader.QualitySettings = QualitySettings.HighPerformance
    For Each result As BarCodeResult In reader.ReadBarCodes()
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName)
    Next
End Using
Using reader As New BarCodeReader("c:\test.png", DecodeType.Code39, DecodeType.Code128)
    'нормальный режим качества установлен по умолчанию
    For Each result As BarCodeResult In reader.ReadBarCodes()
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName)
    Next
End Using
Using reader As New BarCodeReader("c:\test.png", DecodeType.Code39, DecodeType.Code128)
   'установить режим высокой производительности
   reader.QualitySettings = QualitySettings.HighPerformance
   'установить отдельные параметры
   reader.QualitySettings.AllowMedianSmoothing = True
   reader.QualitySettings.MedianSmoothingWindowSize = 5
   For Each result As BarCodeResult In reader.ReadBarCodes()
       Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName)
   Next
End Using

Timeout

Получает или устанавливает тайм-аут процесса распознавания в миллисекундах.

[XmlSerialization(Type = XmlSerializationType.Element)]
public int Timeout { get; set; }

Значение свойства

int

Примеры

Этот пример показывает, как избежать зависания распознавания с тайм-аутом на больших изображениях.

using (BarCodeReader reader = new BarCodeReader(@"c:\test.png"))
{
    reader.Timeout = 5000;
    foreach (BarCodeResult result in reader.ReadBarCodes())
        Console.WriteLine("Текст штрих-кода: " + result.CodeText);
}
Using reader As New BarCodeReader("c:\test.png")
    reader.Timeout = 5000
    For Each result As BarCodeResult In reader.ReadBarCodes()
        Console.WriteLine("Текст штрих-кода: " + result.CodeText)
    Next
End Using

Методы

Abort()

Функция запрашивает завершение текущей сессии распознавания из другого потока. Abort является неблокирующим методом и возвращает управление сразу после вызова. Метод следует использовать, когда процесс распознавания слишком длительный.

public void Abort()

Примеры

Этот пример показывает, как вызвать функцию Abort из другого потока.

private static void ThreadRecognize(object readerObj)
{
    BarCodeReader reader = (BarCodeReader)readerObj;
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        Console.WriteLine("Тип штрих-кода: " + result.CodeType);
        Console.WriteLine("Текст штрих-кода: " + result.CodeText);
    }
}

BarCodeReader reader = new BarCodeReader(@"c:\test.png", DecodeType.Code39, DecodeType.Code128);
Thread thread1 = new Thread(ThreadRecognize);
thread1.Start(reader);
Thread.Sleep(100);
reader.Abort();
Private Shared Sub ThreadRecognize(readerObj As Object)
    Dim reader As BarCodeReader = readerObj
    For Each result As BarCodeResult In reader.ReadBarCodes()
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName)
        Console.WriteLine("Текст штрих-кода: " + result.CodeText)
    Next
End Sub

Dim reader As New BarCodeReader("c:\test.png", DecodeType.Code39, DecodeType.Code128)
Dim thread1 As New Thread(AddressOf ThreadRecognize)
thread1.Start(reader)
Thread.Sleep(100)
reader.Abort()

Dispose()

public void Dispose()

ExportToXml(string)

Экспортирует свойства BarCode в указанный xml-файл.

public bool ExportToXml(string xmlFile)

Параметры

xmlFile string

Имя файла.

Возвращает

bool

Успешно ли завершен экспорт.

Возвращает True в случае успеха; False В противном случае

ExportToXml(Stream)

Экспортирует свойства BarCode в указанный xml-поток.

public bool ExportToXml(Stream xmlStream)

Параметры

xmlStream Stream

Xml-поток для сохранения.

Возвращает

bool

Успешно ли завершен экспорт.

Возвращает True в случае успеха; False В противном случае

ImportFromXml(string)

Импортирует свойства BarCode из указанного xml-файла и применяет их к текущему экземпляру BarCodeReader.

public static BarCodeReader ImportFromXml(string xmlFile)

Параметры

xmlFile string

Имя файла.

Возвращает

BarCodeReader

Возвращает True в случае успеха;

False В противном случае

ImportFromXml(Stream)

Импортирует свойства BarCode из указанного xml-потока и применяет их к текущему экземпляру BarCodeReader.

public static BarCodeReader ImportFromXml(Stream xmlStream)

Параметры

xmlStream Stream

Xml-поток для загрузки.

Возвращает

BarCodeReader

Возвращает True в случае успеха;

False В противном случае

ReadBarCodes()

Читает Aspose.BarCode.BarCodeRecognition.BarCodeResults с изображения.

public BarCodeResult[] ReadBarCodes()

Возвращает

BarCodeResult[]

Возвращает массив распознанных Aspose.BarCode.BarCodeRecognition.BarCodeResults на изображении. Если ничего не распознано, возвращается нулевой массив.

Примеры

Этот пример показывает, как читать штрих-коды с помощью BarCodeReader.

using (BarCodeReader reader = new BarCodeReader(@"c:\test.png", DecodeType.Code39, DecodeType.Code128))
{
    foreach (BarCodeResult result in reader.ReadBarCodes())
        Console.WriteLine("Текст штрих-кода: " + result.CodeText);
}
using (BarCodeReader reader = new BarCodeReader(@"c:\test.png", DecodeType.Code39, DecodeType.Code128))
{
    reader.ReadBarCodes();
    for(int i = 0; reader.FoundCount > i; ++i)
        Console.WriteLine("Текст штрих-кода: " + reader.FoundBarCodes[i].CodeText);
}
Using reader As New BarCodeReader("c:\test.png", DecodeType.Code39, DecodeType.Code128)
    reader.ReadBarCodes()
    For i As Integer = 0 To reader.FoundCount - 1 Step 1
        Console.WriteLine("Текст штрих-кода: " + reader.FoundBarCodes(i).CodeText)
    Next
End Using

Using reader As New BarCodeReader("c:\test.png", DecodeType.Code39, DecodeType.Code128)
    For Each result As BarCodeResult In reader.ReadBarCodes()
        Console.WriteLine("Текст штрих-кода: " + result.CodeText)
    Next
End Using

SetBarCodeImage(Bitmap)

public void SetBarCodeImage(Bitmap value)

Параметры

value Bitmap

SetBarCodeImage(Bitmap, Rectangle[])

public void SetBarCodeImage(Bitmap value, Rectangle[] areas)

Параметры

value Bitmap

areas Rectangle[]

SetBarCodeImage(Bitmap, Rectangle)

public void SetBarCodeImage(Bitmap value, Rectangle area)

Параметры

value Bitmap

area Rectangle

SetBarCodeImage(string)

Устанавливает файл изображения для распознавания. Должен быть вызван перед методом ReadBarCodes().

public void SetBarCodeImage(string filename)

Параметры

filename string

Файл изображения для распознавания.

Примеры

Этот пример показывает, как обнаружить штрих-коды Code39 и Code128.

using (BarCodeReader reader = new BarCodeReader())
{
    reader.SetBarCodeReadType(DecodeType.Code39, DecodeType.Code128);
    reader.SetBarCodeImage(@"c:\test.png");
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName);
        Console.WriteLine("Текст штрих-кода: " + result.CodeText);
    }
}
Using reader As New BarCodeReader()
    reader.SetBarCodeReadType(DecodeType.Code39, DecodeType.Code128)
    reader.SetBarCodeImage("c:\test.png")
    For Each result As BarCodeResult In reader.ReadBarCodes()
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName)
        Console.WriteLine("Текст штрих-кода: " + result.CodeText)
    Next
End Using

SetBarCodeImage(Stream)

Устанавливает поток изображения для распознавания. Должен быть вызван перед методом ReadBarCodes().

public void SetBarCodeImage(Stream stream)

Параметры

stream Stream

Поток изображения для распознавания.

Примеры

Этот пример показывает, как обнаружить штрих-коды Code39 и Code128.

using (FileStream fstr = new FileStream(@"c:\test.png", FileMode.Open))
using (BarCodeReader reader = new BarCodeReader())
{
    reader.SetBarCodeReadType(DecodeType.Code39, DecodeType.Code128);
    reader.SetBarCodeImage(fstr);
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName);
        Console.WriteLine("Текст штрих-кода: " + result.CodeText);
    }
}
Using fstr = New FileStream("c:\test.png", FileMode.Open)
    Using reader As New BarCodeReader()
        reader.SetBarCodeReadType(DecodeType.Code39, DecodeType.Code128)
        reader.SetBarCodeImage(fstr)
        For Each result As BarCodeResult In reader.ReadBarCodes()
            Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName)
            Console.WriteLine("Текст штрих-кода: " + result.CodeText)
        Next
    End Using
End Using

SetBarCodeReadType(params SingleDecodeType[])

Устанавливает массив типов Aspose.BarCode.BarCodeRecognition.SingleDecodeType для распознавания. Должен быть вызван перед методом ReadBarCodes().

public void SetBarCodeReadType(params SingleDecodeType[] barcodeTypes)

Параметры

barcodeTypes SingleDecodeType[]

Массив типов Aspose.BarCode.BarCodeRecognition.SingleDecodeType для чтения.

Примеры

Этот пример показывает, как обнаружить штрих-коды Code39 и Code128.

using (BarCodeReader reader = new BarCodeReader())
{
    reader.SetBarCodeReadType(DecodeType.Code39, DecodeType.Code128);
    reader.SetBarCodeImage(@"c:\test.png");
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName);
        Console.WriteLine("Текст штрих-кода: " + result.CodeText);
    }
}
Using reader As New BarCodeReader()
    reader.SetBarCodeReadType(DecodeType.Code39, DecodeType.Code128)
    reader.SetBarCodeImage("c:\test.png")
    For Each result As BarCodeResult In reader.ReadBarCodes()
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName)
        Console.WriteLine("Текст штрих-кода: " + result.CodeText)
    Next
End Using

SetBarCodeReadType(BaseDecodeType)

Устанавливает тип декодирования для распознавания. Должен быть вызван перед методом ReadBarCodes().

[XmlSerialization(Name = "BarCodeReadType")]
public void SetBarCodeReadType(BaseDecodeType type)

Параметры

type BaseDecodeType

Тип штрих-кода для чтения.

Примеры

Этот пример показывает, как обнаружить штрих-коды Code39 и Code128.

using (BarCodeReader reader = new BarCodeReader())
{
    reader.SetBarCodeReadType(new MultyDecodeType(DecodeType.Code39, DecodeType.Code128));
    reader.SetBarCodeImage(@"c:\test.png");
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName);
        Console.WriteLine("Текст штрих-кода: " + result.CodeText);
    }
}
Using reader As New BarCodeReader()
    reader.SetBarCodeReadType(New MultyDecodeType(DecodeType.Code39, DecodeType.Code128))
    reader.SetBarCodeImage("c:\test.png")
    For Each result As BarCodeResult In reader.ReadBarCodes()
        Console.WriteLine("Тип штрих-кода: " + result.CodeTypeName)
        Console.WriteLine("Текст штрих-кода: " + result.CodeText)
    Next
End Using
 Русский