Getting Started with IronQR
IronQR is the QR Code Reading and Writing Library for .NET
IronQR is an Iron Software's QR Code reading and writing library. In addition to highly customizable QR Generation, it uses an advanced Machine Learning Model with Mobile, Desktop, and Cloud compatibility to detect QR Codes for reading.
C# QR Code Generator Reading Library
- Read and Generate QR Codes in C# .NET Projects
- Create QR Code Generator for Mobile iOS and Android
- Read QR Code Reader for Mobile iOS and Android
- Generate QR Codes Library and in Xamarin
- Use Machine Learning to read QR Codes
Compatibility
IronQR has cross-platform support compatibility with:
.NET Version Support:
- C#, VB.NET, F#
- .NET 7, 6, 5, and Core 3.1+
- .NET Standard (2.0+)
- .NET Framework (4.6.2+)
Operating Systems and Environments Support:
- Windows (10+, Server 2016+)
- Linux (Ubuntu, Debian, CentOS, etc.)
- macOS (10+)
- iOS (12+)
- Android API 21+ (v5 "Lollipop")
- Docker (Windows, Linux, Azure)
- Azure (VPS, WebApp, Function)
- AWS (EC2, Lambda)
.NET Project Types Support:
- Web (Blazor & WebForms)
- Mobile (Xamarin & MAUI)
- Desktop (WPF & MAUI)
- Console (App & Library)
Installation
IronQR Library
Installing the IronQR library is quick and easy. You can install the package using the following command:
Install-Package IronQR
Alternatively, download directly from the official IronQR NuGet website.
Once installed, you can get started by adding using IronQR;
to the top of your C# code.
IronQR.Slim Library
The IronQR.Slim
contains both QR Generation and basic QR Reading capabilities. The IronQR
package provides advanced custom Machine Learning Models and adapters to use it with IronQR.Slim
. If you prefer to use IronQR without the increased package size and improved accuracy of the ML model, you can also use IronQR.Slim alone.
This choice will not affect generating/writing QR Codes, but note that reading will not utilize the advanced detection model. You can use the following command to install just the basic Slim version:
Install-Package IronQR.Slim
Code Examples
Generate QR Code Example
:path=/static-assets/qr/content-code-examples/get-started/get-started-1.cs
using IronQr; // Import the IronQr library containing classes for creating QR codes.
using IronSoftware.Drawing; // Import IronSoftware.Drawing for handling bitmap images.
// Create a QR Code object using the QrWriter class and pass the desired text to encode into the QR code.
// In this case, we're encoding the text "hello world".
QrCode myQr = QrWriter.CreateQrCode("hello world"); // Creates a QrCode instance encoding the string "hello world".
// Save the generated QR Code into a Bitmap object using the ToBitmap method.
AnyBitmap qrImage = myQr.ToBitmap(); // Converts the QrCode to a Bitmap object.
// Save the Bitmap object to a physical file in PNG format.
// The file will be saved in the current working directory with the name "qr.png".
qrImage.SaveAs("qr.png"); // Saves the Bitmap as a file named "qr.png".
Imports IronQr ' Import the IronQr library containing classes for creating QR codes.
Imports IronSoftware.Drawing ' Import IronSoftware.Drawing for handling bitmap images.
' Create a QR Code object using the QrWriter class and pass the desired text to encode into the QR code.
' In this case, we're encoding the text "hello world".
Private myQr As QrCode = QrWriter.CreateQrCode("hello world") ' Creates a QrCode instance encoding the string "hello world".
' Save the generated QR Code into a Bitmap object using the ToBitmap method.
Private qrImage As AnyBitmap = myQr.ToBitmap() ' Converts the QrCode to a Bitmap object.
' Save the Bitmap object to a physical file in PNG format.
' The file will be saved in the current working directory with the name "qr.png".
qrImage.SaveAs("qr.png") ' Saves the Bitmap as a file named "qr.png".
Read QR Code Example
:path=/static-assets/qr/content-code-examples/get-started/get-started-2.cs
using IronQRCode; // Updated namespace as per assumed correct library
using IronSoftware.Drawing;
using System.Collections.Generic;
using System;
// Open the asset to read a QR Code from
var inputBmp = AnyBitmap.FromFile("IMAGE_TO_READ.png");
// Load the asset into QrImageInput
var imageInput = new QrCodeInput(inputBmp); // Corrected the type as per assumed correct library
// Create a QR Reader object
var reader = new QRCodeReader();
// Read the input and get all embedded QR Codes
IEnumerable<QRCodeResult> results = reader.ReadQRCode(imageInput);
// Iterate over the results and process each detected QR Code
foreach (var result in results)
{
// Output each QR Code result
// result.Text will give the text content of the QR Code.
Console.WriteLine(result.Text);
}
/*
* Explanations and Improvements
*
* - Using Declarations: The namespace imports for `IronQRCode`, `IronSoftware.Drawing`, and `System.Collections.Generic` allow access to the necessary classes and interfaces for QR Code reading and list manipulation.
*
* - Reading Image: `AnyBitmap.FromFile("IMAGE_TO_READ.png")` is used to load an image from a given file path into an `AnyBitmap` object. This image is expected to contain QR Codes.
*
* - Creating QrImageInput: The `QrCodeInput` is created with `AnyBitmap` to prepare it for QR Code analysis. Adjustments made to correct class name based on assumed library.
*
* - QR Reader Object: `QRCodeReader` is responsible for analyzing the `QrCodeInput` instance to find any embedded QR Codes. Corrected class name based on assumed library.
*
* - Reading QR Codes: The `ReadQRCode` method of `QRCodeReader` returns an `IEnumerable<QRCodeResult>` collection, which contains zero or more results depending on how many QR Codes are found.
*
* - Iterating Over Results: A `foreach` loop processes each `QRCodeResult` in the collection, allowing access to properties such as `Text`, which contains the decoded information from the QR Code.
*
* This corrected and commented code assumes the presence of the IronBarcode library that provides the classes and methods used.
*/
Imports IronQRCode ' Updated namespace as per assumed correct library
Imports IronSoftware.Drawing
Imports System.Collections.Generic
Imports System
' Open the asset to read a QR Code from
Private inputBmp = AnyBitmap.FromFile("IMAGE_TO_READ.png")
' Load the asset into QrImageInput
Private imageInput = New QrCodeInput(inputBmp) ' Corrected the type as per assumed correct library
' Create a QR Reader object
Private reader = New QRCodeReader()
' Read the input and get all embedded QR Codes
Private results As IEnumerable(Of QRCodeResult) = reader.ReadQRCode(imageInput)
' Iterate over the results and process each detected QR Code
For Each result In results
' Output each QR Code result
' result.Text will give the text content of the QR Code.
Console.WriteLine(result.Text)
Next result
'
' * Explanations and Improvements
' *
' * - Using Declarations: The namespace imports for `IronQRCode`, `IronSoftware.Drawing`, and `System.Collections.Generic` allow access to the necessary classes and interfaces for QR Code reading and list manipulation.
' *
' * - Reading Image: `AnyBitmap.FromFile("IMAGE_TO_READ.png")` is used to load an image from a given file path into an `AnyBitmap` object. This image is expected to contain QR Codes.
' *
' * - Creating QrImageInput: The `QrCodeInput` is created with `AnyBitmap` to prepare it for QR Code analysis. Adjustments made to correct class name based on assumed library.
' *
' * - QR Reader Object: `QRCodeReader` is responsible for analyzing the `QrCodeInput` instance to find any embedded QR Codes. Corrected class name based on assumed library.
' *
' * - Reading QR Codes: The `ReadQRCode` method of `QRCodeReader` returns an `IEnumerable<QRCodeResult>` collection, which contains zero or more results depending on how many QR Codes are found.
' *
' * - Iterating Over Results: A `foreach` loop processes each `QRCodeResult` in the collection, allowing access to properties such as `Text`, which contains the decoded information from the QR Code.
' *
' * This corrected and commented code assumes the presence of the IronBarcode library that provides the classes and methods used.
'
Support Available
Information
For more information about Iron Software please visit our website: https://ironsoftware.com/
Support from Iron Software
For general support and technical inquiries, please email us at: mailto:support@ironsoftware.com