LEADTOOLS Barcode (Leadtools.Barcode assembly)

BarcodeData Class

Show in webframe
Example 







Members 
Contains the data for a single barcode.
Object Model
Syntax
[TypeConverterAttribute()]
[SerializableAttribute()]
public class BarcodeData : System.ICloneable  
'Declaration
 
<TypeConverterAttribute()>
<SerializableAttribute()>
Public Class BarcodeData 
   Implements System.ICloneable 
'Usage
 
Dim instance As BarcodeData
public sealed class BarcodeData : System.ICloneable  
@interface LTBarcodeData : NSObject<LTBarcodeDataDelegate>
public class BarcodeData
function Leadtools.Barcode.BarcodeData()
[TypeConverterAttribute()]
[SerializableAttribute()]
public ref class BarcodeData : public System.ICloneable  
Remarks

The BarcodeData class contains the data for a single barcode. It is used by LEADTOOLS when reading and writing barcodes from/to an image.

Reading Barcodes

The BarcodeReader class contains multiple methods to read a single or multiple barcodes from an image ( Refer to the BarcodeReader.ReadBarcode and BarcodeReader.ReadBarcodes methods). For each barcode found, BarcodeReader will return an instance of BarcodeData populated with the data found in the barcode.

The following table lists the members of BarcodeData and their meaning when BarcodeReader returns the object from an image:

Member Description
Symbology

A member of the BarcodeSymbology enumeration that specifies the symbology (or type) of the barcode found

Bounds

The barcode location and size in the image

RotationAngle

The angle of rotation if the barcode was rotated (or skewed)

The data (accessed through GetData)

The raw data found inside the barcode as a byte array

Value

A string representation (in ASCII) of the data. The value returned is simply an ASCII text of the byte array returned from GetData

Tag

User defined field. Not used

DatamatrixSymbolSize

An DatamatrixBarcodeSymbolSize enumeration member that specifies the symbol size of the Datamatrix barcode.

MicroPDF417IsLinked

Indicates that the MicroPDF417 barcode is linked to a linear symbol printed below it.

MicroPDF417DataCode

The MicroPDF417 barcode function code word for Code 128 emulation.

PDF417Group

The group number if this PDF417 barcode symbol is a member of a group of symbols

QRSymbolModel

An QRBarcodeSymbolModel enumeration member that specifies the symbol model and version of the QR barcode.

In addition to the members above, other read options not related to the barcode data can be set using the BarcodeReadOptions class or one of its derived classes.

For a tutorial on reading barcodes, refer to Reading Barcodes Tutorial.

Writing Barcodes

The BarcodeWriter class allows you to write a single barcode to the image. You must create a new instance of the BarcodeData class, fill its members with the values for the new barcode and call the BarcodeWriter.WriteBarcode method passing the created object.

The following table lists the members of BarcodeData and their meaning when writing barcodes:

Member Description
Symbology

A member of the BarcodeSymbology enumeration that specifies the symbology (or type) of the barcode to write

Bounds

The location and size where to write the barcode in the image

The data (set through SetData)

The raw data of the new barcode as byte array

Value

A string representation (in ASCII) of the data. The value set in Value will simply be parsed as an ASCII text and put it in the raw data through SetData

RotationAngle

Not used in writing

Tag

User defined field. Not used

DatamatrixSymbolSize

A member of the DatamatrixBarcodeSymbolSize enumeration that specifies the symbol size of the barcode to write

MicroPDF417IsLinked

Indicates whether the MicroPDF417 barcode is linked to a linear symbol printed below it, To link MicroPDF417 when writing, use the MicroPDF417BarcodeWriteOptions.IsLinked property.

MicroPDF417DataCode

Indicates the MicroPDF417 barcode function code word for Code 128 emulation, to use this value when writing MicroPDF417 symbols, set the value of MicroPDF417BarcodeWriteOptions.EnableGroupMode to true

PDF417Group

Specifies whether this PDF417 barcode symbol is a member of a group of symbols, To use this value when writing PDF417 symbols you must set the value of PDF417BarcodeWriteOptions.EnableGroupMode to true

QRSymbolModel

A QRBarcodeSymbolModel enumeration member that specifies the QR barcode symbol model and version.

In addition to the members above, other write options not related to the barcode data can be set using the BarcodeWriteOptions class or one of its derived classes.

You can also use the BarcodeWriter.CalculateBarcodeDataBounds method to pre-calculate the barcode location and size based on the barcode data, its "XModule" and various other properties.

For a tutorial on writing barcodes, refer to Writing Barcodes Tutorial.

General

Note: This section is not supported in LEADTOOLS for Windows Runtime.

