跳至頁尾內容
與其他組件的比較
IronBarcode 與 ZXing.NET 庫的比較

LEADTOOLS Barcode對比IronBarcode:企業比較指南

條碼掃描儀可能並不總是適合我們的應用程式。 您可能已經擁有條碼的數字圖像,並希望知道它在英文文字中代表什麼。 此外,這個掃描儀僅能讀取1D條碼,這些條碼包含資料量有限,且僅能在Windows RT Class程式庫中使用。 2D條碼(也稱為QR碼)現在很常見,可以容納更多的資訊。

可以建立一個基於C#的應用程式來使用簡單的API調用和一些編程步驟讀取條碼。 .NET支持的應用程式可以在Windows、macOS或Linux上運行,而無需依賴任何第三方工具或API。

本文將比較兩個功能最強大的.NET Core應用程式庫,用於以編程方式讀取條碼。 這兩個程式庫是IronBarcode和ZXing.NET。 我們將看到什麼使IronBarcode比ZXing.NET更強大和穩健。


什麼是ZXing.NET

ZXing.NET是一個解碼和生成條碼的程式庫(如QR碼、PDF 417、EAN、UPC、Aztec、Data Matrix、Codabar)。 ZXing,意思是"斑馬過街",是一個基於Java的開源程式庫,支持多種1D和2D條碼格式。

其基本特徵如下:

  • 能夠儲存URL、聯繫方式、日曆事件等
  • 為Java SE應用程式量身定制
  • 允許通過intent整合條碼掃描儀
  • 是一個簡單的Google Glass應用

什麼是IronBarcode

IronBarcode是一個C#程式庫,允許程式設計師讀取和生成條碼。 作為領先的條碼程式庫,IronBarcode支持多種一維和二維條碼,包括裝飾(彩色和品牌)QR碼。 它支持.NET Standard和Core版本2及更高版本,允許跨平台在Azure、Linux、macOS、Windows和Web上使用。 IronBarcode是.NET系統中一個知名的類程式庫或組件,允許C#、VB.NET和F#開發者使用標準化的編程語言。 它允許客戶瀏覽掃描器標籤並建立新的標準化標籤。 它在處理2D條碼和其他3D標準化條碼時效果非常好。

IronBarcode現在支持2D條碼。 它提供優化這些程式碼的顏色、樣式和像素化的功能,並能夠為其新增標誌,用於列印或廣告材料。 此程式庫還可以讀取傾斜和變形的條碼,這是其他條碼軟體可能無法讀到的。

安裝IronBarcode和ZXing.NET

ZXing.NET的安裝

要使用ZXing.NET程式庫,請在ASP.NET Core應用程式中使用NuGet套件管理器控制台安裝以下兩個套件:

1. ZXing.Net

Install-Package ZXing.Net

2. ZXing.Net.Bindings.CoreCompat.System.Drawing

Install-Package ZXing.Net.Bindings.CoreCompat.System.Drawing -Version 0.16.5-beta

或者,使用NuGet套件管理器將ZXing.NET安裝到您的項目中。 為此,請轉到工具 > NuGet包管理器 > 為解決方案管理NuGet包...,然後切換到"瀏覽"標籤,並搜索"ZXing.NET"。

A Comparison between IronBarcode and Zxing.NET, Figure 1: ASP.NET Web應用程式

ASP.NET Web應用程式

IronBarcode的安裝

使用NuGet套件管理器安裝IronBarcode,或從產品網站直接下載DLL。 IronBarcode命名空間包含所有IronBarcode類。

IronBarcode可以在Visual Studio中使用NuGet套件管理器安裝:套件名稱為"Barcode"。

Install-Package BarCode

建立2D條碼

使用ZXing.NET

首先,在項目文件的根文件夾內建立一個名為'qrr'的新文件夾。

然後我們將建立QR文件,並將圖像系統文件儲存在'qrr'文件夾內。

在控制器中,按照以下顯示的源程式碼新增GenerateFile()方法。

public ActionResult GenerateFile()
{
    return View();
}

[HttpPost]
public ActionResult GenerateFile(string qrText)
{
    Byte [] byteArray;
    var width = 250; // width of the QR Code
    var height = 250; // height of the QR Code
    var margin = 0;

    // BarcodeWriterPixelData acts as a QR code generator
    var qrCodeWriter = new ZXing.BarcodeWriterPixelData
    {
        Format = ZXing.BarcodeFormat.QR_CODE,
        Options = new QrCodeEncodingOptions
        {
            Height = height,
            Width = width,
            Margin = margin
        }
    };
    var pixelData = qrCodeWriter.Write(qrText);

    // creating a PNG bitmap from the raw pixel data; if only black and white colors are used it makes no difference if the raw pixel data is BGRA oriented and the bitmap is initialized with RGB
    using (var bitmap = new System.Drawing.Bitmap(pixelData.Width, pixelData.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb))
    {
        using (var ms = new MemoryStream())
        {
            var bitmapData = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, pixelData.Width, pixelData.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
            try
            {
                // we assume that the row stride of the bitmap is aligned to 4 byte multiplied by the width of the image
                System.Runtime.InteropServices.Marshal.Copy(pixelData.Pixels, 0, bitmapData.Scan0, pixelData.Pixels.Length);
            }
            finally
            {
                bitmap.UnlockBits(bitmapData);
           }

            // Save to folder
            string fileGuid = Guid.NewGuid().ToString().Substring(0, 4);
            bitmap.Save(Server.MapPath("~/qrr") + "/file-" + fileGuid + ".png", System.Drawing.Imaging.ImageFormat.Png);

            // Save to stream as PNG
            bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
            byteArray = ms.ToArray();
        }
    }
    return View(byteArray);
}
public ActionResult GenerateFile()
{
    return View();
}

