private void cw_picBox_Click(object sender, EventArgs e) { OpenFileDialog file = new OpenFileDialog(); file.InitialDirectory = "."; file.Filter = "所有文件(*.*)|*.*"; file.ShowDialog(); if (file.FileName != string.Empty) { try { this.cw_picBox.Load(file.FileName); BarcodeResult[] results = BarCodeScanner.Scan(file.FileName); if (results != null) { foreach (BarcodeResult result in results) { this.cw_txtBox.Clear(); this.cw_txtBox.AppendText("> 类型:" + result.BarType.ToString() + Environment.NewLine); this.cw_txtBox.AppendText("> 内容:" + Environment.NewLine + result.Data); } } else { this.cw_txtBox.Text = "> 所选图像未检测到二维码......"; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public static void ReadAllTypeBarcode() { BarcodeResult[] results = BarCodeScanner.Scan("d:/barcode.png"); foreach (BarcodeResult result in results) { Console.WriteLine(result.BarType.ToString() + "-" + result.Data); } }
public static void ReadSpecifiedTypeBarcode() { BarcodeResult[] results = BarCodeScanner.Scan("d:/qrcode.png", BarCodeType.QRCode); foreach (BarcodeResult result in results) { Console.WriteLine(result.Data); } }
public void ScanQRCodeFromFile(string ImgPath) { BarcodeResult[] results = BarCodeScanner.Scan(ImgPath); foreach (BarcodeResult result in results) { extractedData = result.Data; extractedData = extractedData.Substring(1); System.Diagnostics.Process.Start(extractedData); } }
// Распознавание QR-кода в PDF-файле public void PDFQRCodeRecognition(string PDF) { Bitmap bmp = new Bitmap("c:\\QRPDF Test Directory\\Cutted QR\\Test11.png"); BarcodeResult barcode = BarCodeScanner.ScanSingle(bmp); Console.WriteLine("barcode data:{0}.", barcode.Data); BarcodeResult[] results = BarCodeScanner.Scan("c:\\QRPDF Test Directory\\Cutted QR\\Test11.png", BarCodeType.QRCode); foreach (BarcodeResult result in results) { Console.WriteLine(result.BarType.ToString() + "-" + result.Data); } Console.ReadKey(); }