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

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

如果您已經擁有技術電話/管理電話中條碼的電子影像,並希望將其解碼為英文文本數據,則條碼掃描器可能不是最佳工具。 此外,條碼掃描器僅限於讀取儲存容量有限的1D條碼、域狀態、支持的格式,並只能與Windows RT Class程式庫一起使用。 如今,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 Web](/static-assets/barcode/blog/zxing-org-comparison/zxing-org-comparison-2.webp)

2.點擊"選擇文件"按鈕選擇一個QR碼影像文件。 3.選擇影像後,點擊"提交"按鈕。

![ZXing.org QR Code Library和IronBarcode:全面比較:圖3 - ZXing解碼](/static-assets/barcode/blog/zxing-org-comparison/zxing-org-comparison-3.webp)

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!");
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!");
$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;
$vbLabelText   $csharpLabel

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");
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");
$vbLabelText   $csharpLabel

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;
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;
$vbLabelText   $csharpLabel

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程式包管理器控制台中運行以下命令來完成此操作:

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");
$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;
$vbLabelText   $csharpLabel

這段代碼從圖像文件"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
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
$vbLabelText   $csharpLabel

這段代碼生成一個帶有"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");
var barcode = IronBarCode.BarcodeWriter.CreateBarcode("Hello World!", IronBarCode.BarcodeWriterEncoding.QRCode);
barcode.SaveAsJpeg("QRCode.jpg");
$vbLabelText   $csharpLabel

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);
var barcode = IronBarCode.BarcodeReader.Read("QRCode.jpg", IronBarCode.BarcodeReaderEncoding.QRCode);
Console.WriteLine(barcode.Text);
$vbLabelText   $csharpLabel

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.");
}
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.");
}
$vbLabelText   $csharpLabel

轉換條碼

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");
var barcode = IronBarCode.BarcodeReader.Read("Code39.jpg", IronBarCode.BarcodeReaderEncoding.Code39);
var qrCode = IronBarCode.BarcodeWriter.CreateBarcode(barcode.Text, IronBarCode.BarcodeWriterEncoding.QRCode);
qrCode.SaveAsJpeg("QRCode.jpg");
$vbLabelText   $csharpLabel

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無關,不受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 在佛罗里达州迈阿密长大,曾在佛罗里达大学学习计算机科学和统计学。

鋼鐵支援團隊

我們每週 5 天,每天 24 小時在線上。
聊天
電子郵件
打電話給我