[HttpPost]
public ActionResult GenerateFile(string qrText)
{
    Byte [] byteArray;
    var width = 250; // width of the QR Code
    var height = 250; // height of the QR Code
    var margin = 0;

    // BarcodeWriterPixelData acts as a QR code generator
    var qrCodeWriter = new ZXing.BarcodeWriterPixelData
    {
        Format = ZXing.BarcodeFormat.QR_CODE,
        Options = new QrCodeEncodingOptions
        {
            Height = height,
            Width = width,
            Margin = margin
        }
    };
    var pixelData = qrCodeWriter.Write(qrText);

    // creating a PNG bitmap from the raw pixel data; if only black and white colors are used it makes no difference if the raw pixel data is BGRA oriented and the bitmap is initialized with RGB
    using (var bitmap = new System.Drawing.Bitmap(pixelData.Width, pixelData.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb))
    {
        using (var ms = new MemoryStream())
        {
            var bitmapData = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, pixelData.Width, pixelData.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
            try
            {
                // we assume that the row stride of the bitmap is aligned to 4 byte multiplied by the width of the image
                System.Runtime.InteropServices.Marshal.Copy(pixelData.Pixels, 0, bitmapData.Scan0, pixelData.Pixels.Length);
            }
            finally
            {
                bitmap.UnlockBits(bitmapData);
           }

            // Save to folder
            string fileGuid = Guid.NewGuid().ToString().Substring(0, 4);
            bitmap.Save(Server.MapPath("~/qrr") + "/file-" + fileGuid + ".png", System.Drawing.Imaging.ImageFormat.Png);

            // Save to stream as PNG
            bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
            byteArray = ms.ToArray();
        }
    }
    return View(byteArray);
}
Public Function GenerateFile() As ActionResult
	Return View()
End Function

<HttpPost>
Public Function GenerateFile(ByVal qrText As String) As ActionResult
	Dim byteArray() As Byte
	Dim width = 250 ' width of the QR Code
	Dim height = 250 ' height of the QR Code
	Dim margin = 0

	' BarcodeWriterPixelData acts as a QR code generator
	Dim qrCodeWriter = New ZXing.BarcodeWriterPixelData With {
		.Format = ZXing.BarcodeFormat.QR_CODE,
		.Options = New QrCodeEncodingOptions With {
			.Height = height,
			.Width = width,
			.Margin = margin
		}
	}
	Dim pixelData = qrCodeWriter.Write(qrText)

	' creating a PNG bitmap from the raw pixel data; if only black and white colors are used it makes no difference if the raw pixel data is BGRA oriented and the bitmap is initialized with RGB
	Using bitmap = New System.Drawing.Bitmap(pixelData.Width, pixelData.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb)
		Using ms = New MemoryStream()
			Dim bitmapData = bitmap.LockBits(New System.Drawing.Rectangle(0, 0, pixelData.Width, pixelData.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb)
			Try
				' we assume that the row stride of the bitmap is aligned to 4 byte multiplied by the width of the image
				System.Runtime.InteropServices.Marshal.Copy(pixelData.Pixels, 0, bitmapData.Scan0, pixelData.Pixels.Length)
			Finally
				bitmap.UnlockBits(bitmapData)
			End Try

			' Save to folder
			Dim fileGuid As String = Guid.NewGuid().ToString().Substring(0, 4)
			bitmap.Save(Server.MapPath("~/qrr") & "/file-" & fileGuid & ".png", System.Drawing.Imaging.ImageFormat.Png)

			' Save to stream as PNG
			bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png)
			byteArray = ms.ToArray()
		End Using
	End Using
	Return View(byteArray)
End Function
$vbLabelText   $csharpLabel

剩下的唯一更改是將QR碼文件保存到'qrr'文件夾中。 這是使用下面的兩行程式碼完成的。

string fileGuid = Guid.NewGuid().ToString().Substring(0, 4);
bitmap.Save(Server.MapPath("~/qrr") + "/file-" + fileGuid + ".png", System.Drawing.Imaging.ImageFormat.Png);
string fileGuid = Guid.NewGuid().ToString().Substring(0, 4);
bitmap.Save(Server.MapPath("~/qrr") + "/file-" + fileGuid + ".png", System.Drawing.Imaging.ImageFormat.Png);
Dim fileGuid As String = Guid.NewGuid().ToString().Substring(0, 4)
bitmap.Save(Server.MapPath("~/qrr") & "/file-" & fileGuid & ".png", System.Drawing.Imaging.ImageFormat.Png)
$vbLabelText   $csharpLabel

接下來,您必須建立GenerateFile視圖,並在其中包含以下程式碼。 GenerateFile視圖與Index視圖相同。

@model Byte []
@using (Html.BeginForm(null, null, FormMethod.Post))
{
    <table>
        <tbody>
            <tr>
                <td>
                    <label>Enter text for creating QR Code</label>
                </td>
                <td>
                <input type="text" name="qrText" />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <button>Submit</button>
                </td>
            </tr>
        </tbody>
    </table>
}
@{
    if (Model != null)
    {
        <h3>QR Code Successfully Generated</h3>
        <img src="@String.Format("data:image/png;base64,{0}", Convert.ToBase64String(Model))" />
    }
}
@model Byte []
@using (Html.BeginForm(null, null, FormMethod.Post))
{
    <table>
        <tbody>
            <tr>
                <td>
                    <label>Enter text for creating QR Code</label>
                </td>
                <td>
                <input type="text" name="qrText" />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <button>Submit</button>
                </td>
            </tr>
        </tbody>
    </table>
}
@{
    if (Model != null)
    {
        <h3>QR Code Successfully Generated</h3>
        <img src="@String.Format("data:image/png;base64,{0}", Convert.ToBase64String(Model))" />
    }
}
model Function [using](Html.BeginForm ByVal As (Nothing, Nothing, FormMethod.Post)) As Byte()
'INSTANT VB WARNING: An assignment within expression was extracted from the following statement:
'ORIGINAL LINE: <table> <tbody> <tr> <td> <label> Enter text for creating QR Code</label> </td> <td> <input type="text" name="qrText" /> </td> </tr> <tr> <td colspan="2"> <button> Submit</button> </td> </tr> </tbody> </table>
	"qrText" /> </td> </tr> (Of tr) <td colspan="2"> (Of button) Submit</button> </td> </tr> </tbody> </table>
