VintaSoft Barcode .NET SDK is the professional cross-platform SDK for Windows, Linux, macOS and Android, which allows to recognize and generate QR Code barcodes in .NET, WPF, Web, MAUI. You only need a few lines of code to add the ability to recognize and generate QR Code barcodes to your .NET application.
What is a QR Code barcode?
QR Code is a two-dimensional matrix barcode, which is the most commonly used two-dimensional barcode in the world. The name of this barcode reflects the idea of its development - "Quick Response", fast recognition at an arbitrary angle of inclination. A distinctive feature of the QR Code barcode is clearly distinguishable search patterns - black squares at the corners of the barcode:
Features of QR Code barcode
All modern manufacturers use QR Code barcodes, which are described in the ISO/IEC 18004 standard. The AIM ITS/97-001 standard describes QR Code Model 1, an outdated version of the barcode, the use of which is not recommended.
The QR Code barcode can store mixed data of various types in four encoding modes:
- Alphanumeric (up to 4296 symbols)
- Byte (up to 2953 bytes)
- Numeric (up to 7089 digits)
- Kanji (up to 1817 symbols)
The QR Code barcode uses the Reed-Solomon error correction algorithm, which allows the recognition of damaged barcodes. When creating a barcode, one of 4 error correction levels is selected depending on the expected conditions of use: the higher the error correction level, the less data can be placed in the barcode.
Micro QR barcode
Micro QR barcode is a compact version of QR Code barcode. Micro QR barcode is usually used for marking small packages:
Micro QR barcode has only one search pattern. The amount of data in this barcode is very limited:
- Alphanumeric (up to 21 symbols)
- Byte (up to 15 bytes)
- Numeric (up to 35 digits)
- Kanji (up to 9 symbols)
The structure of barcode matrix
QR and Micro QR barcode matrices have the following structure:
- Quiet zone
- Search patterns
- Information about format
- Timing patterns
- Alignment patterns
- Data and error correction layer
Special "Structure append" symbol
The QR Code barcode supports a special symbol called "Structure append", which allows to split data into several QR Code barcodes. The symbol is encoded in the barcode and allows to clearly determine the number of barcode parts and their order. This feature can be used to mark an elongated area or to place a large array of data.
VintaSoft Barcode .NET SDK allows you to split data and generate several QR Code barcodes that are linked by the "Structure append" symbol. The SDK also contains an algorithm for restoring data from a set of QR Code barcodes that were split using the "Structure append" symbol.
What QR Code barcodes can VintaSoft Barcode .NET SDK recognize?
VintaSoft Barcode .NET SDK recognizes all types of QR and Micro QR barcodes. Unique algorithms are used for recognition, allowing to quickly recognize barcodes that have various problems:
- damaged matrix
- low contrast
- low modulation
- uneven lighting
- compression on one side
- spatial distortions
- barcode printed on a distorted surface
- large number of barcodes in one image
Here is a C# code that demonstrates how to recognize QR Code barcodes in an image captured from a camera:
/// <summary>
/// Reads QR Code barcodes from a <see cref="System.Drawing.Bitmap"/>.
/// </summary>
/// <param name="bitmap">A bitmap with barcodes.</param>
public static void ReadQRCodeBarcodesFromBitmap(System.Drawing.Bitmap bitmap)
{
// create barcode reader
using (Vintasoft.Barcode.BarcodeReader reader = new Vintasoft.Barcode.BarcodeReader())
{
// specify that reader must search for QR Code barcodes
reader.Settings.ScanBarcodeTypes = Vintasoft.Barcode.BarcodeType.QR;
// read barcodes from image
Vintasoft.Barcode.IBarcodeInfo[] infos = Vintasoft.Barcode.GdiExtensions.ReadBarcodes(reader, bitmap);
// if barcodes are not detected
if (infos.Length == 0)
{
System.Console.WriteLine("No barcodes found.");
}
// if barcodes are detected
else
{
// get information about extracted barcodes
System.Console.WriteLine(string.Format("{0} barcodes found:", infos.Length));
System.Console.WriteLine();
for (int i = 0; i < infos.Length; i++)
{
Vintasoft.Barcode.IBarcodeInfo info = infos[i];
System.Console.WriteLine(string.Format("[{0}:{1}]", i + 1, info.BarcodeType));
System.Console.WriteLine(string.Format("Value: {0}", info.Value));
System.Console.WriteLine(string.Format("Region: {0}", info.Region));
System.Console.WriteLine();
}
}
}
}
What QR Code barcodes can VintaSoft Barcode .NET SDK generate?
VintaSoft Barcode .NET SDK generates all types of QR and Micro QR barcodes.
Here is a C# code that demonstrates how to generate a raster image of QR Code barcode:
/// <summary>
/// Returns the QR Code barcode as <see cref="System.Drawing.Bitmap"/>.
/// </summary>
/// <param name="value">The barcode value.</param>
/// <returns>A <see cref="System.Drawing.Bitmap"/> object.</returns>
public static System.Drawing.Bitmap GetQRCodeBarcodeAsBitmap(string value)
{
// create the barcode writer
using (Vintasoft.Barcode.BarcodeWriter barcodeWriter = new Vintasoft.Barcode.BarcodeWriter())
{
// set barcode writer settings
barcodeWriter.Settings.Barcode = Vintasoft.Barcode.BarcodeType.QR;
barcodeWriter.Settings.Value = value;
// get a barcode image as System.Drawing.Bitmap
return Vintasoft.Barcode.GdiExtensions.GetBarcodeAsBitmap(barcodeWriter);
}
}
Here is a C# code that demonstrates how to generate a raster image of Micro QR barcode:
/// <summary>
/// Returns the Micro QR barcode as <see cref="System.Drawing.Bitmap"/>.
/// </summary>
/// <param name="value">The barcode value.</param>
/// <returns>A <see cref="System.Drawing.Bitmap"/> object.</returns>
public static System.Drawing.Bitmap GetMicroQRBarcodeAsBitmap(string value)
{
// create the barcode writer
using (Vintasoft.Barcode.BarcodeWriter barcodeWriter = new Vintasoft.Barcode.BarcodeWriter())
{
// set barcode writer settings
barcodeWriter.Settings.Barcode = Vintasoft.Barcode.BarcodeType.MicroQR;
barcodeWriter.Settings.Value = value;
// get a barcode image as System.Drawing.Bitmap
return Vintasoft.Barcode.GdiExtensions.GetBarcodeAsBitmap(barcodeWriter);
}
}
Here is a C# code that demonstrates how to generate a vector (SVG) image of QR Code barcode:
/// <summary>
/// Returns the QR Code barcode in vector form as a SVG string.
/// </summary>
/// <param name="barcodeValue">Barcode value.</param>
public static void GetQrCodeBarcodeAsSvgString(string barcodeValue)
{
// create the barcode writer
using (Vintasoft.Barcode.BarcodeWriter barcodeWriter = new Vintasoft.Barcode.BarcodeWriter())
{
// set barcode writer settings
barcodeWriter.Settings.Barcode = Vintasoft.Barcode.BarcodeType.QR;
barcodeWriter.Settings.Value = barcodeValue;
// generate QR Code barcode as a SVG string
return barcodeWriter.GetBarcodeAsSvgFile();
}
}