1.添加程序包
2.生产二维码方法
#region 二维码 /// <summary> /// 生成二维码 /// </summary> /// <param name="strQRcode">二维码字符串</param> /// <param name="codePath">二维码图片存储路径</param> public static void CreateQRcode(string strQRcode, string codeImgPath) { QrEncoder qrEncoder = new QrEncoder(ErrorCorrectionLevel.H); QrCode qrCode = new QrCode(); qrEncoder.TryEncode(strQRcode, out qrCode); GraphicsRenderer renderer = new GraphicsRenderer(new FixedModuleSize(15, QuietZoneModules.Two), Brushes.Black, Brushes.White); using (MemoryStream ms = new MemoryStream()) { renderer.WriteToStream(qrCode.Matrix, ImageFormat.Png, ms); System.Drawing.Image img = System.Drawing.Image.FromStream(ms); img.Save(codeImgPath); } } #endregion