Ejemplo n.º 1
0
        public static System.Drawing.Image GetQRCodeImage(string url)
        {
            const int   imageSize   = 120;
            HttpRequest request     = HttpUtils.GetRequest();
            string      resolvedUrl = string.Format("{0}://{1}{2}", request.Url.Scheme, request.Url.Authority, url);
            var         image       = new Bitmap(imageSize, imageSize);

            using (var graphicsObj = Graphics.FromImage(image)) {
                var gdiGraphics = new DevExpress.Printing.GdiGraphicsWrapperBase(graphicsObj);
                var qrcode      = new QRCodeGenerator()
                {
                    CompactionMode = QRCodeCompactionMode.Byte
                };
                var rectf       = new RectangleF(0, 0, imageSize, imageSize);
                var barcodeData = new QRBarCodeData(resolvedUrl);
                qrcode.DrawContent(gdiGraphics, rectf, barcodeData);
            }
            return(image);
        }