我就给大家介绍下这个程序库,你可以在这里[url=http://freebarcode.codeplex.com/]下载[/url]。
[b]简介 [/b]
程序库提供了名为Scan的方法来读取二维码图像。这是一个重载方法,在这部分,我列出了它的定义方法。这些方法将在代码中测试这个程序库的表现。
[code]publicstaticstring [] Scan (Bitmap bitmap);[/code]
在所有支持的二维码种类中扫描某个的图像:
[list]
[*] bitmap: 要扫描的图像[/*]
[/list]
[code]publicstaticstring[] Scan(Bitmap image, BarCodeType barcodeType);[/code]
在特定的二维码中扫描某个图像:
[list]
[*]bitmap: 要扫描的图像[/*]
[*]barcodeType: 指定的二维码种类
[/*]
[/list]
[code]publicstaticstring[] Scan(Bitmap bitmap, Rectangle rect, BarCodeType barcodeType);[/code]
在特定的二维码中扫描某个图像的指定一部分:
[list]
[*]bitmap: 要扫描的图像[/*]
[*]rect: 指定要扫描的位图的部分[/*]
[*]barcodeType: 指定的二维码种类[/*]
[/list]
[b]简单代码[/b]
为了验证Scan方法,我做了幅二维码图像命名为barcode.jpg.在这幅图中有很多元素:有三个QR code二维码,两个Codabar 二维码和一个POSTNET 二维码。用不同的参数来扫描这些图形,我们应该会得到不同的结果。
[img]http://files.jb51.net/file_images/article/201612/2016120611053613.jpg[/img]
下面是结果:
程序片段:
datas = BarcodeScanner.Scan(bitmap);
结果:
[img]http://files.jb51.net/file_images/article/201612/2016120611053614.jpg[/img]
程序片段:
datas = BarcodeScanner.Scan(bitmap, BarCodeType.Codabar);
结果:
[img]http://files.jb51.net/file_images/article/201612/2016120611053615.jpg[/img]
程序片段:
datas = BarcodeScanner.Scan(bitmap, newRectangle(0, 0, bitmap.Width, bitmap.Height / 2),BarCodeType.QRCode);
结果:
[img]http://files.jb51.net/file_images/article/201612/2016120611053616.jpg[/img]
结论:
你可以自己试试看,我觉得这个程序库一定可以满足你。