'INSTANT VB WARNING: An assignment within expression was extracted from the following statement:
'ORIGINAL LINE: <table> <tbody> <tr> <td> <label> Enter text for creating QR Code</label> </td> <td> <input type="text" name="qrText" /> </td> </tr> <tr> <td colspan
	"text" name="qrText" /> </td> </tr> (Of tr) <td colspan
	(Of table) (Of tbody) (Of tr) (Of td) (Of label) Enter text for creating QR Code</label> </td> (Of td) <input type="text" name
End Function
@
If True Then
	If Model IsNot Nothing Then
'INSTANT VB WARNING: Instant VB cannot determine whether both operands of this division are integer types - if they are then you should use the VB integer division operator:
		(Of h3) QR Code Successfully Generated</h3> <img src="@String.Format("data:image/png
		base64,
		If True Then
			0
		End If
		", Convert.ToBase64String(Model))" />
	End If
End If
$vbLabelText   $csharpLabel

在文字框中輸入任何值,然後點擊"提交"按鈕。 QR Code將生成並保存為.PNG文件在'qrr'文件夾中。

A Comparison between IronBarcode and ZXing.NET, Figure 2: QR碼生成器

QR碼生成器

A Comparison between IronBarcode and ZXing.NET, Figure 3: 顯示的QR碼文件

顯示的QR碼文件

支持的條碼格式

IronBarcode支持多種常用的條碼格式,包括:

  • 帶標誌和顏色的QR碼(包括裝飾和品牌程式碼)
  • 包括Aztec、Data Matrix、Code 93、Code 128、RSS Expanded Databar、UPS MaxiCode和USPS、IMB(OneCode)條碼的多格式條碼
  • RSS-14和PDF-417堆疊線性條碼
  • UPCA、UPCE、EAN-8、EAN-13、Codabar、ITF、MSI和Plessey是傳統的數字條碼格式。

建立和保存條碼

using IronBarCode;
// Create a barcode and save it in various formats
var MyBarCode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeEncoding.Code128);
MyBarCode.SaveAsImage("MyBarCode.png");
MyBarCode.SaveAsGif("MyBarCode.gif");
MyBarCode.SaveAsHtmlFile("MyBarCode.html");
MyBarCode.SaveAsJpeg("MyBarCode.jpg");
MyBarCode.SaveAsPdf("MyBarCode.Pdf");
MyBarCode.SaveAsPng("MyBarCode.png");
MyBarCode.SaveAsTiff("MyBarCode.tiff");
MyBarCode.SaveAsWindowsBitmap("MyBarCode.bmp");

// Convert barcode to different image formats and obtain binary data
System.Drawing.Image MyBarCodeImage = MyBarCode.Image;
System.Drawing.Bitmap MyBarCodeBitmap = MyBarCode.ToBitmap();
string DataURL = MyBarCode.ToDataUrl();
string ImgTagForHTML = MyBarCode.ToHtmlTag();
byte[] PngBytes = MyBarCode.ToPngBinaryData();

// Save barcode in PDF stream
using (System.IO.Stream PdfStream = MyBarCode.ToPdfStream())
{
    // The Stream barcode image output also works for GIF, JPEG, PDF, PNG, BMP and TIFF
}

// Stamp barcode onto an existing PDF at a specific position
MyBarCode.StampToExistingPdfPage("ExistingPDF.pdf", 1, 200, 50);
using IronBarCode;
// Create a barcode and save it in various formats
var MyBarCode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeEncoding.Code128);
MyBarCode.SaveAsImage("MyBarCode.png");
MyBarCode.SaveAsGif("MyBarCode.gif");
MyBarCode.SaveAsHtmlFile("MyBarCode.html");
MyBarCode.SaveAsJpeg("MyBarCode.jpg");
MyBarCode.SaveAsPdf("MyBarCode.Pdf");
MyBarCode.SaveAsPng("MyBarCode.png");
MyBarCode.SaveAsTiff("MyBarCode.tiff");
MyBarCode.SaveAsWindowsBitmap("MyBarCode.bmp");

// Convert barcode to different image formats and obtain binary data
System.Drawing.Image MyBarCodeImage = MyBarCode.Image;
System.Drawing.Bitmap MyBarCodeBitmap = MyBarCode.ToBitmap();
string DataURL = MyBarCode.ToDataUrl();
string ImgTagForHTML = MyBarCode.ToHtmlTag();
byte[] PngBytes = MyBarCode.ToPngBinaryData();

// Save barcode in PDF stream
using (System.IO.Stream PdfStream = MyBarCode.ToPdfStream())
{
    // The Stream barcode image output also works for GIF, JPEG, PDF, PNG, BMP and TIFF
}

// Stamp barcode onto an existing PDF at a specific position
MyBarCode.StampToExistingPdfPage("ExistingPDF.pdf", 1, 200, 50);
Imports IronBarCode
' Create a barcode and save it in various formats
Private MyBarCode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeEncoding.Code128)
MyBarCode.SaveAsImage("MyBarCode.png")
MyBarCode.SaveAsGif("MyBarCode.gif")
MyBarCode.SaveAsHtmlFile("MyBarCode.html")
MyBarCode.SaveAsJpeg("MyBarCode.jpg")
MyBarCode.SaveAsPdf("MyBarCode.Pdf")
MyBarCode.SaveAsPng("MyBarCode.png")
MyBarCode.SaveAsTiff("MyBarCode.tiff")
MyBarCode.SaveAsWindowsBitmap("MyBarCode.bmp")

' Convert barcode to different image formats and obtain binary data
Dim MyBarCodeImage As System.Drawing.Image = MyBarCode.Image
Dim MyBarCodeBitmap As System.Drawing.Bitmap = MyBarCode.ToBitmap()
Dim DataURL As String = MyBarCode.ToDataUrl()
Dim ImgTagForHTML As String = MyBarCode.ToHtmlTag()
Dim PngBytes() As Byte = MyBarCode.ToPngBinaryData()

' Save barcode in PDF stream
Using PdfStream As System.IO.Stream = MyBarCode.ToPdfStream()
	' The Stream barcode image output also works for GIF, JPEG, PDF, PNG, BMP and TIFF
