comparison mupdf-source/thirdparty/zxing-cpp/wrappers/dotnet/ZXingCpp/README.md @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 # ZXingCpp
2
3 ZXingCpp is a .NET wrapper for the C++ library [zxing-cpp](https://github.com/zxing-cpp/zxing-cpp).
4
5 It is an open-source, multi-format linear/matrix barcode image processing library implemented in C++.
6 It was originally ported from the Java ZXing library but has been developed further and now includes
7 many improvements in terms of runtime and detection performance.
8
9
10 ## Usage Reading
11
12 ```cs
13 using SkiaSharp;
14 using ZXingCpp;
15
16 public class Program
17 {
18 public static void Main(string[] args)
19 {
20 var img = SKBitmap.Decode(args[0]).Copy(SKColorType.Gray8);
21 var iv = new ImageView(img.GetPixels(), img.Info.Width, img.Info.Height, ImageFormat.Lum);
22
23 var readBarcodes = new BarcodeReader() {
24 Formats = args.Length > 1 ? Barcode.FormatsFromString(args[1]) : BarcodeFormats.Any,
25 TryInvert = false,
26 // see the ReaderOptions implementation for more available options
27 };
28
29 foreach (var b in readBarcodes.From(iv))
30 Console.WriteLine($"{b.Format} : {b.Text}");
31 }
32 }
33 ```
34
35 Executing this sample code from the command line would look like this:
36 ```sh
37 dotnet run -- <image-file-name> [barcode-format-list]
38 ```
39
40 See also the [ZXingCpp.DemoReader](https://github.com/zxing-cpp/zxing-cpp/blob/master/wrappers/dotnet/ZXingCpp.DemoReader/Program.cs)
41 which shows the use of extension classes to support SkiaSharp and ImageMagick based input.
42
43 The NuGet package includes the runtime/native c++ libraries for the x64 architecture on
44 Windows, Linux and macOS. If something is not working out of the box or you need arm64 support
45 then you need to build the `[lib]ZXing[.dll|.so|.dylib]` file yourself and make sure the .NET
46 runtime find it (see e.g. the environment variables `LD_LIBRARY_PATH` on Linux or `PATH` on
47 Windows).
48
49 Note: This is an alpha release, meaning the API may still change slightly to potentially feel even
50 more like a native C# library depending on community feedback.
51
52 ## Usage Writing
53
54 ```cs
55 using ZXingCpp;
56
57 public class Program
58 {
59 public static void Main(string[] args)
60 {
61 var barcode = new Barcode(args[1], Barcode.FormatFromString(args[0]));
62 File.WriteAllText(args[2], barcode.ToSVG());
63 }
64 }
65 ```
66
67 Executing this sample code from the command line would look like this:
68 ```sh
69 dotnet run -- <barcode-format> <text> <out-svg-file-name>
70 ```
71
72 For an example how to write a PNG file instead of a SVG file, have a look at the
73 [ZXingCpp.DemoWriter](https://github.com/zxing-cpp/zxing-cpp/blob/master/wrappers/dotnet/ZXingCpp.DemoWriter/Program.cs).
74
75 ## Why ZXingCpp?
76
77 There are a number of areas where ZXingCpp shines compared to other popular .NET barcode scanner libraries.
78 The following comparison is with respect to the open source [ZXing.Net](https://www.nuget.org/packages/ZXing.Net)
79 and the commercial [Dynamsoft](https://www.nuget.org/packages/Dynamsoft.DotNet.Barcode) projects.
80
81 ### Performance
82
83 To compare the performance of ZXingCpp with the other two libraries, I started the project
84 [zxing-bench](https://github.com/axxel/zxing-bench).
85 The [README](https://github.com/axxel/zxing-bench/blob/main/dotnet/README.md) contains a few details but to get
86 an idea: ZXingCpp is on average 2x-10x faster than Dynamsoft and 10x-50x faster than ZXing.Net.
87
88 ### Detection rate
89
90 The benchmarking tool also showed that ZXingCpp has a superior detection rate compared to ZXing.Net while it is
91 sometimes better sometimes worse than the commercial Dynamsoft package, depending on the sample type and the
92 library configuration. The latter definitively supports more barcode formats compared to the two ZXing decendents.
93
94 ### Ease of use
95
96 The sample program above shows the simplicitly of the API. The others are similar but seem a bit more
97 complicated with regards to setting parameters.
98
99 ### Standards support
100
101 ZXingCpp has full support for binary data and ECI handling and provides a standards conforming `bytesECI()`
102 data that can be used to simulate a hardware/handheld barcode scanner. This seems not the case for ZXing.Net
103 and is unclear for Dynamsoft.
104
105 ### License / costs
106
107 ZXingCpp has the liberal Apache-2.0 license and is free to use in commercial applications. That said,
108 I accept [donations](https://github.com/sponsors/axxel) and might be available for commercial consulting ;).