image width

Sep 30, 2013 at 6:35 PM
Hi, I'm having problems generating QR codes with the right dimensions. I'm sorry if this has been discussed before, I found some sample code but it didn't address my problem.

While the resulting image is 70x70, the qr code that is generated doesn't fill the whole content of the image.

If I print a 78 chars long qr code it looks ok while if I try to print a 79 chars long qr code it appears pretty small in the center of the image...

Here is a sample code, am I doing something wrong? (I'm using the precompiled dll of version 0.12 for .net 4.0).

Thanks a lot!
        int codeSize = 70;

        IBarcodeWriter writer = new BarcodeWriter
            Format = BarcodeFormat.QR_CODE,
            Options = new ZXing.QrCode.QrCodeEncodingOptions
                Width = codeSize,
                Height = codeSize,
                ErrorCorrection = ZXing.QrCode.Internal.ErrorCorrectionLevel.L,
                DisableECI = true,
                CharacterSet = "UTF-8",
                Margin = 0

        // 79 is too small while 78 looks ok

    private string generateQrCodeContent(int length)
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < length; i++)

        return sb.ToString();
Oct 2, 2013 at 12:19 PM
The QR Code generator scales the resulting matrix to fit the requested dimension. It uses an integer value.
In your case you have found a content length where the resulting matrix can't scaled anymore. The pixelsize is one time smaller.
Oct 2, 2013 at 5:07 PM
Ok, thank you.

What I ended up doing was crop the resulting image and then put it into a wpf image with uniform stretching enabled.