using IronBarCode;using System;// Set the option to read multiple barcodesBarcodeReaderOptions options = new BarcodeReaderOptions(){ExpectMultipleBarcodes = true,ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,};// Read barcodevar results = BarcodeReader.Read("testbc1.png", options);foreach (var result in results){Console.WriteLine(result.ToString());}
using IronBarCode;
using System;
// Set the option to read multiple barcodes
BarcodeReaderOptions options = new BarcodeReaderOptions()
{
ExpectMultipleBarcodes = true,
ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,
};
// Read barcode
var results = BarcodeReader.Read("testbc1.png", options);
foreach (var result in results)
{
Console.WriteLine(result.ToString());
}
ImportsIronBarCodeImportsSystem' Set the option to read multiple barcodesPrivate options As New BarcodeReaderOptions() With { .ExpectMultipleBarcodes = True, .ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional}' Read barcodePrivate results = BarcodeReader.Read("testbc1.png", options)For Each result In resultsConsole.WriteLine(result.ToString())Next result
Imports IronBarCode
Imports System
' Set the option to read multiple barcodes
Private options As New BarcodeReaderOptions() With {
.ExpectMultipleBarcodes = True,
.ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional
}
' Read barcode
Private results = BarcodeReader.Read("testbc1.png", options)
For Each result In results
Console.WriteLine(result.ToString())
Next result
using IronBarCode;using System;using System.Linq;// Configure advanced options for mixed barcode typesBarcodeReaderOptions advancedOptions = new BarcodeReaderOptions(){ExpectMultipleBarcodes = true, // Read both 1D and 2D barcodesExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional | BarcodeEncoding.QRCode | BarcodeEncoding.DataMatrix, // Apply image correction filters for better accuracyImageFilters = new ImageFilterCollection() { new SharpenFilter(), new ContrastFilter() }, // Set speed vs accuracy balanceSpeed = ReadingSpeed.Balanced};// Read barcodes from the imagevar imageResults = BarcodeReader.Read("mixed-barcodes.jpg", advancedOptions);// Process results with error handlingforeach (var result in imageResults){Console.WriteLine($"Barcode Type: {result.BarcodeType}");Console.WriteLine($"Value: {result.Value}");Console.WriteLine($"Page: {result.PageNumber}");Console.WriteLine("---");}
using IronBarCode;
using System;
using System.Linq;
// Configure advanced options for mixed barcode types
BarcodeReaderOptions advancedOptions = new BarcodeReaderOptions()
{
ExpectMultipleBarcodes = true,
// Read both 1D and 2D barcodes
ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional | BarcodeEncoding.QRCode | BarcodeEncoding.DataMatrix,
// Apply image correction filters for better accuracy
ImageFilters = new ImageFilterCollection() {
new SharpenFilter(),
new ContrastFilter()
},
// Set speed vs accuracy balance
Speed = ReadingSpeed.Balanced
};
// Read barcodes from the image
var imageResults = BarcodeReader.Read("mixed-barcodes.jpg", advancedOptions);
// Process results with error handling
foreach (var result in imageResults)
{
Console.WriteLine($"Barcode Type: {result.BarcodeType}");
Console.WriteLine($"Value: {result.Value}");
Console.WriteLine($"Page: {result.PageNumber}");
Console.WriteLine("---");
}
using IronBarCode;using System;// Set the option to read single barcodeBarcodeReaderOptions options = new BarcodeReaderOptions(){ExpectMultipleBarcodes = false,ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,};// Read barcodevar results = BarcodeReader.Read("testbc1.png", options);foreach (var result in results){Console.WriteLine(result.ToString());}
using IronBarCode;
using System;
// Set the option to read single barcode
BarcodeReaderOptions options = new BarcodeReaderOptions()
{
ExpectMultipleBarcodes = false,
ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,
};
// Read barcode
var results = BarcodeReader.Read("testbc1.png", options);
foreach (var result in results)
{
Console.WriteLine(result.ToString());
}
ImportsIronBarCodeImportsSystem' Set the option to read single barcodePrivate options As New BarcodeReaderOptions() With { .ExpectMultipleBarcodes = False, .ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional}' Read barcodePrivate results = BarcodeReader.Read("testbc1.png", options)For Each result In resultsConsole.WriteLine(result.ToString())Next result
Imports IronBarCode
Imports System
' Set the option to read single barcode
Private options As New BarcodeReaderOptions() With {
.ExpectMultipleBarcodes = False,
.ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional
}
' Read barcode
Private results = BarcodeReader.Read("testbc1.png", options)
For Each result In results
Console.WriteLine(result.ToString())
Next result
using IronBarCode;using IronSoftware.Drawing;// Define a crop region where the barcode is likely locatedvar cropRegion = new Rectangle(100, 100, 300, 200);// Configure options for optimal single barcode readingBarcodeReaderOptions optimizedOptions = new BarcodeReaderOptions(){ExpectMultipleBarcodes = false,ExpectBarcodeTypes = BarcodeEncoding.Code128,CropArea = cropRegion,Speed = ReadingSpeed.Faster};// Read with optimized settingsvar result = BarcodeReader.Read("product-label.png", optimizedOptions).FirstOrDefault();if (result != null){Console.WriteLine($"Barcode found: {result.Value}");}
using IronBarCode;
using IronSoftware.Drawing;
// Define a crop region where the barcode is likely located
var cropRegion = new Rectangle(100, 100, 300, 200);
// Configure options for optimal single barcode reading
BarcodeReaderOptions optimizedOptions = new BarcodeReaderOptions()
{
ExpectMultipleBarcodes = false,
ExpectBarcodeTypes = BarcodeEncoding.Code128,
CropArea = cropRegion,
Speed = ReadingSpeed.Faster
};
// Read with optimized settings
var result = BarcodeReader.Read("product-label.png", optimizedOptions).FirstOrDefault();
if (result != null)
{
Console.WriteLine($"Barcode found: {result.Value}");
}
try{ var results = BarcodeReader.Read("barcodes.png", new BarcodeReaderOptions { ExpectMultipleBarcodes = true }); if (!results.Any()) {Console.WriteLine("No barcodes found in the image"); } else {Console.WriteLine($"Found {results.Count()} barcodes"); }}catch (Exception ex){Console.WriteLine($"Error reading barcodes: {ex.Message}"); // Log error for debugging}
try
{
var results = BarcodeReader.Read("barcodes.png", new BarcodeReaderOptions
{
ExpectMultipleBarcodes = true
});
if (!results.Any())
{
Console.WriteLine("No barcodes found in the image");
}
else
{
Console.WriteLine($"Found {results.Count()} barcodes");
}
}
catch (Exception ex)
{
Console.WriteLine($"Error reading barcodes: {ex.Message}");
// Log error for debugging
}
Try Dim results = BarcodeReader.Read("barcodes.png", New BarcodeReaderOptionsWith { .ExpectMultipleBarcodes = True }) IfNot results.Any() ThenConsole.WriteLine("No barcodes found in the image") ElseConsole.WriteLine($"Found {results.Count()} barcodes") End IfCatch ex AsExceptionConsole.WriteLine($"Error reading barcodes: {ex.Message}") ' Log error for debuggingEndTry
Try
Dim results = BarcodeReader.Read("barcodes.png", New BarcodeReaderOptions With {
.ExpectMultipleBarcodes = True
})
If Not results.Any() Then
Console.WriteLine("No barcodes found in the image")
Else
Console.WriteLine($"Found {results.Count()} barcodes")
End If
Catch ex As Exception
Console.WriteLine($"Error reading barcodes: {ex.Message}")
' Log error for debugging
End Try
Is stream processing supported in IronBarcode for large barcode batches?
Yes, IronBarcode supports reading barcodes from streams, which is particularly useful for optimizing memory usage in high-throughput applications or large batch processing.