C#利用QRCoder生产二维码
2021-07-15 12:15
标签:ref res lin generator cti bitmap wing targe new 系统使用.NET4.5.1 代码如下: https://files.cnblogs.com/files/mqingqing123/QR.rar C#利用QRCoder生产二维码 标签:ref res lin generator cti bitmap wing targe new 原文地址:https://www.cnblogs.com/mqingqing123/p/9514452.htmlusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using QRCoder;
using System.Drawing;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string strCode = "http://www.dotnetcms.org";
QRCodeGenerator qrGenerator = new QRCoder.QRCodeGenerator();
QRCodeData qrCodeData = qrGenerator.CreateQrCode(strCode, QRCodeGenerator.ECCLevel.Q);
QRCode qrcode = new QRCode(qrCodeData);
// qrcode.GetGraphic 方法可参考最下发“补充说明”
Bitmap qrCodeImage = qrcode.GetGraphic(5, Color.Black, Color.White, null, 15, 6, false);
MemoryStream ms = new MemoryStream();
qrCodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
// 如果想保存图片 可使用 qrCodeImage.Save(filePath);
// 响应类型
Response.ContentType = "image/Jpeg";
//输出字符流
Response.BinaryWrite(ms.ToArray());
}
}