概述
using ThoughtWorks.QRCode.Codec; 引用这个 如果没有 下载下来 项目右键 NUGET 输入ThoughtWorks.QRCode
#region 生成二维码
public string Ewmscs(string dingdan)
{
Bitmap bt;
string enCodeString = dingdan;
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
string encoding = "Byte";
switch (encoding)
{
case "Byte":
qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
break;
case "AlphaNumeric":
qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC;
break;
case "Numeric":
qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.NUMERIC;
break;
default:
qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
break;
}
qrCodeEncoder.QRCodeScale = Convert.ToInt32(8);//版本
qrCodeEncoder.QRCodeVersion = Convert.ToInt32(5);//规模
string level = "L";
switch (level)
{
case "L":
qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L;
break;
case "M":
qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
break;
case "Q":
qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.Q;
break;
default:
qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H;
break;
}
bt = qrCodeEncoder.Encode(enCodeString, Encoding.UTF8);
Random r = new Random();
string filename = dingdan + ".png";//string.Format(DateTime.Now.ToString(), "yyyy-mm-dd");
string url_liu = "/erweima/";
string imagesname = Server.MapPath(url_liu) + filename;
if (!Directory.Exists(Server.MapPath(url_liu)))
{
Directory.CreateDirectory(Server.MapPath(url_liu));
}
System.IO.FileStream fs = new System.IO.FileStream(imagesname, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
bt.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg);
fs.Close();
//#region 生成缩略图
//string fileName = imagesname;
//string newFileName = Server.MapPath(url_liu) + dingdan + "_suo.png";
Cuzcms.Common.Thumbnail.MakeThumbnailImage(fileName, newFileName, 770, 770, "HW");
//#endregion
//#region 打水印
//string suoluetu = url_liu + dingdan + ".jpg";
//string yuantu = url_liu + dingdan + "_suo.png";
//#endregion
//#region 生成网闸-非正式网闸
//string filepath = "/erweima/" + id + ".txt";
//string toFileFullPath = "/erweima/";
//if (!Directory.Exists(toFileFullPath))
//{
//
Directory.CreateDirectory(toFileFullPath);
//}
//dc2205af-55b8-4852-addf-0f660ff46189++5513314872301198
#endregion
//#region 转移到正式网闸
//string filepath_zhengshi = Utils.GetMapPath(ConfigurationManager.AppSettings["erweima_zheng"]);
//if (!Directory.Exists(filepath_zhengshi))
//{
//
Directory.CreateDirectory(filepath_zhengshi);
//}
//File.Copy(Utils.GetMapPath(filepath), filepath_zhengshi + id + ".txt");
//#endregion
return url_liu + filename;
}
最后
以上就是开心白猫为你收集整理的.net生产二维码 ThoughtWorks.QRCode的全部内容,希望文章能够帮你解决.net生产二维码 ThoughtWorks.QRCode所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复