// Import necessary IronQR and IronDrawing namespacesusing IronSoftware.Drawing; using IronBarcode;public class QRCodeReader{ public static voidMain() { // Load an image from a file path using (var inputImage = Image.FromFile("path/to/your/image/file.webp")) { // Create a QrImageInput object from the image var qrImageInput = new QrImageInput(inputImage); // Decode the QRコード from the image var result = BarcodeReader.Read(qrImageInput); // Iterate through each detected QRコード and display its information foreach (var barcodeResult in result.Barcodes) {Console.WriteLine($"QR Code Data: {barcodeResult.Value}"); } } }}
// Import necessary IronQR and IronDrawing namespaces
using IronSoftware.Drawing;
using IronBarcode;
public class QRCodeReader
{
public static void Main()
{
// Load an image from a file path
using (var inputImage = Image.FromFile("path/to/your/image/file.webp"))
{
// Create a QrImageInput object from the image
var qrImageInput = new QrImageInput(inputImage);
// Decode the QRコード from the image
var result = BarcodeReader.Read(qrImageInput);
// Iterate through each detected QRコード and display its information
foreach (var barcodeResult in result.Barcodes)
{
Console.WriteLine($"QR Code Data: {barcodeResult.Value}");
}
}
}
}
' Import necessary IronQR and IronDrawing namespacesImportsIronSoftware.DrawingImportsIronBarcodePublic Class QRCodeReader PublicShared Sub Main() ' Load an image from a file pathUsing inputImage = Image.FromFile("path/to/your/image/file.webp") ' Create a QrImageInput object from the image Dim qrImageInput = New QrImageInput(inputImage) ' Decode the QRコード from the image Dim result = BarcodeReader.Read(qrImageInput) ' Iterate through each detected QRコード and display its information For Each barcodeResult In result.BarcodesConsole.WriteLine($"QR Code Data: {barcodeResult.Value}") NextEndUsing End SubEnd Class
' Import necessary IronQR and IronDrawing namespaces
Imports IronSoftware.Drawing
Imports IronBarcode
Public Class QRCodeReader
Public Shared Sub Main()
' Load an image from a file path
Using inputImage = Image.FromFile("path/to/your/image/file.webp")
' Create a QrImageInput object from the image
Dim qrImageInput = New QrImageInput(inputImage)
' Decode the QRコード from the image
Dim result = BarcodeReader.Read(qrImageInput)
' Iterate through each detected QRコード and display its information
For Each barcodeResult In result.Barcodes
Console.WriteLine($"QR Code Data: {barcodeResult.Value}")
Next
End Using
End Sub
End Class
// Example: Reading QRコードs with enhanced error correctionusing IronBarcode;public class EnhancedQRReader{ public static voidReadPoorQualityImage() { // Configure reader with multiple attempts and error correction var options = new BarcodeReaderOptions {Speed = ReadingSpeed.Detailed, // More thorough scanningExpectMultipleBarcodes = true, // Check for multiple codesExpectBarcodeTypes = BarcodeType.QRCode// Focus on QRコードs only }; using (var inputImage = Image.FromFile("blurry_qr_code.jpg")) { var qrImageInput = new QrImageInput(inputImage); var results = BarcodeReader.Read(qrImageInput, options); foreach (var result in results.Barcodes) {Console.WriteLine($"Decoded: {result.Value}");Console.WriteLine($"Confidence: {result.Confidence}%"); } } }}
// Example: Reading QRコードs with enhanced error correction
using IronBarcode;
public class EnhancedQRReader
{
public static void ReadPoorQualityImage()
{
// Configure reader with multiple attempts and error correction
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Detailed, // More thorough scanning
ExpectMultipleBarcodes = true, // Check for multiple codes
ExpectBarcodeTypes = BarcodeType.QRCode // Focus on QRコードs only
};
using (var inputImage = Image.FromFile("blurry_qr_code.jpg"))
{
var qrImageInput = new QrImageInput(inputImage);
var results = BarcodeReader.Read(qrImageInput, options);
foreach (var result in results.Barcodes)
{
Console.WriteLine($"Decoded: {result.Value}");
Console.WriteLine($"Confidence: {result.Confidence}%");
}
}
}
}
ImportsIronBarcodePublic Class EnhancedQRReader PublicShared Sub ReadPoorQualityImage() ' Configure reader with multiple attempts and error correction Dim options = New BarcodeReaderOptionsWith { .Speed = ReadingSpeed.Detailed, ' More thorough scanning .ExpectMultipleBarcodes = True, ' Check for multiple codes .ExpectBarcodeTypes = BarcodeType.QRCode' Focus on QRコードs only }Using inputImage = Image.FromFile("blurry_qr_code.jpg") Dim qrImageInput = New QrImageInput(inputImage) Dim results = BarcodeReader.Read(qrImageInput, options) For Each result In results.BarcodesConsole.WriteLine($"Decoded: {result.Value}")Console.WriteLine($"Confidence: {result.Confidence}%") NextEndUsing End SubEnd Class
Imports IronBarcode
Public Class EnhancedQRReader
Public Shared Sub ReadPoorQualityImage()
' Configure reader with multiple attempts and error correction
Dim options = New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Detailed, ' More thorough scanning
.ExpectMultipleBarcodes = True, ' Check for multiple codes
.ExpectBarcodeTypes = BarcodeType.QRCode ' Focus on QRコードs only
}
Using inputImage = Image.FromFile("blurry_qr_code.jpg")
Dim qrImageInput = New QrImageInput(inputImage)
Dim results = BarcodeReader.Read(qrImageInput, options)
For Each result In results.Barcodes
Console.WriteLine($"Decoded: {result.Value}")
Console.WriteLine($"Confidence: {result.Confidence}%")
Next
End Using
End Sub
End Class
using System;using System.Collections.Generic;using System.Linq;using IronQr;using System.Drawing;// Import imagevar inputImage = Image.FromFile("sample.jpg");// Load the asset into QrImageInputQrImageInput imageInput = new QrImageInput(inputImage);// Create a QR Reader objectQrReader reader = new QrReader();// Read the Input an get all embedded QR CodesIEnumerable<QrResult> results = reader.Read(imageInput);// Display the value of the first QR code foundConsole.WriteLine($"QR code value is {results.First().Value}");
using System;
using System.Collections.Generic;
using System.Linq;
using IronQr;
using System.Drawing;
// Import image
var inputImage = Image.FromFile("sample.jpg");
// Load the asset into QrImageInput
QrImageInput imageInput = new QrImageInput(inputImage);
// Create a QR Reader object
QrReader reader = new QrReader();
// Read the Input an get all embedded QR Codes
IEnumerable<QrResult> results = reader.Read(imageInput);
// Display the value of the first QR code found
Console.WriteLine($"QR code value is {results.First().Value}");
ImportsSystemImportsSystem.Collections.GenericImportsSystem.LinqImportsIronQrImportsSystem.Drawing' Import imageDim inputImage AsImage = Image.FromFile("sample.jpg")' Load the asset into QrImageInputDim imageInput As New QrImageInput(inputImage)' Create a QR Reader objectDim reader As New QrReader()' Read the Input and get all embedded QR CodesDim results AsIEnumerable(OfQrResult) = reader.Read(imageInput)' Display the value of the first QR code foundConsole.WriteLine($"QR code value is {results.First().Value}")
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports IronQr
Imports System.Drawing
' Import image
Dim inputImage As Image = Image.FromFile("sample.jpg")
' Load the asset into QrImageInput
Dim imageInput As New QrImageInput(inputImage)
' Create a QR Reader object
Dim reader As New QrReader()
' Read the Input and get all embedded QR Codes
Dim results As IEnumerable(Of QrResult) = reader.Read(imageInput)
' Display the value of the first QR code found
Console.WriteLine($"QR code value is {results.First().Value}")
using System;using System.Collections.Generic;using IronQr;using System.Drawing;using System.Linq;// Import an image containing a QR codevar inputImage = Image.FromFile("urlQr.png");// Load the asset into a QrImageInput objectvar imageInput = new QrImageInput(inputImage);// Create a QR Reader objectvar reader = new QrReader();// Read the input and get all embedded QR codesIEnumerable<QrResult> results = reader.Read(imageInput);// [TL, TR, BL, BR]string[] labels = { "Top-Left", "Top-Right", "Bottom-Left", "Bottom-Right" };var points = results.First().Points;for (int i = 0; i < points.Length; i++){Console.WriteLine($"{labels[i]}: {points[i].X}, {points[i].Y}");}
using System;
using System.Collections.Generic;
using IronQr;
using System.Drawing;
using System.Linq;
// Import an image containing a QR code
var inputImage = Image.FromFile("urlQr.png");
// Load the asset into a QrImageInput object
var imageInput = new QrImageInput(inputImage);
// Create a QR Reader object
var reader = new QrReader();
// Read the input and get all embedded QR codes
IEnumerable<QrResult> results = reader.Read(imageInput);
// [TL, TR, BL, BR]
string[] labels = { "Top-Left", "Top-Right", "Bottom-Left", "Bottom-Right" };
var points = results.First().Points;
for (int i = 0; i < points.Length; i++)
{
Console.WriteLine($"{labels[i]}: {points[i].X}, {points[i].Y}");
}
ImportsSystemImportsSystem.Collections.GenericImportsIronQrImportsSystem.DrawingImportsSystem.Linq' Import an image containing a QR codeDim inputImage AsImage = Image.FromFile("urlQr.png")' Load the asset into a QrImageInput objectDim imageInput As New QrImageInput(inputImage)' Create a QR Reader objectDim reader As New QrReader()' Read the input and get all embedded QR codesDim results AsIEnumerable(OfQrResult) = reader.Read(imageInput)' [TL, TR, BL, BR]Dim labels AsString() = { "Top-Left", "Top-Right", "Bottom-Left", "Bottom-Right" }Dim points = results.First().PointsFor i AsInteger = 0 To points.Length - 1Console.WriteLine($"{labels(i)}: {points(i).X}, {points(i).Y}")Next
Imports System
Imports System.Collections.Generic
Imports IronQr
Imports System.Drawing
Imports System.Linq
' Import an image containing a QR code
Dim inputImage As Image = Image.FromFile("urlQr.png")
' Load the asset into a QrImageInput object
Dim imageInput As New QrImageInput(inputImage)
' Create a QR Reader object
Dim reader As New QrReader()
' Read the input and get all embedded QR codes
Dim results As IEnumerable(Of QrResult) = reader.Read(imageInput)
' [TL, TR, BL, BR]
Dim labels As String() = { "Top-Left", "Top-Right", "Bottom-Left", "Bottom-Right" }
Dim points = results.First().Points
For i As Integer = 0 To points.Length - 1
Console.WriteLine($"{labels(i)}: {points(i).X}, {points(i).Y}")
Next
作成と読み取りの両方で、複数の種類の QR コードがサポートされています。 IronQRは多様なアプリケーションのニーズに応えるため、様々なQRコードフォーマットを包括的にサポートしています。 サポートされているQRフォーマットの詳細については、当社のドキュメントを参照してください。 サポートされている QR コードの種類は次のとおりです。
using IronBarcode;using IronSoftware.Drawing;public class MultiTypeQRReader{ public static voidReadVariousQRTypes() { // Configure reader to handle all QRコード types var options = new BarcodeReaderOptions {ExpectBarcodeTypes = BarcodeType.QRCode | BarcodeType.MicroQRCode | BarcodeType.RectangularMicroQRCode }; string[] imagePaths = { "standard_qr.png", "micro_qr.png", "rectangular_qr.png" }; foreach (var path in imagePaths) { using (var image = Image.FromFile(path)) { var qrInput = new QrImageInput(image); var results = BarcodeReader.Read(qrInput, options); foreach (var qr in results.Barcodes) {Console.WriteLine($"Type: {qr.BarcodeType}");Console.WriteLine($"Data: {qr.Value}");Console.WriteLine($"Format: {qr.Format}");Console.WriteLine("---"); } } } }}
using IronBarcode;
using IronSoftware.Drawing;
public class MultiTypeQRReader
{
public static void ReadVariousQRTypes()
{
// Configure reader to handle all QRコード types
var options = new BarcodeReaderOptions
{
ExpectBarcodeTypes = BarcodeType.QRCode |
BarcodeType.MicroQRCode |
BarcodeType.RectangularMicroQRCode
};
string[] imagePaths = {
"standard_qr.png",
"micro_qr.png",
"rectangular_qr.png"
};
foreach (var path in imagePaths)
{
using (var image = Image.FromFile(path))
{
var qrInput = new QrImageInput(image);
var results = BarcodeReader.Read(qrInput, options);
foreach (var qr in results.Barcodes)
{
Console.WriteLine($"Type: {qr.BarcodeType}");
Console.WriteLine($"Data: {qr.Value}");
Console.WriteLine($"Format: {qr.Format}");
Console.WriteLine("---");
}
}
}
}
}
ImportsIronBarcodeImportsIronSoftware.DrawingPublic Class MultiTypeQRReader PublicShared Sub ReadVariousQRTypes() ' Configure reader to handle all QRコード types Dim options = New BarcodeReaderOptionsWith { .ExpectBarcodeTypes = BarcodeType.QRCodeOrBarcodeType.MicroQRCodeOrBarcodeType.RectangularMicroQRCode } Dim imagePaths AsString() = { "standard_qr.png", "micro_qr.png", "rectangular_qr.png" } For Each path In imagePathsUsing image = Image.FromFile(path) Dim qrInput = New QrImageInput(image) Dim results = BarcodeReader.Read(qrInput, options) For Each qr In results.BarcodesConsole.WriteLine($"Type: {qr.BarcodeType}")Console.WriteLine($"Data: {qr.Value}")Console.WriteLine($"Format: {qr.Format}")Console.WriteLine("---") NextEndUsing Next End SubEnd Class
Imports IronBarcode
Imports IronSoftware.Drawing
Public Class MultiTypeQRReader
Public Shared Sub ReadVariousQRTypes()
' Configure reader to handle all QRコード types
Dim options = New BarcodeReaderOptions With {
.ExpectBarcodeTypes = BarcodeType.QRCode Or
BarcodeType.MicroQRCode Or
BarcodeType.RectangularMicroQRCode
}
Dim imagePaths As String() = {
"standard_qr.png",
"micro_qr.png",
"rectangular_qr.png"
}
For Each path In imagePaths
Using image = Image.FromFile(path)
Dim qrInput = New QrImageInput(image)
Dim results = BarcodeReader.Read(qrInput, options)
For Each qr In results.Barcodes
Console.WriteLine($"Type: {qr.BarcodeType}")
Console.WriteLine($"Data: {qr.Value}")
Console.WriteLine($"Format: {qr.Format}")
Console.WriteLine("---")
Next
End Using
Next
End Sub
End Class
IronQR can read various types of QR codes, including Standard QR Code, Micro QR Code, and RMQR Code, supporting different use cases and data capacities for applications requiring compact or rectangular formats.
When should I choose Micro or RMQR codes?
Choose Micro QR codes for small surfaces like circuit boards or medical devices and RMQR codes for rectangular labels like narrow shipping labels or marketing materials that require fitting into elongated spaces.
How does IronQR locate a QR code within an image?
IronQR uses a standard coordinate system to pinpoint where a QR code is located within an image. It retrieves and prints the exact spatial coordinates of the QR code's corners using the Points[] array.