The BarcodeData class contains support for the following:

Note: The functionality in the above list is not supported in LEADTOOLS for Windows Runtime.

Derived Types

Note: This section is not supported in LEADTOOLS for Windows Runtime.

This section deals with derived barcode data types only currently available in the following symbologies: BarcodeSymbology.Datamatrix, BarcodeSymbology.MicroPDF417, BarcodeSymbology.PDF417 and BarcodeSymbology.QR. All other symbology types do not contain specialized data types and the base BarcodeData must be used exclusively when reading or writing barcodes.

Some barcode symbologies contain extra information that are not available in BarcodeData, for these types, LEADTOOLS adds derived classes to contain the extra information.

When the BarcodeReader class encounters a barcode of one of these symbologies, it returns one of the following types casted down as BarcodeData. You can then cast the object up to its derived type if needed, refer to any of the classes listed in the table below for an example.

The following table lists the derived types:

Type Description
DatamatrixBarcodeData

Used with BarcodeSymbology.Datamatrix. Adds the Datamatrix barcode symbol size to be used when reading and writing

MicroPDF417BarcodeData

Used with BarcodeSymbology.MicroPDF417. Adds the MicroPDF417 data code to be used when reading and writing. Also, contains information on whether a MicroPDF417 barcode read is linked to a linear barcode below it

PDF417BarcodeData

Used with BarcodeSymbology.PDF417. Contains information about the group number of a PDF417 barcode found in the image

QRBarcodeData

Used with BarcodeSymbology.QR. Adds the QR barcode symbol size to be used when reading and writing

When reading barcodes, you can use the base BarcodeData class exclusively only when you are interested in the extra options. Generally, all the relevant data of the barcode read can be obtained with BarcodeData.GetData or BarcodeData.Value. If you are however interested in reading those extra values, then simple cast the object up to the correct derived class and read the extra properties.

When writing barcodes, you must generally always pass a derived class since all information is needed when writing a barcode. Create an instance of the correct derived class and pass it to BarcodeWriter.WriteBarcode. This method will take the data as a base BarcodeData instance and will accept passing generic BarcodeData objects when writing more specific barcodes (such as QR) although this is generally not a recommended process.

The GetBarcodeDataType returns the System.Type of the derived BarcodeData class associated with a certain BarcodeSymbology or the BarcodeData type when the symbology does not have a specialized data class.

Notes

The color of the barcode is not considered part of its data. Colors of barcode read can be controlled through the BarcodeReadOptions.ForeColor and BarcodeReadOptions.BackColor properties. Also colors of barcodes to be written can be set through BarcodeWriteOptions.ForeColor and BarcodeWriteOptions.BackColor.

Some barcodes like QR and PDF417 support data that is not necessary ASCII text. For example, an image, a URL or just raw stream of bytes. When reading these barcodes, the Value property may not return an accurate representation of the data. Hence, use the BarcodeData.GetData method and then parse it. Also, when writing barcodes, you must set the raw data using the SetData method

The Australian post barcode (BarcodeSymbology.AustralianPost4State) string has a special format to distinguish different fields (i.e. FCC, DPID, and CIF). The string format puts dashes between fields as follows: "FCC-DIPD-CIF", where FCC is a 2-digit field (valid values are 11, 87, 45, 92, 59, 62, and 44), DPID is an 8-digit field representing the address, and CIF (optional) represents the customer information field. For more information, please refer to the standard. This string format applies for both read and write.

GS1 Databar Expanded (BarcodeSymbology.GS1DatabarExpanded) and GS1 Databar Expanded Stacked (BarcodeSymbology.GS1DatabarExpandedStaceked) barcode strings need to be written conforming to a string format that indicates a particular encoding method, such as Method "1", Method "0100", Method "0101", … etc. For example, a string (01)00012345678905(10)ABC123" is encoded using Method "1" (i.e. General Identification Data). Note that the 14th digit of the item identification number (in this case, "5"), if it exists, is considered as a check digit and is ignored. A string that is written without following any of these special encoding formats will be encoded by Method "00" (i.e. General Purpose Data).

When a BarcodeData is returned from a read operation, an extra digit in curly brackets (i.e. "{" and "}") is added to indicate the linkage bit at the beginning of the string. The curly brackets are not part of the encoded barcode data, and are not defined in the standard. Rather, they distinguish the linkage digit from other data. For example, if a barcode is written with string "(01)00012345678905(10)ABC123" while the linkage bit is set to zero, the read function result will be "{0}(01)00012345678905(10)ABC123", where {0} is the linkage digit and the remaining characters are the barcode data.

