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 碼掃描器

使用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 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天試用金鑰
無需信用卡或帳戶建立