IRONSOFTWAREHOME
WPF QR码扫描器
using IronQr;
using IronSoftware.Drawing;
using Microsoft.Win32;

// Open a file dialog to select a QR code image
var dialog = new OpenFileDialog
{
    Title = "Select a QR code image",
    Filter = "Image Files|*.png;*.jpg;*.jpeg;*.bmp;*.gif;*.tiff"
};

if (dialog.ShowDialog() == true)
{
    // Load the selected image into IronQR
    var inputBmp = AnyBitmap.FromFile(dialog.FileName);
    QrImageInput imageInput = new QrImageInput(inputBmp);

    // Create a QR Reader object and read the image
    QrReader reader = new QrReader();
    IEnumerable<QrResult> results = reader.Read(imageInput);

    // Display the first result
    ResultLabel.Text = results.FirstOrDefault()?.Value ?? "No QR code found.";
}
Imports IronQr
Imports IronSoftware.Drawing
Imports Microsoft.Win32

' Open a file dialog to select a QR code image
Dim dialog = New OpenFileDialog With {
    .Title = "Select a QR code image",
    .Filter = "Image Files|*.png;*.jpg;*.jpeg;*.bmp;*.gif;*.tiff"
}

If dialog.ShowDialog() = True Then
    ' Load the selected image into IronQR
    Dim inputBmp = AnyBitmap.FromFile(dialog.FileName)
    Dim imageInput As New QrImageInput(inputBmp)

    ' Create a QR Reader object and read the image
    Dim reader As New QrReader()
    Dim results As IEnumerable(Of QrResult) = reader.Read(imageInput)

    ' Display the first result
    ResultLabel.Text = If(results.FirstOrDefault()?.Value, "No QR code found.")
End If
NuGet Download
PM > Install-Package IronQR
WPF QR码扫描器

WPF QR码扫描器

在 WPF 桌面应用程序中使用 IronQR 扫描二维码。 使用本机QrReader.Read解码。 无需 JavaScript 或浏览器。

WPF 中扫描二维码的 5 步指南

  • using IronQr;
  • using IronSoftware.Drawing;
  • var dialog = new OpenFileDialog { Filter = "图像文件|.png;.jpg;.jpeg;.bmp" };
  • var inputBmp = FileName);
  • var results = imageInput/);

代码解释

OpenFileDialog 处理本机Windows文件选择,过滤为常见图像类型。AnyBitmap.FromFile 将所选文件加载到位图中,无论格式如何。 一个QrImageInput 将该位图包装,以便IronQR可以使用它,QrReader.Read 返回一个IEnumerable<QrResult>,每个在图像中找到的QR码都有一个条目。 FirstOrDefault 安全地获取第一个结果,因此如果图像没有QR码,应用程序不会崩溃。

了解如何使用 IronQR 构建 WPF QR 码扫描器。

准备开始了吗?

Nuget Downloads 74,386版本:2026.9刚刚发布

Key in blue circle

立即获取免费的 30 天试用版密钥

Your trial license will be sent to your email address

无任何限制。100% 解锁。无需信用卡。

bullet_checked无需信用卡或创建账户无任何限制。100% 解锁。无需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
预约您的免费现场演示
Booking Badge

深受全球数百万工程师信赖

Iron Software 的客户徽标
获取您的无义务咨询
填写下面的表格或通过sales@ironsoftware.com
您的资料将始终保密。
深受全球数百万工程师信赖
Iron Software 的客户徽标
立即获取您的免费30 天试用密钥
无需信用卡或创建账户