IRONSOFTWAREHOME
與其他組件的比較

IronBarcode與ZXing.NET的比較

Curtis Chau
Curtis Chau
Updated: 2025年8月31日

如果您已經擁有技術電話/管理電話上的條碼的電子圖片,並希望將其解碼為英文文字資料,條碼掃描器可能不是最佳工具。 此外,條碼掃描器僅限於讀取具有有限儲存容量、域狀態、支持格式的1D條碼,並且只能與Windows RT類庫一起使用。 如今,2D條碼(也稱為QR碼)更為常見,並且可以儲存顯著多的資訊,如更新日期。

條碼掃描應用程式可以在Windows、MacOS或Linux上運行,而不依賴於任何第三方工具或API,因為它由.NET支持。

ZXing.org QR Code Library和IronBarcode:全面比較:圖2 - Web應用程式

建立和掃描條碼已成為許多企業避免垃圾郵件的必要手段。 建立條碼的兩個流行工具是開源的ZXing專案解碼和IronBarcode。 在本文中,我們將探索這些工具的功能和優勢並加以比較。

ZXing解碼器

ZXing是一個流行的開源庫,用於生成和解碼1D和2D條碼。

它還支持多種編程語言,包括Java、C++和.NET。

ZXing解碼器線上是基於網路的工具,允許使用者掃描並解碼條碼和QR碼圖片。 此外,使用者可以為任何資訊建立QR碼,通常以URL或他們想要編碼的文字的形式呈現。

要使用ZXing線上解碼器,請按照以下步驟操作:

  1. 存取ZXing解碼器線上網站。

    ZXing.org QR Code Library和IronBarcode:全面比較:圖2 - 由Google開發的ZXing網頁

  2. 點擊"選擇檔案"按鈕選擇一個QR碼圖片檔案。

  3. 一旦選擇了圖片,點擊"提交"按鈕。

    ZXing.org QR Code Library和IronBarcode:全面比較:圖3 - ZXing解碼

  4. 如果發現可識別的程式碼,該工具將解碼QR碼並顯示所得資訊。

該庫易於使用,可以整合到Web應用程式、移動應用程式和桌面應用程式中。

ZXing被廣泛採用,擁有大社群的開發者參與其開發並提供支援。

該庫收集裝置資訊,例如裝置型號和作業系統版本,這可以被視作潛在的安全風險。

此外,有些人對該庫的所有權和控制權提出了擔憂,因為它不是由獨立機構維護的。

總體而言,ZXing是一個強大且多功能的條碼生成和解碼庫,具有廣泛的採用和社群支持。

例如,使用ZXing生成QR碼,開發者只需要編寫幾行程式碼:

using ZXing;
using ZXing.QrCode;

// Create a BarcodeWriter instance to generate QR codes
BarcodeWriter writer = new BarcodeWriter
{
    Format = BarcodeFormat.QR_CODE // Set format to QR_CODE
};

// Generate a QR code with the text "Hello, ZXing!"
Bitmap qrCode = writer.Write("Hello, ZXing!");

使用ZXing專案解碼QR碼,開發者可以使用以下程式碼:

using ZXing;
using ZXing.QrCode;

// Create a BarcodeReader instance for decoding QR codes
BarcodeReader reader = new BarcodeReader();

// Decode the QR code from a bitmap image
Result result = reader.Decode(qrCode);

// Extract the text from the decoded QR code
string text = result.Text;

ZXing.org QR Code Library和IronBarcode:全面比較:圖4 - QR碼生成器

ZXing.org QR Code Library和IronBarcode:全面比較:圖5 - QR碼檔案顯示

介紹IronBarcode

IronBarcode是一個為.NET開發者建立的強大條碼生成和掃描庫,由Iron Software開發。

IronBarcode提供一個易於使用的API,允許開發者生成和掃描各種條碼型別,包括QR碼、Data Matrix碼和UPC-A條碼。

IronBarcode程式庫由Iron Software建立,以擴展ZXing.NET庫的功能。

ZXing.org QR Code Library和IronBarcode:全面比較:圖6 - 支持的條碼格式

它增加了新功能,例如生成2D條碼、PDF417條碼以及直接從圖片文件讀取條碼的能力。

這是如何使用IronBarcode生成QR碼的範例:

using IronBarCode;

