![]() |
VOOZH | about |
dotnet add package ZXingCpp --version 0.5.1
NuGet\Install-Package ZXingCpp -Version 0.5.1
<PackageReference Include="ZXingCpp" Version="0.5.1" />
<PackageVersion Include="ZXingCpp" Version="0.5.1" />Directory.Packages.props
<PackageReference Include="ZXingCpp" />Project file
paket add ZXingCpp --version 0.5.1
#r "nuget: ZXingCpp, 0.5.1"
#:package ZXingCpp@0.5.1
#addin nuget:?package=ZXingCpp&version=0.5.1Install as a Cake Addin
#tool nuget:?package=ZXingCpp&version=0.5.1Install as a Cake Tool
ZXingCpp is a .NET wrapper for the C++ library zxing-cpp.
It is an open-source, multi-format linear/matrix barcode image processing library implemented in C++. It was originally ported from the Java ZXing library but has been developed further and now includes many improvements in terms of runtime and detection performance.
using SkiaSharp;
using ZXingCpp;
public class Program
{
public static void Main(string[] args)
{
var img = SKBitmap.Decode(args[0]).Copy(SKColorType.Gray8);
var iv = new ImageView(img.GetPixels(), img.Info.Width, img.Info.Height, ImageFormat.Lum);
var readBarcodes = new BarcodeReader() {
Formats = args.Length > 1 ? BarcodeFormats.Parse(args[1]) : BarcodeFormat.All,
TryInvert = false,
// see the ReaderOptions implementation for more available options
};
foreach (var b in readBarcodes.From(iv))
Console.WriteLine($"{b.Format} : {b.Text}");
}
}
Executing this sample code from the command line would look like this:
dotnet run -- <image-file-name> [barcode-format-list]
See also the ZXingCpp.DemoReader which shows the use of extension classes to support SkiaSharp and ImageMagick based input.
The NuGet package includes the runtime/native C++ libraries for x64 and arm64 on
Windows, Linux and macOS. If something is not working out of the box and you need to override
library loading, make sure the .NET runtime can find [lib]ZXing[.dll|.so|.dylib]
(see e.g. LD_LIBRARY_PATH on Linux or PATH on Windows).
using ZXingCpp;
public class Program
{
public static void Main(string[] args)
{
var barcode = new Barcode(args[1], BarcodeFormat.Parse(args[0]));
File.WriteAllText(args[2], barcode.ToSVG());
}
}
Executing this sample code from the command line would look like this:
dotnet run -- <barcode-format> <text> <out-svg-file-name>
For an example how to write a PNG file instead of a SVG file, have a look at the ZXingCpp.DemoWriter.
There are a number of areas where ZXingCpp shines compared to other popular .NET barcode scanner libraries. The following comparison is with respect to the open source ZXing.Net and the commercial Dynamsoft projects.
To compare the performance of ZXingCpp with the other two libraries, I started the project zxing-bench. The README contains a few details but to get an idea: ZXingCpp is on average 2x-10x faster than Dynamsoft and 10x-50x faster than ZXing.Net.
The benchmarking tool also showed that ZXingCpp has a superior detection rate compared to ZXing.Net while it is sometimes better sometimes worse than the commercial Dynamsoft package, depending on the sample type and the library configuration. The latter definitively supports more barcode formats compared to the two ZXing descendents.
The sample program above shows the simplicity of the API. The others are similar but seem a bit more complicated with regards to setting parameters.
ZXingCpp has full support for binary data and ECI handling and provides a standards conforming bytesECI()
data that can be used to simulate a hardware/handheld barcode scanner. This seems not the case for ZXing.Net
and is unclear for Dynamsoft.
ZXingCpp has the liberal Apache-2.0 license and is free to use in commercial applications. That said, I accept donations and might be available for commercial consulting 😉.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 is compatible. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 2 NuGet packages that depend on ZXingCpp:
| Package | Downloads |
|---|---|
|
BarcodeScanning.Native.Maui
Barcode scanning library for .NET MAUI |
|
|
evodoc-library-dotnet-barcode-detector
Package Description |
Showing the top 1 popular GitHub repositories that depend on ZXingCpp:
| Repository | Stars |
|---|---|
|
afriscic/BarcodeScanning.Native.Maui
Barcode scanning library for .NET MAUI
|
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 0.5.1 | 7,476 | 2/17/2026 | |
| 0.5.0 | 7,297 | 2/13/2026 | 0.5.0 is deprecated. |
| 0.4.0-alpha | 10,486 | 1/4/2025 | 0.4.0-alpha is deprecated because it is no longer maintained. |
| 0.3.0-alpha | 339 | 11/5/2024 | 0.3.0-alpha is deprecated because it is no longer maintained. |
| 0.2.2-alpha | 2,862 | 9/8/2024 | 0.2.2-alpha is deprecated because it is no longer maintained. |