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.";
}
NuGet Download
PM > Install-Package IronQR
WPF QR 碼掃描器

WPF QR 碼掃描器

使用IronQR在WPF桌面應用程式中掃描QR碼。 使用本機QrReader.Read解碼。 不需要JavaScript或瀏覽器。

5步驟指南用於在WPF中掃描QR碼

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

程式碼說明

AnyBitmap.FromFile將選擇的檔案載入為位圖,無論其格式如何。 一個IEnumerable<QrResult>,其中每個找到的QR碼在圖像中都有一個條目。 FirstOrDefault安全地獲取第一個結果,以防圖片中沒有QR碼時應用程式不會崩潰。

了解如何使用IronQR構建WPF QR碼掃描器。

準備好開始了嗎?

Nuget Downloads 80,612版本:2026.11剛剛發布