End Using

' Stamp barcode onto an existing PDF at a specific position
MyBarCode.StampToExistingPdfPage("ExistingPDF.pdf", 1, 200, 50)
$vbLabelText   $csharpLabel

另一方面,ZXing是一個基於Java的開源1D/2D條碼圖像處理程式庫。 支持UPC-A、UPC-E、EAN-8、Code 93、Code 128、QR Code、Data Matrix、Aztec、PDF 417和其他條碼格式。

A Comparison between IronBarcode and Zxing.NET, Figure 4: 支持的條碼格式

支持的條碼格式

使用IronBarcode建立QR碼文件

要使用IronBarcode建立QR碼,我們可以使用BarcodeWriter類。 這個類引入了一些新穎和有趣的功能來建立QR碼。 它使我們能夠設置QR錯誤校正等級,使您可以在QR尺寸和可讀性之間取得平衡。

using IronBarCode;
// Generate a simple QR Code image and save as PNG
QRCodeWriter.CreateQrCode("hello world", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium).SaveAsPng("MyQR.png");
using IronBarCode;
// Generate a simple QR Code image and save as PNG
QRCodeWriter.CreateQrCode("hello world", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium).SaveAsPng("MyQR.png");
Imports IronBarCode
' Generate a simple QR Code image and save as PNG
QRCodeWriter.CreateQrCode("hello world", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium).SaveAsPng("MyQR.png")
$vbLabelText   $csharpLabel

錯誤校正允許我們指定在現實情況下讀取QR的難易度。 更高等級的錯誤校正會產生更大的QR碼,並具有更多的像素和複雜性。 在下面的圖像中,我們看到顯示出的QR碼文件。

A Comparison between IronBarcode and ZXing.NET, Figure 5: 支持的條碼格式

QR碼圖像

我們開始指定條碼的值以及IronBarCode.BarcodeWriterEncoding枚舉中的條碼格式。 然後我們可以將其保存為一個圖像、System.Drawing.Image或Bitmap程式碼物件。

using IronBarCode;
using System.Diagnostics;

// Generate a simple BarCode image and save as PNG using the following namespaces
GeneratedBarcode MyBarCode = IronBarCode.BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeWriterEncoding.Code128);
MyBarCode.SaveAsPng("MyBarCode.png");

// This line opens the image in your default image viewer
Process.Start("MyBarCode.png");
using IronBarCode;
using System.Diagnostics;

// Generate a simple BarCode image and save as PNG using the following namespaces
GeneratedBarcode MyBarCode = IronBarCode.BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeWriterEncoding.Code128);
MyBarCode.SaveAsPng("MyBarCode.png");

// This line opens the image in your default image viewer
Process.Start("MyBarCode.png");
Imports IronBarCode
Imports System.Diagnostics

' Generate a simple BarCode image and save as PNG using the following namespaces
Dim MyBarCode As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeWriterEncoding.Code128)
MyBarCode.SaveAsPng("MyBarCode.png")

' This line opens the image in your default image viewer
Process.Start("MyBarCode.png")
$vbLabelText   $csharpLabel
A Comparison between IronBarcode and ZXing.NET, Figure 6: 在C#中的條碼圖像建立範例

在C#中的條碼圖像建立範例

IronBarcode還支持QR碼的樣式設計,例如將標誌圖形放置在圖像正中心網格上扣緊。 它還可以被著色以匹配特定品牌或圖形身份。

在下面的程式碼範例中建立一個標誌,看看使用QRCodeWriter.CreateQRCodeWithLogo方法多麼簡單。

using IronBarCode;

// Adding a Logo
var MyQRWithLogo = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", "visual-studio-logo.png", 500);
MyQRWithLogo.ChangeBarCodeColor(System.Drawing.Color.DarkGreen);
using IronBarCode;

// Adding a Logo
var MyQRWithLogo = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", "visual-studio-logo.png", 500);
MyQRWithLogo.ChangeBarCodeColor(System.Drawing.Color.DarkGreen);
Imports IronBarCode

' Adding a Logo
Private MyQRWithLogo = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", "visual-studio-logo.png", 500)
MyQRWithLogo.ChangeBarCodeColor(System.Drawing.Color.DarkGreen)
$vbLabelText   $csharpLabel
A Comparison between IronBarcode and ZXing.NET, Figure 7: 建立帶有標誌圖像的QR碼

建立帶有標誌圖像的QR碼

最後,我們將生成的QR碼保存為一個PDF文件。為了您的方便,最後一行程式碼將QR碼保存為HTML文件。

using IronBarCode;

// Adding a Logo
var MyQRWithLogo = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", "visual-studio-logo.png", 500);
MyQRWithLogo.ChangeBarCodeColor(System.Drawing.Color.DarkGreen);

// Save as PDF
MyQRWithLogo.SaveAsPdf("MyQRWithLogo.pdf");

// Also Save as HTML
MyQRWithLogo.SaveAsHtmlFile("MyQRWithLogo.html");
using IronBarCode;

// Adding a Logo
var MyQRWithLogo = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", "visual-studio-logo.png", 500);
MyQRWithLogo.ChangeBarCodeColor(System.Drawing.Color.DarkGreen);

// Save as PDF
MyQRWithLogo.SaveAsPdf("MyQRWithLogo.pdf");

// Also Save as HTML
MyQRWithLogo.SaveAsHtmlFile("MyQRWithLogo.html");
Imports IronBarCode

' Adding a Logo
Private MyQRWithLogo = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", "visual-studio-logo.png", 500)
MyQRWithLogo.ChangeBarCodeColor(System.Drawing.Color.DarkGreen)

' Save as PDF
MyQRWithLogo.SaveAsPdf("MyQRWithLogo.pdf")

' Also Save as HTML
MyQRWithLogo.SaveAsHtmlFile("MyQRWithLogo.html")
$vbLabelText   $csharpLabel

下面我們看看如何用一行程式碼建立、設計和導出條碼。

