←Select platform

Symbology Property

Summary
Gets or sets the barcode symbology (type) associated with this BarcodeData.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public virtual BarcodeSymbology Symbology { get; set; } 
@property (nonatomic, assign) LTBarcodeSymbology symbology; 
public BarcodeSymbology getSymbology() 
public void setSymbology(BarcodeSymbology value) 
[BrowsableAttribute(false)] 
public: 
virtual property BarcodeSymbology Symbology { 
   BarcodeSymbology get(); 
   void set (    BarcodeSymbology ); 
} 
Symbology # get and set (BarcodeData) 

Property Value

An BarcodeSymbology enumeration member that specifies the barcode symbology (type) associated with this BarcodeData. The default value is BarcodeSymbology.Unknown.

Remarks

Reading Barcodes

The BarcodeReader.ReadBarcode or BarcodeReader.ReadBarcodes methods are used to read a barcode or more from an image. Each of these methods return an object or an array of objects of type BarcodeData for each barcode found. Inside each object, the value of the Symbology property will be set by the BarcodeReader object to the symbology (or type) of the barcode. You can examine this value to decide how to parse the data of the barcode stored in GetData or Value.

The value of Symbology will never be BarcodeSymbology.Unknown on BarcodeData objects returned from BarcodeReader.ReadBarcode or BarcodeReader.ReadBarcodes.

For a tutorial, refer to one of the Extract Barcodes Tutorials.

Writing Barcodes

The BarcodeWriter.WriteBarcode method is used to write a barcodes to an image. You must create an instance of BarcodeData and fill its members before passing it to this method. The Symbology property inform the BarcodeWriter object of the symbology (or type) of barcode to write.

You cannot set the value of Symbology to BarcodeSymbology.Unknown when writing barcodes, as it will result in an exception being thrown. The reason for the exception is due to the object BarcodeWriter will not know the symbology (or type) of barcode to write.

For a tutorial, refer to Write Barcodes Tutorials.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Barcode; 
using Leadtools.ImageProcessing; 
 
 
public void BarcodeData_Example() 
{ 
   string imageFileName = Path.Combine(LEAD_VARS.ImagesDir, "Barcode1.tif"); 
 
   // Create a Barcode engine 
   BarcodeEngine engine = new BarcodeEngine(); 
 
   // Load the image 
   using (RasterCodecs codecs = new RasterCodecs()) 
   { 
      using (RasterImage image = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)) 
      { 
         // Read the first barcode 
         BarcodeData data = engine.Reader.ReadBarcode(image, LeadRect.Empty, BarcodeSymbology.Unknown); 
 
         // Show the barcode data found (if any) 
         if (data != null) 
         { 
            Console.WriteLine("Found barcode at {0}", data.Bounds); 
            Console.WriteLine("Symbology: {0}", data.Symbology); 
            Console.WriteLine("Data: {0}", data.Value); 
         } 
      } 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.File; 
import java.io.IOException; 
import java.nio.charset.StandardCharsets; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.barcode.*; 
import leadtools.codecs.*; 
 
 
public void barcodeDataExample() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   String imageFileName = combine(LEAD_VARS_IMAGES_DIR, "barcode1.tif"); 
 
   // Create a Barcode engine 
   BarcodeEngine engine = new BarcodeEngine(); 
 
   // Load the image 
   RasterCodecs codecs = new RasterCodecs(); 
       
   RasterImage image = codecs.load(imageFileName, 0, CodecsLoadByteOrder.BGR_OR_GRAY, 1, 1); 
             
   // Read the first barcode 
   BarcodeData data = engine.getReader().readBarcode(image, LeadRect.getEmpty(), BarcodeSymbology.UNKNOWN); 
 
   // Show the barcode data found (if any) 
   if (data != null) 
   { 
      System.out.printf("Found barcode at %s%n", data.getBounds()); 
      System.out.printf("Symbology: %s%n", data.getSymbology().getValue()); 
      System.out.printf("Data: %s%n", data.getValue()); 
   }      
          
   codecs.dispose(); 
   image.dispose(); 
   assertTrue("File does not exist", new File(imageFileName).exists()); 
   System.out.println("Command run and file exported to: " + imageFileName); 
} 
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.