要领很多,可以参考以下几种方案,就不展开,地点如下:
https://www.cnblogs.com/mingmingruyuedlut/p/6120671.html
这里描述的,是某项目需求,,在网页中输出为图片并展示,代码如下:
using ThoughtWorks.QRCode.Codec;
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string OrderNo = context.Request.Params["OrderNo"];
QRCodeEncoder encoder = new QRCodeEncoder();
encoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;//编码方法(注意:BYTE能撑持中文,ALPHA_NUMERIC扫描出来的都是数字)
encoder.QRCodeScale = 6;//巨细(值越大生成的二维码图片像素越高)
encoder.QRCodeVersion = 0;//版本(注意:设置为0主要是防备编码的字符串太永劫产生错误)
encoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;//错误效验、错误改正(有4个品级)
//encoder.QRCodeBackgroundColor = Color.Yellow;
//encoder.QRCodeForegroundColor = Color.Green;
System.Drawing.Image _CodeImage = encoder.Encode(OrderNo);
System.IO.MemoryStream _Stream = new System.IO.MemoryStream();
_CodeImage.Save(_Stream, System.Drawing.Imaging.ImageFormat.Jpeg);
context.Response.ContentType = "image/tiff";
context.Response.Clear();
context.Response.BufferOutput = true;
context.Response.BinaryWrite(_Stream.GetBuffer());
context.Response.Flush();
//39码生成部分,屏蔽
/*context.Response.ContentType = "text/plain";
string OrderNo = context.Request.Params["OrderNo"];
WebApplication1.Code39 _Code39 = new Code39();
_Code39.Height = 60;
_Code39.Magnify = 0;
_Code39.ViewFont = new Font("Arial", 12);
System.Drawing.Image _CodeImage = _Code39.GetCodeImage(OrderNo, Code39.Code39Model.Code39Normal, true);
System.IO.MemoryStream _Stream = new System.IO.MemoryStream();
_CodeImage.Save(_Stream, System.Drawing.Imaging.ImageFormat.Jpeg);
context.Response.ContentType = "image/tiff";
context.Response.Clear();
context.Response.BufferOutput = true;
context.Response.BinaryWrite(_Stream.GetBuffer());
context.Response.Flush();*/
}
this.Image1.ImageUrl = "/TextBuilder.ashx?OrderNo=" + Ti_NO;
附上此种QrCode使用要领