How to Customize and Add Logos to QR Codes

QR codes have gained popularity over traditional barcodes due to their higher data capacity and ease of scanning. They are especially valued in marketing for their customizability, including options for adding logos, changing colors, and incorporating other branding elements.

To meet this demand, IronBarcode offers a suite of features for customizing QR codes. Users can create QR codes with logos, change the color schemes, and add annotations. These capabilities are powered by IronDrawing, a free and open-source library.

Get started with IronBarcode

Start using IronBarcode in your project today with a free trial.

First Step:
green arrow pointer



Create QR Codes With Logo Example

A QRCodeLogo object is required to embed the logo image while generating the QR code. The CreateQrCodeWithLogo method is also used to generate a QR code with a logo.

:path=/static-assets/barcode/content-code-examples/how-to/customize-qr-code-style-logo.cs
using IronBarCode;
using IronSoftware.Drawing;

AnyBitmap qrlogo = AnyBitmap.FromFile("ironbarcode_top.webp");

QRCodeLogo logo = new QRCodeLogo(qrlogo, 0, 0, 20f);

GeneratedBarcode QrCodeWithLogo = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", logo, 250);

QrCodeWithLogo.SaveAsPng("QrCodeWLogo2.png");
Imports IronBarCode
Imports IronSoftware.Drawing

Private qrlogo As AnyBitmap = AnyBitmap.FromFile("ironbarcode_top.webp")

Private logo As New QRCodeLogo(qrlogo, 0, 0, 20F)

Private QrCodeWithLogo As GeneratedBarcode = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", logo, 250)

QrCodeWithLogo.SaveAsPng("QrCodeWLogo2.png")
$vbLabelText   $csharpLabel
QR Code With Logo

Let's examine the output QR code generated by the above code. We can see that the QR code features a logo in the center with rounded edges.

To customize the logo, you need to fill in certain fields while creating a new QRCodeLogo object. Here are the explanations for the required fields:

  • Importing Image: You can import images in multiple ways, such as from AnyBitmap, Stream, Byte Array, relative filepath, or URI.
  • Image Dimensions: Specify the desired width and height of the logo image in pixels. If the image is too large for the QR code to be readable, an exception will be thrown. Use the value 0 to automatically determine the largest viable size.
  • Image Corners: Set the radius of the logo image's rounded corners. Use the default value 0 for square corners.

Finally, to export the generated QR code, simply invoke a save method. You have multiple export options, including image files, Streams, HTML, and PDF.

Change Color of QR Code Example

Besides adding a logo to your QR code, IronBarcode also enables users to further customize their QR code by changing its color. With our IronDrawing library, users can easily define their own colors using RGB values or Hex color codes and apply them to the QR code. Let's look at the code snippet that demonstrates this feature and the resulting QR code obtained from running this code.

:path=/static-assets/barcode/content-code-examples/how-to/customize-qr-code-style-logo-color.cs
using IronBarCode;
using IronSoftware.Drawing;

AnyBitmap qrlogo = AnyBitmap.FromFile("ironbarcode_top.webp");

QRCodeLogo logo = new QRCodeLogo(qrlogo, 0, 0, 20f);

IronSoftware.Drawing.Color ColorFromRgb = new IronSoftware.Drawing.Color(51, 51, 153);

GeneratedBarcode QrCodeWithLogo = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", logo, 250);
GeneratedBarcode QrCodeWithLogoAndColor = QrCodeWithLogo.ChangeBarCodeColor(ColorFromRgb);
QrCodeWithLogoAndColor.SaveAsPng("ColorQrCodeWithLogo.png");
Imports IronBarCode
Imports IronSoftware.Drawing

Private qrlogo As AnyBitmap = AnyBitmap.FromFile("ironbarcode_top.webp")

Private logo As New QRCodeLogo(qrlogo, 0, 0, 20F)

Private ColorFromRgb As New IronSoftware.Drawing.Color(51, 51, 153)

Private QrCodeWithLogo As GeneratedBarcode = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", logo, 250)
Private QrCodeWithLogoAndColor As GeneratedBarcode = QrCodeWithLogo.ChangeBarCodeColor(ColorFromRgb)
QrCodeWithLogoAndColor.SaveAsPng("ColorQrCodeWithLogo.png")
$vbLabelText   $csharpLabel
QR Code With Custom Logo and Color

The code snippet above extends a previous example of creating QR codes with a logo. It demonstrates how to change the QR code color using the ChangeBarCodeColor method, which takes an IronSoftware.Drawing.Color object as an input. You can create this object using RGB values, Hex codes, or predefined enums. Visit our "Create Color" code example to learn more.

Add QR Code Annotation Example

Another important aspect of customizing or styling a QR code is adding annotations within the QR code image. These annotations can either be the barcode value itself or custom text for promotional or marketing purposes.

Now, let's examine the implementation of these methods and the resulting QR code image generated by the code snippet below.

:path=/static-assets/barcode/content-code-examples/how-to/customize-qr-code-style-logo-color-annotation.cs
using IronBarCode;
using IronSoftware.Drawing;

AnyBitmap qrlogo = AnyBitmap.FromFile("ironbarcode_top.webp");

QRCodeLogo logo = new QRCodeLogo(qrlogo, 0, 0, 20f);

Color colorForBarcode = new Color(51, 51, 153); // color from RGB
Color annotationAboveBarcodeColor = new Color("#176feb");  // color from Hex
Font annotationAboveBarcodeFont = new Font("Candara", FontStyle.Bold, 15);
Color barcodeValueBelowBarcodeColor = new Color("#6e53bb");
Font barcodeValueBelowBarcodeFont = new Font("Cambria", FontStyle.Regular, 15);

