How to create styled QR Code with logo image in C#
Integration & Developer Guide for styled QR Code with logo image generation in ASP.NET Core MVC web application
Create custumized styled QR Code images in Visual C# .NET with complete sample C# source code
QR Code is a two-dimensional barcode symbology and it encodes some data. Now QR Codes connect the physical and digital worlds. A standard and ISO compatible QR Code cannot meet business and marketing requirements. We need more extra requirements for QR Code, including displaying logos, styled colors.
To meet these requirements, OnBarcode C# Barcode Generator provides list of functions for styled QR Code barcodes. C# developers can generate QR Codes with company logos, change the colors.
A sample styled QR Code with facebook logo printed
How to create QR Code with logo image using C#?
To create a QR Code with logo image inside is an easy task. First you need create a standard QR Code. Then you need provide a Bitmap object with logo image inside.
Here are the C# sample code and text to explain how to do it.
To add a logo image on the qr code barcode, you need create a QR Code object with options applied, such as, QR Code data message, data mode, versions, and QR Code dimension size settings.
And you also need apply the following required options for logo image rendering.
- Logo: A Bitmap object which is containing the logo image. You can create and load the Bitmap object from an existing image filepath, Stream, byte array from database, or url.
- LogoActualSize: The actual displayed dimension size (System.Drawing.SizeF) on the center of the QR Code.
QRCode barcode = new QRCode();
barcode.Data = "https://www.facebook.com";
barcode.DataMode = QRCodeDataMode.Auto;
// Selecte format mode
// from V1 to V40
barcode.Version = QRCodeVersion.V3;
barcode.Logo = new System.Drawing.Bitmap("W://Projects//Test-Files//facebook_logo_2021.svg.png");
barcode.LogoActualSize = new System.Drawing.SizeF(600, 600);
// Barcode Size Related Settings
barcode.UOM = UnitOfMeasure.INCH;
barcode.AutoResize = true;
barcode.BarcodeWidth = 3;
barcode.BarcodeHeight = 3;
barcode.Resolution = 900;
barcode.AutoResizePaddingTransparent = true;
// Image format setting
barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;
barcode.drawBarcode("W://Projects//Test-Output//OnBarcode.com//csharp-qrcode-logo.png");
Change the Colors of QR Codes
Using the above C# code, you can place a logo on the center of the generated QR Codes.
Here we will add more features to the styled QR Code. You can change the QR Code module and background colors to meet your business or marketing requirements.
The following C# code will change the QR Code module color to the same color as facebook logo.
- ForeColor: Set the QR Code module color (forecolor) to Color.FromArgb(24, 119, 242)
QRCode barcode = new QRCode();
barcode.Data = "https://www.facebook.com";
barcode.DataMode = QRCodeDataMode.Auto;
// Selecte format mode
// from V1 to V40
barcode.Version = QRCodeVersion.V3;
barcode.Logo = new System.Drawing.Bitmap("W://Projects//Test-Files//facebook_logo_2021.svg.png");
barcode.LogoActualSize = new System.Drawing.SizeF(600, 600);
barcode.ForeColor = Color.FromArgb(24, 119, 242);
// Barcode Size Related Settings
barcode.UOM = UnitOfMeasure.INCH;
barcode.AutoResize = true;
barcode.BarcodeWidth = 3;
barcode.BarcodeHeight = 3;
barcode.Resolution = 900;
barcode.AutoResizePaddingTransparent = true;
// Image format setting
barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;
barcode.drawBarcode("W://Projects//Test-Output//OnBarcode.com//csharp-qrcode-logo.png");
In a nutshell, OnBarcode
C# barcode generator library will not only create fully ISO compatible QR Code, but also custumized styled QR Code
for your business and marketing requirements.