VOOZH about

URL: https://www.nuget.org/packages/ZXingCpp/

⇱ NuGet Gallery | ZXingCpp 0.5.1




ZXingCpp 0.5.1

dotnet add package ZXingCpp --version 0.5.1
 
 
NuGet\Install-Package ZXingCpp -Version 0.5.1
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ZXingCpp" Version="0.5.1" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZXingCpp" Version="0.5.1" />
 
Directory.Packages.props
<PackageReference Include="ZXingCpp" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ZXingCpp --version 0.5.1
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ZXingCpp, 0.5.1"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ZXingCpp@0.5.1
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ZXingCpp&version=0.5.1
 
Install as a Cake Addin
#tool nuget:?package=ZXingCpp&version=0.5.1
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

ZXingCpp

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.

Usage Reading

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).

Usage Writing

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.

Why ZXingCpp?

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.

Performance

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.

Detection rate

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.

Ease of use

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.

Standards support

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.

License / costs

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net5.0

    • No dependencies.

NuGet packages (2)

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

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on ZXingCpp:

Repository Stars
afriscic/BarcodeScanning.Native.Maui
Barcode scanning library for .NET MAUI