GeneratedBarcode qrCodeWithLogo = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", logo, 250);
GeneratedBarcode qrCodeWithLogoAndColor = qrCodeWithLogo.ChangeBarCodeColor(colorForBarcode);
GeneratedBarcode qrCodeWithAnnotation = qrCodeWithLogoAndColor.AddAnnotationTextAboveBarcode("IronBarcodeRocks!", annotationAboveBarcodeFont, annotationAboveBarcodeColor, 2).AddBarcodeValueTextBelowBarcode(barcodeValueBelowBarcodeFont, barcodeValueBelowBarcodeColor, 2);
qrCodeWithAnnotation.SaveAsPng("QRCodeWithAnnotation.png");
Imports IronBarCode
Imports IronSoftware.Drawing

Private qrlogo As AnyBitmap = AnyBitmap.FromFile("ironbarcode_top.webp")

Private logo As New QRCodeLogo(qrlogo, 0, 0, 20F)

Private colorForBarcode As New Color(51, 51, 153) ' color from RGB
Private annotationAboveBarcodeColor As New Color("#176feb") ' color from Hex
Private annotationAboveBarcodeFont As New Font("Candara", FontStyle.Bold, 15)
Private barcodeValueBelowBarcodeColor As New Color("#6e53bb")
Private barcodeValueBelowBarcodeFont As New Font("Cambria", FontStyle.Regular, 15)

Private qrCodeWithLogo As GeneratedBarcode = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", logo, 250)
Private qrCodeWithLogoAndColor As GeneratedBarcode = qrCodeWithLogo.ChangeBarCodeColor(colorForBarcode)
Private qrCodeWithAnnotation As GeneratedBarcode = qrCodeWithLogoAndColor.AddAnnotationTextAboveBarcode("IronBarcodeRocks!", annotationAboveBarcodeFont, annotationAboveBarcodeColor, 2).AddBarcodeValueTextBelowBarcode(barcodeValueBelowBarcodeFont, barcodeValueBelowBarcodeColor, 2)
qrCodeWithAnnotation.SaveAsPng("QRCodeWithAnnotation.png")
$vbLabelText   $csharpLabel
QR Code With Annotation

IronBarcode provides methods for setting the annotation's position (above or below the QR code) as well as its font family and color. Below are the available methods for this functionality:

  • AddAnnotationTextAboveBarcode: Adds annotation text above the QR code.
  • AddAnnotationTextBelowBarcode: Adds annotation text below the QR code.
  • AddBarcodeValueTextAboveBarcode: Adds the barcode value text above the QR code.
  • AddBarcodeValueTextBelowBarcode: Adds the barcode value text below the QR code.

Customizing Annotation and Barcode Value

All four methods mentioned above accept a custom font as an IronSoftware.Drawing.Font object, color as an IronSoftware.Drawing.Color object, and an integer to specify the top and bottom spacing of the text in pixels. Please note that these parameters are optional; if not specified, the default font, color, and spacing will be used.

In a nutshell, IronBarcode is an ideal tool for creating and customizing your QR code. Apart from the direct methods used for the customizations, IronBarcode also uses our own IronDrawing as a helper library for anything related to image processing, which is assumed to be more stable than depending on other outside libraries.

Frequently Asked Questions

What is a powerful .NET library for creating and customizing QR codes?

IronBarcode is a powerful .NET library that allows users to create and customize QR codes, including adding logos, changing colors, and adding annotations.

How can I add a logo to a QR code?

To add a logo to a QR code, use the 'CreateQrCodeWithLogo' method provided by IronBarcode. You need to create a QRCodeLogo object with your logo image and use the SetLogo method to embed it in the QR code.

Can I change the color of a QR code?

Yes, with IronBarcode, you can change the color of a QR code using the 'ChangeBarCodeColor' method. This allows you to apply custom colors using RGB values or Hex color codes.

How do I add annotations to a QR code?

You can add annotations using methods like 'AddAnnotationTextAboveBarcode' and 'AddBarcodeValueTextBelowBarcode'. These methods allow you to position text or the barcode value above or below the QR code.

What are the available export options for QR codes?

QR codes created with IronBarcode can be exported as image files, Streams, HTML, or PDF, using various save methods available in the library.

What is the IronDrawing library?

IronDrawing is a free and open-source library used by IronBarcode for image processing tasks, such as creating and customizing QR codes.

Is IronDrawing required for using the QR code library?

Yes, IronDrawing is utilized by IronBarcode for handling image processing tasks related to QR code customization.

What methods are available for customizing QR code annotations?

IronBarcode provides methods like 'AddAnnotationTextAboveBarcode', 'AddAnnotationTextBelowBarcode', 'AddBarcodeValueTextAboveBarcode', and 'AddBarcodeValueTextBelowBarcode' for customizing annotations.

How can I specify the color and font for annotations?

You can specify the color and font for annotations by providing an IronSoftware.Drawing.Color object and an IronSoftware.Drawing.Font object, respectively, as parameters to the annotation methods.

What are the benefits of using QR codes over traditional barcodes?

QR codes offer higher data capacity and ease of scanning, making them especially useful in marketing due to their customizability, such as adding logos and branding elements.

Hairil Hasyimi Bin Omar
Software Engineer
Like all great engineers, Hairil is an avid learner. He’s refining his knowledge of C#, Python, and Java, using that knowledge to add value to team members across Iron Software. Hairil joined the Iron Software team from Universiti Teknologi MARA in Malaysia, where he graduated with a Bachelor's degree in Chemical and Process Engineering.