VOOZH about

URL: https://ironsoftware.com/csharp/barcode/how-to/error-correction/

⇱ C# QR Code Error Correction Levels | IronBarcode Guide


Skip to footer content

On This Page

  1. IronBarcode
  2. How-Tos
  3. Set Error Correction

How To Set Error Correction in C#

Error correction in C# barcodes is set using the QrErrorCorrectionLevel parameter in IronBarcode's QRCodeWriter.CreateQrCode method, supporting four levels (L, M, Q, H) that can recover 7-30% of damaged data, with higher levels creating more complex QR codes.

Error Correction in barcodes refers to the ability to maintain barcode readability despite visual defects or encoding errors. These damages can arise due to factors such as printing imperfections, smudges, scratches, or variations in scanning conditions. Error correction is a major factor in determining which type of barcode encoding is suitable, especially when working with QR codes in C#.

In general, 2D barcodes have a higher tolerance to defects compared to 1D barcodes due to the following factors:

  • Data Capacity: 2D barcodes store more data than 1D barcodes, encoding both horizontally and vertically. Learn more about supported barcode formats.
  • Redundancy: 2D barcodes have multiple layers of data encoding, allowing information extraction from any remaining intact sections even when part of the barcode is damaged.
  • Compactness: 2D barcodes are suitable for limited spaces due to their compact shape.
  • Flexibility: 2D barcodes can be scanned from various angles and orientations.

Error correction becomes particularly important when dealing with imperfect barcodes and image correction scenarios where scanning conditions are less than ideal.

Quickstart: Use Error Correction Level in QR Code Creation

This short example shows how to generate a QR code with IronBarcode, setting the error correction level to Medium. Developers can use the CreateQrCode method with content, size, and error correction level.

  1. Install IronBarcode with NuGet Package Manager

    PM > Install-Package BarCode
  2. Copy and run this code snippet.

    var qr = IronBarCode.QRCodeWriter.CreateQrCode("https://ironsoftware.com", 500, IronBarCode.QRCodeWriter.QrErrorCorrectionLevel.Medium).SaveAsPng("qr.png");
  3. Deploy to test on your live environment

    Start using IronBarcode in your project today with a free trial

Minimal Workflow (5 steps)

  1. Download the C# library to adjust error correction on barcodes
  2. Use the QRCodeWriter class to generate a QR code
  3. Modify the QrErrorCorrection parameter to adjust the error correction level
  4. Compare the QR codes generated visually at four different error correction levels
  5. Examine the output QR codes


How Do I Adjust Error Correction in QR Codes?

Currently, IronBarcode supports setting error correction in QR Codes, Micro QRs, and rMQRs as part of its comprehensive barcode generation features. It supports all four pre-set error correction levels specified by QR code standards. The error correction level is adjusted via the QrErrorCorrectionLevel parameter in the QRCodeWriter.CreateQrCode method. The four levels of error correction are:

  • Highest: Level H. Can recover up to 30% of data.
  • High: Level Q. Can recover up to 25% of data.
  • Medium: Level M. Can recover up to 15% of data.
  • Low: Level L. Can recover up to 7% of data.

Higher error correction levels result in more complex QR code images, requiring a balance between visual clarity and error correction when generating QR codes. The code sample below demonstrates setting error correction:

:path=/static-assets/barcode/content-code-examples/how-to/set-error-correction.cs
// Import the necessary namespace for barcode generation
using IronBarCode;

// Create a QR code with the specified URL, size, and error correction level
GeneratedBarcode mediumCorrection = QRCodeWriter.CreateQrCode(
 "https://ironsoftware.com/csharp/barcode/", // URL to be encoded in the QR code
 500, // Size of the QR code (500x500 pixels)
 QRCodeWriter.QrErrorCorrectionLevel.Medium // Error correction level to handle distortions
);

// Save the generated QR code image as a PNG file with the specified filename
mediumCorrection.SaveAsPng("mediumCorrection.png");
' Import the necessary namespace for barcode generation
Imports IronBarCode

' Create a QR code with the specified URL, size, and error correction level
Private mediumCorrection As GeneratedBarcode = QRCodeWriter.CreateQrCode("https://ironsoftware.com/csharp/barcode/", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium)

