跳過到頁腳內容
與其他組件的比較

ZXing.org QR碼庫和IronBarcode:全面的比較

如果您已經有條碼的電子影像在技術電話/管理電話中,並希望將其解碼為英文文本數據,條碼掃描器可能不是最佳工具。 此外,條碼掃描器僅限於閱讀存儲容量有限、域名狀態受到限制、支持的格式有限的1D條碼,只能在Windows RT類庫中使用。 如今,2D條碼(也稱為QR碼)更為常見,可以存儲更多更新的信息,如更新日期。

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

ZXing.org二維碼庫和IronBarcode:全面比較:圖2 - 網頁應用程序

創建和掃描條形碼對許多企業來說已經變得不可或缺,以避免垃圾郵件。 創建條碼的兩個流行工具是開源ZXing項目解碼和IronBarcode。 在本文中,我們將探討每種工具的功能和優勢,並進行比較。

ZXing解碼器

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

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

ZXing Decoder Online是一個基於網絡的工具,能讓用戶掃描和解碼條形碼和QR碼圖像。 此外,用戶可以為任何信息創建QR碼,通常是他們想要編碼的URL或文本。

使用ZXing在線解碼器,請按照這些步驟操作:

  1. 訪問ZXing Decoder Online網站。

    ZXing.org二維碼庫和IronBarcode:全面比較:圖2 - ZXing Web由Google開發

  2. 點擊“選擇文件”按鈕以選擇QR碼圖像文件。
  3. 當您選擇好圖像後,點擊“提交”按鈕。

    ZXing.org二維碼庫和IronBarcode:全面比較:圖3 - ZXing解碼

  4. 如果找到可識別的代碼,工具將解碼QR碼並顯示結果信息。

該庫易於使用,可以集成到網絡應用程序、移動應用程序和桌面應用程序中。

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!");
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!");
Imports ZXing
Imports ZXing.QrCode

' Create a BarcodeWriter instance to generate QR codes
Private writer As New BarcodeWriter With {.Format = BarcodeFormat.QR_CODE}

' Generate a QR code with the text "Hello, ZXing!"
Private qrCode As Bitmap = writer.Write("Hello, ZXing!")
$vbLabelText   $csharpLabel

要使用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;
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;
Imports ZXing
Imports ZXing.QrCode

' Create a BarcodeReader instance for decoding QR codes
Private reader As New BarcodeReader()

' Decode the QR code from a bitmap image
Private result As Result = reader.Decode(qrCode)

' Extract the text from the decoded QR code
Private text As String = result.Text
$vbLabelText   $csharpLabel

ZXing.org二維碼庫和IronBarcode:全面比較:圖4 - QR碼生成器

ZXing.org二維碼庫和IronBarcode:全面比較:圖5 - 显示的QR碼文件

介紹 IronBarcode

IronBarcode是為.NET開發人員創建的強大條碼生成和掃描庫,由Iron Software創建。

IronBarcode提供易於使用的API,允許開發人員生成和掃描各種條碼類型,包括QR碼、數據矩陣碼和UPC-A條碼。

IronBarcode庫由Iron Software創建,作為擴展ZXing.NET庫功能的方法。

ZXing.org二維碼庫和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");
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");
Imports IronBarCode

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

' Save the generated QR code as a PNG image
barcode.SaveAsImage("qrcode.png")
$vbLabelText   $csharpLabel

ZXing.org二維碼庫和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;
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;
Imports IronBarCode

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

' Extract the text from the decoded QR code
Private text As String = barcode.Text
$vbLabelText   $csharpLabel

ZXing.org二維碼庫和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包管理器控制台中運行以下命令來做到這一點:

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");
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");
Imports IronBarCode

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

' Save the generated QR code as an image file
barcode.SaveAsImage("qrcode.png")
$vbLabelText   $csharpLabel

這段代碼創建了一個包含“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;
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;
Imports IronBarCode

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

' Extract the text from the decoded QR code
Private text As String = barcode.Text
$vbLabelText   $csharpLabel

這段代碼從“qrcode.png”圖像文件中讀取QR碼,並返回編碼在條碼中的文本。

ZXing.org二維碼庫和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
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
Imports IronBarCode

' Customize a QR code
Private 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
$vbLabelText   $csharpLabel

此代碼生成一個包含“Hello, IronBarcode!”文本的QR碼,並將其自定義為調整大小為400x400像素,添加20像素邊距,將前景色設為黑色,背景色設為白色,在條碼上方添加標題並添加logo圖片。

IronBarcode可以做到什麼

IronBarcode基於開源ZXing庫,但擴展其能力以支持更廣泛的條碼類型,包括QR碼、Code 128、Code 39、EAN-13、EAN-8、UPC-A等。

以下是IronBarcode可以做的一些事情:

生成條碼

IronBarcode可以輕鬆生成各種類型和風格的條碼,包括線性和2D條碼,具有可自定義的功能,如顏色、文本和圖像疊加。 以下代碼片段生成了一個QR Code:

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

ZXing.org二維碼庫和IronBarcode:全面比較:圖10 - Code128條碼圖像待掃描

讀取條碼

IronBarcode還提供了一個強大的條碼掃描器,可以從圖像、PDF和實時相機流中讀取條碼。 以下代碼讀取了一個圖像文件中的依據QR碼:

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

