与其他组件比较

ZXing解码器与IronBarcode的比较

发布 2023年三月17日
分享:

条形码无处不在。作者使用条形码扫描实现对其产品进行签名,而大多数图书签名都是通过条形码扫描实现的。不过,对于我们的应用来说,条形码扫描仪并不总是合适的。您可能拥有条形码的数字图像和视频,并希望知道它们在英文文本中的含义。此外,条形码扫描仪只能读取一维条形码,这种条形码只能在 Windows RT 类库中使用,而且数据量有限。二维条形码(也称为 QR 码)如今已被广泛使用,其数据矩阵中可存储更多数据。

ZXing (斑马线) 是一个开源的多格式一维/二维条形码图像处理库,用 Java 实现,并可移植到其他语言。它可以读写多种不同条形码格式的数据,包括计算机上的 QR 码和 UPC 码。

IronBarcode 是一个 C# .NET 软件库,允许开发人员使用 ZXing 库读写条形码图像,用于网络应用程序测试。其设计简单易用,易于集成到任何 .NET 应用程序中,可与 Windows 窗体、WPF 和 ASP.NET 框架一起使用。

IronBarcode 库为读写条形码图像提供了一个简单的应用程序接口(API),使开发人员可以轻松地在其软件中添加条形码扫描和生成功能。IronBarcode 支持读写多种不同的条形码格式,包括 QR 码、UPC 码、UPC-A 码、EAN 码、RSS 扩展码等,这些条形码可用于标识产品。

A Comparison Between IronBarcode and ZXing .NET, Figure 1: 支持的条码格式

支持的条码格式

该程序库拥有精心编写的文档和示例代码,展示了如何开始使用 IronBarcode、如何扫描和解码条形码、如何生成和编码条形码以及如何自定义读写过程。

IronBarcode 最重要的功能之一是支持从 PDF 文档或图像文件中识别条形码和 QR 码,并能从文件路径或位图对象中读取条形码。

IronBarcode 易于使用、功能强大且速度极快。对于需要在其软件中添加条形码扫描或生成功能的人来说,它是一款绝佳的工具。由于它是建立在广受欢迎且可靠的 ZXing 库之上,因此您可以确信它是一个可靠且高质量的解决方案。

IronBarcode 和 ZXing .NET 的比较,图 2:支持的条形码格式

IronBarcode C# 库及其功能

IronBarcode 是如何从 ZXing 解码器创建的

IronBarcode 是一个商业第三方 .NET 库,用于在 C# 和 VB.NET 中解码条形码,它使用开源的 ZXing 库作为底层引擎。该库为处理条形码提供了简化、易用的 API,还提供了其他功能,如从图像和 PDF 中读取条形码,以及创建各种格式的条形码。

IronBarcode是由一个开发团队创建的,他们希望为.NET生态系统创建一个用户更友好、功能更丰富的条形码解码库。他们利用 ZXing 库作为库的基础,ZXing 库是一个成熟的开源库,支持多种条码格式。然后,他们在 ZXing 代码库的基础上建立了自己的定制封装,为开发人员提供了更简单、更一致的 API,并提供了更多的功能,如支持从图像和 PDF 中读取条形码。

IronBarcode 与 ZXing 解码器的比较

IronBarcode 和 ZXing 都是用于解码条码图像的库,但它们有一些重要的区别,这使得 IronBarcode 成为更先进、更多功能的选择。

与 ZXing 相比,IronBarcode 支持更多的 Web 条码格式。IronBarcode 可以解码支持的格式,如 QR 码、Code 39、Code 128、EAN -8、EAN -13、UPC-A、UPC-E、Codabar、ITF、Data Matrix、PDF-417、RSS 扩展等。安卓用户也不例外;IronBarcode 可以轻松集成到移动应用程序中,使安卓用户的条形码扫描变得更加容易。ZXing 支持许多相同的格式,但不完全支持某些格式,如 ITF 和 Codabar,也不支持某些二维条形码格式,如 PDF-417。

