String link ="www.baidu.com";//这里一般是一个链接
封装后的方法,直接调用就可以了
public void CreateQRCode(string content)
{
var qrCodeEncoder = new QRCodeEncoder
{
QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE,
QRCodeScale = 6,
QRCodeVersion = 4,
QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M
};
System.Drawing.Image QRCodeImg = qrCodeEncoder.Encode(content);
MemoryStream stream = new MemoryStream();
QRCodeImg.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
Response.ClearContent();
Response.ContentType = "image/Png";
Response.BinaryWrite(stream.ToArray());
}