IronBarcode包含一個與System.Linq相似的流暢API。 我們建立一個條碼,設置其邊距,並通過連結方法調用將其導出為位圖,只需一行程式碼。 這非常有用,並使程式碼更易讀。

using IronBarCode;
using System.Drawing;

// Fluent API for Barcode image generation
string MyValue = "https://ironsoftware.com/csharp/barcode";
Bitmap BarcodeBmp = IronBarCode.BarcodeWriter.CreateBarcode(MyValue, BarcodeEncoding.PDF417)
    .ResizeTo(300, 200)
    .SetMargins(100)
    .ToBitmap();
using IronBarCode;
using System.Drawing;

// Fluent API for Barcode image generation
string MyValue = "https://ironsoftware.com/csharp/barcode";
Bitmap BarcodeBmp = IronBarCode.BarcodeWriter.CreateBarcode(MyValue, BarcodeEncoding.PDF417)
    .ResizeTo(300, 200)
    .SetMargins(100)
    .ToBitmap();
Imports IronBarCode
Imports System.Drawing

' Fluent API for Barcode image generation
Dim MyValue As String = "https://ironsoftware.com/csharp/barcode"
Dim BarcodeBmp As Bitmap = IronBarCode.BarcodeWriter.CreateBarcode(MyValue, BarcodeEncoding.PDF417) _
    .ResizeTo(300, 200) _
    .SetMargins(100) _
    .ToBitmap()
$vbLabelText   $csharpLabel

結果,以下展示的PDF417條碼的System.Drawing.Image出現了。

A Comparison between IronBarcode and ZXing.NET, Figure 8: 簡單的流暢PDF417條碼生成在C#中

簡單的流暢PDF417條碼生成在C#中

讀取QR碼文件

使用IronBarcode讀取QR碼

當您使用IronBarcode類程式庫搭配.NET條碼閱讀器時,讀取條碼或QR碼輕而易舉。 在我們的第一個例子中,我們可以看到如何用一行程式碼讀取條碼。

A Comparison between IronBarcode and ZXing.NET, Figure 9: 將掃描的Code128條碼圖像用C#掃描

將掃描的Code128條碼圖像用C#掃描

我們可以獲取條碼的值、圖像、編碼型別和二進制資料(如果有的話),然後將其輸出到控制台。

using IronBarCode;
using System;

// Read a barcode or QR code from an image
BarcodeResult Result = BarcodeReader.QuicklyReadOneBarcode("GetStarted.png");
if (Result != null && Result.Text == "https://ironsoftware.com/csharp/barcode/")
{
    Console.WriteLine("GetStarted was a success.  Read Value: " + Result.Text);
}
using IronBarCode;
using System;

// Read a barcode or QR code from an image
BarcodeResult Result = BarcodeReader.QuicklyReadOneBarcode("GetStarted.png");
if (Result != null && Result.Text == "https://ironsoftware.com/csharp/barcode/")
{
    Console.WriteLine("GetStarted was a success.  Read Value: " + Result.Text);
}
Imports IronBarCode
Imports System

' Read a barcode or QR code from an image
Private Result As BarcodeResult = BarcodeReader.QuicklyReadOneBarcode("GetStarted.png")
If Result IsNot Nothing AndAlso Result.Text = "https://ironsoftware.com/csharp/barcode/" Then
	Console.WriteLine("GetStarted was a success.  Read Value: " & Result.Text)
End If
$vbLabelText   $csharpLabel

讀取PDF內的條碼

我們將研究讀取已掃描的PDF文件,並用幾行程式碼找到所有的一維條碼。

正如您所看到的,這與從單個文件中讀取單個條碼非常相似,除了我們現在知道條碼是在哪一頁發現的。

using IronBarCode;
using System;
using System.Drawing;

// Multiple barcodes may be scanned up from a single document or image. A PDF document may also be 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 be 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 be 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
$vbLabelText   $csharpLabel

您將獲得PDF中所有位圖條碼的結果資料。

A Comparison between IronBarcode and ZXing.NET, Figure 10: 讀取PDF記憶體儲的條碼結果

讀取PDF記憶體儲的條碼結果

從GIF和TIFF中讀取條碼

using IronBarCode;
using System;

// Multi-frame TIFF and GIF images can also be scanned, and multiple threads will be used automatically in the background for improved performance
PagedBarcodeResult[] MultiFrameResults = BarcodeReader.ReadBarcodesFromMultiFrameTiff("Multiframe.tiff", BarcodeEncoding.Code128, BarcodeReader.BarcodeRotationCorrection.High, BarcodeReader.BarcodeImageCorrection.MediumCleanPixels);
foreach (var PageResult in MultiFrameResults)
{
    // Process each page result
}
using IronBarCode;
using System;

// Multi-frame TIFF and GIF images can also be scanned, and multiple threads will be used automatically in the background for improved performance
PagedBarcodeResult[] MultiFrameResults = BarcodeReader.ReadBarcodesFromMultiFrameTiff("Multiframe.tiff", BarcodeEncoding.Code128, BarcodeReader.BarcodeRotationCorrection.High, BarcodeReader.BarcodeImageCorrection.MediumCleanPixels);
foreach (var PageResult in MultiFrameResults)
{
    // Process each page result
}
Imports IronBarCode
Imports System

' Multi-frame TIFF and GIF images can also be scanned, and multiple threads will be used automatically in the background for improved performance
Private MultiFrameResults() As PagedBarcodeResult = BarcodeReader.ReadBarcodesFromMultiFrameTiff("Multiframe.tiff", BarcodeEncoding.Code128, BarcodeReader.BarcodeRotationCorrection.High, BarcodeReader.BarcodeImageCorrection.MediumCleanPixels)
For Each PageResult In MultiFrameResults
	' Process each page result
Next PageResult
$vbLabelText   $csharpLabel
A Comparison between IronBarcode and ZXing.NET, Figure 11: 從多幀TIFF圖像中讀取條碼

從多幀TIFF圖像中讀取條碼

下面的例子顯示了如何從掃描的PDF中讀取QR碼和PDF-417條碼。 我們設置了適當的條碼旋轉校正等級和條碼圖像校正,以輕微清理文件而不會產生重大性能損失。