// Generate a QR code with the text "Hello, IronBarcode!"
var barcode = BarcodeWriter.CreateBarcode("Hello, IronBarcode!", BarcodeWriterEncoding.QRCode);

// Save the generated QR code as a PNG image
barcode.SaveAsImage("qrcode.png");

ZXing.org QR Code Library和IronBarcode:全面比較:圖7 - QR碼

要使用IronBarcode掃描條碼,您可以使用以下程式碼:

using IronBarCode;

// Read the QR code from the image file "qrcode.png"
var barcode = BarcodeReader.ReadBarcode("qrcode.png", BarcodeEncoding.QRCode);

// Extract the text from the decoded QR code
string text = barcode.Text;

ZXing.org QR Code Library和IronBarcode:全面比較:圖8 - 在C#中建立條碼圖片

IronBarcode支持廣泛的條碼型別,包括2D條碼、UPC-A、UPC-E、EAN-8、EAN-13、Code39、Code128、PDF417等。

它建立在ZXing.NET庫的優勢基礎上,提供更快、更準確的條碼掃描和生成,同時增加了新功能。

如何使用IronBarcode

以下是一些如何使用IronBarcode的步驟:

步驟1:安裝IronBarcode程式庫

要在您的.NET項目中使用IronBarcode,首先需要使用NuGet安裝IronBarcode程式庫。 您可以通過在NuGet套件管理器控制台中運行以下命令完成此操作:

PM > Install-Package BarCode

步驟2:生成條碼

要使用IronBarcode生成條碼,您可以使用BarcodeWriter類。

using IronBarCode;

// Generate a QR code with the text "Hello, IronBarcode!"
var barcode = BarcodeWriter.CreateBarcode("Hello, IronBarcode!", BarcodeWriterEncoding.QRCode);

// Save the generated QR code as an image file
barcode.SaveAsImage("qrcode.png");

此程式碼建立一個帶有文字"Hello, IronBarcode!"的QR碼,並將其保存為名為"qrcode.png"的圖片文件。

步驟3:掃描條碼

要使用IronBarcode掃描條碼,您可以使用BarcodeReader類。

using IronBarCode;

// Read the QR code from the image file "qrcode.png"
var barcode = BarcodeReader.ReadBarcode("qrcode.png", BarcodeEncoding.QRCode);

// Extract the text from the decoded QR code
string text = barcode.Text;

此程式碼從圖片文件"qrcode.png"讀取QR碼,並返回在條碼中編碼的文字。

ZXing.org QR Code Library和IronBarcode:全面比較:圖9 - 掃描條碼

步驟4:自定義條碼

IronBarcode提供一系列自定義選項,允許您控制生成的條碼掃描實現的外觀和行為。

這是如何使用IronBarcode針對條碼掃描實現自定義QR碼的範例:

using IronBarCode;

// Customize a QR code
var barcode = BarcodeWriter.CreateBarcode("Hello, IronBarcode!", BarcodeWriterEncoding.QRCode);
barcode.ResizeTo(400, 400); // Resize the barcode
barcode.SetMargins(20); // Set margins around the barcode
barcode.SetForegroundColor(Color.Black); // Set the foreground color
barcode.SetBackgroundColor(Color.White); // Set the background color
barcode.AddCaptionAbove("Scan me with your smartphone!"); // Add a caption above the barcode
barcode.AddImageLogo("logo.png", 80, 80); // Add a logo to the barcode
barcode.SaveAsImage("qrcode.png"); // Save the customized barcode as an image

此程式碼生成一個帶有文字"Hello, IronBarcode!"的QR碼,並通過將其調整為400x400像素大小、新增20像素邊距、將前景顏色設為黑色、背景顏色設為白色、在條碼上方新增標題以及插入徽標圖片等方式進行自定義。

IronBarcode的功能

IronBarcode建立在開源ZXing庫的基礎上,但擴展了功能以支持更廣泛的條碼型別,包括QR碼、Code 128、Code 39、EAN-13、EAN-8、UPC-A等。

以下是IronBarcode可以完成的一些事情:

生成條碼

IronBarcode可以輕鬆生成各型別和風格的條碼,包括線性和2D條碼,具有可自定義的功能,如顏色、文字和圖片覆蓋。 以下程式碼片段生成了一個QR碼:

var barcode = IronBarCode.BarcodeWriter.CreateBarcode("Hello World!", IronBarCode.BarcodeWriterEncoding.QRCode);
barcode.SaveAsJpeg("QRCode.jpg");

