How to Customize and Add Logos to QR Codes in C#

In this tutorial, we delve into customizing QR codes by incorporating logos using Iron Barcode. Starting with the necessary using statements, we utilize the Iron Barcode and Iron Software Drawing namespaces for barcode generation and drawing capabilities. The process involves loading a logo from a local file, setting up styles, including colors and fonts, and generating a QR code with a custom logo. We demonstrate changing the barcode color and adding text annotations above and below the barcode. The final output is a highly personalized QR code saved as a PNG image file. This tutorial provides a comprehensive guide for enhancing QR codes, making them visually appealing and suitable for branding purposes. Viewers are encouraged to try Iron Barcode by accessing a trial key via the link provided in the description. This tutorial is ideal for anyone looking to leverage QR codes for marketing or personal branding, offering a robust solution for integrating logos and customizing QR code designs.

Here is an example of how you can implement this in C#:

using IronBarCode;
using System.Drawing;

class Program
{
    static void Main()
    {
        // This is the content that will be converted to a QR code.
        string content = "https://yourwebsite.com";

        // Generate a basic QR Code
        var qrCode = QRCodeWriter.CreateQrCode(content, 300);

        // Load a logo image from a file
        var logo = Image.FromFile("path/to/logo.png");

        // Set styling options for the QR code
        var qrWithLogo = qrCode
            .AddLogo(logo, 15) // Add the logo to the center of the QR code
            .ChangeBarCodeColor(Color.Black) // Change QR code color (default is black)
            .AddAnnotationAboveBarcode("Your Company", Color.Black, fontSize: 16) // Add text above QR code
            .AddAnnotationBelowBarcode("Scan Me", Color.Black, fontSize: 12); // Add text below QR code

        // Save the QR code as a PNG file
        qrWithLogo.SaveAsPng("YourQRCode.png");

        // Display a message indicating that the QR code has been saved
        System.Console.WriteLine("QR Code with logo saved as 'YourQRCode.png'.");
    }
}
using IronBarCode;
using System.Drawing;

class Program
{
    static void Main()
    {
        // This is the content that will be converted to a QR code.
        string content = "https://yourwebsite.com";

        // Generate a basic QR Code
        var qrCode = QRCodeWriter.CreateQrCode(content, 300);

        // Load a logo image from a file
        var logo = Image.FromFile("path/to/logo.png");

        // Set styling options for the QR code
        var qrWithLogo = qrCode
            .AddLogo(logo, 15) // Add the logo to the center of the QR code
            .ChangeBarCodeColor(Color.Black) // Change QR code color (default is black)
            .AddAnnotationAboveBarcode("Your Company", Color.Black, fontSize: 16) // Add text above QR code
            .AddAnnotationBelowBarcode("Scan Me", Color.Black, fontSize: 12); // Add text below QR code

        // Save the QR code as a PNG file
        qrWithLogo.SaveAsPng("YourQRCode.png");

        // Display a message indicating that the QR code has been saved
        System.Console.WriteLine("QR Code with logo saved as 'YourQRCode.png'.");
    }
}
Imports IronBarCode
Imports System.Drawing

Friend Class Program
	Shared Sub Main()
		' This is the content that will be converted to a QR code.
		Dim content As String = "https://yourwebsite.com"

		' Generate a basic QR Code
		Dim qrCode = QRCodeWriter.CreateQrCode(content, 300)

		' Load a logo image from a file
		Dim logo = Image.FromFile("path/to/logo.png")

		' Set styling options for the QR code
		Dim qrWithLogo = qrCode.AddLogo(logo, 15).ChangeBarCodeColor(Color.Black).AddAnnotationAboveBarcode("Your Company", Color.Black, fontSize:= 16).AddAnnotationBelowBarcode("Scan Me", Color.Black, fontSize:= 12) ' Add text below QR code

		' Save the QR code as a PNG file
		qrWithLogo.SaveAsPng("YourQRCode.png")

		' Display a message indicating that the QR code has been saved
		System.Console.WriteLine("QR Code with logo saved as 'YourQRCode.png'.")
	End Sub
End Class
$vbLabelText   $csharpLabel

Explanation:

  • IronBarCode: This is a comprehensive library designed for working with barcodes, especially useful in generating and customizing QR codes.
  • QRCodeWriter.CreateQrCode: This method initializes the creation of a QR code with the specified content and size.
  • AddLogo: Allows the incorporation of a logo image onto the QR code, placed typically in the center.
  • ChangeBarCodeColor: This method can adjust the color of the QR code from its default black to any specified color.
  • AddAnnotationAboveBarcode / AddAnnotationBelowBarcode: These methods permit the addition of text annotations, both above and below the barcode, facilitating customization and branding.

For further exploration and in-depth understanding of QR code customization, refer to: How to Customize and Add Logos to QR Codes.

Jordi Bardia
Software Engineer
Jordi is most proficient in Python, C# and C++, when he isn’t leveraging his skills at Iron Software; he’s game programming. Sharing responsibilities for product testing, product development and research, Jordi adds immense value to continual product improvement. The varied experience keeps him challenged and engaged, and he says it’s one of his favorite aspects of working with Iron Software. Jordi grew up in Miami, Florida and studied Computer Science and Statistics at University of Florida.
< PREVIOUS
How to create Barcodes as Streams in C# Using IronBarcode
NEXT >
How to Create Barcode & QR Code Images in C#

Report an Issue