赞
踩
项目中添加对zxing的引用,对于zxing可在GitHub直接下载
下面代码是一个具体使用实例:
//create QRcode by zxing
private Bitmap GenByZXingNet(string msg)
{
BarcodeWriter writer = new BarcodeWriter();
writer.Format = BarcodeFormat.QR_CODE;
writer.Options.Hints.Add(EncodeHintType.CHARACTER_SET, "UTF-8");//编码问题
writer.Options.Hints.Add(EncodeHintType.ERROR_CORRECTION, ZXing.QrCode.Internal.ErrorCorrectionLevel.H);
writer.Options.Height = writer.Options.Width = 180;
writer.Options.Margin = 1;//设置边框
ZXing.Common.BitMatrix bm = writer.Encode(msg);
Bitmap img = writer.Write(bm);
return img;
}
如果是中文请添加writer.Options.Hints.Add(EncodeHintType.CHARACTER_SET, "UTF-8");//编码问题
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。