Beispiel #1
0
        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();
        }
Beispiel #2
0
        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();
        }
Beispiel #3
0
 public static System.Drawing.Image CombinImage(System.Drawing.Image imgBack, System.Drawing.Image img)
 {
     if (img.Height != 65 || img.Width != 65)
     {
         img = GetQRCode.KiResizeImage(img, 250, 250, 0);
     }
     System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(imgBack);
     graphics.DrawImage(imgBack, 0, 0, imgBack.Width, imgBack.Height);
     graphics.DrawImage(img, imgBack.Width / 2 - img.Width / 2 + 10, imgBack.Width / 2 - img.Width / 2 + 85, 136, 136);
     System.GC.Collect();
     return(imgBack);
 }
Beispiel #4
0
        public static Image CombinImage(Image imgBack, Image img)
        {
            if (img.Height != 65 || img.Width != 65)
            {
                img = GetQRCode.KiResizeImage(img, 250, 250, 0);
            }
            Graphics graphic = Graphics.FromImage(imgBack);

            graphic.DrawImage(imgBack, 0, 0, imgBack.Width, imgBack.Height);
            graphic.DrawImage(img, imgBack.Width / 2 - img.Width / 2 + 10, imgBack.Width / 2 - img.Width / 2 + 85, 136, 136);
            GC.Collect();
            return(imgBack);
        }