comparison mupdf-source/thirdparty/zxing-cpp/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 [![Build Status](https://github.com/zxing-cpp/zxing-cpp/workflows/CI/badge.svg?branch=master)](https://github.com/zxing-cpp/zxing-cpp/actions?query=workflow%3ACI)
2
3 # ZXing-C++
4
5 ZXing-C++ ("zebra crossing") is an open-source, multi-format linear/matrix barcode image processing library implemented in C++.
6
7 It was originally ported from the Java [ZXing Library](https://github.com/zxing/zxing) but has been developed further and now includes many improvements in terms of runtime and detection performance. It can both read and write barcodes in a number of formats.
8
9 ## Sponsors
10
11 You can sponsor this library at [GitHub Sponsors](https://github.com/sponsors/axxel).
12
13 Named Sponsors:
14 * [KURZ Digital Solutions GmbH & Co. KG](https://github.com/kurzdigital)
15 * [Useful Sensors Inc](https://github.com/usefulsensors)
16 * [EUREKAM](https://eurekam.fr/)
17
18 Thanks a lot for your contribution!
19
20 ## Features
21
22 * Written in pure C++20 (/C++17), no third-party dependencies (for the library itself)
23 * Thread safe
24 * Wrappers/Bindings for:
25 * [Android](wrappers/android/README.md)
26 * [C](wrappers/c/README.md)
27 * [iOS](wrappers/ios/README.md)
28 * [Kotlin/Native](wrappers/kn/README.md)
29 * [.NET](wrappers/dotnet/README.md)
30 * [Python](wrappers/python/README.md)
31 * [Rust](wrappers/rust/README.md)
32 * [WebAssembly](wrappers/wasm/README.md)
33 * [WinRT](wrappers/winrt/README.md)
34 * [Flutter](https://pub.dev/packages/flutter_zxing) (external project)
35
36 ## Supported Formats
37
38 | Linear product | Linear industrial | Matrix |
39 |-----------------|-------------------|--------------------|
40 | UPC-A | Code 39 | QR Code |
41 | UPC-E | Code 93 | Micro QR Code |
42 | EAN-8 | Code 128 | rMQR Code |
43 | EAN-13 | Codabar | Aztec |
44 | DataBar | DataBar Expanded | DataMatrix |
45 | DataBar Limited | DX Film Edge | PDF417 |
46 | | ITF | MaxiCode (partial) |
47
48 [Note:]
49 * DataBar used to be called RSS.
50 * DataBar, DX Film Edge, MaxiCode, Micro QR Code and rMQR Code are not supported for writing (unless the library is configured `ZXING_WRITERS=NEW` and `ZXING_EXPERIMENTAL_API=ON`).
51 * Building with only C++17 (see [CMakeLists.txt](https://github.com/zxing-cpp/zxing-cpp/blob/d4b0f502775857f257d13efd25fb840ece1bca3e/CMakeLists.txt#L45)) changes the behavior of the library: it then lacks support for DataBarLimited and multi-symbol and position independent detection for DataMatrix.
52
53 ## Getting Started
54
55 ### To read barcodes:
56 1. Load your image into memory (3rd-party library required).
57 2. Call `ReadBarcodes()` from [`ReadBarcode.h`](core/src/ReadBarcode.h), the simplest API to get a list of `Barcode` objects.
58
59 A very simple example looks like this:
60 ```c++
61 #include "ZXing/ReadBarcode.h"
62 #include <iostream>
63
64 int main(int argc, char** argv)
65 {
66 int width, height;
67 unsigned char* data;
68 // load your image data from somewhere. ImageFormat::Lum assumes grey scale image data.
69
70 auto image = ZXing::ImageView(data, width, height, ZXing::ImageFormat::Lum);
71 auto options = ZXing::ReaderOptions().setFormats(ZXing::BarcodeFormat::Any);
72 auto barcodes = ZXing::ReadBarcodes(image, options);
73
74 for (const auto& b : barcodes)
75 std::cout << ZXing::ToString(b.format()) << ": " << b.text() << "\n";
76
77 return 0;
78 }
79 ```
80 To see the full capability of the API, have a look at [`ZXingReader.cpp`](example/ZXingReader.cpp).
81
82 [Note: At least C++17 is required on the client side to use the API.]
83
84 ### To write barcodes:
85 1. Create a [`MultiFormatWriter`](core/src/MultiFormatWriter.h) instance with the format you want to generate. Set encoding and margins if needed.
86 2. Call `encode()` with text content and the image size. This returns a [`BitMatrix`](core/src/BitMatrix.h) which is a binary image of the barcode where `true` == visual black and `false` == visual white.
87 3. Convert the bit matrix to your native image format. See also the `ToMatrix<T>(BitMatrix&)` helper function.
88
89 As an example, have a look at [`ZXingWriter.cpp`](example/ZXingWriter.cpp). That file also contains example code showing the new `ZXING_EXPERIMENTAL_API` for writing barcodes.
90
91 ## Web Demos
92 - [Read barcodes](https://zxing-cpp.github.io/zxing-cpp/demo_reader.html)
93 - [Write barcodes](https://zxing-cpp.github.io/zxing-cpp/demo_writer.html)
94 - [Read barcodes from camera](https://zxing-cpp.github.io/zxing-cpp/demo_cam_reader.html)
95
96 [Note: those live demos are not necessarily fully up-to-date at all times.]
97
98 ## Build Instructions
99 These are the generic instructions to build the library on Windows/macOS/Linux. For details on how to build the individual wrappers, follow the links above.
100
101 1. Make sure [CMake](https://cmake.org) version 3.16 or newer is installed. The python module requires 3.18 or higher.
102 2. Make sure a sufficiently C++20 compliant compiler is installed (minimum VS 2019 16.10? / gcc 11 / clang 12?).
103 3. See the cmake `ZXING_...` options to enable the testing code, python wrapper, etc.
104
105 ```
106 git clone https://github.com/zxing-cpp/zxing-cpp.git --recursive --single-branch --depth 1
107 cmake -S zxing-cpp -B zxing-cpp.release -DCMAKE_BUILD_TYPE=Release
108 cmake --build zxing-cpp.release -j8 --config Release
109 ```
110
111 [Note: binary packages are available for/as
112 [vcpkg](https://github.com/Microsoft/vcpkg/tree/master/ports/nu-book-zxing-cpp),
113 [conan](https://github.com/conan-io/conan-center-index/tree/master/recipes/zxing-cpp),
114 [mingw](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-zxing-cpp) and a bunch of
115 [linux distributions](https://repology.org/project/zxing-cpp/versions).]