生成二维码示例
#region 生成二维码
private static string QRCode()
{
Bitmap bt;
string enCodeString = "https://www.nuget.org/profiles/haoersheng";
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
qrCodeEncoder.QRCodeScale = 48;
qrCodeEncoder.QRCodeVersion = 0;
qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
qrCodeEncoder.QRCodeBackgroundColor = Color.White;
qrCodeEncoder.QRCodeForegroundColor = Color.Black;
bt = qrCodeEncoder.Encode(enCodeString, Encoding.UTF8);
string filename = Guid.NewGuid().ToString();
string file_path = AppDomain.CurrentDomain.BaseDirectory + "QRCode\";
string codeUrl = file_path + filename + ".png";
if (!System.IO.Directory.Exists(file_path))
System.IO.Directory.CreateDirectory(file_path);
bt.Save(codeUrl);
return codeUrl;
}
#endregion
生成效果