IronBarcode與ZXing.NET的比較
條碼掃描器可能不會總是適用於我們的應用場景。 您可能已經擁有條碼的數位圖像,並想知道它在英文文字中代表什麼。 此外,此掃描器只能讀取一維條碼,其包含的資料量有限,且只能在 Windows RT 類別庫中使用。 二維條碼(也稱為 QR 碼)現在很常見,可以儲存更多資訊。
使用簡單的 API 呼叫和幾個編碼步驟,即可建立基於 AC# 的應用程式來讀取條碼。 支援 .NET 的應用程式可以在 Windows、macOS 或 Linux 上運行,而無需依賴任何第三方工具或 API。
本文將比較兩個功能最強大的 .NET Core 應用程式庫,以程式設計方式讀取條碼。 這兩個函式庫分別是 IronBarcode 和 ZXing.NET。 我們將看看是什麼讓 IronBarcode 比 ZXing.NET 更強大、更穩定。
如何使用 Zxing 在 C# 中產生條碼
- 安裝 C# 庫以產生條碼
- 使用
BarcodeWriterPixelData類別建立一個新物件來自訂條碼 - 使用
Format屬性設定條碼類型 - 實例化
QrCodeEncodingOptions類別以進一步自訂高度、寬度和邊距 - 使用步驟 2 中物件的
Write方法在 C# 中產生條碼。
什麼是 ZXing.NET
ZXing.NET 是一個可以解碼和產生條碼(如 QR 碼、PDF 417、EAN、UPC、Aztec、Data Matrix、Codabar)的函式庫。 ZXing(即"斑馬線")是一個基於 Java 的開源程式庫,支援各種一維和二維條碼格式。
它的主要特點如下:
它可以儲存網址、聯絡資訊、日曆事件等等。 它是專為 Java SE 應用程式量身定制的。 它允許透過意圖整合條碼掃描器 這是一個簡單易用的Google眼鏡應用
什麼是 IronBarcode
IronBarcode 是一個 C# 函式庫,允許程式設計師讀取和產生條碼。 作為領先的條碼庫,IronBarcode 支援各種一維和二維條碼,包括裝飾性(彩色和品牌化)二維碼。 它支援 .NET Standard 和 Core 版本 2 及更高版本,因此可以在 Azure、Linux、macOS、Windows 和 Web 等跨平台使用。 IronBarcode 是一個知名的 .NET 系統類別庫或元件,它允許 C#、VB.NET 和 F# 開發人員使用標準化的程式語言。 它允許客戶瀏覽掃描標籤並創建新的標準化標籤。 它與二維條碼和其他三維標準條碼配合使用效果非常好。
IronBarcode 現在支援二維條碼。 它提供了優化這些程式碼的顏色、樣式和像素化的功能,並允許向其中添加徽標,以便在印刷或廣告素材中使用。 該庫還可以讀取傾斜和變形的條碼,這是其他條碼軟體可能無法讀取的。
安裝 IronBarcode 和 ZXing.NET
安裝 ZXing.NET
若要使用 ZXing.NET 程式庫,請使用 NuGet 套件管理器控制台在 ASP.NET Core 應用程式中安裝以下兩個套件:
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"。

ASP.NET Web 應用程式
IronBarcode的安裝
使用 NuGet 套件管理器安裝 IronBarcode,或直接從產品網站下載 DLL 檔案進行安裝。 IronBarcode命名空間包含所有 IronBarcode 類別。
可以使用 Visual Studio 的 NuGet 套件管理器安裝 IronBarcode:套件名稱為"Barcode"。
Install-Package BarCode
建立二維條碼
使用 ZXing.NET
首先,在專案文件的根資料夾內建立一個名為"qrr"的新資料夾。
然後我們將創建 QR 檔案並將圖像系統檔案儲存在"qrr"資料夾中。
在 Controller 中,新增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剩下的唯一改動就是將二維碼檔案儲存到"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)接下來,您必須建立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在文字方塊中輸入任意值,然後按一下"提交"按鈕。 二維碼將產生並以 .PNG 檔案格式儲存在"qrr"資料夾中。

QR Code Generator

顯示的二維碼文件
支援的條碼格式
IronBarcode 支援多種常用條碼格式,包括:
- 帶有標誌和顏色的二維碼(包括裝飾性和品牌化的二維碼)
- 支援多種條碼格式,包括 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)另一方面,ZXing 是一個基於 Java 的開源 1D/2D 條碼影像處理函式庫。 支援 UPC-A、UPC-E、EAN-8、Code 93、Code 128、QR Code、Data Matrix、Aztec、PDF 417 和其他條碼格式。

