Класс Code39ExtendedBarcodeSymbology
Определяет расширенную символику штрих-кода Code39 - подмножество символики штрих-кода Code 39.
Этот C#/VB.NET код показывает, как сгенерировать или распознать штрих-код Code39 Extended.
''' <summary>
''' Generates an image of Code 39 Extended barcode with specified value.
''' </summary>
Public Shared Function Generate(value As String) As VintasoftBitmap
' create barcode writer
Using writer As New BarcodeWriter()
' encode Code39 Extended value
BarcodeSymbologySubsets.Code39Extended.Encode(value, writer.Settings)
' create barcode image
Return writer.GetBarcodeAsVintasoftBitmap()
End Using
End Function
''' <summary>
''' Recognizes the Code 39 Extended barcode in specified image.
''' </summary>
Public Shared Sub Recognize(image As VintasoftBitmap)
' create the barcode reader
Using reader As New BarcodeReader()
' specify that reader must search for Code39 Extended barcodes only
reader.Settings.ScanBarcodeTypes = BarcodeType.None
reader.Settings.ScanBarcodeSubsets.Add(BarcodeSymbologySubsets.Code39Extended)
' recognize barcode in image
Dim infos As IBarcodeInfo() = reader.ReadBarcodes(image)
' for each found barcode
For j As Integer = 0 To infos.Length - 1
Dim info As BarcodeSubsetInfo = DirectCast(infos(j), BarcodeSubsetInfo)
' print barcode value
Console.WriteLine(String.Format("{0} value: {1}", info.BarcodeSubset, info.Value))
Next
End Using
End Sub
/// <summary>
/// Generates an image of Code 39 Extended barcode with specified value.
/// </summary>
public static VintasoftBitmap Generate(string value)
{
// create barcode writer
using (BarcodeWriter writer = new BarcodeWriter())
{
// encode Code39 Extended value
BarcodeSymbologySubsets.Code39Extended.Encode(value, writer.Settings);
// create barcode image
return writer.GetBarcodeAsVintasoftBitmap();
}
}
/// <summary>
/// Recognizes the Code 39 Extended barcode in specified image.
/// </summary>
public static void Recognize(VintasoftBitmap image)
{
// create the barcode reader
using (BarcodeReader reader = new BarcodeReader())
{
// specify that reader must search for Code39 Extended barcodes only
reader.Settings.ScanBarcodeTypes = BarcodeType.None;
reader.Settings.ScanBarcodeSubsets.Add(BarcodeSymbologySubsets.Code39Extended);
// recognize barcode in image
IBarcodeInfo[] infos = reader.ReadBarcodes(image);
// for each found barcode
for (int j = 0; j < infos.Length; j++)
{
BarcodeSubsetInfo info = (BarcodeSubsetInfo)infos[j];
// print barcode value
Console.WriteLine(string.Format("{0} value: {1}", info.BarcodeSubset, info.Value));
}
}
}
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5