Exemplo n.º 1
0
 private void ADD_Btn_Click(object sender, EventArgs e)
 {
     if (name1Txt.Text != "" && Gmail1Txt.Text != "" && gender != "" && phone1Txt.Text != "" && parent1Txt.Text != "")
     {
         Student stu = new Student();
         stu.set_name(name1Txt.Text);
         stu.set_gmail(Gmail1Txt.Text);
         stu.set_gender(gender);
         stu.set_phone(phone1Txt.Text);
         stu.set_status("Good");
         stu.set_parant_phone(parent1Txt.Text);
         stu.add_student(stu);
         QRCodeGenerator coder  = new QRCodeGenerator();
         var             mydata = coder.CreateQrCode(name1Txt.Text, QRCodeGenerator.ECCLevel.H);
         var             code   = new QRCoder.QRCode(mydata);
         pictureBox1.Image = code.GetGraphic(50);
         string path = SaveImageCapture_one(pictureBox1.Image, name1Txt.Text);
         if (sendChB.Checked == true)
         {
             stu.send_qr(stu, path, yourEmail1.Text, yourPass1.Text);
         }
         MessageBox.Show("Done!");
     }
     else
     {
         MessageBox.Show("please enter all data");
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 带logo的二维码
        /// </summary>
        /// <param name="data"></param>
        /// <param name="logoPath"></param>
        /// <param name="pixel"></param>
        /// <returns></returns>
        public static MemoryStream GetLogoQRCode(string data, string logoPath, int pixel = 5)
        {
            QRCodeGenerator generator = new QRCodeGenerator();
            QRCodeData      codeData  = generator.CreateQrCode(data, QRCodeGenerator.ECCLevel.M, true);

            QRCoder.QRCode qrcode  = new QRCoder.QRCode(codeData);
            Bitmap         icon    = new Bitmap(logoPath);
            Bitmap         qrImage = qrcode.GetGraphic(pixel, Color.Black, Color.White, icon, 15, 6, true);

            #region 参数介绍
            //GetGraphic方法参数介绍
            //pixelsPerModule //生成二维码图片的像素大小 ,我这里设置的是5
            //darkColor       //暗色   一般设置为Color.Black 黑色
            //lightColor      //亮色   一般设置为Color.White  白色
            //icon             //二维码 水印图标 例如:Bitmap icon = new Bitmap(context.Server.MapPath("~/images/zs.png")); 默认为NULL ,加上这个二维码中间会显示一个图标
            //iconSizePercent  //水印图标的大小比例 ,可根据自己的喜好设置
            //iconBorderWidth  // 水印图标的边框
            //drawQuietZones   //静止区,位于二维码某一边的空白边界,用来阻止读者获取与正在浏览的二维码无关的信息 即是否绘画二维码的空白边框区域 默认为true
            #endregion
            MemoryStream stream = new MemoryStream();

            try
            {
                qrImage.Save(stream, ImageFormat.Png);
                return(stream);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                qrImage.Dispose();
            }
        }
Exemplo n.º 3
0
 private void Test_Load(object sender, EventArgs e)
 {
     checkFonePay = cd.FonePayCheck();
     if (checkFonePay != "")
     {
         pictureBox1.ImageLocation = checkFonePay;
     }
     else
     {
         DataTable dt = blfp.getALLFonePayData();
         if (dt.Rows.Count > 0)
         {
             secret_key   = dt.Rows[0]["secret_key"].ToString();
             user_name    = dt.Rows[0]["user_name"].ToString();
             password     = Encryption.StringEncryption.Decrypt(dt.Rows[0]["password"].ToString(), "sblw-3hn8-sqoy19");
             merchantCode = dt.Rows[0]["merchant_code"].ToString();
             string  dv        = FonePayDataValidation.SHA512_keyHash(secret_key, amount + "," + prnNo + "," + merchantCode + ",Billing," + remarks2);
             string  abc       = fpa.posFonePay(amount, remarks, remarks2, prnNo, merchantCode, dv.ToLower(), user_name, password);
             JObject deserjson = JObject.Parse(abc);
             string  qrmessage = deserjson["qrMessage"].ToString();
             wss = deserjson["thirdpartyQrWebSocketUrl"].ToString();
             QRCodeGenerator qrgen  = new QRCodeGenerator();
             var             qrdata = qrgen.CreateQrCode(qrmessage.ToString(), QRCodeGenerator.ECCLevel.H);
             var             qrcode = new QRCoder.QRCode(qrdata);
             image             = qrcode.GetGraphic(2);
             pictureBox1.Image = image;
             //WebSocketManager wsm = new WebSocketManager();
             //wsm.connection(wss);
             WebSocketManager.connection(wss);
         }
     }
 }
Exemplo n.º 4
0
        public static byte[] GetQRCodeWithLogo(string logoPath, string plainText, int pixel)
        {
            QRCodeGenerator generator = new QRCodeGenerator();
            QRCodeData      codeData  = generator.CreateQrCode(plainText, QRCodeGenerator.ECCLevel.M, true);

            QRCoder.QRCode qrcode = new QRCoder.QRCode(codeData);
            using (Bitmap icon = new Bitmap(logoPath))
            {
                using (Bitmap bitmap = qrcode.GetGraphic(pixel, Color.Black, Color.White, icon, 15, 6, true))
                {
                    using (MemoryStream ms = new MemoryStream())
                    {
                        bitmap.Save(ms, ImageFormat.Jpeg);
                        return(ms.GetBuffer());
                    }
                }
            }


            //GetGraphic方法参数介绍
            //pixelsPerModule //生成二维码图片的像素大小 ,我这里设置的是5
            //darkColor       //暗色   一般设置为Color.Black 黑色
            //lightColor      //亮色   一般设置为Color.White  白色
            //icon             //二维码 水印图标 例如:Bitmap icon = new Bitmap(context.Server.MapPath("~/images/zs.png")); 默认为NULL ,加上这个二维码中间会显示一个图标
            //iconSizePercent  //水印图标的大小比例 ,可根据自己的喜好设置
            //iconBorderWidth  // 水印图标的边框
            //drawQuietZones   //静止区,位于二维码某一边的空白边界,用来阻止读者获取与正在浏览的二维码无关的信息 即是否绘画二维码的空白边框区域 默认为true
        }
Exemplo n.º 5
0
        public static string TaoQRCode(string data)
        {
            //Tạo QRCode
            using (MemoryStream ms = new MemoryStream())
            {
                QRCodeGenerator qrGenerator = new QRCodeGenerator();

                QRCodeData     qrCodeData = qrGenerator.CreateQrCode(data, QRCodeGenerator.ECCLevel.Q);
                QRCoder.QRCode qrCode     = new QRCoder.QRCode(qrCodeData);
                using (Image bitMap = qrCode.GetGraphic(20))
                {
                    Image resized = new Bitmap(bitMap, new Size(100, 100));
                    resized.Save(ms, ImageFormat.Png);
                    resized = Controllers.TaoMaController.Transparent2Color(resized, Color.Transparent);
                    string filePath = Path.Combine(HttpContext.Current.Server.MapPath("/Storage/images"), DateTime.Now.ToFileTime() + ".png");
                    System.IO.File.WriteAllBytes(filePath, ms.ToArray());
                    //string filePath = Path.Combine(Server.MapPath("/images"), DateTime.UtcNow.ToBinary() + ".jpg");
                    //System.IO.File.WriteAllBytes(filePath, ms.ToArray());
                    //var fileVm = new FileResultViewModel();
                    //fileVm.Content = Convert.ToBase64String(ms.ToArray());
                    //fileVm.FileName =HoTen+"_"+DateTime.Now.ToFileTimeUtc() + ".png";
                    return(filePath);
                }
            }
        }
        public string saveQRCode(QRCoder.QRCode qrCode, string imageSavePath)
        {
            Bitmap qrCodeImage = qrCode.GetGraphic(20);
            var    fileName    = Guid.NewGuid().ToString() + ".png";

            qrCodeImage.Save(Path.Combine(imageSavePath, fileName));
            return(fileName);
        }
        public string GenerateQRCode(string qRData, string imageSavePath)
        {
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(qRData, QRCodeGenerator.ECCLevel.Q);

            QRCoder.QRCode qrCode = new QRCoder.QRCode(qrCodeData);
            return(saveQRCode(qrCode, imageSavePath));
        }
Exemplo n.º 8
0
        public ActionResult DownloadZh()
        {
            string merchantId = Request.Form["QRCodeMerchantId"];

            MerchantAccount merchant = new MerchantBLL().GetById(new Guid(merchantId));

            string strCode = FiiiPay.Framework.Component.QRCode.Generate(SystemPlatform.FiiiPOS, QRCodeEnum.MerchantScanPay, merchant.Id.ToString());

            QRCodeGenerator qrGenerator = new QRCoder.QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(strCode, QRCodeGenerator.ECCLevel.Q);

            QRCoder.QRCode qrcode      = new QRCoder.QRCode(qrCodeData);
            Bitmap         qrCodeImage = qrcode.GetGraphic(17, Color.Black, Color.White, null, 15, 6, false);
            MemoryStream   ms          = new MemoryStream();

            qrCodeImage.Save(ms, ImageFormat.Jpeg);

            string bgImagePath           = @"E:\API\BackOffice\FiiiPay.BackOffice\images\bg-zh.jpg";
            List <ImageMergeEntity> imgs = new List <ImageMergeEntity>();
            var bm = new Bitmap(bgImagePath);

            imgs.Add(new ImageMergeEntity
            {
                ContentType = ImageContentType.Image,
                Image       = new Bitmap(bgImagePath),
                Index       = 0
            });
            imgs.Add(new ImageMergeEntity
            {
                ContentType = ImageContentType.Image,
                Image       = new Bitmap(ms),
                Index       = 0,
                X           = 300,
                Y           = 620,
                AreaHeight  = 650,
                AreaWidth   = 650
            });
            imgs.Add(new ImageMergeEntity
            {
                ContentType = ImageContentType.Text,
                Text        = merchant.MerchantName,
                FontSize    = 50,
                FontColor   = Color.Black,
                Index       = 4,
                X           = 220,
                Y           = 1310,
                AreaHeight  = 80,
                AreaWidth   = 785
            });
            var imgByte = ImageHelper.ImageMerge(imgs.ToArray());

            Response.ContentType = "application/octet-stream";
            //通知浏览器下载文件而不是打开
            Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(merchantId + ".jpg", System.Text.Encoding.UTF8));
            Response.BinaryWrite(imgByte);
            Response.Flush();
            return(null);
        }
Exemplo n.º 9
0
        private void btn_Generate_Click(object sender, EventArgs e)
        {
            QRCoder.QRCodeGenerator qrGen = new QRCoder.QRCodeGenerator();
            var qrData = qrGen.CreateQrCode(txtBox_UserInput.Text, QRCoder.QRCodeGenerator.ECCLevel.H);
            var qrCode = new QRCoder.QRCode(qrData);
            var img    = qrCode.GetGraphic(150);

            picBox_QrCode.Image = img;
        }
Exemplo n.º 10
0
        private static Bitmap GenerateImage(string text)
        {
            using var qrGenerator = new QRCodeGenerator();
            var qrCodeData  = qrGenerator.CreateQrCode(text, QRCodeGenerator.ECCLevel.Q);
            var qrCode      = new QRCoder.QRCode(qrCodeData);
            var qrCodeImage = qrCode.GetGraphic(10);

            return(qrCodeImage);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 获取二维码
        /// </summary>
        /// <param name="url"></param>
        /// <param name="pixel">像素</param>
        /// <returns></returns>
        public static Bitmap GetPTQRCode(string url, int pixel)
        {
            QRCodeGenerator generator = new QRCodeGenerator();
            QRCodeData      codeData  = generator.CreateQrCode(url, QRCodeGenerator.ECCLevel.M, true);
            QRCode          qrcode    = new QRCoder.QRCode(codeData);
            Bitmap          qrImage   = qrcode.GetGraphic(pixel, Color.Black, Color.White, true);

            return(qrImage);
        }
Exemplo n.º 12
0
        /// <summary>
        /// GetQRCode
        /// </summary>
        /// <param name="content"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public Bitmap GetQRCode(string content, int size)
        {
            var generator = new QRCodeGenerator();
            var codedata  = generator.CreateQrCode(content, QRCodeGenerator.ECCLevel.M, true);
            var qrcode    = new QRCoder.QRCode(codedata);
            var img       = qrcode.GetGraphic(size);

            return(img);
        }
Exemplo n.º 13
0
        public static Bitmap GenerateQRCode(string url)
        {
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(url, QRCodeGenerator.ECCLevel.Q);

            QRCoder.QRCode qrCode      = new QRCoder.QRCode(qrCodeData);
            Bitmap         qrCodeImage = qrCode.GetGraphic(20);

            return(qrCodeImage);
        }
Exemplo n.º 14
0
        public Bitmap GetQRCode(string plainText, int pixel)
        {
            var generator  = new QRCodeGenerator();
            var qrCodeData = generator.CreateQrCode(plainText, QRCodeGenerator.ECCLevel.Q);
            var qrCode     = new QRCoder.QRCode(qrCodeData);

            var bitmap = qrCode.GetGraphic(pixel);

            return(bitmap);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 生成二维码图片
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public Bitmap CreateQRimg(string str)
        {
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(str, QRCodeGenerator.ECCLevel.Q);

            QRCoder.QRCode qrCode = new QRCoder.QRCode(qrCodeData);
            Bitmap         bt     = qrCode.GetGraphic(20);

            return(bt);
        }
Exemplo n.º 16
0
        // add logo/image in qrcode
        public Bitmap GetQRCodeWithLogo(string plainText, int pixel, string logoPath)
        {
            var generator  = new QRCodeGenerator();
            var qrCodeData = generator.CreateQrCode(plainText, QRCodeGenerator.ECCLevel.Q);
            var qrCode     = new QRCoder.QRCode(qrCodeData);

            var bitmap = qrCode.GetGraphic(pixel, Color.Black, Color.White, (Bitmap)Image.FromFile(logoPath), 20, 10);

            return(bitmap);
        }
Exemplo n.º 17
0
        public void ProcessRequest(HttpContext context)
        {
            string          merchantId = context.Request.QueryString["id"];
            MerchantAccount merchant   = new MerchantBLL().GetById(new Guid(merchantId));

            string strCode = FiiiPay.Framework.Component.QRCode.Generate(SystemPlatform.FiiiPOS, QRCodeEnum.MerchantScanPay, merchant.Id.ToString());

            QRCodeGenerator qrGenerator = new QRCoder.QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(strCode, QRCodeGenerator.ECCLevel.Q);

            QRCoder.QRCode qrcode      = new QRCoder.QRCode(qrCodeData);
            Bitmap         qrCodeImage = qrcode.GetGraphic(17, Color.Black, Color.White, null, 15, 6, false);
            MemoryStream   ms          = new MemoryStream();

            qrCodeImage.Save(ms, ImageFormat.Jpeg);

            string bgImagePath           = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory + "/images/bg-en.jpg");
            List <ImageMergeEntity> imgs = new List <ImageMergeEntity>();
            var bm = new Bitmap(bgImagePath);

            imgs.Add(new ImageMergeEntity
            {
                ContentType = ImageContentType.Image,
                Image       = new Bitmap(bgImagePath),
                Index       = 0
            });
            imgs.Add(new ImageMergeEntity
            {
                ContentType = ImageContentType.Image,
                Image       = new Bitmap(ms),
                Index       = 0,
                X           = 300,
                Y           = 620,
                AreaHeight  = 650,
                AreaWidth   = 650
            });
            imgs.Add(new ImageMergeEntity
            {
                ContentType = ImageContentType.Text,
                Text        = merchant.MerchantName.Length > 10 ? merchant.MerchantName.Substring(0, 8) + "..." : merchant.MerchantName,
                FontSize    = 48,
                FontColor   = Color.Black,
                Index       = 4,
                X           = 220,
                Y           = 1310,
                AreaHeight  = 80,
                AreaWidth   = 785
            });
            var imgByte = ImageHelper.ImageMerge(imgs.ToArray());

            context.Response.ContentType = "image/jpeg";
            context.Response.BinaryWrite(imgByte);
            context.Response.End();
        }
        private string GenerateEventQrCode(int id, string url, enQRCodeFor type, int qrId)
        {
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(string.Format("{2}:{0},URL:{1},QRId:{3}", id, url, type.ToString(), qrId), QRCodeGenerator.ECCLevel.Q);

            QRCoder.QRCode qrCode      = new QRCoder.QRCode(qrCodeData);
            Bitmap         qrCodeImage = qrCode.GetGraphic(20);
            var            fileName    = Guid.NewGuid().ToString() + ".png";

            qrCodeImage.Save(Path.Combine(ImageSavePath, fileName));
            return(fileName);
        }
Exemplo n.º 19
0
        /// <summary>
        /// 生成二维码图片
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static Bitmap CreateQRimg(string str, string imgPath, ImageFormat imgType)
        {
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(str, QRCodeGenerator.ECCLevel.Q);

            QRCoder.QRCode qrCode = new QRCoder.QRCode(qrCodeData);
            Bitmap         bt     = qrCode.GetGraphic(20);

            bt.Save(imgPath, imgType);//@"E:\test.png"      ImageFormat.Png
            bt.Dispose();
            return(bt);
        }
Exemplo n.º 20
0
        public byte[] GenerateQrCode(string value)
        {
            using QRCodeGenerator qrGenerator = new QRCodeGenerator();
            using QRCodeData qrCodeData       = qrGenerator.CreateQrCode(value, QRCodeGenerator.ECCLevel.Q);
            using QRCoder.QRCode qrCode       = new QRCoder.QRCode(qrCodeData);

            Bitmap qrCodeImage = qrCode.GetGraphic(20);

            using MemoryStream stream = new MemoryStream();
            qrCodeImage.Save(stream, System.Drawing.Imaging.ImageFormat.Png);

            return(stream.ToArray());
        }
Exemplo n.º 21
0
        public ActionResult Code(string code)
        {
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(code, QRCodeGenerator.ECCLevel.Q);

            QRCoder.QRCode qrCode      = new QRCoder.QRCode(qrCodeData);
            var            qrCodeImage = qrCode.GetGraphic(4);
            var            ms          = new System.IO.MemoryStream();

            qrCodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
            ms.Position = 0;
            return(File(ms, "image/png"));
        }
Exemplo n.º 22
0
        public IActionResult QRCodeClient(string url, int w = 300, int h = 300)
        {
            // 编码解码
            url = System.Web.HttpUtility.UrlDecode(url);
            QRCodeGenerator qrG    = new QRCodeGenerator();
            QRCodeData      qrData = qrG.CreateQrCode(url, QRCodeGenerator.ECCLevel.M, true);

            QRCoder.QRCode qrCode  = new QRCoder.QRCode(qrData);
            Bitmap         qrImage = qrCode.GetGraphic(5, Color.Black, Color.White, true);
            MemoryStream   ms      = new MemoryStream();

            qrImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            return(File(ms.ToArray(), "image/png"));
        }
Exemplo n.º 23
0
        /// <summary>
        /// 生成二维码
        /// </summary>
        /// <param name="msg">信息</param>
        /// <param name="version">版本 1 ~ 40</param>
        /// <param name="pixel">像素点大小</param>
        /// <param name="icon_path">图标路径</param>
        /// <param name="icon_size">图标尺寸</param>
        /// <param name="icon_border">图标边框厚度</param>
        /// <param name="white_edge">二维码白边</param>
        /// <returns>位图</returns>
        public static Bitmap QRCode(string msg, int version, int pixel, string icon_path, int icon_size, int icon_border, bool white_edge)
        {
            QRCoder.QRCodeGenerator code_generator = new QRCoder.QRCodeGenerator();

            QRCoder.QRCodeData code_data = code_generator.CreateQrCode(msg, QRCoder.QRCodeGenerator.ECCLevel.M /* 这里设置容错率的一个级别 */, true, true, QRCoder.QRCodeGenerator.EciMode.Utf8, version);

            QRCoder.QRCode code = new QRCoder.QRCode(code_data);

            Bitmap icon = new Bitmap(icon_path);

            Bitmap bmp = code.GetGraphic(pixel, Color.Black, Color.White, icon, icon_size, icon_border, white_edge);

            return(bmp);
        }
Exemplo n.º 24
0
 private void Generate_Btn_Click(object sender, EventArgs e)
 {
     if (LinkTxt.Text != "https://******" && nameTxt.Text != "Name of Qr pic")
     {
         QRCodeGenerator coder  = new QRCodeGenerator();
         var             mydata = coder.CreateQrCode(LinkTxt.Text, QRCodeGenerator.ECCLevel.H);
         var             code   = new QRCoder.QRCode(mydata);
         pictureBox1.Image = code.GetGraphic(50);
         SaveImageCapture(pictureBox1.Image, nameTxt.Text);
     }
     else
     {
         MessageBox.Show("please enter full data");
     }
 }
Exemplo n.º 25
0
        private void AddBtn2_Click(object sender, EventArgs e)
        {
            try
            {
                Excel.Application xlapp  = new Excel.Application();
                Excel.Workbook    wrokb  = xlapp.Workbooks.Open(ExelPathTXT.Text, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                Excel.Worksheet   wsheet = (Excel.Worksheet)wrokb.Worksheets.get_Item(1);
                Excel.Range       range  = wsheet.UsedRange;
                int rows = range.Rows.Count;
                int cols = range.Columns.Count;
                progressBar1.Visible = true;

                for (int i = 2; i <= rows; i++)
                {
                    double x = i;
                    double y = rows;
                    double z = x / y;
                    int    a = Convert.ToUInt16(z);
                    progressBar1.Increment(a * 100);


                    Student stu = new Student();
                    stu.set_name(((range.Cells[i, 2] as Excel.Range).Value2).ToString());
                    stu.set_gmail(((range.Cells[i, 3] as Excel.Range).Value2).ToString());
                    stu.set_phone(((range.Cells[i, 4] as Excel.Range).Value2).ToString());
                    stu.set_gender(((range.Cells[i, 5] as Excel.Range).Value2).ToString());
                    stu.set_parant_phone(((range.Cells[i, 6] as Excel.Range).Value2).ToString());
                    stu.set_status("Good");
                    stu.add_student(stu);
                    QRCodeGenerator coder  = new QRCodeGenerator();
                    var             mydata = coder.CreateQrCode(stu.get_name(), QRCodeGenerator.ECCLevel.H);
                    var             code   = new QRCoder.QRCode(mydata);
                    PictureBox      pic    = new PictureBox();

                    pic.Image = code.GetGraphic(50);
                    SaveImageCapture(pic.Image, qrFileTXT.Text + "\\" + stu.get_name() + ".jpg");
                    if (Send2CheckBox.Checked == true)
                    {
                        stu.send_qr(stu, qrFileTXT.Text + "\\" + stu.get_name() + ".jpg", yourMail2.Text, yourPass2.Text);
                    }
                }
                MessageBox.Show("Done!");
                progressBar1.Visible = false;
            }
            catch (Exception ex) {
                MessageBox.Show("select full data please");
            }
        }
Exemplo n.º 26
0
        public ActionResult GetImage()
        {
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode("hello", QRCodeGenerator.ECCLevel.Q);

            QRCoder.QRCode qrCode            = new QRCoder.QRCode(qrCodeData);
            Bitmap         qrCodeImageBitMap = qrCode.GetGraphic(20);

            byte[] imgData;
            using (var stream = new MemoryStream())
            {
                qrCodeImageBitMap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                imgData = stream.ToArray();
            }
            return(File(imgData, "image/png"));
        }
Exemplo n.º 27
0
        public static void generateQRCode(string name, string jmbg, string medication, string description)
        {
            string input = name + " \n " + jmbg + " \n " + DateTime.Today + " \n " + medication + " \n " + description;

            using (MemoryStream ms = new MemoryStream())
            {
                QRCodeGenerator QR     = new QRCodeGenerator();
                QRCodeData      qrData = QR.CreateQrCode(input, QRCodeGenerator.ECCLevel.Q);
                QRCoder.QRCode  qrCode = new QRCoder.QRCode(qrData);
                using (Bitmap oBitmap = qrCode.GetGraphic(5))
                {
                    oBitmap.Save(ms, ImageFormat.Png);
                    GeneratePDF(name, jmbg, medication, description, ms, qrCode);
                }
            }
        }
        public async Task <ActionResult> GenerateQrCode(int id, enQRCodeFor type, string url)
        {
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(string.Format("Event:{0},URL:{1}", id, url), QRCodeGenerator.ECCLevel.Q);

            QRCoder.QRCode qrCode      = new QRCoder.QRCode(qrCodeData);
            Bitmap         qrCodeImage = qrCode.GetGraphic(20);
            var            fileName    = Guid.NewGuid().ToString() + ".png";

            //if (enQRCodeFor.Event == type)
            //    await eventLogic.EventQrCode(id, fileName, CurrentUserSession.UserID ?? 0);
            //else
            //    await eventLogic.ActivityQrCode(id, fileName, CurrentUserSession.UserID ?? 0);

            qrCodeImage.Save(Path.Combine(ImageSavePath, fileName));
            return(Json(fileName, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 29
0
        public byte[] GenerateQRCode(string content)
        {
            var generator = new QRCodeGenerator();

            var codeData = generator.CreateQrCode(content, QRCodeGenerator.ECCLevel.M, true);

            QRCoder.QRCode qrcode    = new QRCoder.QRCode(codeData);
            var            path      = Path.Combine(AppContext.BaseDirectory, "Images", "1.png");
            Bitmap         icon      = new Bitmap(path);
            var            bitmapImg = qrcode.GetGraphic(10, Color.Black, Color.White, icon: icon, drawQuietZones: false);

            using (MemoryStream stream = new MemoryStream())
            {
                bitmapImg.Save(stream, ImageFormat.Jpeg);
                return(stream.GetBuffer());
            }
        }
Exemplo n.º 30
0
        /// <summary>
        ///  QR코드 데이터 받아서 이미지로 변환
        /// </summary>
        /// <param name="data"></param>
        /// <param name="icon"></param>
        /// <returns></returns>
        public Image RenderQrCode(string data, Bitmap icon = null)
        {
            Image  img;
            string level    = "M";
            int    iconsize = 25;

            QRCodeGenerator.ECCLevel eccLevel = (QRCodeGenerator.ECCLevel)(level == "L" ? 0 : level == "M" ? 1 : level == "Q" ? 2 : 3);
            using (QRCodeGenerator qrGenerater = new QRCodeGenerator())
            {
                using (QRCodeData qrCodeData = qrGenerater.CreateQrCode(data, eccLevel))
                {
                    using (QRCoder.QRCode qrCode = new QRCoder.QRCode(qrCodeData))
                    {
                        img = qrCode.GetGraphic(18, Color.Black, Color.White, icon, iconsize, 6, false);
                    }
                }
            }
            return(img);
        }