.NET??????????ThoughtWorks.QRCode??
???????????? ???????[ 2015/6/24 13:42:38 ] ???????????????
????????ThoughtWorks.QRCode.dll ??????????У?
????1?????????????????????
//???????????
private void CreateCode_Simple(string nr)
{
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
qrCodeEncoder.QRCodeScale = 4;
qrCodeEncoder.QRCodeVersion = 8;
qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
//System.Drawing.Image image = qrCodeEncoder.Encode("4408810820 ????????? С??");
System.Drawing.Image image = qrCodeEncoder.Encode(nr);
string filename = DateTime.Now.ToString("yyyymmddhhmmssfff").ToString() + ".jpg";
string filepath = Server.MapPath(@"~Upload") + "\" + filename;
System.IO.FileStream fs = new System.IO.FileStream(filepath?? System.IO.FileMode.OpenOrCreate?? System.IO.FileAccess.Write);
image.Save(fs?? System.Drawing.Imaging.ImageFormat.Jpeg);
fs.Close();
image.Dispose();
//????????
var codeDecoder = CodeDecoder(filepath);
}
/// <summary>
/// ????????
/// </summary>
/// <param name="filePath">??·??</param>
/// <returns></returns>
public string CodeDecoder(string filePath)
{
if (!System.IO.File.Exists(filePath))
return null;
Bitmap myBitmap = new Bitmap(Image.FromFile(filePath));
QRCodeDecoder decoder = new QRCodeDecoder();
string decodedString = decoder.decode(new QRCodeBitmapImage(myBitmap));
return decodedString;
}
????2???????????????????????????
????????Ч????
??????????
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Code</title>
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(function () {
$("#createCode").click(function () {
var strData = $("#strData").val();
var level = $("#level").val();
var encoding = $("#encoding").val();
var version = $("#version").val();
var scale = $("#scale").val();
$.post("/home/CreateCode_Choose"?? { strData: strData?? level: level?? qrEncoding: encoding?? version: version?? scale: scale }?? function (data) {
$("img").attr("src"?? data);
});
});
});
</script>
</head>
<body>
<div>
<p>??????????(???????)??<input id="strData" type="text" value="123456 ????" /></p>
<p>
Encoding:<select id="encoding">
<option value="Byte">Byte</option>
<option value="AlphaNumeric">AlphaNumeric</option>
<option value="Numeric">Numeric</option>
</select>
</p>
<p>
Correction Level:<select id="level">
<option value="M">M</option>
<option value="L">L</option>
<option value="Q">Q</option>
<option value="H">H</option>
</select>
</p>
<p>Version:<input id="version" type="text" value="8" /></p>
<p>scale:<input id="scale" type="text" value="4" /></p>
<img src="" alt="" />
<input id="createCode" type="button" value="????" />
</div>
</body>
</html>
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11