// Generate a Simple BarCode image and save as PDF
QRCodeWriter.CreateQrCode("hello world", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium).SaveAsPng("MyQR.png");
// Generate a Simple BarCode image and save as PDF
QRCodeWriter.CreateQrCode("hello world", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium).SaveAsPng("MyQR.png");
' Generate a Simple BarCode image and save as PDF
QRCodeWriter.CreateQrCode("hello world", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium).SaveAsPng("MyQR.png")
VB   C#
IronBarcode 和 ZXing .NET 的比较,图 3:生成条形码

使用 IronBarcode 生成简单的 QR 码图像

IronBarcode 的另一个优点是其网络 API 更方便用户使用。该库的设计简单易用,易于集成到现有项目中,其高级 Web API 抽象了条码解码的许多复杂细节。

IronBarcode 的性能也优于 ZXing。该库是用 C# 开发的,能够使用并行处理,解码条形码的速度比 ZXing 库更快。此外,IronBarcode 还能从 ZXing 不支持的图像文件类型中读取条形码,如 GIF、TIFF 和 JPEG-XR。

IronBarcode 和 ZXing .NET 的比较,图 4:生成条形码

使用 IronBarcode 生成简单的 QR 码图像

总之,IronBarcode 是一款比 ZXing 更先进、功能更全面的条码解码库。它支持的条形码格式范围更广,API 更友好,性能更好,是使用 .NET 框架的开发人员的最佳选择。

如何在 C&num 中使用 ZXing 解码器和 IronBarcode;

ZXing .NET 是 ZXing 库的移植版本,ZXing 库是一个用于处理多种格式的一维/二维条形码的开源库,最初用 Java 实现。它已被移植到 C# 中,可通过 NuGet 软件包管理器获取。IronBarcode 是一个可以读写条形码的 C# .NET 库。它是 ZXing 库的包装器,也可通过 NuGet 获取。

在本教程中,我们将在 C# .NET Web 应用程序中使用 ZXing 在线解码器和 IronBarcode 来解码条形码。本教程将使用 Visual Studio,但其概念应适用于任何 C# 开发环境。

步骤 1:在 Visual Studio 中创建一个新的 C# .NET 项目

通过文件 > 新建 > 项目,在 Visual Studio 中创建一个新的 C# 项目。选择 "Windows 窗体应用程序 "并为项目命名。

步骤 2:安装 ZXing .NET 和 IronBarcode NuGet 软件包

在解决方案资源管理器中,右键单击项目并选择 "管理 NuGet 包"。搜索 ZXing.NET 和 "IronBarcode",并将它们安装到项目中。

步骤 3:在表单中添加 PictureBox 和按钮

在表单的设计视图中,为表单添加一个 "PictureBox "和一个 "Button"。PictureBox "将用于显示我们要解码的图像,"Button "将用于启动解码过程。

步骤 4:在表单代码的顶部添加以下 using 语句:

using IronBarCode;
using ZXing;
using IronBarCode;
using ZXing;
Imports IronBarCode
Imports ZXing
VB   C#

步骤 5:处理按钮的点击事件

在设计视图中双击按钮,创建一个单击事件处理程序。在处理程序中,添加以下代码以打开 "OpenFileDialog "并让用户选择要解码的图像:

private void button1_Click(object sender, EventArgs e) {
    OpenFileDialog ofd = new OpenFileDialog();
    ofd.Filter = "Images (*.BMP;*.JPG;*.GIF;*.PNG)
*.BMP;*.JPG;*.GIF;*.PNG
All files (*.*)
*.*";
    ofd.FilterIndex = 1;
    if (ofd.ShowDialog() == DialogResult.OK) {
        pictureBox1.Image = Image.FromFile(ofd.FileName);
        // Decode the barcode from the image here
    }
}
private void button1_Click(object sender, EventArgs e) {
    OpenFileDialog ofd = new OpenFileDialog();
    ofd.Filter = "Images (*.BMP;*.JPG;*.GIF;*.PNG)
*.BMP;*.JPG;*.GIF;*.PNG
All files (*.*)
*.*";
    ofd.FilterIndex = 1;
    if (ofd.ShowDialog() == DialogResult.OK) {
        pictureBox1.Image = Image.FromFile(ofd.FileName);
        // Decode the barcode from the image here
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
VB   C#

第 6 步: 从图像中解码条形码

在以下一行之后

pictureBox1.Image = Image.FromFile(ofd.FileName); 
pictureBox1.Image = Image.FromFile(ofd.FileName); 
pictureBox1.Image = Image.FromFile(ofd.FileName)
VB   C#

在按钮单击事件处理程序中添加以下代码块,从图像中解码条形码。

var BarcodeReader = new BarcodeReader();
var Result = BarcodeReader.Decode((Bitmap)pictureBox1.Image);
if (Result != null) {
    MessageBox.Show(Result.Text);
} else {
    MessageBox.Show("No barcode found.");
}
var BarcodeReader = new BarcodeReader();
var Result = BarcodeReader.Decode((Bitmap)pictureBox1.Image);
if (Result != null) {
    MessageBox.Show(Result.Text);
} else {
    MessageBox.Show("No barcode found.");
}
Dim BarcodeReader As New BarcodeReader()
Dim Result = BarcodeReader.Decode(CType(pictureBox1.Image, Bitmap))
If Result IsNot Nothing Then
	MessageBox.Show(Result.Text)
Else
	MessageBox.Show("No barcode found.")
End If
VB   C#

此代码从 ZXing.NET 中创建一个新的 BarcodeReader 类实例,然后使用 Decode 方法从图像中解码条形码。Decode "方法会返回一个 "Result "对象,其中包含已解码条形码的相关信息。

A Comparison Between IronBarcode and ZXing .NET, Figure 5: 用徽标图像创建 QR 码

用徽标图像创建 QR 码

IronBarcode 与 ZXIng 在线解码器相比的优势

IronBarcode 和 ZXing 都是 C# 编程语言的条形码和二维码读取库。这两个库各有优缺点,如何选择取决于您项目的具体要求。

与 ZXing 相比,IronBarcode 的主要优势之一是其易用性。IronBarcode 拥有简单直观的应用程序接口(API),使开发人员能够轻松快速地开始使用条形码和二维码。只需几行代码,您就可以轻松读写条形码和二维码。相比之下,ZXing 的应用程序接口更为复杂,对开发人员(尤其是刚开始读取条形码和二维码的开发人员)来说具有挑战性。

IronBarcode 的另一个优势是其高性能。IronBarcode 使用先进的算法来快速读取和解码条形码和二维码,因此比 ZXing 等其他程序库更快。因此,对于需要快速扫描和解码条形码和二维码的项目来说,IronBarcode 是一个不错的选择。

IronBarcode 还能更好地支持各种图像格式的条形码读写,包括 JPEG、PNG、GIF、BMP 和 TIFF。相比之下,ZXing 对图像格式的支持较为有限,可能无法从某些类型的图像中读取或写入条形码。

using IronBarCode;
using System;
using System.Drawing;
// All BarcodeResult.Read methods provide the developer with control to correct image and photograph correction and straightening rotation and perspective from skewed images
// * RotationCorrection   e.g BarcodeReader.BarcodeRotationCorrection.Extreme  un-rotates and removes perspective from barcode images.
// * ImageCorrection      e.g BarcodeReader.BarcodeImageCorrection.DeepCleanPixels  separates Barcodes from background imagery and digital noise.
// * BarcodeEncoding      e.g. BarcodeEncoding.Code128  Setting a specific Barcode format improves speed and reduces the risk of false positive results
// Example with a photo image
var PhotoResult = BarcodeReader.ReadASingleBarcode("Photo.png", BarcodeEncoding.Code128, BarcodeReader.BarcodeRotationCorrection.Medium, BarcodeReader.BarcodeImageCorrection.DeepCleanPixels);
string Value = PhotoResult.Value;
System.Drawing.Bitmap Img = PhotoResult.BarcodeImage;
BarcodeEncoding BarcodeType = PhotoResult.BarcodeType;
byte [] Binary = PhotoResult.BinaryValue;
Console.WriteLine(PhotoResult.Value);  
using IronBarCode;
using System;
using System.Drawing;
// All BarcodeResult.Read methods provide the developer with control to correct image and photograph correction and straightening rotation and perspective from skewed images
// * RotationCorrection   e.g BarcodeReader.BarcodeRotationCorrection.Extreme  un-rotates and removes perspective from barcode images.
// * ImageCorrection      e.g BarcodeReader.BarcodeImageCorrection.DeepCleanPixels  separates Barcodes from background imagery and digital noise.
// * BarcodeEncoding      e.g. BarcodeEncoding.Code128  Setting a specific Barcode format improves speed and reduces the risk of false positive results
// Example with a photo image
var PhotoResult = BarcodeReader.ReadASingleBarcode("Photo.png", BarcodeEncoding.Code128, BarcodeReader.BarcodeRotationCorrection.Medium, BarcodeReader.BarcodeImageCorrection.DeepCleanPixels);
string Value = PhotoResult.Value;
System.Drawing.Bitmap Img = PhotoResult.BarcodeImage;
BarcodeEncoding BarcodeType = PhotoResult.BarcodeType;
byte [] Binary = PhotoResult.BinaryValue;
Console.WriteLine(PhotoResult.Value);  
Imports IronBarCode
Imports System
Imports System.Drawing
' All BarcodeResult.Read methods provide the developer with control to correct image and photograph correction and straightening rotation and perspective from skewed images
' * RotationCorrection   e.g BarcodeReader.BarcodeRotationCorrection.Extreme  un-rotates and removes perspective from barcode images.
' * ImageCorrection      e.g BarcodeReader.BarcodeImageCorrection.DeepCleanPixels  separates Barcodes from background imagery and digital noise.
' * BarcodeEncoding      e.g. BarcodeEncoding.Code128  Setting a specific Barcode format improves speed and reduces the risk of false positive results
' Example with a photo image
Private PhotoResult = BarcodeReader.ReadASingleBarcode("Photo.png", BarcodeEncoding.Code128, BarcodeReader.BarcodeRotationCorrection.Medium, BarcodeReader.BarcodeImageCorrection.DeepCleanPixels)
Private Value As String = PhotoResult.Value
Private Img As System.Drawing.Bitmap = PhotoResult.BarcodeImage
Private BarcodeType As BarcodeEncoding = PhotoResult.BarcodeType
Private Binary() As Byte = PhotoResult.BinaryValue
Console.WriteLine(PhotoResult.Value)
VB   C#
IronBarcode 和 ZXing .NET 的比较,图 6:用 C# 从手机摄像头读取条形码

用 C# 从手机摄像头图像读取条形码

IronBarcode 提供了更多的自定义选项,如微调条形码读取、支持多页文档和各种条形码格式,如 DataMatrix、Aztec 和 PDF-417。如果您需要处理不同类型的条形码或有特殊要求,这将非常有用。

另一方面,ZXing 是一个开源库,可以免费使用。对于预算有限的项目来说,这可能是一大优势。

总之,IronBarcode 和 ZXing 都是在 C# 中处理条形码和二维码的功能强大的库,但 IronBarcode 比 ZXing 有几个优势,如易用性、高性能、更好的图像格式支持和更多的自定义选项。最好对这两个库进行评估,然后选择最适合您项目需求的一个。

IronBarcode 和 ZXing 都是在 C# 中处理条形码和二维码的流行库。这两个库各有优缺点,如何选择取决于项目的具体要求。在本文中,我们将详细介绍使用 IronBarcode 相对于 ZXing 的优势,并通过示例帮助说明两者的主要区别。

IronBarcode 的主要优势之一是易于使用。IronBarcode 拥有简单直观的应用程序接口(API),开发人员可以轻松快速地开始使用条形码和 QR 码。只需几行代码,您就可以轻松读写条形码和 QR 码。例如,要使用 IronBarcode 从图像文件中读取条形码,您可以使用以下代码:

var reader = new BarcodeReader();
var result = reader.Read("image.jpg");
Console.WriteLine(result.Text);
var reader = new BarcodeReader();
var result = reader.Read("image.jpg");
Console.WriteLine(result.Text);
Dim reader = New BarcodeReader()
Dim result = reader.Read("image.jpg")
Console.WriteLine(result.Text)
VB   C#

相比之下,ZXing 的应用程序接口更为复杂,对于开发人员来说,尤其是条形码和 QR 码读取方面的新手来说,使用起来可能具有挑战性。如果使用 ZXing,上面提供的示例需要更多行代码才能实现同样的结果。

IronBarcode 的另一个优势是其高性能。IronBarcode 使用先进的算法来快速读取和解码条形码和二维码,因此比 ZXing 等其他程序库更快。因此,对于需要高速扫描和解码条形码和二维码的项目来说,IronBarcode 是一个不错的选择。例如,IronBarcode 可在一秒钟内从图像中读取并解码条形码,是大规模扫描和解码操作的理想选择。

IronBarcode 还能更好地支持从各种图像格式中读写条形码,包括 JPEG、PNG、GIF、BMP 和 TIFF。这样,开发人员就可以轻松处理不同图像格式的条形码,而不必担心兼容性问题。相比之下,ZXing 对图像格式的支持较为有限,可能无法从某些类型的图像中读取或写入条形码。

using IronBarCode;
using System;
using System.Drawing;
// Multiple barcodes may be scanned up from a single document or image.  A PDF document may also used as the input image
PagedBarcodeResult [] PDFResults = BarcodeReader.ReadBarcodesFromPdf("MultipleBarcodes.pdf");
// Work with the results
foreach (var PageResult in PDFResults)
{
    string Value = PageResult.Value;
    int PageNum = PageResult.PageNumber;
    System.Drawing.Bitmap Img = PageResult.BarcodeImage;
    BarcodeEncoding BarcodeType = PageResult.BarcodeType;
    byte [] Binary = PageResult.BinaryValue;
    Console.WriteLine(PageResult.Value + " on page " + PageNum);
}     
using IronBarCode;
using System;
using System.Drawing;
// Multiple barcodes may be scanned up from a single document or image.  A PDF document may also used as the input image
PagedBarcodeResult [] PDFResults = BarcodeReader.ReadBarcodesFromPdf("MultipleBarcodes.pdf");
// Work with the results
foreach (var PageResult in PDFResults)
{
    string Value = PageResult.Value;
    int PageNum = PageResult.PageNumber;
    System.Drawing.Bitmap Img = PageResult.BarcodeImage;
    BarcodeEncoding BarcodeType = PageResult.BarcodeType;
    byte [] Binary = PageResult.BinaryValue;
    Console.WriteLine(PageResult.Value + " on page " + PageNum);
}     
Imports IronBarCode
Imports System
Imports System.Drawing
' Multiple barcodes may be scanned up from a single document or image.  A PDF document may also used as the input image
Private PDFResults() As PagedBarcodeResult = BarcodeReader.ReadBarcodesFromPdf("MultipleBarcodes.pdf")
' Work with the results
For Each PageResult In PDFResults
	Dim Value As String = PageResult.Value
	Dim PageNum As Integer = PageResult.PageNumber
	Dim Img As System.Drawing.Bitmap = PageResult.BarcodeImage
	Dim BarcodeType As BarcodeEncoding = PageResult.BarcodeType
	Dim Binary() As Byte = PageResult.BinaryValue
	Console.WriteLine(PageResult.Value & " on page " & PageNum)
Next PageResult
VB   C#
A Comparison Between IronBarcode and ZXing .NET, Figure 7: 从多帧 TIFF 图像中读取条形码

从多帧 TIFF 图像中读取条形码

IronBarcode 还提供更多的自定义选项,允许开发人员对条形码读取过程进行微调,以满足他们的特定需求。例如,您可以使用 IronBarcode 指定不同的条形码格式,如 DataMatrix、Aztec 和 PDF-417。如果您需要处理不同格式或有特定要求的条形码,这将非常有用。此外,IronBarcode 支持多页文档,允许开发人员从文档的多页中读取和提取条形码信息。

此外,IronBarcode 的错误处理能力更强,更适合企业级应用。

下面是如何从图像文件中解码多个条形码的示例:

var barcodeResults = IronBarCode.BarcodeReader.ReadMultiple("multibarcode.png");
foreach (var result in barcodeResults)
{
    Console.WriteLine(result.Text);
}
var barcodeResults = IronBarCode.BarcodeReader.ReadMultiple("multibarcode.png");
foreach (var result in barcodeResults)
{
    Console.WriteLine(result.Text);
}
Dim barcodeResults = IronBarCode.BarcodeReader.ReadMultiple("multibarcode.png")
For Each result In barcodeResults
	Console.WriteLine(result.Text)
Next result
VB   C#

另一方面,ZXing 是一个开源库,可以免费使用。对于预算有限的项目来说,这可能是一个很大的优势。不过,需要注意的是,使用 IronBarcode 的成本可能会被使用更友好、功能更强大的库所节省的时间和精力所抵消。

IronBarcode 与 ZXing .NET 的比较,图 8:从多帧 TIFF 图像中读取条码

使用 C# 创建带注释和样式的条形码图像

总之,IronBarcode 和 ZXing 都是在 C# 中处理条形码和二维码的强大库。然而,与 ZXing 相比,IronBarcode 具有许多优势,例如易用性、高性能、对图像格式的更好支持以及更多的自定义选项。如果您的项目需要快速高效的条形码扫描和解码,或者您需要对条形码读取过程进行更多的控制,那么 IronBarcode 将是您的最佳选择。

定价和许可

ZXing 根据 Apache 2.0 开放源码许可证发布,这意味着它可以被自由使用、分发和修改。在软件项目中使用该库无需任何费用。但是,如果在商业产品中使用该库,则必须遵守 Apache 2.0 许可证的条款,包括在显著位置显示许可证通知和免责声明。

IronBarcode 软件提供免费的开发者许可证。Lite套餐的起价为"$liteLicense",包括永久许可证、在开发、暂存和生产环境中使用软件的能力、30天退款保证以及一年的软件支持和升级。有关IronBarcode定价和许可的更多信息,请访问公司网站。

IronBarcode 与 ZXing .NET 的比较,图 9:从多帧 TIFF 图像中读取条码

IronBarcode 许可证价格

为什么选择 IronBarcode

IronBarcode 是专为 .NET 应用程序开发的,基于 ZXing 库。IronBarcode 完全由 C# 编写,如果您的应用程序也是由 C# 编写,并且您想在 .NET 生态系统中使用它,这将是一个优势。

IronBarcode 的目标是为条形码的解码和编码提供更友好、更易用的界面,而 ZXing 则主要侧重于提供底层算法和库。

IronBarcode 在 ZXing 库的基础上提供了一些附加功能,如自动纠正常见扫描错误的能力、支持不同类型的条形码读取和扫描,以及直接从图像文件或位图读取条形码内容的能力。

总之,如果您的应用程序是用 C# 编写的,并且您正在寻找一个简单易用、功能强大且能读写各种条形码格式的库,那么 IronBarcode 不失为一个不错的选择。但是,如果您正在寻找一种通用性更强、可用于多种语言的低级库,ZXing 可能是更好的选择。

结论

总之,IronBarcode 是一款灵活高效的软件库,支持多种条码格式、符号和字符。它与各种操作系统兼容,并提供可靠的许可和支持。

IronBarcode 和 ZXing 都是 .NET Framework 中用于读写条形码的库。IronBarcode 将 ZXing 库作为执行条形码读写操作的依赖库。IronBarcode 为在 C# 和 VB.NET 中读写条形码提供了一个简单易用的 API,而 ZXing 则是一个底层库,具有很大的灵活性和定制性。IronBarcode 使用 ZXing 执行底层条码处理和解码,但为开发人员提供了更简单、更方便的界面。

IronBarcode 是 ZXing 库的一个 C# / VB.NET 封装器,这意味着它为 ZXing 提供的功能提供了一个 C# / VB.NET 接口。IronBarcode 通过提供更方便、更简单的 API 来读写条形码,从而促进 ZXing 的使用。

与 ZXing.NET 相比,IronBarcode 在条形码识别和生成方面提供了更多的功能和更快的处理时间,并增加了从各种图像格式和 PDF 文档中读取条形码的功能。

IronBarcode 和 ZXing .NET 的比较,图 10:Iron 套件价格

铁套房许可价格

此外,IronBarcode 还可免费用于早期开发,并提供以下服务 免费试用 用于商业用途。通过不同的定价层级,开发人员可以选择最适合自己需求和预算的解决方案。此外,还提供以 2 的价格购买 5 套 Iron 软件产品的优惠。总体而言,IronBarcode 与 ZXing.NET 相比具有明显的优势

< 前一页
IronBarcode & QrCoder C#之间的比较
下一步 >
IronBarcode和ZXing.NET的比较

准备开始了吗? 版本: 2024.8 刚刚发布

免费NuGet下载 总下载量: 1,167,541 查看许可证 >