LEADTOOLS Barcode (Leadtools.Barcode assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
BarcodeWriteQr Class
See Also  Members  
Leadtools.Barcode Namespace : BarcodeWriteQr Class



The BarcodeWriteQr Class includes members that are available as an add-on to the LEADTOOLS Imaging Pro, Document, and Medical Imaging toolkits.

This class contains QR barcode information for writing QR barcodes.

Object Model

BarcodeWriteQr Class

Syntax

Visual Basic (Declaration) 
Public Class BarcodeWriteQr 
Visual Basic (Usage)Copy Code
Dim instance As BarcodeWriteQr
C# 
public class BarcodeWriteQr 
C++/CLI 
public ref class BarcodeWriteQr 

Example

Visual BasicCopy Code
Public Sub BarcodeWriteQrExample()
      ' Load an image
      Dim codecs As RasterCodecs = New RasterCodecs()
      codecs.ThrowExceptionsOnInvalidImages = True

      Dim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "barcode1.tif"))

      Dim barEngine As BarcodeEngine

      Try
         ' Unlock barcode support.
         ' Note that this is a sample key, which will not work in your toolkit
         RasterSupport.Unlock(RasterSupportType.BarcodesQRWrite, "TestKey")

         ' Initialize barcodes
         barEngine = New BarcodeEngine()

         Dim data As BarcodeData = New BarcodeData()
         Dim rc As LeadRect = New LeadRect(100, 100, 0, 0)
         data.Unit = BarcodeUnit.ScanlinesPerPixels
         data.Location = rc
         data.SearchType = BarcodeSearchTypeFlags.QrDefault

         Dim barcodeText As String()
         barcodeText = New String(0) {}
         barcodeText(0) = "QR Default Size"
         data.Data = BarcodeData.ConvertFromStringArray(barcodeText)

         Dim barColor As BarcodeColor = New BarcodeColor()
         barColor.BarColor = RasterColor.FromKnownColor(RasterKnownColor.Black)
         barColor.SpaceColor = RasterColor.FromKnownColor(RasterKnownColor.White)

         Dim bar1d As Barcode1d = New Barcode1d()
         Dim barPDF As BarcodeWritePdf = New BarcodeWritePdf()
         Dim barDM As BarcodeWriteDatamatrix = New BarcodeWriteDatamatrix()
         Dim barQR As BarcodeWriteQr = New BarcodeWriteQr()

         barQR.EccLevel = BarcodeQrEccLevel.LevelL
         barQR.GroupNumber = 0
         barQR.GroupTotal = 0
         barQR.Justify = BarcodeJustifyFlags.Right
         barQR.XModule = 0

         barEngine.Write(image, data, barColor, BarcodeWriteFlags.Truncate, bar1d, barPDF, barDM, barQR, LeadRect.Empty)
      Catch ex As BarcodeException
         Console.WriteLine(ex.Message)
      End Try

   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
