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

How can I create a custom QR code with a logo in .NET?

You can create a custom QR code with a logo in .NET by using the IronBarcode library's CreateQrCodeWithLogo method. This allows you to embed a logo within the QR code, and you can customize the dimensions and corner styles for better aesthetics.

What steps are involved in customizing the color of a QR code?

To customize the color of a QR code, use IronBarcode's ChangeBarCodeColor method. This allows you to apply custom colors using RGB values or Hex color codes, providing a wide range of vibrant customization options.

How can I add text annotations to a QR code?

You can add text annotations to a QR code using IronBarcode's AddAnnotationTextAboveBarcode and AddBarcodeValueTextBelowBarcode methods. These methods allow you to customize the font and color of the text for enhanced readability and branding.

What are the best practices for ensuring QR code readability?

To ensure QR code readability, IronBarcode provides guidelines on maintaining appropriate image size and corner radius. This helps in preserving the QR code's integrity and ensuring it is easily scannable.

How can I export my customized QR code?

Customized QR codes created with IronBarcode can be exported in multiple formats, including image files, PDF, Streams, and HTML, using various save methods available within the library.

What role does the IronDrawing library play in QR code customization?

The IronDrawing library is essential for handling image processing tasks within IronBarcode, allowing for QR code customization such as color changes and logo integration.

What are the benefits of using QR codes with custom styles?

Custom-styled QR codes, created using IronBarcode, offer higher visual appeal and brand alignment. This enhances user engagement and marketing effectiveness by integrating logos and specific color schemes.

Why is IronBarcode considered efficient for QR code generation?

IronBarcode is efficient for QR code generation due to its comprehensive features like logo embedding, color customization, and annotation addition, all while maintaining high readability and aesthetic standards.

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 ...Read More