Exemplo n.º 1
0
        /// <summary>
        /// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="T:System.Web.IHttpHandler"/> interface.
        /// </summary>
        /// <param name="context">An <see cref="T:System.Web.HttpContext"/> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param>
        /// <remarks></remarks>
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "image/jpeg";

            var text = context.Request.QueryString["Text"];

            QrEncoder qrEncoder = new QrEncoder(ErrorCorrectionLevel.H);
            QrCode.Web.Encoder.QrCode qrCode = qrEncoder.Encode(text);

            GraphicsRenderer renderer = new GraphicsRenderer(new FixedModuleSize(5, QuietZoneModules.Two), Brushes.Black, Brushes.White);

            renderer.WriteToStream(qrCode.Matrix, ImageFormat.Jpeg, context.Response.OutputStream);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="T:System.Web.IHttpHandler"/> interface.
        /// </summary>
        /// <param name="context">An <see cref="T:System.Web.HttpContext"/> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param>
        /// <remarks></remarks>
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                context.Response.ContentType = "image/jpeg";
                string text = context.Request.QueryString[0];

                var    qrEncoder = new QrEncoder(ErrorCorrectionLevel.H);
                QrCode qrCode    = qrEncoder.Encode(text);

                var renderer = new GraphicsRenderer(new FixedModuleSize(5, QuietZoneModules.Two), Brushes.Black,
                                                    Brushes.White);
                renderer.WriteToStream(qrCode.Matrix, ImageFormat.Jpeg, context.Response.OutputStream);
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 3
0
        private void GetQrImage()
        {
            HttpContext.Current.Response.ContentType = "image/jpeg";
            
 
            QrEncoder qrEncoder = new QrEncoder(ErrorCorrectionLevel.H);
            QrCode.Web.Encoder.QrCode qrCode = qrEncoder.Encode(this.Text);

            GraphicsRenderer renderer = new GraphicsRenderer(new FixedModuleSize(5, QuietZoneModules.Two), Brushes.Black, Brushes.White);

            renderer.WriteToStream(qrCode.Matrix, ImageFormat.Png, HttpContext.Current.Response.OutputStream);
             
            //using (FileStream stream = new FileStream(@"c:\temp\HelloWorld.png", FileMode.Create))
            //{
            //    renderer.WriteToStream(qrCode.Matrix, ImageFormat.Png, stream);

            //    img.Save(HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
            //}

            //image.Save(context.Response.OutputStream, ImageFormat.Jpeg)
        }