' Save the generated QR code image as a PNG file with the specified filename
mediumCorrection.SaveAsPng("mediumCorrection.png")
$vbLabelText   $csharpLabel

Which Error Correction Level Should I Choose?

The choice of error correction level depends on your specific use case and environment. For applications where QR codes might be exposed to physical damage, dirt, or partial obscuration, higher error correction levels (Q or H) are recommended. These levels provide better fault tolerance at the cost of increased QR code complexity and size.

For clean, controlled environments like digital displays or high-quality printing, lower error correction levels (L or M) may suffice. These produce simpler, less dense QR codes that are easier to scan at smaller sizes. Consider these factors:

  • Physical Environment: Outdoor or industrial settings benefit from higher error correction
  • Print Quality: Lower quality printing requires higher error correction
  • Size Constraints: Limited space may require lower error correction for readability
  • Scanning Distance: Longer scanning distances work better with simpler QR codes

Here's an example showing how to generate QR codes with different error correction levels for comparison:

:path=/static-assets/barcode/content-code-examples/how-to/error-correction-3.cs
using IronBarCode;
using System.Drawing;

// Generate QR codes with all four error correction levels
var content = "https://ironsoftware.com/csharp/barcode/";
int size = 500;

// Create QR codes with different error correction levels
var lowCorrection = QRCodeWriter.CreateQrCode(content, size, QRCodeWriter.QrErrorCorrectionLevel.Low);
var mediumCorrection = QRCodeWriter.CreateQrCode(content, size, QRCodeWriter.QrErrorCorrectionLevel.Medium);
var highCorrection = QRCodeWriter.CreateQrCode(content, size, QRCodeWriter.QrErrorCorrectionLevel.High);
var highestCorrection = QRCodeWriter.CreateQrCode(content, size, QRCodeWriter.QrErrorCorrectionLevel.Highest);

// Save each with descriptive filenames
lowCorrection.SaveAsPng("qr_low_correction.png");
mediumCorrection.SaveAsPng("qr_medium_correction.png");
highCorrection.SaveAsPng("qr_high_correction.png");
highestCorrection.SaveAsPng("qr_highest_correction.png");
Imports IronBarCode
Imports System.Drawing

' Generate QR codes with all four error correction levels
Dim content As String = "https://ironsoftware.com/csharp/barcode/"
Dim size As Integer = 500

' Create QR codes with different error correction levels
Dim lowCorrection = QRCodeWriter.CreateQrCode(content, size, QRCodeWriter.QrErrorCorrectionLevel.Low)
Dim mediumCorrection = QRCodeWriter.CreateQrCode(content, size, QRCodeWriter.QrErrorCorrectionLevel.Medium)
Dim highCorrection = QRCodeWriter.CreateQrCode(content, size, QRCodeWriter.QrErrorCorrectionLevel.High)
Dim highestCorrection = QRCodeWriter.CreateQrCode(content, size, QRCodeWriter.QrErrorCorrectionLevel.Highest)

' Save each with descriptive filenames
lowCorrection.SaveAsPng("qr_low_correction.png")
mediumCorrection.SaveAsPng("qr_medium_correction.png")
highCorrection.SaveAsPng("qr_high_correction.png")
highestCorrection.SaveAsPng("qr_highest_correction.png")
$vbLabelText   $csharpLabel

What Parameters Control Error Correction?

The primary parameter controlling error correction in IronBarcode is the QrErrorCorrectionLevel enumeration. This parameter is passed to the CreateQrCode method and determines how much redundant data is embedded in the QR code. When creating custom QR codes, you can combine error correction settings with other styling options:

:path=/static-assets/barcode/content-code-examples/how-to/error-correction-4.cs
using IronBarCode;

// Create a styled QR code with high error correction
var styledQr = QRCodeWriter.CreateQrCode("Important Data", 500, QRCodeWriter.QrErrorCorrectionLevel.High);

// Apply custom styling
styledQr.ChangeBarCodeColor(System.Drawing.Color.DarkBlue)
 .SetMargins(10)
 .AddAnnotationTextAboveBarcode("Scan for Details");

// Export with various options
styledQr.SaveAsPng("styled_high_correction.png");
styledQr.SaveAsJpeg("styled_high_correction.jpg");
styledQr.SaveAsPdf("styled_high_correction.pdf");
Imports IronBarCode
Imports System.Drawing

