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.
How to Customize and Add Logos to QR Codes
- Download the C# library for customizing and adding logos to QR codes
- Use the
CreateQrCodeWithLogo
method to create a QR code with a logo - Use the
ChangeBarCodeColor
method to add custom colors to the QR code - Add annotations to the QR code using the
AddAnnotationTextAboveBarcode
method - Display the QR code's value using the
AddBarcodeValueTextBelowBarcode
method
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
// Import necessary namespaces
using IronBarCode; // Namespace for QR code generation
using IronSoftware.Drawing; // Namespace for advanced image handling
// Main execution code for generating a QR code with a logo
// Load the logo image from the file
AnyBitmap qrLogo = AnyBitmap.FromFile("ironbarcode_top.webp");
// Create a QRCodeLogo object with the loaded image.
// Arguments: image, horizontal offset, vertical offset, size percentage
// Horizontal and vertical offsets are set to 0,
// and the size percentage is set to 20% of the QR code's size.
QRCodeLogo logo = new QRCodeLogo(qrLogo, 0, 0, 20f);
// Generate a QR code with the specified URL and embed the previously created logo in it
// The number 250 defines the size (width and height) of the generated QR code
GeneratedBarcode qrCodeWithLogo = QRCodeWriter.CreateQrCodeWithLogo(
"https://ironsoftware.com/csharp/barcode/", // URL to encode in QR code
logo, // Logo to embed
250 // Size of the QR code
);
// Save the final QR code as a PNG image file
qrCodeWithLogo.SaveAsPng("QrCodeWLogo2.png");
' Import necessary namespaces
Imports IronBarCode ' Namespace for QR code generation
Imports IronSoftware.Drawing ' Namespace for advanced image handling
' Main execution code for generating a QR code with a logo
' Load the logo image from the file
Private qrLogo As AnyBitmap = AnyBitmap.FromFile("ironbarcode_top.webp")
' Create a QRCodeLogo object with the loaded image.
' Arguments: image, horizontal offset, vertical offset, size percentage
' Horizontal and vertical offsets are set to 0,
' and the size percentage is set to 20% of the QR code's size.
Private logo As New QRCodeLogo(qrLogo, 0, 0, 20F)
' Generate a QR code with the specified URL and embed the previously created logo in it
' The number 250 defines the size (width and height) of the generated QR code
Private qrCodeWithLogo As GeneratedBarcode = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", logo, 250)
' Save the final QR code as a PNG image file
qrCodeWithLogo.SaveAsPng("QrCodeWLogo2.png")

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;
// Load an image file to be used as the logo on the QR code.
AnyBitmap qrLogo = AnyBitmap.FromFile("ironbarcode_top.webp");
// Create a QRCodeLogo object with the loaded image and specified size properties.
// The parameters are: AnyBitmap logo, int xPos, int yPos, float width.
QRCodeLogo logo = new QRCodeLogo(qrLogo, 0, 0, 20f);
// Create a color by specifying the RGB values. In this case, it's a shade of blue.
IronSoftware.Drawing.Color colorFromRgb = IronSoftware.Drawing.Color.FromArgb(51, 51, 153);
// Generate a QR code with the specified logo and with dimensions 250x250 pixels.
// The first parameter is the URL the QR code will represent.
GeneratedBarcode qrCodeWithLogo = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", logo, 250);
// Change the color of the QR code to the specified RGB color.
GeneratedBarcode qrCodeWithLogoAndColor = qrCodeWithLogo.ChangeBarCodeColor(colorFromRgb);
// Save the final QR code with the logo and color modifications as a PNG file.
qrCodeWithLogoAndColor.SaveAsPng("ColorQrCodeWithLogo.png");
Imports IronBarCode
Imports IronSoftware.Drawing
' Load an image file to be used as the logo on the QR code.
Private qrLogo As AnyBitmap = AnyBitmap.FromFile("ironbarcode_top.webp")
' Create a QRCodeLogo object with the loaded image and specified size properties.
' The parameters are: AnyBitmap logo, int xPos, int yPos, float width.
Private logo As New QRCodeLogo(qrLogo, 0, 0, 20F)
' Create a color by specifying the RGB values. In this case, it's a shade of blue.
Private colorFromRgb As IronSoftware.Drawing.Color = IronSoftware.Drawing.Color.FromArgb(51, 51, 153)
' Generate a QR code with the specified logo and with dimensions 250x250 pixels.
' The first parameter is the URL the QR code will represent.
Private qrCodeWithLogo As GeneratedBarcode = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", logo, 250)
' Change the color of the QR code to the specified RGB color.
Private qrCodeWithLogoAndColor As GeneratedBarcode = qrCodeWithLogo.ChangeBarCodeColor(colorFromRgb)
' Save the final QR code with the logo and color modifications as a PNG file.
qrCodeWithLogoAndColor.SaveAsPng("ColorQrCodeWithLogo.png")

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; // Namespace for working with bitmaps and colors
using System.Drawing; // Required namespace to work with color and fonts
// Load the image file to be used as the logo on the QR code
AnyBitmap qrLogo = AnyBitmap.FromFile("ironbarcode_top.webp");
// Create a QRCodeLogo object using the loaded image, position (0, 0), and size ratio 20% of the QR code.
QRCodeLogo logo = new QRCodeLogo(qrLogo, 0, 0, 20f);
// Define colors using RGB and Hexadecimal values
Color colorForBarcode = Color.FromArgb(51, 51, 153); // Color from RGB
Color annotationAboveBarcodeColor = ColorTranslator.FromHtml("#176feb"); // Color from Hex
Color barcodeValueBelowBarcodeColor = ColorTranslator.FromHtml("#6e53bb");
// Define fonts to be used for annotation text
Font annotationAboveBarcodeFont = new Font("Candara", 15, FontStyle.Bold);
Font barcodeValueBelowBarcodeFont = new Font("Cambria", 15, FontStyle.Regular);
// Create a QR code with the specified logo and a size of 250 pixels
GeneratedBarcode qrCodeWithLogo = QRCodeWriter.CreateQrCodeWithLogo(
"https://ironsoftware.com/csharp/barcode/", logo, 250);
// Change the color of the barcode to the specified color
GeneratedBarcode qrCodeWithLogoAndColor = qrCodeWithLogo.ChangeBarCodeColor(colorForBarcode);
// Add text annotations. These methods return a new barcode object with modifications.
GeneratedBarcode qrCodeWithAnnotation = qrCodeWithLogoAndColor
.AddAnnotationTextAboveBarcode("IronBarcodeRocks!", annotationAboveBarcodeFont, annotationAboveBarcodeColor, 2)
.AddBarcodeValueTextBelowBarcode(barcodeValueBelowBarcodeFont, barcodeValueBelowBarcodeColor, 2);
// Save the final QR code image as a PNG file
qrCodeWithAnnotation.SaveAsPng("QRCodeWithAnnotation.png");
Imports IronBarCode
Imports IronSoftware.Drawing ' Namespace for working with bitmaps and colors
Imports System.Drawing ' Required namespace to work with color and fonts
' Load the image file to be used as the logo on the QR code
Private qrLogo As AnyBitmap = AnyBitmap.FromFile("ironbarcode_top.webp")
' Create a QRCodeLogo object using the loaded image, position (0, 0), and size ratio 20% of the QR code.
Private logo As New QRCodeLogo(qrLogo, 0, 0, 20F)
' Define colors using RGB and Hexadecimal values
Private colorForBarcode As Color = Color.FromArgb(51, 51, 153) ' Color from RGB
Private annotationAboveBarcodeColor As Color = ColorTranslator.FromHtml("#176feb") ' Color from Hex
Private barcodeValueBelowBarcodeColor As Color = ColorTranslator.FromHtml("#6e53bb")
' Define fonts to be used for annotation text
Private annotationAboveBarcodeFont As New Font("Candara", 15, FontStyle.Bold)
Private barcodeValueBelowBarcodeFont As New Font("Cambria", 15, FontStyle.Regular)
' Create a QR code with the specified logo and a size of 250 pixels
Private qrCodeWithLogo As GeneratedBarcode = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", logo, 250)
' Change the color of the barcode to the specified color
Private qrCodeWithLogoAndColor As GeneratedBarcode = qrCodeWithLogo.ChangeBarCodeColor(colorForBarcode)
' Add text annotations. These methods return a new barcode object with modifications.
Private qrCodeWithAnnotation As GeneratedBarcode = qrCodeWithLogoAndColor.AddAnnotationTextAboveBarcode("IronBarcodeRocks!", annotationAboveBarcodeFont, annotationAboveBarcodeColor, 2).AddBarcodeValueTextBelowBarcode(barcodeValueBelowBarcodeFont, barcodeValueBelowBarcodeColor, 2)
' Save the final QR code image as a PNG file
qrCodeWithAnnotation.SaveAsPng("QRCodeWithAnnotation.png")

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 IronBarcode?
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 using IronBarcode?
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 with IronBarcode?
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 using IronBarcode?
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 created with IronBarcode?
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 IronBarcode?
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 in IronBarcode?
IronBarcode provides methods like 'AddAnnotationTextAboveBarcode', 'AddAnnotationTextBelowBarcode', 'AddBarcodeValueTextAboveBarcode', and 'AddBarcodeValueTextBelowBarcode' for customizing annotations.
How can I specify the color and font for annotations in IronBarcode?
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.