using IronBarCode;
using System;

// PDF documents can also be scanned, and multiple threads will be used automatically in the background for improved performance
var ScanResults = BarcodeReader.ReadBarcodesFromPdf("Scan.pdf", BarcodeEncoding.All, BarcodeReader.BarcodeRotationCorrection.Low, BarcodeReader.BarcodeImageCorrection.LightlyCleanPixels);

// Work with the results
foreach (var PageResult in ScanResults)
{
    string Value = PageResult.Value;
    //...
}
using IronBarCode;
using System;

// PDF documents can also be scanned, and multiple threads will be used automatically in the background for improved performance
var ScanResults = BarcodeReader.ReadBarcodesFromPdf("Scan.pdf", BarcodeEncoding.All, BarcodeReader.BarcodeRotationCorrection.Low, BarcodeReader.BarcodeImageCorrection.LightlyCleanPixels);

// Work with the results
foreach (var PageResult in ScanResults)
{
    string Value = PageResult.Value;
    //...
}
Imports IronBarCode
Imports System

' PDF documents can also be scanned, and multiple threads will be used automatically in the background for improved performance
Private ScanResults = BarcodeReader.ReadBarcodesFromPdf("Scan.pdf", BarcodeEncoding.All, BarcodeReader.BarcodeRotationCorrection.Low, BarcodeReader.BarcodeImageCorrection.LightlyCleanPixels)

' Work with the results
For Each PageResult In ScanResults
	Dim Value As String = PageResult.Value
	'...
Next PageResult
$vbLabelText   $csharpLabel
A Comparison between IronBarcode and ZXing.NET, Figure 12: 從掃描的PDF文件中讀取條碼

從掃描的PDF文件中讀取條碼

從位圖圖像中讀取損壞的QR碼

下面的例子顯示了這個C#條碼程式庫甚至可以讀取已損壞的條碼縮略圖。

條碼縮略圖大小的校正是自動完成的。 IronBarcode在C#中使文件可讀。

讀者方法會自動檢測到太小而無法成為合法條碼的條碼圖像,並放大它們。 他們清除所有與縮略圖相關的數字噪音,讓它們再次可讀。

using IronBarCode;

// Small or 'Thumbnail' barcode images are automatically detected by IronBarcode and corrected wherever possible even if they have much digital noise.
BarcodeResult SmallResult = BarcodeReader.QuicklyReadOneBarcode("ThumbnailOfBarcode.gif", BarcodeEncoding.Code128);
using IronBarCode;

// Small or 'Thumbnail' barcode images are automatically detected by IronBarcode and corrected wherever possible even if they have much digital noise.
BarcodeResult SmallResult = BarcodeReader.QuicklyReadOneBarcode("ThumbnailOfBarcode.gif", BarcodeEncoding.Code128);
Imports IronBarCode

' Small or 'Thumbnail' barcode images are automatically detected by IronBarcode and corrected wherever possible even if they have much digital noise.
Private SmallResult As BarcodeResult = BarcodeReader.QuicklyReadOneBarcode("ThumbnailOfBarcode.gif", BarcodeEncoding.Code128)
$vbLabelText   $csharpLabel
A Comparison between IronBarcode and ZXing.NET, Figure 13: 自動條碼縮略圖大小校正

自動條碼縮略圖大小校正

從不完美的圖像中讀取條碼

在現實情境中,我們可能希望從不完美的圖像中讀取條碼。 它們可能是傾斜的圖像或帶有數字噪音的照片。這對大多數開源.NET條碼生成和讀取程式庫來說是無法實現的。 另一方面,IronBarcode使得從不完美的圖像中讀取條碼變得輕而易舉。

現在我們將看看ReadASingleBarcode方法。 使用其RotationCorrection參數,IronBarcode嘗試從不完美的數字樣本中進行去除傾斜並讀取條碼。

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)
$vbLabelText   $csharpLabel
A Comparison between IronBarcode and ZXing.NET, Figure 14: 從手機相機讀取條碼

從手機相機讀取條碼

IronBarcode還可以同時讀取多個條碼。我們從IronBarcode得到更好的結果,當我們建立一個文件列表並使用條碼閱讀器讀取多個文件時。 條碼掃描過程的ReadBarcodesMultithreaded方法使用多個執行緒,並可能使用您的CPU的所有核心,這比一次讀取一個條碼要快得多。

using IronBarCode;

// The BarcodeResult.ReadBarcodesMultiThreaded method allows for faster barcode scanning of multiple images or PDFs. All threads are automatically managed by IronBarcode.
var ListOfDocuments = new[] { "Image1.png", "image2.JPG", "image3.pdf" };
PagedBarcodeResult[] BatchResults = BarcodeReader.ReadBarcodesMultiThreaded(ListOfDocuments);

// Work with the results
foreach (var Result in BatchResults)
{
    string Value = Result.Value;
    //...
}
using IronBarCode;

// The BarcodeResult.ReadBarcodesMultiThreaded method allows for faster barcode scanning of multiple images or PDFs. All threads are automatically managed by IronBarcode.
var ListOfDocuments = new[] { "Image1.png", "image2.JPG", "image3.pdf" };
PagedBarcodeResult[] BatchResults = BarcodeReader.ReadBarcodesMultiThreaded(ListOfDocuments);

// Work with the results
foreach (var Result in BatchResults)
{
    string Value = Result.Value;
    //...
}
Imports IronBarCode

' The BarcodeResult.ReadBarcodesMultiThreaded method allows for faster barcode scanning of multiple images or PDFs. All threads are automatically managed by IronBarcode.
Private ListOfDocuments = { "Image1.png", "image2.JPG", "image3.pdf" }
Private BatchResults() As PagedBarcodeResult = BarcodeReader.ReadBarcodesMultiThreaded(ListOfDocuments)

' Work with the results
For Each Result In BatchResults
	Dim Value As String = Result.Value
	'...
Next Result
$vbLabelText   $csharpLabel

使用ZXing.NET讀取和解碼QR碼

