locked
issue with QR Code ECCLevel RRS feed

  • Question

  • User-614655055 posted

    Hi,

    am facing this issue with qrcode genrator and getting diffrent code which is not expected
    i am using  QRCodeGenerator dll for QR code genration. like in below example i have one string i am generating qrcode using ECCLevel.H and ECCLevel.Q both level giving different result. can you please sugggest why this is happinng.

    eg.


    string code = "1Y8FRG3FFG7FSV";

    QRCodeGenerator qrGenerator = new QRCodeGenerator();
    QRCodeGenerator.QRCode qrCode = qrGenerator.CreateQrCode(code, QRCodeGenerator.ECCLevel.H);
    System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
    imgBarCode.Height = 150;
    imgBarCode.Width = 150;
    using (Bitmap bitMap = qrCode.GetGraphic(20))
    {
    using (MemoryStream ms = new MemoryStream())
    {
    bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
    byte[] byteImage = ms.ToArray();
    imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
    }
    plBarCode.Controls.Add(imgBarCode);
    }

    but i got result like this-->1Y8FRG3FFG7FSZ

    and suppose i change QRCodeGenerator.ECCLevel.Q then its give me correct result but some time its also give me wrong result .

    Monday, April 3, 2017 3:11 PM

All replies

  • User-1599850035 posted

    Not sure what caused the issue. I used free barcode API to generate QR code images with different Error Correction Levels and it worked like a charm.

    BarcodeSettings settings = new BarcodeSettings();
    settings.Type = BarCodeType.QRCode;
    settings.Unit = GraphicsUnit.Pixel;
    settings.ShowText = false;
    settings.ResolutionType = ResolutionType.UseDpi;
    settings.X = 5f;
    settings.Data = "1Y8FRG3FFG7FSZ";
    
    //error correction level
    settings.QRCodeECL = QRCodeECL.Q;
    
    BarCodeGenerator generator = new BarCodeGenerator(settings);
    Image image = generator.GenerateImage();
    image.Save("qr.png");
    


    Tuesday, April 4, 2017 2:04 AM
  • User-707554951 posted

    Hi dsoftpatil@gmail.com

    The CreateQrCode() function takes two arguments. At first the string which shall be encoded in the QR code and as second argument the error correction level (ECCLevel). Here, the levels L (7%), M (15%), Q (25%) and H (30%) are available, whereby the percentage indicates how much of the QR-code can be hidden/destroyed until the error correction algorithm can’t recreate the original message which was encoded in the QR code.

    For more information. Please refer to the following link:

    https://en.code-bude.net/2013/10/17/qrcoder-an-open-source-qr-code-generator-implementation-in-csharp/

    Best regards

    Cathy

    Tuesday, April 4, 2017 8:03 AM