How to create QR Code with logo image using C#?
To create a QR Code with logo image inside is an easy task using C# QR Code Generator library. First you need create a standard QR Code. Then you need provide a Bitmap object with logo image inside.
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.
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 image. - ECL: QR Code error correction level.
Here are the C# sample source code to create a QR Code with logo printed.
QRCode barcode = new QRCode(); barcode.Data = "https://www.facebook.com"; barcode.Logo = new System.Drawing.Bitmap("C://Input//facebook.png"); barcode.LogoActualSize = new System.Drawing.SizeF(60, 60); barcode.ECL = QRCodeECL.Q; barcode.BarcodeWidth = 300; barcode.BarcodeHeight = 300; barcode.AutoResizePaddingTransparent = true; barcode.drawBarcode("C://Output//barcode-styled-qrcode.png");
Remove partial covered QR Code modules
When you print QR Code with logo in C# application, the C# Barcode Generator library will automatically remove the QR Code modules which are partial covered by logo image.
You can choose to render these partial QR Code modules by setting the property
You can choose to render these partial QR Code modules by setting the property
CleanImageCoveredArea to false.
barcode.CleanImageCoveredArea = false;
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.
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 to
Color.FromArgb(24, 119, 242)
QRCode barcode = new QRCode(); barcode.Data = "https://www.facebook.com"; barcode.Logo = new System.Drawing.Bitmap("C://Input//facebook_logo_2021.svg.png"); barcode.LogoActualSize = new System.Drawing.SizeF(60, 60); barcode.BarcodeWidth = 300; barcode.BarcodeHeight = 300; barcode.AutoResizePaddingTransparent = true; barcode.ForeColor = Color.FromArgb(24, 119, 242); barcode.drawBarcode("C://Output//barcode-styled-qrcode-color.png");
Best and Worst Colors for QR Code
Here we will help you choose the right colors for scannable QR codes.
Proper color selection ensures high compatibility with standard QR Code scanners.
Guiding Principles for QR Code Color Selection
Color contrast (the luminance and hue difference between two adjacent colors) is the key indicator for successful color matching.
Low color contrast is the main reason for unreadable QR Codes.
QR Code Scanners rely on the light reflection principle (light bounces off the background and is absorbed by the bars).
QR Code Scanners rely on the light reflection principle (light bounces off the background and is absorbed by the bars).
- The background should reflect light well.
- The barcode bars must absorb light.
Note: Always use light-colored backgrounds and dark-colored barcode bars for standard QR Code labels.
Good color combinations
Good color combinations is dark bars with light background.
| Black & White | Black & Red | Black & Yellow |
|
|
|
| Green & White | Green & Red | Green & Yellow |
|
|
|
Bad color combinations
Bad color combinations is low contrast:
- Light bars + light background
- Dark bars + dark background
| Red & White | Lavender & White | Yellow & White |
|
|
|
| Black & Green | Black & Brown | Black & Blue |
|
|
|
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.
