Barcode Reader SDK for .NET可以帮助开发人员创建一个条码识别应用程序,可以从图片中识别常用的一维和2维条形码,下面的图片中包含了EAN-13和Code-128条码,然后可以通过Barcode Reader SDK for .NET提供的条码识别功能,快速读取图片中的这两种条形码,具体代码如下:
//Create a BarcodeReader object
BarcodeReader myReader = new BarcodeReader();
//Add the barcode symbologies to be recognized
myReader.Symbology.Add(Symbology.Ean13);
myReader.Symbology.Add(Symbology.Code128);
//Set max num of barcode symbols to be detected
myReader.Hints.MaxNumOfBarcodes = 2;
//Scan the source image and get result
List<BarcodeScanResult> results = myReader.Scan(@"c:\barcode_sample.jpg");
//Display scan result
foreach (BarcodeScanResult result in results)
{
Console.WriteLine("Barcode Type: " + result.Symbology.ToString());
Console.WriteLine("Barcode Data: " + result.Text);
Console.WriteLine("=============");
}