Embed image in a QR Code

Is it possible to generate a QR Code with a logo/image embedded in the middle ?
If yes, how can we do it ?

@StanT,

Yes, it is possible. Please refer to the following sample code and write/update your own code by yourselves for your requirements.
e.g.
Sample code:

            string dataDir = "g:\\test2\\";

            // Create an instance of BarcodeGenerator class
            // Set the barcode text
            // Set the barcode symbology 
            using (Aspose.BarCode.Generation.BarcodeGenerator generator_1 = new Aspose.BarCode.Generation.BarcodeGenerator(Aspose.BarCode.Generation.EncodeTypes.QR, "123456789012"))
            {
                // Generate Barcode image and store it in a Bitmap
                using (System.Drawing.Bitmap barcode_1 = generator_1.GenerateBarCodeImage())
                {
                    // Load the logo/other image as Bitmap
                    using (System.Drawing.Bitmap picture1 = (System.Drawing.Bitmap)System.Drawing.Image.FromFile(dataDir + "logo.png"))
                    {
                        // Create a new empty image with new Calculated height & width
                        using (System.Drawing.Bitmap output1 = new System.Drawing.Bitmap(System.Math.Max(barcode_1.Width, picture1.Width), barcode_1.Height + picture1.Height))
                        {
                            // Get the Graphics object9
                            using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(output1))
                            {
                                // Clear the canvas 
                                g.Clear(System.Drawing.Color.White);

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

                                // Draw the second image (logo image) on the canvas inside the barcode image
                                g.DrawImage(barcode_1, new System.Drawing.PointF(0, picture1.Height));
                            }
                            output1.Save(dataDir + "output.jpg");
                            Console.WriteLine(Environment.NewLine + "Barcode saved at " + dataDir + "output.jpg");
                        }
                    }
                }
            } 

Hope, this helps a bit.

1 Like

Also you should add better error correction level to make the barcode readable.