lena和shane,家庭日志,xulavigne,Lena&Shane

如何实现

C# 中使用 ThoughtWorks.QRCode.dll 识别图片中的二维码

2018-09-17 Shane Jhu

ThoughtWorks.QRCode.dll 最常用的就是生成二维码(见《C# 中使用 ThoughtWorks.QRCode.dll 生成指定尺寸和边框宽度的二维码》),同样,它也可以解析二维码,本文介绍使用 ThoughtWorks.QRCode.dll 解析图片中的二维码的方法。



首先,将 ThoughtWorks.QRCode.dll 放在 bin 目录后,在页面中引用:

using System.Drawing;
using ThoughtWorks.QRCode.Codec;
using ThoughtWorks.QRCode.Codec.Data;


调用方法:

BitMap image = null;
//此处为 image 变量赋值,就是要解析的二维码图片。可以从本地取、可以上传、也可以使用HttpWebRequest从网络获取
//image = *****;

QRCodeDecoder decoder = new QRCodeDecoder();
string decodedString = decoder.decode(new QRCodeBitmapImage(image));

呃。。没了,就这么简单。

本文由lenashane.com原创,转载请注明出处:查看原文

如果觉得文章还不错,请点个赞吧

2月 27 2025
成年人身上的天真往往很迷人,但若是加上虚荣,就和愚蠢没什么区别。

埃里克·霍弗 (Eric Hoffer 美国作家)