How to Customize and add Logos to QR Codes
How to Customize and add Logos to QR Codes
- Create QR codes with logo
- Change the color of QR code and Background
- Add QR code annotation
- Change QR code background color //include save as image on final product

Install with NuGet
Install-Package BarCode
Over the years, QR codes has come to fame and preferred over other barcode types. Besides than its advantages and properties such as higher data capacity and fast and easy to scan, QR codes offer versatility by allowing users to customize the QR codes by adding logo, changing colors and add branding elements that makes them a popular choice for marketing and advertising campaigns!
Therefore, IronBarcode has come up with the features to do just that! IronBarcode offers all of our users to create and customize their QR codes the way they want. This includes Create QR codes with logo, change the color of QR code logo, and also add QR code annotation. This all made possible with the help of our free and open source library, IronDrawing. Now let us see and try the features one-by-one.
Create QR Codes With Logo
Creating plain QR code and creating QR code with logo differs in a way where creating a QR code with logo will require users to instantiate a QRCodeLogo
object to apply the logo image into the generated QR code logo. Let us first see the code snippet for generating a QR code with 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")

From the code snippet above, we used 2 libraries, which are IronBarcode and IronDrawing. Why do we need to use this 2 libraries? You will get explanation in the later part of the article.
Let us look at the output QR code produced by running the code above. We can see that the QR code has a logo attached in the middle, as well as the edges of the logo has been rounded. To achieve this, we must first load and convert our logo image into IronSoftware.Drawing AnyBitmap
object, by simply use AnyBitmap.FromFile()
method that accepts the logo image file name(if it is readily copied into the project), or file path that points to the image file.
Once we have IronSoftware.Drawing AnyBitmap
object for the image logo, we will use it to instantiate a new QRCodeLogo
object, which is basically used to be attached to the QR code. In this case, we instantiate the object by using new QRCodeLogo(AnyBitmap, Int32, Int32, Single)
. Following is the explanation of the fields we used
- AnyBitmap: We converted the image into
AnyBitmap
because our image logo format is. webp
. However, if your logo image format is in Jpeg, Jpeg2000, Png, Bmp, Tiff, or Gif, you can directly input the logo image file name or filepath of the logo image in place of AnyBitmap. - Int32: This represents the Width and Height of the image logo that will be placed on the QR code. However, in this case, we input 0 as the value, because we want IronBarcode to automatically decide the largest viable size(width and height) for the logo image.
- Single: This is the property in case users want the QR code logo corners to be rounded. Users can input the
System.Single
type value into this property as the circle radius. In case users want square corner, this property can be left out, or set 0 as the value.
Once we have our QRCodeLogo object, we can use it inside the QRCodeWriter.CreateQrCodeWithLogo()
method to render our own QR code with logo. Simply call QRCodewriter.CreateQrCodeWithLogo()
method and input the barcode value, QRCodeLogo object, and QR Code size measured in pixels(px). Lastly, to save the GeneratedBarcode
into disk, simply attach a save method to it. You can refer to our various save method here.
There, we have obtained our QR code with a rounded logo. However, there still feels like something is missing innit? The logo image and the barcode color does not seem to compliment each other.Let's see on how to Change the Color of QR Code.
Change Color of QR Code
Apart from ability to add logo image in your QR code, IronBarcode also enable users to further customize their QR code by changing the barcode color. By using our own IronDrawing, users can easily define their own color and apply it to the barcode color.Let us see the code snippet that demonstrates this feature and the resulting QR code we get 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")

The code snippet above is a continuation from the previous code snippet on how to create a QR code with logo. Once we have the GeneratedBarcode
object, we can further manipulate the object by attaching the ChangeBarCodeColor()
method to the obejct to change the barcode color. This method accepts IronSoftware.Drawing.Color
object as the parameter. In this code snippet, the object, ColorFromRgb
was created from RGB values of a color. Apart from RGB, users can also create color from HEX values of a color, or simply choose from one of the Color.Enums
. More information on creating color using IronDrawing can be seen here. Once the desired color has been applied, users can save the GeneratedBarcode
object into the disk using the method shown in the code snippet.
Add QR Code Annotation
Another important part in customizing or styling a QR code is to add annotation inside the QR code image. This can be the barcode value itself, or simply custom annotation that can be used for promotional or marketing purposes. Luckily enough, IronBarcode has the methods to do all that, including setting the position of the annotations (above or below QR code), and setting the font family as well as the font color of the annotation! Let us see the available methods for this functionality below:
AddAnnotationTextAboveBarcode()
: As the name implies, this method will add annotation text above the QR code. This method accepts the annotation text as aSystem.String
object ,IronSoftware.Drawing.Font
object for the font face of the annotation text,IronSoftware.Drawing.Color
object for the color of the annotation text, and also 2 integers to specify the top and bottom spacing of the text annotation. Please note that these parameters apart from annotation text are all overloads, hence default font, color, and spacing will be used if only annotation text were fed in the method.AddAnnotationTextBelowBarcode()
: This method uses pretty much the same parameters as the above method, only this method places the annotation text below the barcode image.AddBarcodeValueTextAboveBarcode()
: This method adds the barcode value above the barcode. Users can use this method as is, and IronBarcode will render the barcode value above the barcode using default fonts and colours. However, this method also accept parameters for colors and fonts asIronSoftware.Drawing.Color
andIronSoftware.Font
object respectively as overloads to allow users to use their own font face and text colors. This method also accept overloads of integers for spacing between the barcode value and the barcode image.AddBarcodeValueTextBelowBarcode()
: This method basically renders the barcode value text below the barcode image. All the parameters and overloads are similar to those inAddBarcodeValueTextAboveBarcode()
method.
Now, let us see the implementation of this method and see the resultant barcode image from running this code snippet
: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")

The code snippet above is an extension from the previous code snippet where we changed the color of the QR code. In this code snippet, we can see that 2 new IronSoftware.Drawing.Color
type object was instantiated which will later be used as a the text color for annotation above and below the barcode respectively. We also instantiated 2 new IronSoftware.Drawing.Font
objects to be applied in the text annotation for above and below barcode respectively.The purpose of doing this is to show the outcome of applying different colors and fonts to the annotation texts.
Let us now look at the annotation above the QR code. We linked AddAnnotationTextAboveBarcode()
method to the GeneratedBarcode QQrCodeWithLogoAndColor
in order to add annotation above the QR code. The parameter used in this method are IronSoftware.Drawing.Color AnnotationAboveBarcodeColor
and IronSoftware.Drawing.Font AnnotationAboveBarcodeFont
, as well as integer 2. This will apply the color and font object to the annotation as well as applying margin of 2 pixels between the barcode and the annotation. The same parameter are also used in AddBarcodeValueTextBelowBarcode()
method, for the same reason, only this method shows the barcode value and under the QR code.
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 used our own IronDrawing as a helper library for anything related to image processing, which assumed to be more stable than depending on other outside libraries.