要讀取QR碼文件,將ViewFile動作方法新增到您的控制器中,如下所示。

public ActionResult ViewFile()
{
    List<KeyValuePair<string, string>> fileData = new List<KeyValuePair<string, string>>();
    KeyValuePair<string, string> data;

    string[] files = Directory.GetFiles(Server.MapPath("~/qrr"));
    foreach (string file in files)
    {
        // Create a barcode reader instance
        IBarcodeReader reader = new BarcodeReader();

        // Load a bitmap
        var barcodeBitmap = (Bitmap)Image.FromFile(Server.MapPath("~/qrr") + "/" + Path.GetFileName(file));

        // Detect and decode the barcode inside the bitmap
        var result = reader.Decode(barcodeBitmap);

        // Do something with the result
        data = new KeyValuePair<string, string>(result.ToString(), "/QR/" + Path.GetFileName(file));
        fileData.Add(data);
    }
    return View(fileData);
}
public ActionResult ViewFile()
{
    List<KeyValuePair<string, string>> fileData = new List<KeyValuePair<string, string>>();
    KeyValuePair<string, string> data;

    string[] files = Directory.GetFiles(Server.MapPath("~/qrr"));
    foreach (string file in files)
    {
        // Create a barcode reader instance
        IBarcodeReader reader = new BarcodeReader();

        // Load a bitmap
        var barcodeBitmap = (Bitmap)Image.FromFile(Server.MapPath("~/qrr") + "/" + Path.GetFileName(file));

        // Detect and decode the barcode inside the bitmap
        var result = reader.Decode(barcodeBitmap);

        // Do something with the result
        data = new KeyValuePair<string, string>(result.ToString(), "/QR/" + Path.GetFileName(file));
        fileData.Add(data);
    }
    return View(fileData);
}
Public Function ViewFile() As ActionResult
	Dim fileData As New List(Of KeyValuePair(Of String, String))()
	Dim data As KeyValuePair(Of String, String)

	Dim files() As String = Directory.GetFiles(Server.MapPath("~/qrr"))
	For Each file As String In files
		' Create a barcode reader instance
		Dim reader As IBarcodeReader = New BarcodeReader()

		' Load a bitmap
		Dim barcodeBitmap = CType(Image.FromFile(Server.MapPath("~/qrr") & "/" & Path.GetFileName(file)), Bitmap)

		' Detect and decode the barcode inside the bitmap
		Dim result = reader.Decode(barcodeBitmap)

		' Do something with the result
		data = New KeyValuePair(Of String, String)(result.ToString(), "/QR/" & Path.GetFileName(file))
		fileData.Add(data)
	Next file
	Return View(fileData)
End Function
$vbLabelText   $csharpLabel
A Comparison between IronBarcode and ZXing.NET, Figure 15: 讀取和解碼QR碼

讀取和解碼QR碼

A Comparison between IronBarcode and ZXing.NET, Figure 16: 解碼後的QR碼

解碼後的QR碼

解碼位圖中的條碼

using ZXing;
using System.Drawing;

// Create a barcode reader instance
BarcodeReader reader = new BarcodeReader();

// Load a bitmap
var barcodeBitmap = (Bitmap)Image.FromFile("C:\\sample-barcode-image.png");

// Detect and decode the barcode inside the bitmap
var result = reader.Decode(barcodeBitmap);

// Do something with the result
if (result != null)
{
    txtDecoderType.Text = result.BarcodeFormat.ToString();
    txtDecoderContent.Text = result.Text;
}
using ZXing;
using System.Drawing;

// Create a barcode reader instance
BarcodeReader reader = new BarcodeReader();

// Load a bitmap
var barcodeBitmap = (Bitmap)Image.FromFile("C:\\sample-barcode-image.png");

// Detect and decode the barcode inside the bitmap
var result = reader.Decode(barcodeBitmap);

// Do something with the result
if (result != null)
{
    txtDecoderType.Text = result.BarcodeFormat.ToString();
    txtDecoderContent.Text = result.Text;
}
Imports ZXing
Imports System.Drawing

' Create a barcode reader instance
Private reader As New BarcodeReader()

' Load a bitmap
Private barcodeBitmap = CType(Image.FromFile("C:\sample-barcode-image.png"), Bitmap)

' Detect and decode the barcode inside the bitmap
Private result = reader.Decode(barcodeBitmap)

' Do something with the result
If result IsNot Nothing Then
	txtDecoderType.Text = result.BarcodeFormat.ToString()
	txtDecoderContent.Text = result.Text
End If
$vbLabelText   $csharpLabel

ZXing解碼器線上

ZXing解碼器線上是一個可在線上使用的條碼和QR碼掃描器,支持解碼。 上傳PNG或其他格式的QR碼圖像,然後它將開始解碼。 同樣,您也可以為任何資料生成一個QR碼。 大多數時候,該資訊將是您希望在QR碼中編碼的URL或文字。

導航至ZXing解碼器網站。

A Comparison between IronBarcode and ZXing.NET, Figure 17: 解碼後的QR碼

ZXing解碼器網站

A Comparison between IronBarcode and ZXing.NET, Figure 18: 解碼後的QR碼

ZXing解碼結果

定價和授權

ZXing.NET程式庫是一個免費的開源程式庫,允許您構建條碼讀取應用程式,根據Apache License 2.0許可,允許免費商業使用並有適當的歸屬。

IronBarcode的開發者許可是免費提供的。 IronBarcode有一個獨特的定價機制:Lite包的價格從$liteLicense開始,無需額外費用。 SaaS和OEM項目也可以再次發布。 每個許可包括永久許可,開發/預發/生產的有效性,30天退款保證,以及一年期的軟體支持和更新(一次性購買)。 存取此頁面以查看IronBarcode的完整定價和許可資訊。

為什麼選擇IronBarcode?

IronBarcode包含一個易於使用的API供開發者在.NET中讀寫條碼,這在現實用例中優化了精度和低錯誤率。