C#Copy Code
public void BarcodeWriteQrExample()
   {
      // Load an image
      RasterCodecs codecs = new RasterCodecs();
      codecs.ThrowExceptionsOnInvalidImages = true;
      string fileName = Path.Combine(LEAD_VARS.ImagesDir, "barcode1.tif");
      RasterImage image = codecs.Load(fileName);

      BarcodeEngine barEngine;

      try
      {
         // Unlock barcode support.
         // Note that this is a sample key, which will not work in your toolkit
         RasterSupport.Unlock(RasterSupportType.BarcodesQRWrite, "TestKey");

         // Initialize barcodes
         barEngine = new BarcodeEngine();

         BarcodeData data = new BarcodeData();

         data.Unit = BarcodeUnit.ScanlinesPerPixels;
         LeadRect rc = new LeadRect(100, 100, 0, 0);
         data.Location = rc;
         data.SearchType = BarcodeSearchTypeFlags.QrDefault;

         string[] barcodeText;
         barcodeText = new string[1];
         barcodeText[0] = "QR Default Size";
         data.Data = BarcodeData.ConvertFromStringArray(barcodeText);

         BarcodeColor barColor = new BarcodeColor();
         barColor.BarColor = RasterColor.FromKnownColor(RasterKnownColor.Black);
         barColor.SpaceColor = RasterColor.FromKnownColor(RasterKnownColor.White);

         Barcode1d bar1d = new Barcode1d();
         BarcodeWritePdf barPDF = new BarcodeWritePdf();
         BarcodeWriteDatamatrix barDM = new BarcodeWriteDatamatrix();
         BarcodeWriteQr barQR = new BarcodeWriteQr();

         barQR.EccLevel = BarcodeQrEccLevel.LevelL;
         barQR.GroupNumber = 0;
         barQR.GroupTotal = 0;
         barQR.Justify = BarcodeJustifyFlags.Right;
         barQR.XModule = 0;

         barEngine.Write(image, data, barColor, BarcodeWriteFlags.Truncate, bar1d, barPDF, barDM, barQR, LeadRect.Empty);
      }
      catch (BarcodeException ex)
      {
         Console.WriteLine(ex.Message);
      }

   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
SilverlightCSharpCopy Code
public void BarcodeWriteQrExample(RasterImage image)
{
   BarcodeEngine barEngine;
   try
   {
      // Unlock barcode support.
      // Note that this is a sample key, which will not work in your toolkit
      RasterSupport.Unlock(RasterSupportType.BarcodesQRWrite, "TestKey");

      // Initialize barcodes
      barEngine = new BarcodeEngine();

      BarcodeData data = new BarcodeData();

      data.Unit = BarcodeUnit.ScanlinesPerPixels;
      LeadRect rc = new LeadRect(100, 100, 0, 0);
      data.Location = rc;
      data.SearchType = BarcodeSearchTypeFlags.QrDefault;

      string[] barcodeText;
      barcodeText = new string[1];
      barcodeText[0] = "QR Default Size";
      data.Data = BarcodeData.ConvertFromStringArray(barcodeText);

      BarcodeColor barColor = new BarcodeColor();
      barColor.BarColor = RasterColor.FromKnownColor(RasterKnownColor.Black);
      barColor.SpaceColor = RasterColor.FromKnownColor(RasterKnownColor.White);

      Barcode1d bar1d = new Barcode1d();
      BarcodeWritePdf barPDF = new BarcodeWritePdf();
      BarcodeWriteDatamatrix barDM = new BarcodeWriteDatamatrix();
      BarcodeWriteQr barQR = new BarcodeWriteQr();

      barQR.EccLevel = BarcodeQrEccLevel.LevelL;
      barQR.GroupNumber = 0;
      barQR.GroupTotal = 0;
      barQR.Justify = BarcodeJustifyFlags.Right;
      barQR.XModule = 0;

      barEngine.Write(image, data, barColor, BarcodeWriteFlags.Truncate, bar1d, barPDF, barDM, barQR, LeadRect.Empty);
   }
   catch (BarcodeException ex)
   {
      Console.WriteLine(ex.Message);
   }

}
SilverlightVBCopy Code
Public Sub BarcodeWriteQrExample(ByVal image As RasterImage)
  Dim barEngine As BarcodeEngine
  Try
    ' Unlock barcode support.
    ' Note that this is a sample key, which will not work in your toolkit
    RasterSupport.Unlock(RasterSupportType.BarcodesQRWrite, "TestKey")

    ' Initialize barcodes
    barEngine = New BarcodeEngine()

    Dim data As BarcodeData = New BarcodeData()

    data.Unit = BarcodeUnit.ScanlinesPerPixels
    Dim rc As LeadRect = New LeadRect(100, 100, 0, 0)
    data.Location = rc
    data.SearchType = BarcodeSearchTypeFlags.QrDefault

    Dim barcodeText As String()
    barcodeText = New String(0){}
    barcodeText(0) = "QR Default Size"
    data.Data = BarcodeData.ConvertFromStringArray(barcodeText)

    Dim barColor As BarcodeColor = New BarcodeColor()
    barColor.BarColor = RasterColor.FromKnownColor(RasterKnownColor.Black)
    barColor.SpaceColor = RasterColor.FromKnownColor(RasterKnownColor.White)

    Dim bar1d As Barcode1d = New Barcode1d()
    Dim barPDF As BarcodeWritePdf = New BarcodeWritePdf()
    Dim barDM As BarcodeWriteDatamatrix = New BarcodeWriteDatamatrix()
    Dim barQR As BarcodeWriteQr = New BarcodeWriteQr()

    barQR.EccLevel = BarcodeQrEccLevel.LevelL
    barQR.GroupNumber = 0
    barQR.GroupTotal = 0
    barQR.Justify = BarcodeJustifyFlags.Right
    barQR.XModule = 0

    barEngine.Write(image, data, barColor, BarcodeWriteFlags.Truncate, bar1d, barPDF, barDM, barQR, LeadRect.Empty)
  Catch ex As BarcodeException
    Console.WriteLine(ex.Message)
  End Try

End Sub

Remarks

The QR standard specifies 40 different sizes of the QR code and the maximum data capacity will vary depending on the size and Error Correction level. The table below lists the maximum data capacity for each ECC level and encoding scheme.

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

Inheritance Hierarchy

System.Object
   Leadtools.Barcode.BarcodeWriteQr

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

See Also

Leadtools.Barcode requires a Barcode Module license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features