QRCoder生成二维码
Posted zhao123
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了QRCoder生成二维码相关的知识,希望对你有一定的参考价值。
QRCoder是一个简单的生成二维码的库,用C#.NET编写,他是开源的MIT-license。
//WIFI二维码 //WiFi generator = new WiFi("My-WiFis-Name", "s3cr3t-p4ssw0rd", WiFi.Authentication.WPA); //string payload = generator.ToString(); //邮件二维码 //Mail generator = new Mail("[email protected]", "Look at this!", "Hi John, have a look at this QRCoder library!"); //string payload = generator.ToString(); //网址 //Url generator = new Url("https://github.com/codebude/QRCoder/"); //string payload = generator.ToString(); //电话 //PhoneNumber generator = new PhoneNumber("+491701234567"); //string payload = generator.ToString(); //普通字符串的二维码 string payload = "第一张二维码图片"; QRCodeGenerator qRCodeGenerator = new QRCodeGenerator(); QRCodeData qRCodeData = qRCodeGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q); QRCode qRCode = new QRCode(qRCodeData); Bitmap bitmap = qRCode.GetGraphic(20); //有图标的二维码 //Bitmap bitmap = qRCode.GetGraphic(20, Color.Black, Color.White, (Bitmap)Bitmap.FromFile(@"D:\1612181843.png")); bitmap.Save($@"D:\Environment.TickCount.png", System.Drawing.Imaging.ImageFormat.Png); //释放资源 bitmap.Dispose(); qRCode.Dispose(); qRCodeData.Dispose(); qRCodeGenerator.Dispose();
以上是关于QRCoder生成二维码的主要内容,如果未能解决你的问题,请参考以下文章