3

I am making a website with Blazor Server Side. I have successfully generated a QR code that will display the details of the user in text. I was wondering if it is possible to have the QR code display this text and also an image of the user. The image will have been previously uploaded to the project directory. I have searched online but can't seem to find anything to let me know if this is even possible. If it is possible how would this be added to this code, I am using the QRCoder extension:

    string QRCodeStr { get; set; } = "";

    public void GenerateQRCode()
    {
        QRCodeStr = "";

        using (MemoryStream ms = new MemoryStream())
        {
      
                QRCodeGenerator oQRCodeGenerator = new QRCodeGenerator();
                QRCodeData oQRCodeData = oQRCodeGenerator.CreateQrCode("Guest: " + guest.FirstName + " " + guest.LastName
                + "\nDOB: " + guest.DOB.ToShortDateString()
                + "\nArrival: " + guest.ArrivalDate.ToShortDateString()
                + "\nDepart: " + guest.DepartureDate.ToShortDateString()
                + "\nStudent: " + guest.StudentFirstName + " " + guest.StudentLastName
                + "\nRoom: " + guest.BlockName + ", " + guest.Room
                + "\nStatus: " + Status
                ,QRCodeGenerator.ECCLevel.Q);
                QRCode oQRCode = new QRCode(oQRCodeData);
                using (Bitmap oBitMap = oQRCode.GetGraphic(20))
                {
                    oBitMap.Save(ms, ImageFormat.Png);
                    QRCodeStr = "data:image/png;base64," + Convert.ToBase64String(ms.ToArray());

                }
            }
        }
    
Paula999
  • 63
  • 5
  • Are you saying you want to store binary image data in the data of the QR code itself? Or that you want the QR code to link to a web resource that displays an image? – Jonathan Aug 31 '20 at 22:20
  • yes I want to know if it is possible to store the binary image in the data – Paula999 Sep 01 '20 at 08:00
  • 1
    you should think about [how many bytes you can store in a QR-Code](https://stackoverflow.com/questions/11065415/how-much-data-information-can-we-save-store-in-a-qr-code) (not so many actually), and how many bytes you would need to store a picture that shows something recognizeable. – jps Sep 01 '20 at 08:06

0 Answers0