BarcodeSymbology.UCCEAN128 is designed for reading UCCEAN 128 barcode only, and it is not designed for writing this barcode type.

Code Interleaved 2 of 5: I = # of digits and must be even.

Linear (1D) barcodes are not supported in UNICODE.

For a table containing information useful when writing 1D barcode data see http://www.leadtools.com/SDK/Document/Document-Addon-Barcodelinear1D-chart.htm.

Example
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Forms
Imports Leadtools.Barcode
Imports Leadtools.ImageProcessing

Public Sub BarcodeData_Example()
   Dim imageFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Barcode1.tif")

   ' Create a Barcode engine
   Dim engine As New BarcodeEngine()

   ' Load the image
   Using codecs As New RasterCodecs()
      Using image As RasterImage = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)
         ' Read the first barcode
         Dim data As BarcodeData = engine.Reader.ReadBarcode(image, LogicalRectangle.Empty, BarcodeSymbology.Unknown)

         ' Show the barcode data found (if any)
         If Not IsNothing(data) Then
            Console.WriteLine("Found barcode at {0}", data.Bounds)
            Console.WriteLine("Symbology: {0}", data.Symbology)
            Console.WriteLine("Data: {0}", data.Value)
         End If
      End Using
   End Using
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Forms;
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, LogicalRectangle.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:\Users\Public\Documents\LEADTOOLS Images";
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Barcode;
using Leadtools.ImageProcessing;

      
public async Task BarcodeData_Example()
{
   string imageFileName = @"Assets\Barcode1.tif";
   // Create a Barcode engine
   BarcodeEngine engine = new BarcodeEngine();

   // Load the image
   using(RasterCodecs codecs = new RasterCodecs())
   {
      StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(imageFileName);
      using(RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile)))
      {
         // Read the first barcode
         BarcodeData data = engine.Reader.ReadBarcode(image, LeadRectHelper.Empty, BarcodeSymbology.Unknown);

         // Show the barcode data found (if any)
         if(data != null)
         {
            Debug.WriteLine("Found barcode at {0}", data.Bounds);
            Debug.WriteLine("Symbology: {0}", data.Symbology);
            Debug.WriteLine("Data: {0}", data.Value);
         }
      }
   }
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Forms;
using Leadtools.Barcode;
using Leadtools.ImageProcessing;
using Leadtools.Examples;

public void BarcodeData_Example(RasterImage image)
{
   // Create a Barcode engine
   BarcodeEngine engine = new BarcodeEngine();
   // Load the image
   RasterCodecs codecs = new RasterCodecs();

   // Read the first barcode
   BarcodeData data = engine.Reader.ReadBarcode(image, LogicalRectangle.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);
   }
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Forms
Imports Leadtools.Barcode
Imports Leadtools.ImageProcessing

Public Sub BarcodeData_Example(ByVal image As RasterImage)
  ' Create a Barcode engine
  Dim engine As BarcodeEngine = New BarcodeEngine()
  ' Load the image
  Dim codecs As RasterCodecs = New RasterCodecs()

  ' Read the first barcode
  Dim data As BarcodeData = engine.Reader.ReadBarcode(image, LogicalRectangle.Empty, BarcodeSymbology.Unknown)

  ' Show the barcode data found (if any)
  If Not data Is Nothing Then
    Console.WriteLine("Found barcode at {0}", data.Bounds)
    Console.WriteLine("Symbology: {0}", data.Symbology)
    Console.WriteLine("Data: {0}", data.Value)
  End If
End Sub
Requirements

Target Platforms

See Also

Reference

BarcodeData Members
Leadtools.Barcode Namespace
BarcodeReader Class
BarcodeWriter Class
BarcodeSymbology Enumeration
BarcodeEngine Class
DatamatrixBarcodeData Class
MicroPDF417BarcodeData Class
PDF417BarcodeData Class
QRBarcodeData Class
BarcodeReader.ReadBarcode
BarcodeReader.ReadBarcodes
BarcodeWriter.WriteBarcode
Programming with LEADTOOLS Barcode
Supported Barcode Symbologies
Unlocking Barcode Support
Reading Barcodes Tutorial
Writing Barcodes Tutorial
UPC / EAN Barcodes in LEADTOOLS
2 of 5 Barcodes 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
Codabar Barcodes in LEADTOOLS
Miscellaneous Barcodes in LEADTOOLS
Datamatrix Barcodes in LEADTOOLS
PDF417 and MicroPDF417 Barcodes in LEADTOOLS
MicroPDF417 Barcodes in LEADTOOLS
QR Barcodes in LEADTOOLS
Writing Barcodes - Bounds and XModule

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.

Leadtools.Barcode requires a Barcode Module license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features