VintaSoft Barcode .NET SDK 15.1: Руководство для .NET разработчика
В этом разделе
    Распознавание штрих-кодов в объекте Vintasoft.Imaging.VintasoftBitmap
    В этом разделе
    Пример: Вот пример, который показывает, как распознавать штрих-коды в изображении, которое представлено объектом Vintasoft.Imaging.VintasoftBitmap.
    /// <summary>
    /// Reads barcode from a <see cref="Vintasoft.Imaging.VintasoftBitmap"/>.
    /// </summary>
    /// <param name="bitmap">A bitmap with barcodes.</param>
    public static void ReadBarcodesFromBitmap(Vintasoft.Imaging.VintasoftBitmap bitmap)
    {
        // create barcode reader
        using (Vintasoft.Barcode.BarcodeReader reader = new Vintasoft.Barcode.BarcodeReader())
        {
            // specify that reader must search for Code39, Code39Extended,
            // Code128, SSCC18 and DataMatrix barcodes
            reader.Settings.ScanBarcodeTypes =
                Vintasoft.Barcode.BarcodeType.Code39 |
                Vintasoft.Barcode.BarcodeType.Code128 |
                Vintasoft.Barcode.BarcodeType.DataMatrix;
            reader.Settings.ScanBarcodeSubsets.Add(Vintasoft.Barcode.SymbologySubsets.BarcodeSymbologySubsets.Code39Extended);
            reader.Settings.ScanBarcodeSubsets.Add(Vintasoft.Barcode.SymbologySubsets.BarcodeSymbologySubsets.SSCC18);
    
            // read barcodes from image
            Vintasoft.Barcode.IBarcodeInfo[] infos = reader.ReadBarcodes(bitmap);
    
            // if barcodes are not detected
            if (infos.Length == 0)
            {
                System.Console.WriteLine("No barcodes found.");
            }
            // if barcodes are detected
            else
            {
                // get information about extracted barcodes
    
                System.Console.WriteLine(string.Format("{0} barcodes found:", infos.Length));
                System.Console.WriteLine();
                for (int i = 0; i < infos.Length; i++)
                {
                    Vintasoft.Barcode.IBarcodeInfo info = infos[i];
                    System.Console.WriteLine(string.Format("[{0}:{1}]", i + 1, info.BarcodeType));
                    System.Console.WriteLine(string.Format("Value:      {0}", info.Value));
                    System.Console.WriteLine(string.Format("Region:     {0}", info.Region));
                    System.Console.WriteLine();
                }
            }
        }
    }
    
    ''' <summary>
    ''' Reads barcode from a <see cref="Vintasoft.Imaging.VintasoftBitmap"/>.
    ''' </summary>
    ''' <param name="bitmap">A bitmap with barcodes.</param>
    Public Shared Sub ReadBarcodesFromBitmap(bitmap As Vintasoft.Imaging.VintasoftBitmap)
        ' create barcode reader
        Using reader As New Vintasoft.Barcode.BarcodeReader()
            ' specify that reader must search for Code39, Code39Extended,
            ' Code128, SSCC18 and DataMatrix barcodes
            reader.Settings.ScanBarcodeTypes = Vintasoft.Barcode.BarcodeType.Code39 Or Vintasoft.Barcode.BarcodeType.Code128 Or Vintasoft.Barcode.BarcodeType.DataMatrix
            reader.Settings.ScanBarcodeSubsets.Add(Vintasoft.Barcode.SymbologySubsets.BarcodeSymbologySubsets.Code39Extended)
            reader.Settings.ScanBarcodeSubsets.Add(Vintasoft.Barcode.SymbologySubsets.BarcodeSymbologySubsets.SSCC18)
    
            ' read barcodes from image
            Dim infos As Vintasoft.Barcode.IBarcodeInfo() = reader.ReadBarcodes(bitmap)
    
            ' if barcodes are not detected
            If infos.Length = 0 Then
                System.Console.WriteLine("No barcodes found.")
            Else
                ' if barcodes are detected
                ' get information about extracted barcodes
    
                System.Console.WriteLine(String.Format("{0} barcodes found:", infos.Length))
                System.Console.WriteLine()
                For i As Integer = 0 To infos.Length - 1
                    Dim info As Vintasoft.Barcode.IBarcodeInfo = infos(i)
                    System.Console.WriteLine(String.Format("[{0}:{1}]", i + 1, info.BarcodeType))
                    System.Console.WriteLine(String.Format("Value:      {0}", info.Value))
                    System.Console.WriteLine(String.Format("Region:     {0}", info.Region))
                    System.Console.WriteLine()
                Next
            End If
        End Using
    End Sub