Класс BarcodeSymbologySubsets
В этом разделе
Содержит подмножества стандартных символов штрих-кода.
Объектная модель
Синтаксис
'Declaration
Public MustInherit NotInheritable Class BarcodeSymbologySubsets
public static class BarcodeSymbologySubsets
public __gc abstract __sealed class BarcodeSymbologySubsets
public ref class BarcodeSymbologySubsets abstract sealed
Пример
Распознавание подмножеств штрих-кодов: см. пример здесь.
Генерация подмножеств штрих-кодов: см. пример здесь.
Распознавание и генерация штрих-кода PPN: см. пример здесь.
Этот код C#/VB.NET показывает, как распознать штрих-код GS1-128 в изображении:
''' <summary>
''' Recognizes GS1-128 barcodes in specified image.
''' </summary>
''' <param name="filename">The filename of image file with barcodes.</param>
Public Shared Sub Recognize(filename As String)
' create the barcode reader
Using reader As New BarcodeReader()
' specify that reader must search for GS1-128 barcodes only
reader.Settings.ScanBarcodeTypes = BarcodeType.None
reader.Settings.ScanBarcodeSubsets.Add(BarcodeSymbologySubsets.GS1_128)
' recognize barcodes in image
Dim infos As IBarcodeInfo() = reader.ReadBarcodes(filename)
' for each found barcode
For j As Integer = 0 To infos.Length - 1
Dim info As GS1BarcodeInfo = DirectCast(infos(j), GS1BarcodeInfo)
' print barcode symbology
Console.WriteLine(info.BarcodeSubset)
' print barcode region on image
Console.WriteLine(info.Region.ToString())
' print Transmitted data
Console.WriteLine(String.Format("Transmitted data : {0} ", info.TransmittedData))
' print values of Application identifiers
Dim printableValue As New StringBuilder()
Dim aiValues As GS1ApplicationIdentifierValue() = info.ApplicationIdentifierValues
For i As Integer = 0 To aiValues.Length - 1
Dim aiValue As GS1ApplicationIdentifierValue = aiValues(i)
Dim ai As GS1ApplicationIdentifier = aiValue.ApplicationIdentifier
Console.WriteLine(String.Format("Application identifier {0} : {1}", i + 1, ai.ApplicationIdentifier))
Console.WriteLine(String.Format(" Value : {0}", aiValue.Value))
Console.WriteLine(String.Format(" Data title : {0}", ai.DataTitle))
Console.WriteLine(String.Format(" Data content : {0}", ai.DataContent))
Console.WriteLine(String.Format(" Format : {0}", ai.Format))
Console.WriteLine(String.Format(" Is contains decimal point : {0}", ai.IsContainsDecimalPoint))
Console.WriteLine(String.Format(" Is variable length : {0}", ai.IsVariableLength))
printableValue.Append(aiValue.ToString())
Next
' print GS1 printable value
Console.WriteLine("Printable GS1 value: " & printableValue.ToString())
Console.WriteLine()
Next
End Using
End Sub
/// <summary>
/// Recognizes GS1-128 barcodes in specified image.
/// </summary>
/// <param name="filename">The filename of image file with barcodes.</param>
public static void Recognize(string filename)
{
// create the barcode reader
using (BarcodeReader reader = new BarcodeReader())
{
// specify that reader must search for GS1-128 barcodes only
reader.Settings.ScanBarcodeTypes = BarcodeType.None;
reader.Settings.ScanBarcodeSubsets.Add(BarcodeSymbologySubsets.GS1_128);
// recognize barcodes in image
IBarcodeInfo[] infos = reader.ReadBarcodes(filename);
// for each found barcode
for (int j = 0; j < infos.Length; j++)
{
GS1BarcodeInfo info = (GS1BarcodeInfo)infos[j];
// print barcode symbology
Console.WriteLine(info.BarcodeSubset);
// print barcode region on image
Console.WriteLine(info.Region.ToString());
// print Transmitted data
Console.WriteLine(string.Format("Transmitted data : {0} ", info.TransmittedData));
// print values of Application identifiers
StringBuilder printableValue = new StringBuilder();
GS1ApplicationIdentifierValue[] aiValues = info.ApplicationIdentifierValues;
for (int i = 0; i < aiValues.Length; i++)
{
GS1ApplicationIdentifierValue aiValue = aiValues[i];
GS1ApplicationIdentifier ai = aiValue.ApplicationIdentifier;
Console.WriteLine(string.Format("Application identifier {0} : {1}", i + 1, ai.ApplicationIdentifier));
Console.WriteLine(string.Format(" Value : {0}", aiValue.Value));
Console.WriteLine(string.Format(" Data title : {0}", ai.DataTitle));
Console.WriteLine(string.Format(" Data content : {0}", ai.DataContent));
Console.WriteLine(string.Format(" Format : {0}", ai.Format));
Console.WriteLine(string.Format(" Is contains decimal point : {0}", ai.IsContainsDecimalPoint));
Console.WriteLine(string.Format(" Is variable length : {0}", ai.IsVariableLength));
printableValue.Append(aiValue.ToString());
}
// print GS1 printable value
Console.WriteLine("Printable GS1 value: " + printableValue.ToString());
Console.WriteLine();
}
}
}
Иерархия наследования
System.Object
 Vintasoft.Barcode.SymbologySubsets.BarcodeSymbologySubsets
Требования
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
Смотрите также