Test in production without watermarks.
Works wherever you need it to.
Get 30 days of fully functional product.
Have it up and running in minutes.
Full access to our support engineering team during your product trial
Creating QR codes in C# applications is a common requirement for developers, especially for applications involving product identification, ticketing, or sharing URLs and other data easily. There are several libraries available for generating QR codes in C#. Two notable options are QRCoder and IronQR. Here, we'll explore both, comparing their capabilities, ease of use, performance, and other factors relevant for developers working with .NET 6. In this article, we'll delve into a detailed comparison of these libraries, examining their features, ease of use, license, and more, along with code samples to illustrate their usage.
QRCoder is an open-source library written in C# and provides QR Code implementation that allows you to generate QR Codes as defined by ISO/IEC 18004 in any .NET application. It’s a lightweight and easy-to-use library with no dependencies on other libraries or network stacks.
Here are the key features and benefits of QRCoder:
C# QRCoder offers a straightforward and intuitive API, making it easy for developers to generate QR codes/ QR code text with minimal effort. Its simplicity allows developers of all skill levels to quickly integrate QR code generation into their projects.
One of the standout features of QRCoder is its ability to customize QR codes according to specific requirements. Developers can adjust parameters such as error correction level, size, color, and even embed logos or images within the QR code.
QRCoder supports various encoding formats, enabling developers to encode different types of data into QR codes. Whether it's plain text, URLs, contact information, or Wi-Fi credentials, QRCoder can handle a wide range of data formats.
The QR codes generated by C# QRCoder are of high quality, ensuring readability and reliability across different devices and scanning conditions. This reliability is crucial for applications where QR codes serve as a bridge between physical and digital interactions.
C# QRCoder is an open-source project, allowing developers to contribute to its development and ensuring continuous improvements and updates. This active community engagement fosters innovation and ensures that the library remains relevant in the ever-evolving landscape of technology.
IronQR is a powerful C# QR Code library developed and maintained by Iron Software. It allows C# software engineers to detect, read, and create QR Codes in .NET applications and websites. Here are some key features of IronQR:
IronQR enables highly customizable QR code generation. You can create QR codes with various options, such as resizing, margins, borders, and recoloring.
using IronQr;
using IronSoftware.Drawing;
public class Program
{
public static void Main()
{
// Prepare a QR Code object
QrCode theQrGen = QrWriter.Write("Awesome IronQR");
// Save QR Code to memory
AnyBitmap myQrImage = theQrGen.Save();
// Save QR Code image to disk
myQrImage.SaveAs("awesome.png");
}
}
using IronQr;
using IronSoftware.Drawing;
public class Program
{
public static void Main()
{
// Prepare a QR Code object
QrCode theQrGen = QrWriter.Write("Awesome IronQR");
// Save QR Code to memory
AnyBitmap myQrImage = theQrGen.Save();
// Save QR Code image to disk
myQrImage.SaveAs("awesome.png");
}
}
IronQR uses an advanced Machine Learning Model for QR code detection. This model ensures accurate and fast QR code reading. IronQR supports reading QR codes from various image formats, including JPG, PNG, SVG, bmp, and multipage images like gif and tiff.
using IronQr;
using IronSoftware.Drawing;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
// Read QR code
var inputBmp = AnyBitmap.FromFile("awesome.png");
// Load the image into QrImageInput
QrImageInput imageInput = new QrImageInput(inputBmp);
// Create the QR Reader object
QrReader reader = new QrReader();
// Read the Input and get all embedded QR Codes
IEnumerable<QrResult> results = reader.Read(imageInput);
}
}
using IronQr;
using IronSoftware.Drawing;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
// Read QR code
var inputBmp = AnyBitmap.FromFile("awesome.png");
// Load the image into QrImageInput
QrImageInput imageInput = new QrImageInput(inputBmp);
// Create the QR Reader object
QrReader reader = new QrReader();
// Read the Input and get all embedded QR Codes
IEnumerable<QrResult> results = reader.Read(imageInput);
}
}
You can encode various types of data in QR codes, including text, URLs, bytes, and numbers.
IronQR provides detailed error messages and custom error correction options.
Trusted by Millions, IronQR is trusted by engineers worldwide for its reliability and ease of use. To get started with IronQR, you can install it via NuGet.
To get started with the code, let us create a Visual Studio Project. Open Microsoft Visual Studio 2022 and select "Create a new project" option.
Select the Console application template from the template list
Then provide the project name and the solution names. Select the path to store the project files
Select the required .NET version. I will go with the latest .NET 8 framework at the time of writing this article.
Once you click the create button the project is created and ready for development.
The QRCoder NuGet package can be installed using Visual Studio NuGet package manager as shown below.
Or install it from NuGet package manager console using the following command
dotnet add package QRCoder --version 1.4.3
The QRCoder NuGet package is available on the NuGet website here
The IronQR can also be installed similarly using the Visual Studio NuGet package manager, shown below.
Also from the NuGet package manager console, use the following command
dotnet add package IronQR --version 2024.4.1
Creating QR codes in the two libraries requires simple code, let's check them out
The following code shows how to generate our first QR code using QRCoder
using QRCoder;
using System.Drawing;
using System.IO;
namespace QRCoderVsIronQR
{
public class Program
{
public static void Main()
{
// Initialize QRCodeGenerator
using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
// Create QR code data
using (QRCodeData qrCodeData = qrGenerator.CreateQrCode("QRCoder Demo 1", QRCodeGenerator.ECCLevel.Q))
// Initialize the QR code with the data
using (BitmapByteQRCode qrCode = new BitmapByteQRCode(qrCodeData))
{
// Generate the QR code's graphic and store it in a byte array
byte[] qrCodeImage = qrCode.GetGraphic(20);
// Convert the byte array to an image format and save it to disk
using (var file = Image.FromStream(new MemoryStream(qrCodeImage)))
{
file.Save("QrCoderDemo1.png");
}
}
}
}
}
using QRCoder;
using System.Drawing;
using System.IO;
namespace QRCoderVsIronQR
{
public class Program
{
public static void Main()
{
// Initialize QRCodeGenerator
using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
// Create QR code data
using (QRCodeData qrCodeData = qrGenerator.CreateQrCode("QRCoder Demo 1", QRCodeGenerator.ECCLevel.Q))
// Initialize the QR code with the data
using (BitmapByteQRCode qrCode = new BitmapByteQRCode(qrCodeData))
{
// Generate the QR code's graphic and store it in a byte array
byte[] qrCodeImage = qrCode.GetGraphic(20);
// Convert the byte array to an image format and save it to disk
using (var file = Image.FromStream(new MemoryStream(qrCodeImage)))
{
file.Save("QrCoderDemo1.png");
}
}
}
}
}
QRCodeGenerator
and call the CreateQrCode
method to generate QR code data.BitmapByteQRCode
class to generate a byte array from the QR code data using the GetGraphic
method.Image.FromStream
.The following code shows how to generate QR code using IronQR:
using IronQr;
using IronSoftware.Drawing;
namespace QrCodeWithIronQR
{
public class Program
{
public static void Main()
{
// Prepare a QR Code object
QrCode theQrGen = QrWriter.Write("Awesome IronQR");
// Save QR Code to memory
AnyBitmap myQrImage = theQrGen.Save();
// Save QR Code image to disk
myQrImage.SaveAs("awesome.png");
}
}
}
using IronQr;
using IronSoftware.Drawing;
namespace QrCodeWithIronQR
{
public class Program
{
public static void Main()
{
// Prepare a QR Code object
QrCode theQrGen = QrWriter.Write("Awesome IronQR");
// Save QR Code to memory
AnyBitmap myQrImage = theQrGen.Save();
// Save QR Code image to disk
myQrImage.SaveAs("awesome.png");
}
}
}
As you can already see the difference in the amount of code. IronQR code generation requires less code.
QrWriter.Write
method, passing the desired content.Save
method.SaveAs
.The output has an IronQR watermark since I am using a trial version of the library. With a licensed version, this will be removed.
Both libraries support customization options. Let's look at some options available
We can set the QR code colors in QRCoder like below:
using QRCoder;
using System.Drawing;
using System.IO;
namespace QRCoderVsIronQR
{
public class Program
{
public static void Main()
{
// Initialize QRCodeGenerator
using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
// Create QR code data
using (QRCodeData qrCodeData = qrGenerator.CreateQrCode("QRCoder Demo 1", QRCodeGenerator.ECCLevel.Q))
// Initialize the QR code with the data
using (BitmapByteQRCode qrCode = new BitmapByteQRCode(qrCodeData))
{
// Generate the QR code's graphic, specifying foreground and background colors
byte[] qrCodeImage = qrCode.GetGraphic(20, Color.Red, Color.Green);
// Convert the byte array to an image format and save it to disk
using (var file = Image.FromStream(new MemoryStream(qrCodeImage)))
{
file.Save("QrCoderDemo1.png");
}
}
}
}
}
using QRCoder;
using System.Drawing;
using System.IO;
namespace QRCoderVsIronQR
{
public class Program
{
public static void Main()
{
// Initialize QRCodeGenerator
using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
// Create QR code data
using (QRCodeData qrCodeData = qrGenerator.CreateQrCode("QRCoder Demo 1", QRCodeGenerator.ECCLevel.Q))
// Initialize the QR code with the data
using (BitmapByteQRCode qrCode = new BitmapByteQRCode(qrCodeData))
{
// Generate the QR code's graphic, specifying foreground and background colors
byte[] qrCodeImage = qrCode.GetGraphic(20, Color.Red, Color.Green);
// Convert the byte array to an image format and save it to disk
using (var file = Image.FromStream(new MemoryStream(qrCodeImage)))
{
file.Save("QrCoderDemo1.png");
}
}
}
}
}
QRCodeGenerator
and call the CreateQrCode
method to generate QR code data.BitmapByteQRCode
class to generate a byte array from the QR code data using the GetGraphic
method, specifying the foreground (red) and background (green) colors.Image.FromStream
.We can set colors for IronQR QR code generation like following code:
using IronQr;
using IronSoftware.Drawing;
using System.Drawing;
namespace QrCodeWithIronQR
{
public class Program
{
public static void Main()
{
// Set options
QrOptions options = new QrOptions(QrErrorCorrectionLevel.Medium, 20);
// Create QR
QrCode myQr = QrWriter.Write("IronQR Generation Demo 1", options);
// Style options
AnyBitmap logoBmp = new AnyBitmap("logo.png");
QrStyleOptions style = new QrStyleOptions
{
BackgroundColor = Color.Aqua,
Dimensions = 300, // px
Margins = 10, // px
Color = Color.Red,
Logo = new QrLogo
{
Bitmap = logoBmp,
Width = 100,
Height = 100,
CornerRadius = 2
}
};
// Save QR Code
AnyBitmap qrImage = myQr.Save(style);
// Save QR Code to local disk
qrImage.SaveAs("advancedQr.png");
}
}
}
using IronQr;
using IronSoftware.Drawing;
using System.Drawing;
namespace QrCodeWithIronQR
{
public class Program
{
public static void Main()
{
// Set options
QrOptions options = new QrOptions(QrErrorCorrectionLevel.Medium, 20);
// Create QR
QrCode myQr = QrWriter.Write("IronQR Generation Demo 1", options);
// Style options
AnyBitmap logoBmp = new AnyBitmap("logo.png");
QrStyleOptions style = new QrStyleOptions
{
BackgroundColor = Color.Aqua,
Dimensions = 300, // px
Margins = 10, // px
Color = Color.Red,
Logo = new QrLogo
{
Bitmap = logoBmp,
Width = 100,
Height = 100,
CornerRadius = 2
}
};
// Save QR Code
AnyBitmap qrImage = myQr.Save(style);
// Save QR Code to local disk
qrImage.SaveAs("advancedQr.png");
}
}
}
With IronQR there are many customization options. In the above program we have tried to customize the background color, QR code color, margins. We can also set dimensions.
QrOptions
object to set the error correction level.QrWriter.Write
method.QrStyleOptions
.QRCoder is a MIT license-based package and is developed with the help of the community. This package is good for small-budget projects. The user needs to wait for the community to resolve issues or can fix and push the code to the Git Repository with pull requests approved.
IronQR requires a license. It has backing from Iron Software.
A IronQR trial license can be obtained. The obtained key needs to be placed in the appSettings.json file here:
{
"IronQR.License.LicenseKey": "myKey"
}
Choosing between C# QRCoder and IronQR ultimately depends on the specific requirements of your project. If you need a free and open source QR code generation library with a lot of customization options, then C# QRCoder might be the preferred choice due to its simplicity and extensive customization options.
If you need an enterprise-level library that supports not only QR code generation with customization options but also supports QR code reading, then IronQR would be the ultimate choice. With the IronQR library, its many benefits, and support functionality from Iron Software, developers can write enterprise applications with ease and peace of mind.
Generating QR codes in C# applications is essential for tasks like product identification, ticketing, and sharing URLs or data seamlessly.
This tutorial compares the QRCoder and IronQR libraries for QR code generation in .NET 6.
QRCoder offers ease of use, extensive customization options, support for multiple encoding formats, high-quality output, and is open-source with active development.
IronQR uses an advanced Machine Learning Model to ensure accurate and fast QR code reading, supporting various image formats.
Yes, QRCoder allows customization of QR codes by specifying parameters like foreground and background colors.
IronQR supports desktop applications (WPF & MAUI), mobile platforms (Xamarin and MAUI), web (Blazor and WebForms), console apps, and cloud environments (Docker, Azure, and AWS).
Yes, QRCoder is an open-source library under the MIT license, allowing community contributions and improvements.
IronQR requires a license for use, and it is supported by Iron Software. A trial license can be obtained for evaluation purposes.
For enterprise-level projects that require QR code generation and reading with robust support, IronQR is recommended.
Developers can customize QR codes in IronQR using options like background color, QR code color, margins, dimensions, and adding logos.