例如,BarcodeWriter類將驗證和糾正UPCA和UPCE條碼的'校驗和'。 它還會'零填充'過短而不能輸入特定數字格式的數字。 如果您的資料與指定資料格式不相容,IronBarcode將通知開發者他們可以使用的更合適的條碼格式。

IronBarcode在讀取條碼時表現優異,當條碼是用於拍攝圖像的時候,也就是說,當圖像在圖形上並不完美且不是機器生成的截圖的時候也是如此。

IronBarcode與ZXing.NET有何不同?

IronBarcode構建自ZXing.NET(斑馬過街)核心,擁有改進的處理能力。 與ZXing.NET核心程式庫相比,它配備了易於使用的API和低錯誤率。 不僅如此,IronBarcode還支持比常規ZXing.NET程式庫更廣泛的條碼格式。

IronBarcode是ZXing.NET的改進版本,為使用者提供了商業用途的平台,並有可能在多個平台上使用同一個包。 它還具有全方位的技術支持,隨時隨地準備為您提供幫助。

IronBarcode包括自動旋轉、視角校正和數字噪音校正,並能夠檢測圖像中編碼的條碼型別。

結論

總之,IronBarcode是一個多功能的.NET軟體程式庫和C# QR碼生成器,用於讀取多種條碼格式,無論是截圖、照片、掃描還是其他不完美的現實圖像。

IronBarcode是建立和識別條碼最有效的程式庫之一。 在建立和識別條碼方面,它也是最快的程式庫之一。 該程式庫與不同的作業系統相容。 它易於設計,並支持多種條碼格式。 此外,還支持各種符號、格式和字元。

ZXing.NET條碼是一個強大的程式庫,可以在各種圖像格式中生成和識別條碼。 我們可以在多種格式中讀取和建立圖像。 ZXing.NET還允許您更改條碼的外觀,調整其高度、寬度、條碼文字等。

與ZXing.NET相比,IronBarcode套件提供可靠的許可和支持。 IronBarcode的價格是$liteLicense。 儘管ZXing是免費且開源的,IronBarcode提供全面的商業支持和專業維護。 除了比ZXing.NET更靈活之外,IronBarcode解決方案還具有更多功能。 因此,顯然IronBarcode比ZXing.NET具有更強的優勢。

在比較識別和生成條碼的處理時間時,IronBarcode比ZXing.NET更出色。 IronBarcode還具有多種屬性,允許我們從不同的圖像格式和PDF文件中讀取條碼。 它還允許我們在條碼或QR碼內包含圖像,這在任何其他程式庫中是不可能做到的。

IronBarcode在開發早期階段是免費的。 您可以獲得免費試用供生產等級或商業用途。 根據開發者的要求,IronBarcode提供三個定價層級。 您可以選擇最佳滿足您需求的解決方案。 您現在可以以兩個Iron Software產品的價格獲得五個Iron Software產品套件。 存取此網站以獲取更多資訊。

請注意ZXing.NET是其各自所有者的註冊商標。 本網站與ZXing.NET無關,未經其認可或贊助。 所有產品名稱、標誌和品牌均為其各自所有者的財產。 比較僅供資訊參考,並反映了撰寫時公開可用的資訊。

常見問題

如何在 C# 中生成 QR code?

您可以使用 IronBarcode 的 `BarcodeWriter` 類別在 C# 中生成 QR code。只需定義 QR code 內容,自訂顏色和大小等選項,然後調用 'Write' 方法即可生成 QR code。

是什麼讓 IronBarcode 比 ZXing.NET 更加強大?

IronBarcode 提供了增強的功能,如支援更多條碼格式、先進的圖像處理功能如旋轉和透視校正,以及建立帶有徽標和顏色的裝飾 QR code 的能力。它還跨平台相容,並提供商業支援。

我可以使用 IronBarcode 從有缺陷的圖像中讀取條碼嗎?

可以,IronBarcode 可以使用旋轉校正、透視校正和數位噪音減少等功能從有缺陷的圖像中讀取條碼,這使得其對於掃描或相片圖像非常有效。

在 C# 中讀取條碼的步驟是什麼?

要在 C# 中讀取條碼,使用 IronBarcode 的 `BarcodeReader` 類別。透過 `BarcodeReader.QuicklyReadOneBarcode` 方法載入包含條碼的圖像,該方法將解碼並返回已識別的條碼內容。

IronBarcode 如何處理跨平台相容性?

IronBarcode 支援 Windows、macOS、Linux 和 Azure 的跨平台相容性,允許您將條碼生成和讀取功能整合到不同的 .NET 應用程式中,且無需第三方依賴。

IronBarcode 提供哪些自訂 QR code 的選項?

IronBarcode 允許透過調整顏色、新增品牌徽標和配置錯誤校正級別來自訂 QR code,以平衡大小和可讀性,滿足各種美學和功能需求的靈活性。

在商業應用中使用 IronBarcode 是否有授權費用?

IronBarcode 提供不同的授權選項,包括適合商業應用的永久授權。這與 ZXing.NET 免費但對商業用途有限制不同。

使用條碼庫時常見的故障排除場景有哪些?

常見問題可能包括由於圖像質量不佳、未支援的條碼格式或配置錯誤引起的不正確條碼識別。IronBarcode 的先進圖像處理可以幫助減輕某些識別問題。

為什麼有人會選擇 IronBarcode 而不是 ZXing.NET 來處理條碼?

IronBarcode 提供更強大的 API、更好的錯誤處理、廣泛的條碼格式支援,以及生成視覺化自訂 QR code 的功能,所有這些都增強了商業授權和專業支援。

如何在 .NET 專案中安裝 IronBarcode?

您可以使用 Visual Studio 中的 NuGet 套件管理器在 .NET 專案中安裝 IronBarcode,只需搜尋 'IronBarcode' 並將其新增到您的專案中,確保輕鬆整合和更新。

Curtis Chau
技術作家

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

除了開發,Curtis對物聯網(IoT)有濃厚的興趣,探索創新的方法來整合硬體和軟體。在空閒時間,他喜歡玩遊戲和建立Discord機器人,結合他對技術的熱愛與創造力。

Iron 支援團隊

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