Cómo Personalizar y Agregar Logos a Códigos QR en C#

How to Customize and Add Logos to QR Codes

This article was translated from English: Does it need improvement?
Translated
View the article in English

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.

Quickstart: Build a Branded QR Code in One Line

Get started instantly by creating a QR code with your logo, custom color, and annotation—all with minimal setup and just one line of IronBarcode code. Ideal for developers who want professional branding fast and hassle-free.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronBarcode with NuGet Package Manager

    PM > Install-Package BarCode

  2. Copy and run this code snippet.

    IronBarCode.QRCodeWriter.CreateQrCodeWithLogo("https://example.com", new IronBarCode.QRCodeLogo("logo.png"), 300).ChangeBarCodeColor(IronSoftware.Drawing.Color.DeepSkyBlue).AddAnnotationTextAboveBarcode("Scan Me", new IronSoftware.Drawing.Font("Verdana",12), IronSoftware.Drawing.Color.White, 5).SaveAsPng("customQR.png");
  3. Deploy to test on your live environment

    Start using IronBarcode in your project today with a free trial
    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.

Preguntas Frecuentes

¿Cómo puedo crear un código QR personalizado con un logotipo en .NET?

Puedes crear un código QR personalizado con un logotipo en .NET usando el método CreateQrCodeWithLogo de la biblioteca IronBarcode. Esto te permite incrustar un logotipo dentro del código QR, y puedes personalizar las dimensiones y los estilos de las esquinas para una mejor estética.

¿Qué pasos implica personalizar el color de un código QR?

Para personalizar el color de un código QR, usa el método ChangeBarCodeColor de IronBarcode. Esto te permite aplicar colores personalizados usando valores RGB o códigos de color Hex, proporcionando una amplia gama de opciones de personalización vibrante.

¿Cómo puedo agregar anotaciones de texto a un código QR?

Puedes agregar anotaciones de texto a un código QR usando los métodos AddAnnotationTextAboveBarcode y AddBarcodeValueTextBelowBarcode de IronBarcode. Estos métodos te permiten personalizar la fuente y el color del texto para una mejor legibilidad y branding.

¿Cuáles son las mejores prácticas para asegurar la legibilidad de un código QR?

Para asegurar la legibilidad de un código QR, IronBarcode proporciona guías sobre cómo mantener el tamaño de imagen y el radio de las esquinas apropiados. Esto ayuda a preservar la integridad del código QR y asegura que sea fácilmente escaneable.

¿Cómo puedo exportar mi código QR personalizado?

Los códigos QR personalizados creados con IronBarcode pueden exportarse en múltiples formatos, incluidos archivos de imagen, PDF, Streams y HTML, usando varios métodos de guardado disponibles en la biblioteca.

¿Qué papel juega la biblioteca IronDrawing en la personalización de códigos QR?

La biblioteca IronDrawing es esencial para manejar tareas de procesamiento de imágenes dentro de IronBarcode, permitiendo la personalización de códigos QR como cambios de color e integración de logotipos.

¿Cuáles son los beneficios de usar códigos QR con estilos personalizados?

Los códigos QR con estilos personalizados, creados usando IronBarcode, ofrecen un mayor atractivo visual y alineación de marca. Esto mejora el compromiso del usuario y la efectividad del marketing al integrar logotipos y esquemas de color específicos.

¿Por qué se considera IronBarcode eficiente para la generación de códigos QR?

IronBarcode es eficiente para la generación de códigos QR debido a sus características comprensivas como la incrustación de logotipos, personalización de colores y adición de anotaciones, todo mientras se mantiene alta legibilidad y estándares estéticos.

Hairil Hasyimi Bin Omar
Ingeniero de Software
Como todos los grandes ingenieros, Hairil es un ávido aprendiz. Está refinando su conocimiento de C#, Python y Java, usando ese conocimiento para agregar valor a los miembros del equipo en Iron Software. Hairil se unió al equipo de Iron Software desde la Universiti Teknologi MARA en Malasia, donde se ...
Leer más
¿Listo para empezar?
Nuget Descargas 1,935,276 | Versión: 2025.11 recién lanzado