ZXing.org二維碼庫和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.");
}
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.");
}
Dim barcode = IronBarCode.BarcodeReader.Read("Code128.jpg", IronBarCode.BarcodeReaderEncoding.Code128)

' Check if the barcode is valid
If barcode.IsValid Then
	Console.WriteLine("Barcode is valid.")
Else
	Console.WriteLine("Barcode is invalid.")
End If
$vbLabelText   $csharpLabel

轉換條碼

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

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

IronBarcode為何優於ZXing Decoder Online

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

  1. 性能:IronBarcode比ZXing更快,非常適合需要高速條碼掃描和生成的網絡應用程序。
  2. 易用性:IronBarcode的API簡單直觀,只需幾行代碼即可創建和掃描條碼。 另一方面,ZXing的API對於初學者來說可能很複雜和難以使用。
  3. 輸出質量:IronBarcode生成的條碼高質量,易於閱讀,即使在小尺寸下也如此。 相比之下,ZXing的條碼有時在較小的尺寸下可能難以閱讀。
  4. 支持的格式:IronBarcode支持廣泛的條碼格式,包括UPC-A、2D條碼等。 相比之下,ZXing項目僅支持有限的條碼格式。
  5. 許可:IronBarcode提供靈活的許可模式,允許開發人員免費使用該庫或根據需要購買許可證。 相比之下,ZXing的許可限制使得開發人員難以在商業項目中使用該庫。

ZXing.org二維碼庫和IronBarcode:全面比較:圖12 - 從多幀TIFF圖像中讀取條碼

IronBarcode在性能、易用性、輸出質量、支持的格式和許可方面是一個優於ZXing的庫。

親自體驗IronBarcode的優勢

使用下面的免費條碼讀取Demo來玩轉IronBarcode的所有功能。

barcode-demo--thumbnail {

位置:相對; 寬度:100%; 高度:450px; 背景圖像:url(/img/freetools/barcode-demo.png); 背景重複:不重複; 背景大小:覆蓋; 光標:指針;

&:hover a.btn-red { 背景:#c9041e; 邊錘:#2a95d5; 盒影:0 0 12px 4px #dee2e2; 文本裝飾:無; }

a.btn.btn-red { 位置:絕對; top: 50%; left: 50%; 字體家族:“Gotham-Medium”; 字體粗細:500; 寬度:280px; 變形:translate(-50%,-50%); } }

IronBarcode還提供免費試用

正在尋找試用IronBarcode,看看如何提高您的條碼掃描和生成能力? 我們很高興為您提供IronBarcode的免費試用,以便您測試其功能和優勢。

在您的試用期內,您將可以完全訪問IronBarcode的所有強大功能,包括支持廣泛的條碼格式、高級自定義選項,以及與現有項目的無縫集成。

要開始試用,只需訪問我們的網站並下載IronBarcode包。 然後,您將有免費試用,以探索IronBarcode的所有功能,親自看看它如何精簡您的條碼掃描和生成工作流程。

[{i:(ZXing 是其各自所有者的註冊商標。 此站點與 ZXing 並無關聯,不由其認可或贊助。 所有產品名稱、徽標和品牌均為其各自所有者的財產。 比較僅供參考,反映撰寫時公開可用的信息。

常見問題解答

使用ZXing進行條碼掃描的限制是什麼?

ZXing是一個受歡迎的開源條碼掃描庫,但集成可能比較複雜,並且可能帶來潛在的安全風險。與像IronBarcode這樣的商業替代品相比,它的格式支持也有限。

如何在.NET中解碼QR碼?

您可以在.NET中使用IronBarcode的BarcodeReader類來解碼QR碼,這提供了一個簡單的API來讀取和解釋條碼圖像。

使用IronBarcode的好處是什麼?

IronBarcode為用戶提供了更友好的體驗,具有更快的性能、更廣泛的格式支持,包括對Data Matrix和PDF417的支持,以及增強的條碼外觀自定義選項。

如何讓.NET開發人員生成具有定制外觀的條碼?

使用IronBarcode,開發人員可以透過其靈活的API自定義條碼,例如調整大小、設置邊距、改變顏色、添加標題,以及在條碼上覆蓋圖像或標誌。

是什麼讓IronBarcode成為.NET開發人員的多功能工具?

IronBarcode支持多個平台,無需第三方依賴,提供了一個強大的工具集,用於條碼生成和掃描,包括廣泛的自定義選項和格式選擇。

如何將條碼庫整合到.NET應用程序中?

要將IronBarcode集成到.NET應用程序中,請通過NuGet安裝它,並使用其API高效生成和掃描條碼,所需設置非常少。

我可以在購買前嘗試IronBarcode嗎?

是的,您可以從Iron Software網站下載IronBarcode的免費試用版,在試用期間可以完全訪問其功能。

商業條碼庫的優勢是什麼?

像IronBarcode這樣的商業條碼庫提供更好的性能、易用性、較高的輸出質量、更廣泛的格式支持和比開源替代品更靈活的許可。

Jordi Bardia
軟體工程師
Jordi 在 Python、C# 和 C++ 上最得心應手,當他不在 Iron Software 展現技術時,便在做遊戲編程。在分担产品测测试,产品开发和研究的责任时,Jordi 为持续的产品改进增值。他说这种多样化的经验使他受到挑战并保持参与, 而这也是他与 Iron Software 中工作一大乐趣。Jordi 在佛罗里达州迈阿密长大,曾在佛罗里达大学学习计算机科学和统计学。