ZXing.org QR Code Library和IronBarcode:全面比較:圖10 - 將被掃描的Code128條碼圖像

讀取條碼

IronBarcode還提供強大的條碼掃描器,可以從圖片、PDF和實時攝像頭流中讀取條碼。 以下程式碼從圖片文件讀取QR碼:

var barcode = IronBarCode.BarcodeReader.Read("QRCode.jpg", IronBarCode.BarcodeReaderEncoding.QRCode);
Console.WriteLine(barcode.Text);

ZXing.org QR Code Library和IronBarcode:全面比較:圖11 - 讀取PDF內部儲存的條碼

驗證條碼

IronBarcode也可以驗證條碼,以確保它們的有效性並能被其他條碼讀碼器掃描。 以下程式碼片段驗證了一個Code 128條碼:

var barcode = IronBarCode.BarcodeReader.Read("Code128.jpg", IronBarCode.BarcodeReaderEncoding.Code128);

// Check if the barcode is valid
if (barcode.IsValid)
{
    Console.WriteLine("Barcode is valid.");
}
else
{
    Console.WriteLine("Barcode is invalid.");
}

轉換條碼

IronBarcode可以將條碼從一種格式轉換為另一種格式,如將Code 39條碼轉換為QR碼。 以下程式碼片段將Code 39條碼轉換為QR碼:

var barcode = IronBarCode.BarcodeReader.Read("Code39.jpg", IronBarCode.BarcodeReaderEncoding.Code39);
var qrCode = IronBarCode.BarcodeWriter.CreateBarcode(barcode.Text, IronBarCode.BarcodeWriterEncoding.QRCode);
qrCode.SaveAsJpeg("QRCode.jpg");

IronBarcode優於ZXing解碼器線上的原因

以下是IronBarcode優於ZXing的一些方式:

  1. 性能: IronBarcode比ZXing更快,使其成為需要高速條碼掃描和生成的Web應用程式的絕佳選擇。
  2. 易用性: IronBarcode的API簡單直觀,使其只需幾行程式碼即可輕鬆建立和掃描條碼。 另一方面,ZXing的API可能對初學者來說較為複雜和難以使用。
  3. 輸出質量: IronBarcode產生的條碼質量高,在小尺寸時也很容易閱讀。 相較之下,ZXing的條碼有時難以閱讀,尤其是尺寸較小時。
  4. 支持格式: IronBarcode支持廣泛的條碼格式,包括UPC-A、2D條碼等。 相比之下,ZXing專案僅支持有限數量的條碼格式。
  5. 授權: IronBarcode提供靈活的授權模式,允許開發者根據需求免費使用或購買授權。 相對而言,ZXing的授權限制較多,使開發者在商業專案中使用該庫變得困難。

ZXing.org QR Code Library和IronBarcode:全面比較:圖12 - 從多幀TIFF圖像讀取條碼

當談到性能、易用性、輸出質量、支持格式和授權時,IronBarcode是一個優於ZXing的庫。

親自看看IronBarcode的優勢

使用下面的免費條碼讀取演示體驗IronBarcode提供的一切。

IronBarcode還提供免費試用

想要試用IronBarcode並看看它如何增強您的條碼掃描和生成能力? 我們很高興為您提供IronBarcode的免費試用,讓您可以測試其功能和優勢。

在試用期間,您將能夠完全存取IronBarcode的強大功能,包括支持多種條碼格式、高級自定義選項,以及與您現有項目的無縫整合。

要開始試用,只需存取我們的網站並下載IronBarcode套件。 然後,您將有免費試用,可以探索IronBarcode提供的一切,並親身看到它如何簡化您的條碼掃描和生成工作流程。

ZXing是其各自所有者的註冊商標。 本網站不隸屬於、未經ZXing認可或贊助。 所有產品名稱、標誌和品牌均為其各自所有者的財產。 比較僅供資訊參考,並反映了撰寫時公開可用的資訊。)}]

Curtis Chau
技術作家

Curtis Chau擁有Carleton大學的電腦科學學士學位,專精於前端開發,擁有Node.js、TypeScript、JavaScript和React的專業知識。Curtis熱衷於建立直觀且美觀的使用者介面,喜愛使用現代框架並建立結構良好、視覺吸引力的手冊。

...
閱讀更多

相關文章

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