装一个QrCode.Net的Nuget包
后台代码:
/// <summary>
/// 根据路径生成二维码
/// </summary>
/// <param name="url">数据路径</param>
///<returns></returns>
public Image CreateQRCodeNet(string url)
{
using (var ms = new MemoryStream())
{ //误差校正水平
ErrorCorrectionLevel Ecl = ErrorCorrectionLevel.M;
//待编码内容
string Content = url;
//空白区域
QuietZoneModules QuietZones = QuietZoneModules.Two;
//二维码大小
int ModuleSize = 3;
var encoder = new QrEncoder(Ecl);
QrCode qr;
//对内容进行编码,并保存生成的矩阵
if (encoder.TryEncode(Content, out qr))
{
var render = new GraphicsRenderer(new FixedModuleSize(ModuleSize, QuietZones));
render.WriteToStream(qr.Matrix, I