LEADTOOLSBarcodeTutorial.zip
LEADTOOLSBarcodeTutorial
Properties
Settings.settings
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Leadtools;
using Leadtools.Barcode;
using Leadtools.Codecs;
using Leadtools.Forms;
namespace LEADTOOLSBarcodeTutorial
{
public partial class Form1 : Form
{
public Form1()
{
/* Uncomment this and add your license file and developer key
//string licenseFilePath = "Replace this with the path to the LEADTOOLS license file";
//string developerKey = "Replace this with your developer key";
//RasterSupport.SetLicense(licenseFilePath, developerKey); */
InitializeComponent();
}
private void btnLoad_Click(object sender, EventArgs e)
{
using (OpenFileDialog ofd = new OpenFileDialog())
{
ofd.Filter = "TIFF|*.tif|JPEG|*.jpg|PNG|*.png|BMP|*.bmp|All Files|*.*";
if (ofd.ShowDialog() == DialogResult.OK)
{
using (RasterCodecs codecs = new RasterCodecs())
{
// Load first page into the viewer
rasterImageViewer1.Image = codecs.Load(ofd.FileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1);
}
}
}
}
private void btnRead_Click(object sender, EventArgs e)
{
// Create a Barcode engine
BarcodeEngine engine = new BarcodeEngine();
// Ignore errors in case there are corrupted ones on the image.
engine.Reader.ErrorMode = BarcodeReaderErrorMode.IgnoreAll;
// Read all barcodes with default options. For a tutorial on how to change the options, for example, read barcodes in both horizontal and vertical directions
// see http://www.leadtools.com/help/leadtools/v175/DH/BA/Leadtools.Barcode~Leadtools.Barcode.BarcodeReadOptions.html
BarcodeData[] barcodes = engine.Reader.ReadBarcodes(rasterImageViewer1.Image, LogicalRectangle.Empty, 0, null);
// Print out the barcodes we found
StringBuilder results = new StringBuilder();
results.AppendFormat("{0} barcodes found.\r\n\r\n", barcodes.Length);
for (int i = 0; i < barcodes.Length; i++)
{
BarcodeData barcode = barcodes[i];
results.AppendFormat(" {0} - {1} - {2}\r\n", i + 1, barcode.Symbology, barcode.Value);
}
txtResults.Text = results.ToString();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of use and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
With a rich history of over twenty years, LEAD has established itself as the world's leading provider of software development toolkits for document, medical, multimedia, raster and vector imaging. LEAD's flagship product, LEADTOOLS, holds the top position in every major country throughout the world and boasts a healthy, diverse customer base and strong list of corporate partners including some of the largest and most influential organizations from around the globe. For more information, contact sales@leadtools.com or support@leadtools.com.