LEADTOOLS Barcode (Leadtools.Barcode assembly)
LEAD Technologies, Inc

ReadBarcode(RasterImage,LeadRect,BarcodeSymbology,IBarcodeReadOptions) Method

Example 







A Leadtools.RasterImage object that contains the image data. Must not be null.
A Leadtools.LeadRect that specifies the region of interest area in the image where the barcode search and detection is performed. You can specify empty rectangle to indicate that the search must be performed on the whole image.
An BarcodeSymbology enumeration member that specifies the barcode symbology (type) to search for. You can pass BarcodeSymbology.Unknown to search for all available symbologies in this BarcodeReader.
An instance of a IBarcodeReadOptions derived class that specifies the options to use.

For information about this method please see ReadBarcode(RasterImage,LogicalRectangle,BarcodeSymbology,BarcodeReadOptions).

.NET support WinRT support
Syntax
'Declaration
 
Public Overloads Function ReadBarcode( _
   ByVal image As RasterImage, _
   ByVal searchBounds As LeadRect, _
   ByVal symbology As BarcodeSymbology, _
   ByVal options As IBarcodeReadOptions _
) As BarcodeData
'Usage
 
Dim instance As BarcodeReader
Dim image As RasterImage
Dim searchBounds As LeadRect
Dim symbology As BarcodeSymbology
Dim options As IBarcodeReadOptions
Dim value As BarcodeData
 
value = instance.ReadBarcode(image, searchBounds, symbology, options)
ObjectiveC Syntax
 function Leadtools.Barcode.BarcodeReader.ReadBarcode(RasterImage,LeadRect,BarcodeSymbology,IBarcodeReadOptions)( 
   image ,
   searchBounds ,
   symbology ,
   options 
)

Parameters

image
A Leadtools.RasterImage object that contains the image data. Must not be null.
searchBounds
A Leadtools.LeadRect that specifies the region of interest area in the image where the barcode search and detection is performed. You can specify empty rectangle to indicate that the search must be performed on the whole image.
symbology
An BarcodeSymbology enumeration member that specifies the barcode symbology (type) to search for. You can pass BarcodeSymbology.Unknown to search for all available symbologies in this BarcodeReader.
options
An instance of a IBarcodeReadOptions derived class that specifies the options to use.

Return Value

An instance of BarcodeData or one of its derived classes that contains the symbology, data, location, and any rotation angle of the barcode found. If no barcodes can be found, then this method will return null (Nothing in Visual Basic).
Remarks

Note: In LEADTOOLS for .NET, the equivalent to Leadtools.LeadRect is Leadtools.Forms.LogicalRectangle, also the equivalent to IBarcodeReadOptions is BarcodeReadOptions.

Example
Copy CodeCopy Code  
[TestMethod]
public async Task BarcodeReader_ReadBarcodeExample2()
{
   string imageFileName = @"Assets\Barcode2.tif";
   // Create a Barcode engine
   BarcodeEngine engine = new BarcodeEngine();

   // Get the Barcode reader instance
   BarcodeReader reader = engine.Reader;

   using(RasterCodecs codecs = new RasterCodecs())
   {
      StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(imageFileName);
      using(RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile)))
      {
         // Invert the image
         Debug.WriteLine("Inverting the image");
         Leadtools.ImageProcessing.Color.InvertCommand invert = new Leadtools.ImageProcessing.Color.InvertCommand();
         invert.Run(image);

         // All barcodes have default options of black foreground color and white background color, so
         // reading the barcode with default options should not return any barcodes right now

         // Read the QR barcode from this image using default options
         Debug.WriteLine("Reading using default options");
         BarcodeData barcode = reader.ReadBarcode(image, LeadRectHelper.Empty, BarcodeSymbology.QR, null);

         // Show its location and data if found
         // This will print out "Not found"
         if(barcode != null)
         {
            Debug.WriteLine("Found at {0}, data:\n{1}", barcode.Bounds, barcode.Value);
         }
         else
         {
            Debug.WriteLine("Not found");
         }

         // Now create QR read options to have white foreground color and black background color
         QRBarcodeReadOptions qrReadOptions = new QRBarcodeReadOptions();
         qrReadOptions.ForeColor = RasterColorHelper.FromKnownColor(RasterKnownColor.White);
         qrReadOptions.BackColor = RasterColorHelper.FromKnownColor(RasterKnownColor.Black);

         // And use it to try to read the QR barcode again
         Debug.WriteLine("Reading using specific options that instruct the engine to look for white on black barcodes");
         barcode = reader.ReadBarcode(image, LeadRectHelper.Empty, BarcodeSymbology.QR, qrReadOptions);

         // Show its location and data if found
         // This will find the barcode and print its information now
         if(barcode != null)
         {
            Debug.WriteLine("Found at {0}, data:\n{1}", barcode.Bounds, barcode.Value);
         }
         else
         {
            Debug.WriteLine("Not found");
         }
      }
   }
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

BarcodeReader Class
BarcodeReader Members
Overload List

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

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