public void ProcessRequest(HttpContext context) { string item = context.Request["code"]; if (!string.IsNullOrEmpty(item)) { QRCodeEncoder qRCodeEncoder = new QRCodeEncoder() { QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE, QRCodeScale = 4, QRCodeVersion = 8, QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M }; Image image = qRCodeEncoder.Encode(item); MemoryStream memoryStream = new MemoryStream(); image.Save(memoryStream, ImageFormat.Png); string str = context.Server.MapPath("/Storage/master/QRcord.jpg"); Image image1 = Image.FromFile(str); MemoryStream memoryStream1 = new MemoryStream(); GetQRCode.CombinImage(image1, image).Save(memoryStream1, ImageFormat.Png); context.Response.ClearContent(); context.Response.ContentType = "image/png"; context.Response.BinaryWrite(memoryStream1.ToArray()); memoryStream.Dispose(); memoryStream1.Dispose(); } context.Response.Flush(); context.Response.End(); }
public void ProcessRequest(System.Web.HttpContext context) { string text = context.Request["code"]; if (!string.IsNullOrEmpty(text)) { System.Drawing.Image image = new QRCodeEncoder { QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE, QRCodeScale = 4, QRCodeVersion = 8, QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M }.Encode(text); System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); image.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png); string filename = context.Server.MapPath("/Storage/master/QRcord.jpg"); System.Drawing.Image imgBack = System.Drawing.Image.FromFile(filename); System.IO.MemoryStream memoryStream2 = new System.IO.MemoryStream(); GetQRCode.CombinImage(imgBack, image).Save(memoryStream2, System.Drawing.Imaging.ImageFormat.Png); context.Response.ClearContent(); context.Response.ContentType = "image/png"; context.Response.BinaryWrite(memoryStream2.ToArray()); memoryStream.Dispose(); memoryStream2.Dispose(); } context.Response.Flush(); context.Response.End(); }