标签:des style blog http io color os ar 使用
首先引用ThoughtWorks.QRCode.dll
代码:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; using ThoughtWorks.QRCode.Codec; namespace QRCodeUtil { /// <summary> /// 二维码生成 /// </summary> public class QRCodeHelper { #region 根据链接获取二维码 /// <summary> /// 根据链接获取二维码 /// </summary> /// <param name="link">链接</param> /// <returns>返回二维码图片</returns> public static Bitmap GetQRCodeBmp(string link) { QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE; qrCodeEncoder.QRCodeScale = 4; qrCodeEncoder.QRCodeVersion = 0; qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M; Bitmap bmp = qrCodeEncoder.Encode(link); return bmp; } #endregion } }
使用示例:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Drawing; using QRCodeUtil; namespace SWX { public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Bitmap bmp = QRCodeHelper.GetQRCodeBmp(@"http://www.baidu.com/"); string str = HttpContext.Current.Request.MapPath("\\aa.bmp"); bmp.Save(str); } } }
标签:des style blog http io color os ar 使用
原文地址:http://www.cnblogs.com/s0611163/p/4056412.html