Tuesday, 24 September 2019 03:38

Add a Logo to QR Code in C#

This article demonstrates how to add a logo or an image to a QR code using Spire.Barcode for .NET.

Note: This feature relies on a comemrcial license. If you want to test it, please contact sales for a temporary license.

using Spire.Barcode;
using Spire.License;
using System.Drawing;

namespace AddLogoToQR
{
    class Program
    {
        static void Main(string[] args)
        {
            //load license file
            Spire.License.LicenseProvider.SetLicenseFileFullPath("license.elic.xml");

            //create BarcodeSettings object
            BarcodeSettings settings = new BarcodeSettings();

            //specify barcode type, data, etc.
            settings.Type = BarCodeType.QRCode;
            settings.QRCodeECL = QRCodeECL.M;
            settings.ShowText = false;
            settings.X = 2.5f;
            string data = "www.e-iceblue.com";
            settings.Data = data;
            settings.Data2D = data;

            //add an image to QR code
            settings.QRCodeLogoImage = Image.FromFile(@"C:\Users\Administrator\Desktop\logo.png");

            //generate QR image based on the settings
            BarCodeGenerator generator = new BarCodeGenerator(settings);
            Image image = generator.GenerateImage();
            image.Save("QR.png", System.Drawing.Imaging.ImageFormat.Png);
        }
    }
}

Add a Logo to QR Code in C#

Additional Info

  • tutorial_title: