Main class for the LEADTOOLS support for reading and writing barcodes.
public class BarcodeEngine Public Class BarcodeEngine @interface LTBarcodeEngine : NSObject public class BarcodeEngine public ref class BarcodeEngine
The BarcodeEngine class is the main entry point for LEADTOOLS support for barcode reading and writing.
This class contains the following members:
BarcodeEngine.Reader: The instance of the BarcodeReader class that you can use to read barcodes from an image.
BarcodeEngine.Writer: The instance of the BarcodeWriter class that you can use to write barcodes to an image.
This class also contains the following helper static (Shared in VB) methods:
BarcodeEngine.GetSupportedSymbologies: Returns an array of BarcodeSymbology enumeration members that lists all the barcode symbologies supported by LEADTOOLS.
BarcodeEngine.GetSymbologyFriendlyName: Returns a string that contains a friendly name of any BarcodeSymbology enumeration member.
To start using LEADTOOLS barcode support, first create an instance of BarcodeEngine. This will automatically create the BarcodeReader and BarcodeWriter objects for you. You can then access those objects through BarcodeEngine.Reader and BarcodeEngine.Writer to start reading or writing barcodes.
All these objects are thread-safe and you can pass the same BarcodeEngine, BarcodeReader or BarcodeWriter object to multiple threads. Additionally, you may read or write barcodes at the same time from/to different images and also create a separate BarcodeEngine for each thread if required. The BarcodeReader.ReadBarcodes(RasterImage image, LeadRect searchBounds, int maximumBarcodes, BarcodeSymbology[] symbologies, BarcodeReadOptions[] options) example shows how to create two threads: One for reading horizontal barcodes and one for reading vertical barcodes. It will then use the same BarcodeReader to try and read all the barcodes from an image using both threads.
For a list of the barcode symbologies supported by LEADTOOLS, refer to Supported Barcode Symbologies.
For tutorials on using LEADTOOLS barcode support, refer to Reading Barcodes Tutorial and Writing Barcodes Tutorial.
This example creates a new BarcodeEngine and reads all the barcodes in an image. For an example on writing barcodes, refer to BarcodeWriter.
using Leadtools;using Leadtools.Codecs;using Leadtools.Barcode;using Leadtools.ImageProcessing;public void BarcodeEngine_Example(){string[] imageFileNames ={Path.Combine(LEAD_VARS.ImagesDir, "Barcode1.tif"),Path.Combine(LEAD_VARS.ImagesDir, "Barcode2.tif")};// Create a Barcode engineBarcodeEngine engine = new BarcodeEngine();// Load the imageusing (RasterCodecs codecs = new RasterCodecs()){foreach (string imageFileName in imageFileNames){using (RasterImage image = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)){// Read all the barcodes in this imageBarcodeData[] barcodes = engine.Reader.ReadBarcodes(image, LeadRect.Empty, 0, null);// Print out the barcodes we foundConsole.WriteLine("{0} contains {1} barcodes", imageFileName, barcodes.Length);for (int i = 0; i < barcodes.Length; i++){BarcodeData barcode = barcodes[i];Console.WriteLine(" {0} - {1} - {2}", i + 1, barcode.Symbology, barcode.Value);}Console.WriteLine("-----------------");}}}}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.BarcodeImports Leadtools.ImageProcessingPublic Sub BarcodeEngine_Example()Dim imageFileNames() As String ={Path.Combine(LEAD_VARS.ImagesDir, "Barcode1.tif"),Path.Combine(LEAD_VARS.ImagesDir, "Barcode2.tif")}' Create a Barcode engineDim engine As New BarcodeEngine()' Load the imageUsing codecs As New RasterCodecs()For Each imageFileName As String In imageFileNamesUsing image As RasterImage = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)' Read all the barcodes in this imageDim barcodes() As BarcodeData = engine.Reader.ReadBarcodes(image, LeadRect.Empty, 0, Nothing)' Print out the barcodes we foundConsole.WriteLine("{0} contains {1} barcodes", imageFileName, barcodes.Length)For i As Integer = 0 To barcodes.Length - 1Dim barcode As BarcodeData = barcodes(i)Console.WriteLine(" {0} - {1} - {2}", i + 1, barcode.Symbology, barcode.Value)NextConsole.WriteLine("-----------------")End UsingNextEnd UsingEnd SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
c#[Silverlight C# Example]using Leadtools;using Leadtools.Codecs;using Leadtools.Forms;using Leadtools.Barcode;using Leadtools.ImageProcessing;using Leadtools.Examples;public void BarcodeEngine_Example(RasterImage image, string imageFileName){// Create a Barcode engineBarcodeEngine engine = new BarcodeEngine();// Load the imageRasterCodecs codecs = new RasterCodecs();// Read all the barcodes in this imageBarcodeData[] barcodes = engine.Reader.ReadBarcodes(image, LogicalRectangle.Empty, 0, null);// Print out the barcodes we foundConsole.WriteLine("{0} contains {1} barcodes", imageFileName, barcodes.Length);for (int i = 0; i < barcodes.Length; i++){BarcodeData barcode = barcodes[i];Console.WriteLine(" {0} - {1} - {2}", i + 1, barcode.Symbology, barcode.Value);}Console.WriteLine("-----------------");}vb[Silverlight VB Example]Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.FormsImports Leadtools.BarcodeImports Leadtools.ImageProcessingPublic Sub BarcodeEngine_Example(ByVal image As RasterImage, ByVal imageFileName As String)' Create a Barcode engineDim engine As BarcodeEngine = New BarcodeEngine()' Load the imageDim codecs As RasterCodecs = New RasterCodecs()' Read all the barcodes in this imageDim barcodes As BarcodeData() = engine.Reader.ReadBarcodes(image, LogicalRectangle.Empty, 0, Nothing)' Print out the barcodes we foundConsole.WriteLine("{0} contains {1} barcodes", imageFileName, barcodes.Length)Dim i As Integer = 0Do While i < barcodes.LengthDim barcode As BarcodeData = barcodes(i)Console.WriteLine(" {0} - {1} - {2}", i + 1, barcode.Symbology, barcode.Value)i += 1LoopConsole.WriteLine("-----------------")End Sub
Programming with LEADTOOLS Barcode
UPC / EAN Barcodes in LEADTOOLS
GS1 DataBar / RSS-14 Barcodes in LEADTOOLS
Code 128 Barcodes in LEADTOOLS
USPS and 4-State Barcodes in LEADTOOLS
MSI Barcodes (Pulse Width Modulated) in LEADTOOLS
Miscellaneous Barcodes in LEADTOOLS
Datamatrix Barcodes in LEADTOOLS
PDF417 and MicroPDF417 Barcodes in LEADTOOLS
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
