Skip to content

Commit a9e72ef

Browse files
committed
Update zxing-cpp to 3.0.2
1 parent dbb8db9 commit a9e72ef

186 files changed

Lines changed: 5671 additions & 3229 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Qt 6.x "minor" versions are full of major breakages, it's just not feasible to s
1212

1313
Available backends:
1414
- QZXing / v3.3.0 + Qt6 port + many patches
15-
- zxing-cpp / v2.3.0 + custom QML integration
15+
- zxing-cpp / v3.0.2 + custom QML integration
1616
- zint / v2.16 + custom QML integration
1717

1818
> Works on Android and iOS!

qml/ScreenAboutFormats.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Flickable {
7373
ListModel {
7474
id: zxingcpp
7575
property string name: "zxing-cpp"
76-
property string version: "2.3.0"
76+
property string version: "3.0.2"
7777
ListElement { type: "linear"; name: "UPC-A"; decode: 1; encode: 1; }
7878
ListElement { type: "linear"; name: "UPC-E"; decode: 1; encode: 1; }
7979
ListElement { type: "linear"; name: "EAN-8"; decode: 1; encode: 1; }

thirdparty/zxing-cpp/CMakeLists.txt

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@ project(ZXing)
44

55
option (ZXING_READERS "Build with reader support (decoders)" ON)
66
set (ZXING_WRITERS "ON" CACHE STRING "Build with old and/or new writer (encoder) backend (OFF/ON/OLD/NEW/BOTH)")
7-
option (ZXING_USE_BUNDLED_ZINT "Use the bundled libzint for barcode creation/writing" ON)
87
option (ZXING_C_API "Build the C-API" OFF)
98
option (ZXING_QT_QML "Build the Qt/QML wrapper" OFF)
109
option (ZXING_EXPERIMENTAL_API "Build with experimental API" OFF)
1110
option (ZXING_EXAMPLES "Build the example barcode reader/writer applications" OFF)
11+
option (ZXING_EXAMPLES_QT "Build the Qt based example barcode reader/writer applications" OFF)
1212
option (ZXING_BLACKBOX_TESTS "Build the black box reader/writer tests" OFF)
1313
option (ZXING_UNIT_TESTS "Build the unit tests (don't enable for production builds)" OFF)
14+
option (ZXING_TEST_DOTNET "Test if the .NET wrapper works" OFF)
15+
option (ZXING_TEST_INSTALL "Test if the installed/public API works" OFF)
1416
option (ZXING_PYTHON_MODULE "Build the python module" OFF)
1517
set (ZXING_DEPENDENCIES "AUTO" CACHE STRING "Fetch from github or use locally installed (AUTO/GITHUB/LOCAL)")
18+
option (ZXING_CLANG_TIDY "Enable clang-tidy analysis" OFF)
1619

17-
if (WIN32 OR IOS)
20+
if (WIN32)
1821
option (BUILD_SHARED_LIBS "Build and link as shared library" OFF)
1922
else()
2023
option (BUILD_SHARED_LIBS "Build and link as shared library" ON)
@@ -35,51 +38,45 @@ if (NOT CMAKE_BUILD_TYPE)
3538
set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
3639
endif()
3740

38-
# provide backward compatibility for deprecated BUILD_... options
39-
if (DEFINED BUILD_READERS)
40-
set (ZXING_READERS ${BUILD_READERS})
41-
endif()
42-
if (DEFINED BUILD_WRITERS)
43-
set (ZXING_WRITERS ${BUILD_WRITERS})
44-
endif()
45-
if (DEFINED BUILD_EXAMPLES)
46-
message (WARNING "zxing-cpp cmake options BUILD_... are deprecated, please switch to ZXING_... variant")
47-
set (ZXING_EXAMPLES ${BUILD_EXAMPLES})
48-
endif()
49-
if (DEFINED BUILD_PYTHON_MODULE)
50-
message (WARNING "zxing-cpp cmake options BUILD_... are deprecated, please switch to ZXING_... variant")
51-
set (ZXING_PYTHON_MODULE ${BUILD_PYTHON_MODULE})
52-
endif()
53-
if (DEFINED BUILD_DEPENDENCIES)
54-
message (WARNING "zxing-cpp cmake options BUILD_... are deprecated, please switch to ZXING_... variant")
55-
set (ZXING_DEPENDENCIES ${BUILD_DEPENDENCIES})
56-
endif()
57-
5841
if (NOT (ZXING_READERS OR ZXING_WRITERS))
5942
message(FATAL_ERROR "At least one of ZXING_READERS/ZXING_WRITERS must be enabled.")
6043
endif()
6144

6245
set(ZXING_WRITERS_LIST OFF ON OLD NEW BOTH)
6346
set_property(CACHE ZXING_WRITERS PROPERTY STRINGS ${ZXING_WRITERS_LIST})
64-
if (NOT ZXING_WRITERS IN_LIST ZXING_WRITERS_LIST)
47+
if(NOT ZXING_WRITERS IN_LIST ZXING_WRITERS_LIST)
6548
message(FATAL_ERROR "ZXING_WRITERS must be one of ${ZXING_WRITERS_LIST}")
6649
endif()
6750

6851
set(ZXING_DEPENDENCIES_LIST AUTO GITHUB LOCAL)
6952
set_property(CACHE ZXING_DEPENDENCIES PROPERTY STRINGS ${ZXING_DEPENDENCIES_LIST})
70-
if (NOT ZXING_DEPENDENCIES IN_LIST ZXING_DEPENDENCIES_LIST)
53+
if(NOT ZXING_DEPENDENCIES IN_LIST ZXING_DEPENDENCIES_LIST)
7154
message(FATAL_ERROR "ZXING_DEPENDENCIES must be one of ${ZXING_DEPENDENCIES_LIST}")
7255
endif()
7356

7457
if (NOT DEFINED CMAKE_CXX_STANDARD)
7558
set (CMAKE_CXX_STANDARD 20)
76-
# Allow the fallback to earlier versions if the compiler does not support it.
77-
set(CMAKE_CXX_STANDARD_REQUIRED OFF)
78-
endif()
79-
if (NOT DEFINED CMAKE_CXX_EXTENSIONS)
59+
set (CMAKE_CXX_STANDARD_REQUIRED ON)
8060
set (CMAKE_CXX_EXTENSIONS OFF)
8161
endif()
8262

63+
set(CMAKE_COLOR_DIAGNOSTICS ON)
64+
65+
if (ZXING_CLANG_TIDY)
66+
find_program(CMAKE_CXX_CLANG_TIDY NAMES "clang-tidy" DOC "Path to clang-tidy executable")
67+
if (NOT CMAKE_CXX_CLANG_TIDY)
68+
message(WARNING "clang-tidy not found.")
69+
else()
70+
message(STATUS "clang-tidy found: ${CMAKE_CXX_CLANG_TIDY}")
71+
set(ZXING_DISABLE_PCH ON)
72+
endif()
73+
endif()
74+
75+
# make installed binaries relocatable on macOS and Linux
76+
set(CMAKE_BUILD_RPATH_USE_ORIGIN ON) # improve build reproducibility
77+
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
78+
set(CMAKE_INSTALL_RPATH "$<$<PLATFORM_ID:Darwin>:@loader_path/../lib>$<$<PLATFORM_ID:Linux>:$ORIGIN/../lib>")
79+
8380
add_subdirectory (core)
8481

8582
enable_testing()
@@ -89,12 +86,29 @@ include(zxing.cmake)
8986
if (ZXING_EXAMPLES)
9087
add_subdirectory (example)
9188
endif()
89+
if (ZXING_EXAMPLES_QT)
90+
add_subdirectory (wrappers/qt)
91+
endif()
9292
if (ZXING_BLACKBOX_TESTS)
9393
add_subdirectory (test/blackbox)
9494
endif()
9595
if (ZXING_UNIT_TESTS)
9696
add_subdirectory (test/unit)
9797
endif()
98+
if (ZXING_TEST_DOTNET)
99+
add_subdirectory (wrappers/dotnet)
100+
endif()
101+
if (ZXING_TEST_INSTALL)
102+
add_test(
103+
NAME InstallTest
104+
COMMAND
105+
${CMAKE_COMMAND}
106+
-DPROJECT_BINARY_DIR=${CMAKE_BINARY_DIR}
107+
-DSOURCE_DIR=${CMAKE_SOURCE_DIR}/test/install
108+
-DZXING_WRITERS=${ZXING_WRITERS}
109+
-P ${CMAKE_SOURCE_DIR}/test/install/run.cmake
110+
)
111+
endif()
98112
if (ZXING_PYTHON_MODULE)
99113
add_subdirectory (wrappers/python)
100114
endif()

thirdparty/zxing-cpp/README.md

Lines changed: 78 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,80 @@
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)
1+
[![Build Status](https://github.com/zxing-cpp/zxing-cpp/actions/workflows/ci.yml/badge.svg)](https://github.com/zxing-cpp/zxing-cpp/actions?query=workflow%3ACI)
22

33
# ZXing-C++
44

55
ZXing-C++ ("zebra crossing") is an open-source, multi-format linear/matrix barcode image processing library implemented in C++.
66

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-
* [Liftric GmbH](https://github.com/Liftric)
15-
* [KURZ Digital Solutions GmbH & Co. KG](https://github.com/kurzdigital)
16-
* [Useful Sensors Inc](https://github.com/usefulsensors)
17-
* [Sergio Olivo](https://github.com/sergio-)
18-
19-
Thanks a lot for your contribution!
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. Since version 3.0 the default writing backend is provided by the [zint library](https://sourceforge.net/projects/zint/).
208

219
## Features
2210

23-
* Written in pure C++17 (/C++20), no third-party dependencies (for the library itself)
11+
* Written in pure C++20 (public API is C++17 compatible), no third-party dependencies (for the library itself)
2412
* Thread safe
2513
* Wrappers/Bindings for:
2614
* [Android](wrappers/android/README.md)
2715
* [C](wrappers/c/README.md)
2816
* [iOS](wrappers/ios/README.md)
17+
* [Kotlin/Native](wrappers/kn/README.md)
18+
* [.NET](wrappers/dotnet/README.md)
2919
* [Python](wrappers/python/README.md)
20+
* [Qt](wrappers/qt/README.md)
21+
* [Rust](wrappers/rust/README.md)
3022
* [WebAssembly](wrappers/wasm/README.md)
3123
* [WinRT](wrappers/winrt/README.md)
3224
* [Flutter](https://pub.dev/packages/flutter_zxing) (external project)
3325

3426
## Supported Formats
3527

36-
| Linear product | Linear industrial | Matrix |
37-
|----------------|-------------------|--------------------|
38-
| UPC-A | Code 39 | QR Code |
39-
| UPC-E | Code 93 | Micro QR Code |
40-
| EAN-8 | Code 128 | rMQR Code |
41-
| EAN-13 | Codabar | Aztec |
42-
| DataBar | DataBar Expanded | DataMatrix |
43-
| | ITF | PDF417 |
44-
| | | MaxiCode (partial) |
28+
| Symbology | Variants |
29+
|:----------|:---------|
30+
| ***Retail:*** | *(Point-of-Sale, Coupons)*
31+
| EAN/UPC | EAN-13, EAN-8, EAN-5ᵂ, EAN-2ᵂ, UPC-A, UPC-E, ISBN
32+
| DataBar | Omnidirectional, Stacked, Limited, Expanded, Expanded Stacked
33+
| ***Industrial:*** | *(Logistics, Tracking, Pharma)*
34+
| Code39 | Standard, Extended, PZN, Code32, (VIN, LOGMARS)
35+
| Code93 |
36+
| Code128 |
37+
| ITF | ITF-14, (DHL Leitcode, DHL Identcode)
38+
| ***Matrix:*** | *(Documents, Tickets, Logistics, IDs)*
39+
| Aztec Code | Aztec Code, Aztec Rune
40+
| Data Matrix | ECC200
41+
| MaxiCode | (partial read support)
42+
| PDF417 | PDF417, Compact PDF417, MicroPDF417ᵂ
43+
| QR Code | Model 1ᴿ, Model 2, Micro QR Code, rMQR
44+
| ***Other:*** | *(Legacy, Niche)*
45+
| Codabar |
46+
| DXFilmEdge |
47+
4548

4649
[Note:]
50+
* ᵂ : write support only
51+
* ᴿ : read support only
4752
* DataBar used to be called RSS.
48-
* DataBar, MaxiCode, Micro QR Code and rMQR Code are not supported for writing.
49-
* Building with C++20 (see [CMakeLists.txt](https://github.com/zxing-cpp/zxing-cpp/blob/d4b0f502775857f257d13efd25fb840ece1bca3e/CMakeLists.txt#L45)) changes the behaviour of the library: it then supports multi-symbol and position independent detection for DataMatrix. This comes at a noticable performace cost. C++20 is enabled by default for the Android, iOS, Python and WASM wrappers.
53+
* DataBar, DX Film Edge, MaxiCode, Micro QR Code and rMQR Code are not supported for writing if the library is configured with `ZXING_WRITERS=OLD`.
54+
55+
## Sponsors
56+
57+
You can sponsor this library at [GitHub Sponsors](https://github.com/sponsors/axxel).
58+
59+
| | Named Sponsors: |
60+
|:-:|:-|
61+
| [![KURZ](https://avatars.githubusercontent.com/u/25196688?s=32)](https://github.com/kurzdigital) | [KURZ Digital Solutions GmbH & Co. KG](https://github.com/kurzdigital) |
62+
| [![Moonshine AI](https://avatars.githubusercontent.com/u/98664891?s=32)](https://github.com/moonshine-ai) | [Moonshine AI](https://github.com/moonshine-ai) |
63+
| [![SAP](https://avatars.githubusercontent.com/u/2531208?s=32)](https://www.sap.com/germany/about/company/innovation/open-source.html) | [SAP (Open Source Program Office)](https://www.sap.com/germany/about/company/innovation/open-source.html) |
64+
| [![Somco Software](https://avatars.githubusercontent.com/u/41477867?s=32)](https://github.com/somcosoftware) | [Somco Software](https://somcosoftware.com/en) |
65+
| [![synedra](https://www.synedra.com/favicon.ico)](https://synedra.com/) | [synedra information technologies GmbH](https://synedra.com/) |
66+
67+
Thanks a lot for your contribution!
5068

5169
## Getting Started
5270

5371
### To read barcodes:
5472
1. Load your image into memory (3rd-party library required).
55-
2. Call `ReadBarcodes()` from [`ReadBarcode.h`](core/src/ReadBarcode.h), the simplest API to get a list of `Result` objects.
73+
2. Call `ReadBarcodes()` from [`ReadBarcode.h`](core/src/ReadBarcode.h), the simplest API to get a list of `Barcode` objects.
5674

5775
A very simple example looks like this:
5876
```c++
59-
#include "ZXing/ReadBarcode.h"
77+
#include "ZXing/ZXingCpp.h"
6078
#include <iostream>
6179

6280
int main(int argc, char** argv)
@@ -66,23 +84,41 @@ int main(int argc, char** argv)
6684
// load your image data from somewhere. ImageFormat::Lum assumes grey scale image data.
6785

6886
auto image = ZXing::ImageView(data, width, height, ZXing::ImageFormat::Lum);
69-
auto options = ZXing::ReaderOptions().setFormats(ZXing::BarcodeFormat::Any);
70-
auto results = ZXing::ReadBarcodes(image, options);
87+
auto options = ZXing::ReaderOptions().formats(ZXing::BarcodeFormat::QRCode);
88+
auto barcodes = ZXing::ReadBarcodes(image, options);
7189

72-
for (const auto& r : results)
73-
std::cout << ZXing::ToString(r.format()) << ": " << r.text() << "\n";
90+
for (const auto& b : barcodes)
91+
std::cout << ZXing::ToString(b.format()) << ": " << b.text() << "\n";
7492

7593
return 0;
7694
}
7795
```
7896
To see the full capability of the API, have a look at [`ZXingReader.cpp`](example/ZXingReader.cpp).
7997
8098
### To write barcodes:
81-
1. Create a [`MultiFormatWriter`](core/src/MultiFormatWriter.h) instance with the format you want to generate. Set encoding and margins if needed.
82-
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.
83-
3. Convert the bit matrix to your native image format. See also the `ToMatrix<T>(BitMatrix&)` helper function.
99+
1. Create a `Barcode` object with `CreateBarcodeFrom...()` from [`CreateBarcode.h`](core/src/CreateBarcode.h).
100+
2. The `Barcode::symbol()` can be used to get access to the bit matrix (1 module == 1 pixel, no quiet zone)
101+
3. Alternatively the 3 `WriteBarcodeTo...()` functions from [`WriteBarcode.h`](core/src/WriteBarcode.h) can be used to create an `Image`, a SVG string or a UTF-8 string representation.
102+
103+
A very simple example looks like this:
104+
```c++
105+
#include "ZXing/ZXingCpp.h"
106+
#include <iostream>
107+
108+
int main(int argc, char** argv)
109+
{
110+
auto barcode = ZXing::CreateBarcodeFromText("some text", ZXing::BarcodeFormat::QRCode);
111+
auto svg = ZXing::WriteBarcodeToSVG(barcode);
112+
113+
// see also ZXing::WriteBarcodeToImage()
114+
115+
std::cout << svg << "\n";
116+
117+
return 0;
118+
}
119+
```
84120

85-
As an example, have a look at [`ZXingWriter.cpp`](example/ZXingWriter.cpp).
121+
As an example for how to parameterize the process with `CreatorOptions` and `WriterOptions`, have a look at [`ZXingWriter.cpp`](example/ZXingWriter.cpp).
86122

87123
## Web Demos
88124
- [Read barcodes](https://zxing-cpp.github.io/zxing-cpp/demo_reader.html)
@@ -94,14 +130,14 @@ As an example, have a look at [`ZXingWriter.cpp`](example/ZXingWriter.cpp).
94130
## Build Instructions
95131
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.
96132

97-
1. Make sure [CMake](https://cmake.org) version 3.15 or newer is installed.
98-
2. Make sure a C++17 compliant compiler is installed (minimum VS 2019 16.8 / gcc 7 / clang 5).
99-
3. See the cmake `BUILD_...` options to enable the testing code, python wrapper, etc.
133+
1. Make sure [CMake](https://cmake.org) version 3.16 or newer is installed. The python module requires 3.18 or higher.
134+
2. Make sure a sufficiently C++20 compliant compiler is installed (minimum VS 2019 16.10? / gcc 11 / clang 12?).
135+
3. See the cmake `ZXING_...` options to enable the testing code, python wrapper, etc.
100136

101137
```
102-
git clone https://github.com/zxing-cpp/zxing-cpp.git --single-branch --depth 1
103-
cmake -S zxing-cpp -B zxing-cpp.release -DCMAKE_BUILD_TYPE=Release
104-
cmake --build zxing-cpp.release -j8 --config Release
138+
git clone https://github.com/zxing-cpp/zxing-cpp.git --recursive --depth 1
139+
cmake -S zxing-cpp -B zxing-cpp/build -DCMAKE_BUILD_TYPE=Release
140+
cmake --build zxing-cpp/build --parallel --config Release
105141
```
106142

107143
[Note: binary packages are available for/as

0 commit comments

Comments
 (0)