跳至页脚内容
与其他组件比较

ZXing.org QR Code Library and IronBarcode: A Comprehensive Comparison

如果您已经有了技术电话/管理电话中的条形码电子图像,并且想要将其解读为英文文本数据,那么条形码扫描器可能不是最佳工具。 此外,条形码扫描器只能读取一维条形码,其存储容量、域状态、支持的格式均受到限制,并且只能与 Windows RT 类库一起使用。 如今,二维条形码(也称为二维码)更加常见,并且可以存储更多信息,例如更新日期。

条形码扫描应用程序可以在 Windows、MacOS 或 Linux 上运行,无需依赖任何第三方工具或 API,因为它由 .NET 支持。

ZXing.org 二维码库和 IronBarcode:全面比较:图 2 - Web 应用程序

创建和扫描条形码已成为许多企业避免垃圾邮件的必要手段。 创建条形码的两种常用工具是开源的 ZXing 项目 decode 和IronBarcode 。 在本文中,我们将探讨这些工具各自的特点和优势,并对它们进行比较。

ZXing解码器

ZXing是一个流行的开源库,用于生成和解码一维和二维条形码。

它还支持多种编程语言,包括 Java、C++ 和 .NET。

ZXing Decoder Online 是一款基于网络的工具,使用户能够扫描和解码条形码和二维码图像。 此外,用户可以为任何信息创建二维码,这些信息通常以 URL 或他们想要编码的文本的形式存在。

要使用ZXing在线解码器,请按照以下步骤操作:

  1. 访问 ZXing 解码器在线网站。

ZXing.org 二维码库和 IronBarcode:全面对比:图 2 - ZXing Web 由 Google 开发

  1. 点击"选择文件"按钮,选择二维码图像文件。
  2. 选择图片后,点击"提交"按钮。

ZXing.org 二维码库与 IronBarcode:全面对比:图 3 - ZXing 解码

  1. 如果找到可识别的代码,该工具将解码二维码并显示结果信息。

该库易于使用,可以集成到 Web 应用程序、移动应用程序和桌面应用程序中。

ZXing 已被广泛采用,并拥有庞大的开发者社区,他们为 ZXing 的开发做出贡献并提供支持。

该库会收集设备信息,例如设备型号和操作系统版本,这可能被视为潜在的安全风险。

此外,一些人对图书馆的所有权和控制权表示担忧,因为它并非由独立组织维护。

总的来说,ZXing 是一个功能强大且用途广泛的条形码生成和解码库,得到了广泛的应用和社区支持。

例如,要使用 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!");
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 项目解码二维码,开发者可以使用以下代码:

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 - 二维码生成器

ZXing.org 二维码库与 IronBarcode:全面对比:图 5 - 二维码文件显示

介绍IronBarcode

IronBarcode 是由 Iron Software 开发的面向 .NET 开发人员的强大条形码生成和扫描库。

IronBarcode提供了一个易于使用的 API,允许开发人员生成和扫描各种条形码类型,包括二维码、数据矩阵码和 UPC-A 条形码。

IronBarcode 库是由 Iron Software 创建的,目的是扩展ZXing.NET库的功能。

ZXing.org 二维码库和 IronBarcode:全面对比:图 6 - 支持的条形码格式

它增加了新的特性和功能,例如生成二维条形码、PDF417 条形码以及直接从图像文件中读取条形码的功能。

以下是使用 IronBarcode 生成二维码的示例:

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 - 二维码

要使用 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支持多种条码类型,包括二维条码、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!"的二维码,并将其保存为名为"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"中读取二维码,并返回条形码中编码的文本。

ZXing.org 二维码库和 IronBarcode:全面对比:图 9 - 扫描条形码

步骤 4:自定义条形码

IronBarcode 提供了一系列自定义选项,允许您控制生成的条形码扫描实现的外观和行为。

以下是如何使用 IronBarcode 自定义二维码以实现条形码扫描的示例:

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!"的二维码,并通过将其大小调整为 400x400 像素、添加 20 像素边距、将前景色设置为黑色、将背景色设置为白色、在条形码上方添加标题以及添加徽标图像来对其进行自定义。

IronBarcode 能做什么

IronBarcode 构建于开源 ZXing 库之上,但它扩展了其功能,以支持更广泛的条形码类型,包括 QR 码、Code 128、Code 39、EAN-13、EAN-8、UPC-A 等等。

以下是IronBarcode的一些功能:

生成条形码

IronBarcode可以轻松生成各种类型和样式的条形码,包括一维条形码和二维条形码,并具有颜色、文本和图像叠加等可自定义功能。 以下代码片段用于生成二维码:

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 和实时摄像头流中的条形码。 以下代码从图像文件中读取二维码:

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 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");
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 在线解码器有哪些优势?

以下是IronBarcode比ZXing更胜一筹的一些方面:

1.性能: IronBarcode 比 ZXing 速度更快,因此对于需要高速条形码扫描和生成的 Web 应用程序来说,它是一个绝佳的选择。 2.易用性: IronBarcode 的 API 简单直观,只需几行代码即可轻松创建和扫描条形码。 另一方面,ZXing 的 API 对于初学者来说可能比较复杂和难以使用。 3.输出质量: IronBarcode 生产的条形码质量高,即使尺寸很小也易于读取。 相比之下,ZXing 的条形码有时难以辨认,尤其是在尺寸较小时。 4.支持的格式: IronBarcode 支持多种条形码格式,包括 UPC-A、二维条形码等。 相比之下,ZXing 项目仅支持有限数量的条形码格式。 5.许可: IronBarcode 提供灵活的许可模式,允许开发人员根据自身需求免费使用该库或购买许可证。 相比之下,ZXing 的许可限制较多,使得开发者难以在商业项目中使用该库。

ZXing.org 二维码库和 IronBarcode:全面比较:图 12 - 从多帧 TIFF 图像中读取条形码

在性能、易用性、输出质量、支持的格式和许可方面,IronBarcode 都是比 ZXing 更优秀的库。

亲眼见证 IronBarcode 的卓越性能

使用下面的免费条形码读取演示版,体验 IronBarcode 的所有功能。

IronBarcode 也提供免费试用。

想试用 IronBarcode,看看它如何增强您的条形码扫描和生成能力吗? 我们很高兴为您提供 IronBarcode 的免费试用版,让您体验其功能和优势。

在试用期内,您将可以完全访问 IronBarcode 的所有强大功能,包括支持各种条形码格式、高级自定义选项以及与您现有项目的无缝集成。

要开始试用,只需访问我们的网站并下载 IronBarcode 软件包即可。 然后您将获得免费试用机会,探索 IronBarcode 的所有功能,并亲眼见证它如何简化您的条形码扫描和生成工作流程。

请注意ZXing 是其各自所有者的注册商标。 本网站与 ZXing 无任何关联,亦未获得 ZXing 的认可或赞助。 所有产品名称、徽标和品牌均为各自所有者的财产。 比较仅供参考,反映的是撰写时的公开信息。

常见问题解答

使用ZXing进行条形码扫描有什么限制?

ZXing是一个流行的开源条形码扫描库,但它可能难以集成,并可能带来潜在的安全风险。与IronBarcode等商业替代品相比,其格式支持也有限。

如何在.NET中解码QR码?

你可以使用IronBarcode的BarcodeReader类在.NET中解码QR码,该类提供了一种简单的API来读取和解释条形码图像。

使用IronBarcode而不是ZXing有什么好处?

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