' Create a styled QR code with high error correction
Dim styledQr = QRCodeWriter.CreateQrCode("Important Data", 500, QRCodeWriter.QrErrorCorrectionLevel.High)

' Apply custom styling
styledQr.ChangeBarCodeColor(Color.DarkBlue) _
 .SetMargins(10) _
 .AddAnnotationTextAboveBarcode("Scan for Details")

' Export with various options
styledQr.SaveAsPng("styled_high_correction.png")
styledQr.SaveAsJpeg("styled_high_correction.jpg")
styledQr.SaveAsPdf("styled_high_correction.pdf")
$vbLabelText   $csharpLabel

Why Does Error Correction Affect QR Code Complexity?

Error correction works by adding redundant data to the QR code using Reed–Solomon error correction algorithms. This redundancy allows the QR code reader to reconstruct missing or damaged portions of the data. The more error correction added, the more modules (black and white squares) are needed to encode the same information, resulting in a denser, more complex pattern.

This complexity has practical implications for barcode reading settings and scanning performance. Higher error correction levels may require adjustments to reader settings for optimal performance.

What Are the Different Error Correction Levels?

Below is a sample set of QR Code images, each representing the same value but with varying levels of error correction. As observed, higher error correction levels lead to more complex QR code images, offering greater fault tolerance.

When Should I Use Higher Error Correction?

Higher error correction levels are recommended in several scenarios:

  1. Industrial Applications: When QR codes are used on products or equipment exposed to harsh conditions
  2. Outdoor Signage: For QR codes displayed outdoors subject to weather damage
  3. Long-term Storage: Documents or products that need to remain scannable for years
  4. Marketing Materials: When incorporating logos or designs that partially obscure the QR code

For advanced scenarios involving reading multiple barcodes or processing damaged images, higher error correction provides additional reliability.

How Does Error Correction Impact QR Code Size?

Error correction directly impacts the physical size and data capacity of QR codes. Higher error correction levels require more modules to encode the same amount of data, which can result in:

  • Larger QR codes for the same data content
  • Reduced maximum data capacity at a given QR code size
  • More complex patterns that may be harder to scan at small sizes
  • Increased processing time for both generation and scanning

What Are the Visual Differences Between Correction Levels?

The visual differences between error correction levels become apparent when comparing QR codes encoding the same data. Lower correction levels produce simpler patterns with fewer modules, while higher levels create denser, more intricate patterns. These differences affect not only appearance but also practical considerations for printing and display.

For more advanced barcode generation techniques, explore our comprehensive documentation and learn about integrating error correction with other barcode features for optimal results in your .NET applications.

Frequently Asked Questions

What is error correction in barcode technology?

Error correction in barcodes refers to the ability to maintain barcode readability despite visual defects or encoding errors. IronBarcode implements error correction through the QrErrorCorrectionLevel parameter, which allows recovery of 7-30% of damaged data depending on the level chosen.

How do I set error correction levels when creating QR codes in C#?

You can set error correction levels using IronBarcode's QRCodeWriter.CreateQrCode method by specifying the QrErrorCorrectionLevel parameter. The method accepts content, size, and one of four error correction levels (L, M, Q, H).

What are the four error correction levels available for QR codes?

IronBarcode supports four pre-set error correction levels for QR codes: L (Low - 7% recovery), M (Medium - 15% recovery), Q (Quartile - 25% recovery), and H (High - 30% recovery). Higher levels create more complex QR codes but offer better damage resistance.

Which barcode types support error correction settings?

Currently, IronBarcode supports setting error correction levels for QR Codes, Micro QRs, and rMQRs. These 2D barcode formats offer superior error correction capabilities compared to traditional 1D barcodes.

Why do 2D barcodes have better error correction than 1D barcodes?

2D barcodes supported by IronBarcode have better error correction due to higher data capacity (encoding both horizontally and vertically), built-in redundancy allowing data extraction from intact sections, compact shape suitable for limited spaces, and flexibility for scanning from various angles.

When should I use higher error correction levels?