支援的條碼格式
使用 IronBarcode 建立二維碼文件
要使用 IronBarcode 建立二維碼,我們可以使用QRCodeWriter類別而不是BarcodeWriter類別。 本課程介紹了一些創建二維碼的新穎有趣的功能。 它允許我們設定二維碼糾錯級別,從而在二維碼的大小和可讀性之間取得平衡。
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")糾錯功能使我們能夠指定在實際情況下讀取二維碼的難易程度。 更高的糾錯能力會導致二維碼更大、像素更多、更複雜。 下圖顯示了二維碼檔案。

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
Private MyBarCode As GeneratedBarcode = 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")
C# 建立條碼影像範例
IronBarcode 還支援對二維碼進行樣式設置,例如將徽標圖形放置在圖像的正中心並使其與網格對齊。 它還可以塗上顏色,以匹配特定的品牌或圖形標誌。
為了進行測試,請在下面的程式碼範例中建立一個徽標,看看使用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)
建立帶有Logo圖片的二維碼
最後,我們將產生的二維碼儲存為 PDF 檔案。為了方便起見,最後一行程式碼將二維碼儲存為 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")下面,我們將看到如何僅使用一行程式碼建立、設定樣式和匯出條碼。
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
Private MyValue As String = "https://ironsoftware.com/csharp/barcode"
Private BarcodeBmp As Bitmap = IronBarcode.BarcodeWriter.CreateBarcode(MyValue, BarcodeEncoding.PDF417).ResizeTo(300, 200).SetMargins(100).ToBitmap()因此,PDF417 條碼的System.Drawing.Image顯示如下:

用 C# 實現簡單流暢的 PDF417 條碼生成
讀取二維碼文件
使用 IronBarcode 讀取二維碼
將 IronBarcode 類別庫與 .NET 條碼閱讀器結合使用,讀取條碼或二維碼就變得輕而易舉。 在第一個例子中,我們可以看到如何只使用一行程式碼讀取條碼。

使用 C# 掃描 Code128 條碼影像
我們可以取得條碼的值、圖像、編碼類型和二進位資料(如果有),然後將其輸出到控制台。
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讀取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您將獲得包含所有點陣圖條碼的結果資料(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
從多幀 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
從掃描的PDF文件中讀取條碼
從點陣圖影像中讀取損壞的二維碼
下面的範例表明,這個 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)
條碼縮圖尺寸自動校正
從不完美影像中讀取條碼
在實際應用中,我們可能需要從不完美的圖像中讀取條碼。 它們可能是扭曲的圖像或帶有數位雜訊的照片。大多數開源的.NET條碼產生和讀取庫都無法處理這種情況。 另一方面,IronBarcode 可以輕鬆讀取不完美影像中的條碼。
現在我們來看看ReadASingleBarcode方法。 IronBarcode 透過其RotationCorrection參數,嘗試對不完美的數字樣本中的條碼進行校正和讀取。
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)
讀取手機相機中的條碼
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使用 ZXing.NET 讀取和解碼二維碼
若要讀取二維碼文件,請為控制器新增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
讀取和解碼二維碼

已解碼的二維碼
解碼位圖中的條碼
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 IfZXing解碼器在線
ZXing Decoder Online 是一款可在線上使用的條碼和二維碼掃描器,支援解碼功能。 上傳 PNG 或其他格式的二維碼圖像,它將開始解碼。 同樣,您可以為任何資料產生二維碼。 大多數情況下,該資訊將是您想要編碼到二維碼中的網址或文字。
造訪 ZXing 解碼器網站。

