.net 生成二维码
nuget 引入QRCode组件
此方法会生成二维码并保存成图片
using QRCoder; using System; using System.Collections.Generic; using System.Drawing.Imaging; using System.Linq; using System.Text; using System.Threading.Tasks; namespace UserQrCode.Tools { public class QrCodeHelper { public static void CreateCode(string content, string fileName) { QRCodeGenerator codeGenerator = new QRCodeGenerator(); using (QRCodeData qrData = codeGenerator.CreateQrCode(content, QRCodeGenerator.ECCLevel.Q,true,true,eciMode:QRCodeGenerator.EciMode.Utf8)) { using (QRCode qrCode = new QRCode(qrData)) { Bitmap qrCodeImage = qrCode.GetGraphic(4, Color.Black, Color.White, null, 15, 6, false); MemoryStream ms = new MemoryStream(); qrCodeImage.Save(ms, ImageFormat.Jpeg); qrCodeImage.Save(fileName); } } } } }