Use higher error correction levels with IronBarcode when dealing with imperfect printing conditions, potential physical damage (scratches, smudges), challenging scanning environments, or when long-term durability is required. Higher levels provide more reliable scanning but increase QR code complexity.

Does IronBarcode provide support for customizing barcode appearance?

Yes, IronBarcode provides extensive customization options for barcode appearance, including color, size, and text annotations, allowing you to tailor barcodes to your specific design requirements.

How can IronBarcode help in improving efficiency in business processes?

IronBarcode enhances business process efficiency by enabling quick and accurate barcode generation and reading, reducing manual data entry errors, and improving inventory and asset tracking.

What programming skills are needed to implement IronBarcode in a project?

Basic knowledge of C# programming is sufficient to implement IronBarcode in a project, as it provides straightforward methods and comprehensive documentation to guide developers.

Is IronBarcode suitable for both small projects and large enterprise applications?

IronBarcode is designed to be scalable and versatile, making it suitable for small projects as well as large enterprise applications that require robust barcode solutions.

Software Engineer
Like all great engineers, Hairil is an avid learner. He’s refining his knowledge of C#, Python, and Java, using that knowledge to add value to team members across Iron Software. Hairil joined the Iron Software team from Universiti Teknologi MARA in Malaysia, where he graduated with a Bachelor's degree ...
Read More
Ready to Get Started?
Nuget Downloads 2,295,550 | Version: 2026.6 just released

Still Scrolling?

Want proof fast? PM > Install-Package BarCode
run a sample watch your string become a barcode.

Get your FREE

30-day Trial Key instantly.

15-day Trial Key instantly.

The trial form was submitted
successfully.

Your trial key should be in the email.
If it is not, please contact
support@ironsoftware.com

πŸ‘ bullet_checked
No credit card or account creation required
πŸ‘ bullet_test
Test in production
without watermarks
πŸ‘ bullet_calendar
30 days fully
functional product
πŸ‘ bullet_support
24/5 technical
support during trial
Try IronBarcode for Free
Get Set Up in 5 Minutes
Install with NuGet
Version: 2026.6
Install-Package BarCode
nuget.org/packages/BarCode/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronBarCode"
  3. Select the package and install
Download DLL
Version: 2026.6
Download Now
Manually install into your project
  1. Download and unzip IronBarCode to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronBarCode.dll"
Licenses from $749

Have a question? Get in touch with our development team.

Now you've installed with Nuget
Your browser is now downloading IronBarcode

Next step: Start free 30-day Trial

No credit card required

  • Test in a live environment
  • Fully-functional product
  • 24/5 technical support

Thank You

Your trial key should be in the email.
If it is not, please contact
support@ironsoftware.com
Get your free 30-day Trial Key instantly.
Thank you.
If you'd like to speak to our licensing team:
πŸ‘ badge_greencheck_in_yellowcircle
The trial form was submitted
successfully.

Your trial key should be in the email.
If it is not, please contact
support@ironsoftware.com

Have a question? Get in touch with our development team.
No credit card or account creation required
Now you've installed with Nuget
Your browser is now downloading IronBarcode

Next step: Start free 30-day Trial

No credit card required

  • Test in a live environment
  • Fully-functional product
  • 24/5 technical support
Thank you.
View your license options:
Thank you.
If you'd like to speak to our licensing team:
Have a question? Get in touch with our development team.
Have a question? Get in touch with our development team.
Talk to Sales Team

Book a No-obligation Consult

How we can help:
  • Consult on your workflow & pain points
  • See how other companies solve their .NET document needs
  • All your questions answered to make sure you have all the information you need. (No commitment whatsoever.)
  • Get a tailored quote for your project's needs
Get Your No-Obligation Consult

Complete the form below or email sales@ironsoftware.com

Your details will always be kept confidential.

Trusted by Millions of Engineers Worldwide
Book Free Live Demo

Book a 30-minute, personal demo.

No contract, no card details, no commitments.

Here's what to expect:
  • A live demo of our product and its key features
  • Get project specific feature recommendations
  • All your questions are answered to make sure you have all the information you need.
    (No commitment whatsoever.)
CHOOSE TIME
YOUR INFO
Book your free Live Demo

Trusted by Millions of Engineers Worldwide

Iron Support Team

We're online 24 hours, 5 days a week.
Chat
Email
Call Me