mohaammed talha

mohaammed talha

  • NA
  • 445
  • 51.7k

How to insert logo in QR code using asp.net and C#

Feb 15 2021 9:17 AM
QR Code Successfully generated but i need to create QR Code with logo .
  1. protected void btnGenerate_Click(object sender, EventArgs e)  
  2. {  
  3. string code = txtName.Text;  
  4. if (!string.IsNullOrEmpty(code))  
  5. {  
  6. string[] commaSeparatedItems = txtName.Text.Split(',');  
  7. var Empcd = string.Concat("'"string.Join("','", commaSeparatedItems), "'");  
  8. foreach (var i in commaSeparatedItems) {  
  9. QRCodeGenerator qrGenerator = new QRCodeGenerator();  
  10. QRCodeGenerator.QRCode qrCode = qrGenerator.CreateQrCode(i , QRCodeGenerator.ECCLevel.Q);  
  11. System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();  
  12. imgBarCode.Height = 150;  
  13. imgBarCode.Width = 150;  
  14. using (Bitmap bitMap = qrCode.GetGraphic(20))  
  15. {  
  16. using (MemoryStream ms = new MemoryStream())  
  17. {  
  18. bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);  
  19. byte[] byteImage = ms.ToArray();  
  20. File.WriteAllBytes(Server.MapPath("QRCodes/" + code + ".png"), byteImage);  
  21. imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);  
  22. // imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);  
  23. }  
  24. plBarCode.Controls.Add(imgBarCode);  
  25. //BindGrid();  
  26. load();  
  27. }  
  28. }  
  29. }  

Answers (3)