原創(chuàng)|使用教程|編輯:龔雪|2015-10-28 14:54:29.000|閱讀 1228 次
概述:在BarCode Reader SDK中用VB.NET或者C#來讀取圖像中的條碼
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
我們知道很多語言都可以在windows平臺上讀取條碼,今天將分享在BarCode Reader SDK中如何用VB.NET或者C#來讀取圖像中的條碼。
這段代碼演示了如何從圖像中讀取條碼及打印到輸出控制臺。
Visual Basic .NET:
Imports System.IO Imports Bytescout.BarCodeReader ' requiring to install evaluation or full version of Barcode Reader SDK <em>Module <font class="Apple-style-span" color="#000000"><span data-scayt_word="Module1" data-scaytid="1">Module1</span></font></em> Sub Main() Dim pat As String = "InputPhoto.jpg" Console.WriteLine("Reading barcode(s) from image {0}", Path.GetFullPath(pat)) Dim <span data-scayt_word="bc" data-scaytid="2">bc</span> As New Reader() bc.TypeToFind = SymbologyFilter.FindAll Dim barcodes As <span data-scayt_word="FoundBarcode" data-scaytid="3">FoundBarcode</span>() = bc.ReadFrom(pat) Dim i As Integer For i = 0 To barcodes.Length - 1 Console.WriteLine("Found barcode with type '{0}' and value '{1}'", barcodes(i).Type, barcodes(i).Value) Next Console.WriteLine("Press any key to exit..") Console.ReadKey() End Sub End Module
C#
using System; using System.Collections.Generic; using System.Text; using System.IO; using Bytescout.BarCodeReader; // requires to have evaluation or full version of Barcode Reader SDK installed <span data-scayt_word="namespace" data-scaytid="6">namespace</span> <span data-scayt_word="SimpleTestSharp" data-scaytid="7">SimpleTestSharp</span> { class Program { <span data-scayt_word="const" data-scaytid="8">const</span> string path = "<span data-scayt_word="InputBarcodeImagejpg" data-scaytid="9">InputBarcodeImagejpg</span>"; static void Main(string[] <span data-scayt_word="args" data-scaytid="60">args</span>) { Console.WriteLine("Reading barcode(s) from image {0}", Path.GetFullPath(path)); Reader <span data-scayt_word="bc" data-scaytid="13">bc</span> = new Reader(); <span data-scayt_word="FoundBarcode" data-scaytid="14">FoundBarcode</span>[] barcodes = bc.ReadFrom(path); <span data-scayt_word="foreach" data-scaytid="18">foreach</span> (<span data-scayt_word="FoundBarcode" data-scaytid="17">FoundBarcode</span> barcode in barcodes) Console.WriteLine("Found barcode with type '{0}' and value '{1}'", barcode.Type, barcode.Value); Console.WriteLine("Press any key to exit.."); Console.ReadKey(); } } }
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn