Add image or logo inside generated QRCode

Aug 21, 2014 at 1:32 PM
Hi all,

Does anyone know if it is possible to add a logo to the centre of the generated QRCode?

Something similar to:
Image

It is very easy to use the library and here is my code so far:
[TestMethod]
public void SimpleQrCode()
{
    IBarcodeWriter writer = new BarcodeWriter
    {
        Format = BarcodeFormat.QR_CODE,
        Options = new QrCodeEncodingOptions
        {
            ErrorCorrection = ErrorCorrectionLevel.L,
            Height = 500,
            Width = 500,
            Margin = 10
        }
    };
    var result = writer.Write("test content");
    var barcodeBitmap = new Bitmap(result);
    barcodeBitmap.Save("C:\\Temp\\qrCode.png", ImageFormat.Png);

    Assert.IsTrue(File.Exists("C:\\Temp\\qrCode.png"));
}
Aug 21, 2014 at 3:55 PM
I wasn't able to achieve this using the library, but by increasing the error correction level I am able to generate the QR code and then apply another image on-top of the QR code.
[TestMethod]
public void SimpleQrCode()
{
    var options = new QrCodeEncodingOptions
    {
        ErrorCorrection = ErrorCorrectionLevel.H, //this allowed me to place my image in the centre of the QR code and maintained scanning functionality.
        Height = 500,
        Width = 500,
        Margin = 0
    };
    IBarcodeWriter writer = new BarcodeWriter
    {
        Format = BarcodeFormat.QR_CODE,
        Options = options
    };

    var result = writer.Write("test content");
    var barcodeBitmap = new Bitmap(result);
    barcodeBitmap.Save(string.Format("C:\\Temp\\qrCode{0}x{1}.png", options.Width, options.Height), ImageFormat.Png);

    Assert.IsTrue(File.Exists(string.Format("C:\\Temp\\qrCode{0}x{1}.png", options.Width, options.Height)));
}
Marked as answer by Seany84 on 8/21/2014 at 8:55 AM