←Select platform

BarcodeEngine Constructor

Summary
Creates a new instance of the BarcodeEngine class.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public BarcodeEngine() 
- (instancetype)init 
public BarcodeEngine() 
public: 
BarcodeEngine(); 
__init__() # Default constructor 
Remarks

When an instance of BarcodeEngine is initialized, the BarcodeEngine.Reader and BarcodeEngine.Writer properties will be initialized with a new instance of BarcodeReader and BarcodeWriter classes respectively.

Example
C#
Java
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 engine 
   BarcodeEngine engine = new BarcodeEngine(); 
 
   // Load the image 
   using (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 image 
            BarcodeData[] barcodes = engine.Reader.ReadBarcodes(image, LeadRect.Empty, 0, null); 
 
            // Print out the barcodes we found 
            Console.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:\LEADTOOLS23\Resources\Images"; 
} 
 
import static org.junit.Assert.assertTrue; 
 
import java.io.File; 
import java.io.IOException; 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import leadtools.*; 
import leadtools.barcode.*; 
import leadtools.codecs.*; 
 
 
public void barcodeEngine_Example() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   String[] imageFileNames = {  
      combine(LEAD_VARS_IMAGES_DIR, "Barcode1.tif"), 
      combine(LEAD_VARS_IMAGES_DIR, "Barcode2.tif")  
   }; 
 
   // Create a Barcode engine 
   BarcodeEngine engine = new BarcodeEngine(); 
 
   // Load the image 
   RasterCodecs codecs = new RasterCodecs(); 
   for (String imageFileName : imageFileNames) { 
 
      RasterImage image = codecs.load(imageFileName, 0, CodecsLoadByteOrder.BGR_OR_GRAY, 1, 1); 
 
      // Read all the barcodes in this image 
      BarcodeData[] barcodes = engine.getReader().readBarcodes(image, LeadRect.getEmpty(), 0, null); 
 
      // Print out the barcodes we found 
      System.out.printf("%1s contains %2s barcodes%n", imageFileName, barcodes.length); 
      for (int i = 0; i < barcodes.length; i++) { 
 
         BarcodeData barcode = barcodes[i]; 
         System.out.printf("  %1s - %2s - %3s%n", i + 1, barcode.getSymbology(), barcode.getValue()); 
 
      } 
 
      System.out.println("-----------------"); 
      codecs.save(image, imageFileName, RasterImageFormat.TIF, 0); 
      assertTrue("The file saves to " + imageFileName, (new File(imageFileName)).exists()); 
   } 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Barcode Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.