ZXing解碼器網站

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 core 函式庫相比,它具有易於使用的 API 和較低的錯誤率。 不僅如此,IronBarcode 還支援比通常的 ZXing.NET 程式庫更廣泛的條碼格式。
IronBarcode 是 ZXing.NET 的改良版本,為使用者提供商業用途的平台,並允許在多個平台上使用同一個軟體包。 它還提供全面的技術支持,隨時準備在您需要時提供幫助。
IronBarcode包含自動旋轉、透視校正和數位雜訊校正功能,並且可以偵測影像中編碼的條碼類型。
結論
總而言之,IronBarcode 是一個功能強大的 .NET 軟體庫和 C# 二維碼產生器,可以讀取各種條碼格式,無論是螢幕截圖、照片、掃描件還是其他不完美的現實世界影像。
IronBarcode 是建立和識別條碼最有效的程式庫之一。 在創建和識別條碼方面,它也是速度最快的庫之一。 該庫與不同的作業系統相容。 它易於設計,並支援多種條碼格式。 此外,還支援各種符號、格式和字元。
ZXing.NET 條碼是一個功能強大的函式庫,可以產生和辨識各種影像格式的條碼。 我們可以讀取和創建多種格式的圖像。 ZXing.NET 還允許您變更條碼的外觀,變更其高度、寬度、條碼文字等。
與 ZXing.NET 相比,IronBarcode 軟體包提供可靠的授權和支援。 IronBarcode 的收費為 $liteLicense。 雖然 ZXing 是免費開源的,但 IronBarcode 提供全面的商業支援和專業維護。 除了比 ZXing.NET 更靈活之外,Iron Barcode 解決方案還具有更多功能。 因此,很明顯,IronBarcode 比 ZXing.NET 具有強大的優勢。
在比較辨識和產生條碼的處理時間時,IronBarcode 的效能優於 ZXing.NET。 IronBarcode 還具有多種特性,使我們能夠從不同的影像格式和 PDF 文件中讀取條碼。 它還允許我們在條碼或二維碼中包含圖像,這是其他任何庫都無法實現的。
IronBarcode 在開發初期階段是免費的。 您可以獲得用於生產級或商業用途的免費試用版。 根據開發者的需求,IronBarcode 提供三種定價方案。 您可以選擇最符合您需求的解決方案。 現在,您只需支付兩件 Iron Software 產品的價格,即可獲得一組五件 Iron Software 產品。 請造訪此網站以了解更多資訊。
常見問題解答
如何在 C# 中產生 QR 代碼?
您可以利用 IronBarcode 的 `BarcodeWriter` 類,在 C# 中產生 QR 碼。只需定義 QR 碼內容、自訂顏色和大小等選項,並呼叫 `Write` 方法即可產生 QR 碼。
是什麼讓 IronBarcode 比 ZXing.NET 更為強大?
IronBarcode 提供增強的功能,例如支援更多的條碼格式、先進的影像處理功能(例如旋轉和透視校正),以及創建具有標誌和顏色的裝飾 QR 代碼的能力。它還具有跨平台相容性,並提供商業支援。
我可以使用 IronBarcode 從有瑕疵的圖像中讀取條碼嗎?
是的,IronBarcode 可以使用旋轉校正、透視校正和數位降噪等功能,從有瑕疵的影像中讀取條碼,因此對掃描或攝影影像都很有效。
在 C# 中讀取 BarCode 的步驟是什麼?
要在 C# 中讀取條碼,請使用 IronBarcode 的 `BarcodeReader` 類。使用`BarcodeReader.QuicklyReadOneBarcode`方法載入包含條碼的圖像,如果能識別,該方法將解碼並傳回條碼內容。
IronBarcode 如何處理跨平台相容性?
IronBarcode 支援 Windows、macOS、Linux 和 Azure 的跨平台相容性,讓您可以將條碼生成和讀取功能整合到多樣化的 .NET 應用程式中,而無需第三方依賴。
使用 IronBarcode 自訂 QR 代碼有哪些選項?
IronBarcode 可透過調整顏色、加入標誌以建立品牌,以及設定錯誤修正等級來自訂 QR 代碼,以平衡大小與可讀性,為各種美學與功能需求提供彈性。
在商業應用中使用 IronBarcode 是否需要授權費?
IronBarcode 提供不同的授權選項,包括適合商業應用的永久授權。這與 ZXing.NET 形成對比,ZXing.NET 是免費的,但對商業用途有限制。
使用 BarCode 程式庫時,有哪些常見的故障排除情況?
常見的問題可能包括由於圖像質量差、不支援的條碼格式或配置錯誤而導致的不準確的條碼識別。IronBarcode 先進的圖像處理技術可以幫助緩解一些識別問題。
為什麼有人會選擇 IronBarcode 而不是 ZXing.NET 來處理條碼?
IronBarcode 提供了更強大的 API、更好的錯誤處理、廣泛的條碼格式支援,以及可視化自訂 QR 代碼的生成功能,所有這些都具有商業 License 和專業支援的額外優勢。
如何在 .NET 專案中安裝 IronBarcode?
您可以使用 Visual Studio 中的 NuGet Package Manager 在 .NET 專案中安裝 IronBarcode,方法是搜尋 'IronBarcode' 並將其加入專案中,以確保容易整合與更新。







