如何從圖像中讀取 QR Code

This article was translated from English: Does it need improvement?
Translated
View the article in English

閱讀 QR 碼是指掃描並解碼儲存在 QR 碼中的信息的過程。 這通常是通過與能夠解析 QR 碼數據的軟體配合使用的相機或掃描器來完成的。 QR碼中的資訊可以是文字、網址、聯繫資料或其他形式的數據。

立即在您的專案中使用IronQR,並享受免費試用。

第一步:
green arrow pointer

從圖像讀取 QR 碼

IronQR的一個突出功能是其內建的能力,可以無縫地從各種圖像格式中讀取QR碼。 這包括:

* 聯合影像專家小組(JPEG)

* 可攜式網絡圖形(PNG)

* 圖形交換格式(GIF)

* 標記圖像檔案格式(TIFF)
  • 位圖圖像檔案(BMP)
  • WBMP
  • WebP
  • 图标(ico)
  • WMF
  • 原始格式(原始)

    此功能是由开源库启用的,鐵繪圖. 現在讓我們來探索如何使用 IronQR 從下方圖片讀取 QR 碼。

    QR碼
:path=/static-assets/qr/content-code-examples/how-to/read-qr-code-image.cs
using IronQr;
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
QrImageInput imageInput = new QrImageInput(inputBmp);

// Create a QR Reader object
QrReader reader = new QrReader();

// Read the Input an get all embedded QR Codes
IEnumerable<QrResult> results = reader.Read(imageInput);

foreach(var result in results)
{
    Console.WriteLine(result.Value);
}
Imports IronQr
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 As New QrImageInput(inputBmp)

' Create a QR Reader object
Private reader As New QrReader()

' Read the Input an get all embedded QR Codes
Private results As IEnumerable(Of QrResult) = reader.Read(imageInput)

For Each result In results
	Console.WriteLine(result.Value)
Next result
VB   C#

想知道樣本圖像中的 QR 碼值嗎?試試使用程式碼片段吧!


支持的 QR Code 類型

支援多種類型的QR碼,用於創建和讀取。 以下是支持的 QR 代碼類型:

  • QRCode:這是當今最常用的標準 QR 碼。 它可以存儲大量數據(最多可達 7,089 個數字字元或 4,296 個字母數字字元),這使其適用於各種應用程式,從網站 URL 到聯繫資訊。

    QR碼
  • MicroQRCode:微型QR Code是一種標準QR Code的小型版本,專為空間有限的情況而設計。 它能存儲的數據比標準 QR Code 少。(最多 35 個數字字符或 21 個字母數字字符)但其小巧的尺寸使其成為標準QR碼過大時的理想選擇,例如在小型包裝或微型印刷標籤上。

    QR碼
  • RMQRCode: RMQR碼(矩形微型QR碼)是另一種緊湊版本的 QR 碼,但形狀是矩形而非正方形。 此版本允許其長寬比具有靈活性,這對於可用矩形空間的應用程式可能很有用。 它可以存儲類似於微型 QR 碼的數據,但專為可用空間不規則的特定使用情況而設計。
    QR碼