Generate QR Code with Logo in the Centre using C#

Hello,

I have recently implemented the Generate QR Code with Logo using C# as outlined within the following article:

Generate Barcode with Logo using C# | Generate QR with Logo using C# (aspose.com)

However, my organisation wishes to know if there is a way to add a logo in the centre of the QR Code.

Is this supported by Aspose?

Kind regards,
Daniel

@djsomers,

You can do that but the logo image will override the underlying barcode. See the sample code segment for your reference, you got to make the logo (image) with transparent background:
e.g.,
Sample code:

// Create a new empty image with height width of the barcode
Bitmap output = new Bitmap(barcode.Width, barcode.Height);

// Get the Graphics object
using (Graphics g = Graphics.FromImage(output))
{
                // Clear the canvas 
                g.Clear(Color.White);

                // Draw the primary image (barcode image) on the canvas
                g.DrawImage(barcode, new PointF(0, 0));

                // Draw the second image (logo image) on the canvas inside the barcode image
                g.DrawImage(picture, new PointF((int)((barcode.Width - picture.Width) / 2), (int)((barcode.Height - picture.Height) / 2)));
            }

...

Hope, this helps a bit.

@Amjad_Sahi

Thanks for the response.

Wouldn’t that just obscure the QR Code and then prevent it from being scanned?

Regards,

Daniel

As a follow on, it appears that we can set up to 30% error correction to a QR Code as outlined within this document. It could be used to allow for a small image to be added to the centre of the QR Code.

QR and Micro QR Codes|Documentation (aspose.com)

@djsomers,

Yes it may effect scanning. We don’t recommend to add bigger logo on the barcodes.

Alright, if it works for your needs, you may use it.

You should know that QR does not support data wiping because we cannot detect wiping position. Because the error correction in most of 2D barcodes is based on Reed–Solomon error correction you need 2X error correction words to correct one incorrect word (QR code uses standard byte as barcode word). In this way event with highest QRErrorLevel.LevelH which adds 30% error correction words you can correct only 15% of incorrect words (the error location and correction are processed automatically by Galois finite fields magic).

To avoid low readability of you barcode on printed images you should cover by logo not more than 2-5% of barcode area (this depends on QRErrorLevel).

1 Like