Skip to content

Commit 510783e

Browse files
committed
README: make the standard API and build instructions more prominent
Add hint at minimum required compiler versions.
1 parent 8ae0db3 commit 510783e

File tree

1 file changed

+27
-31
lines changed

1 file changed

+27
-31
lines changed

README.md

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,47 +27,56 @@ Same as ZXing, following barcode are supported:
2727
| | RSS-14 |
2828
| | RSS-Expanded |
2929

30+
## Getting Started
31+
32+
### To read barcodes:
33+
As an example, have a look at [`ZXingReader.cpp`](example/ZXingReader.cpp).
34+
1. Load your image into memory (3rd-party library required).
35+
2. Call `ReadBarcode()` from [`ReadBarcode.h`](core/src/ReadBarcode.h), the simplest API to get a `Result`.
36+
37+
### To write barcodes:
38+
As an example, have a look at [`ZXingWriter.cpp`](example/ZXingWriter.cpp).
39+
1. Create a [`MultiFormatWriter`](core/src/MultiFormatWriter.h) instance with the format you want to generate. Set encoding and margins if needed.
40+
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.
41+
3. Convert the bit matrix to your native image format. See also the `ToMatrix<T>(BitMatrix&)` helper function.
42+
3043
## Web Demos
31-
- [Scan barcodes](https://nu-book.github.io/zxing-cpp/demo_reader.html)
32-
- [Generate barcodes](https://nu-book.github.io/zxing-cpp/demo_writer.html)
44+
- [Read barcodes](https://nu-book.github.io/zxing-cpp/demo_reader.html)
45+
- [Write barcodes](https://nu-book.github.io/zxing-cpp/demo_writer.html)
3346
- [Scan with camera](https://nu-book.github.io/zxing-cpp/zxing_viddemo.html)
3447

35-
3648
## WinRT Package
3749
A nuget package is available for WinRT: [huycn.zxingcpp.winrt](https://www.nuget.org/packages/huycn.zxingcpp.winrt).
3850
To install it, run the following command in the Package Manager Console
3951
```sh
4052
PM> Install-Package huycn.zxingcpp.winrt
4153
```
4254

43-
## Getting Started
44-
The wrappers export very simple API to use, check `BarcodeReader` and `BarcodeGenerator` in each wrapper.
45-
For more fine-grain control in scanning process, check [`MultiFormatReader`](core/src/MultiFormatReader.h) class. For more customization when generating particular barcode format, you need to instantiate appropriate writer, see [`MultiFormatWriter`](core/src/MultiFormatWriter.h) for more details.
55+
## Build Instructions
4656

57+
### Standard setup on Windows/macOS/Linux
58+
1. Make sure [CMake](https://cmake.org) version 3.10 or newer is installed.
59+
2. Make sure a C++14 compliant compiler is installed (minimum VS 2017 15.0 / gcc 5 / clang 3.4)
60+
3. See the cmake `BUILD_...` options to enable the testing code, python wrapper, etc.
4761

48-
## Build Instructions
49-
### For Windows Desktop with VS
50-
1. Download and install [CMake](https://cmake.org) if it's not already installed.
51-
2. Open CMake GUI, specify [`wrappers/gdiplus`](wrappers/gdiplus) as source folder in the first input, specify the build output in the second input, and click on Generate.
52-
3. At prompt, select "Visual Studio 14 2015" (or "Visual Studio 14 2015 Win64" if you want to build for x64 platform); leave the second input (Optional toolset...) empty; leave "Use default native compilers" checked; and click on Finish to generate the VS project. At the end, you will get a solution (.sln) in your binary output directory that you can open in VS. The project ZXingGdiPlus in the solution will generate a static library.
62+
### Windows GDIPlus wrapper
63+
1. Open CMake GUI, specify [`wrappers/gdiplus`](wrappers/gdiplus) as source folder in the first input, specify the build output in the second input, and click on Generate.
64+
2. At prompt, select "Visual Studio 15 2017" (or "Visual Studio 15 2017 Win64" if you want to build for x64 platform); leave the second input (Optional toolset...) empty; leave "Use default native compilers" checked; and click on Finish to generate the VS project. At the end, you will get a solution (.sln) in your binary output directory that you can open in VS. The project ZXingGdiPlus in the solution will generate a static library.
5365

54-
### For Windows Universal Platform
66+
### Windows Universal Platform
5567
1. Download and install [CMake](https://cmake.org) 3.4 or more recent if it's not already installed.
5668
2. Edit the file [`wrappers/winrt/BuildWinCom.bat`](wrappers/winrt/BuildWinCom.bat) to adjust the path to your CMake installation.
5769
3. Double-click on the batch script to run it.
5870
4. If the build succeeds, it will put the results in the folder UAP which is ready-to-use SDK extension.
5971

60-
### For Android NDK
61-
Note: The original Java-only [ZXing](https://github.com/zxing/zxing) project has a very good support for Android, whether you want to use it
62-
as external app via Intent or directly integrated into your app. You should consider using it first before
63-
trying this library since involving with native code is always more complex than Java-only code. Performance-wise,
64-
except for specific usecases, you won't notice the difference!
72+
### Android NDK
73+
Note: The original Java-only [ZXing](https://github.com/zxing/zxing) project has a very good support for Android, whether you want to use it as external app via Intent or directly integrated into your app. You should consider using it first before trying this library since involving with native code is always more complex than Java-only code. Performance-wise, except for specific usecases, you won't notice the difference!
6574

6675
1. Edit [`wrappers/android/jni/Application.mk`](wrappers/android/jni/Application.mk) and adjust for your project.
6776
2. On command line, `cd` into [`wrappers/android/jni`](wrappers/android/jni), type `ndk-build` (or `ndk-build -j <number of your CPU cores>`)
6877
3. Copy files in `libs` and `java` into corresponding folders of your Android project.
6978

70-
### For web browser (WebAssembly)
79+
### WebAssembly
7180
1. [Install Emscripten](https://kripken.github.io/emscripten-site/docs/getting_started/) if not done already.
7281
2. In an empty build folder, invoke `emcmake cmake <path to zxing-cpp.git/wrappers/wasm>`.
7382
3. Invoke `cmake --bulid .` to create `zxing.js` and `zxing.wasm` (and `_reader`/`_writer` versions).
@@ -76,16 +85,3 @@ except for specific usecases, you won't notice the difference!
7685
You can also download the latest build output from the continuous integration system from the [Actions](https://github.com/nu-book/zxing-cpp/actions) tab. Look for 'wasm-artifacts'.
7786

7887
For usage examples see [reader](wrappers/wasm/demo_reader.html) and [writer](wrappers/wasm/demo_writer.html) demos or the [live demos](https://nu-book.github.io/zxing-cpp/).
79-
80-
### For other platforms
81-
82-
##### To read barcodes:
83-
As an example, have a look at [`ZXingReader.cpp`](example/ZXingReader.cpp).
84-
1. Load your image into memory (3rd-party library required).
85-
2. Call `ReadBarcode()` from [`ReadBarcode.h`](core/src/ReadBarcode.h), the simplest API to get a `Result`.
86-
87-
##### To write barcodes:
88-
As an example, have a look at [`ZXingWriter.cpp`](example/ZXingWriter.cpp).
89-
1. Create a [`MultiFormatWriter`](core/src/MultiFormatWriter.h) instance with the format you want to generate. Set encoding and margins if needed.
90-
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.
91-
3. Convert the bit matrix to your native image format. See also the `ToMatrix<T>(BitMatrix&)` helper function.

0 commit comments

Comments
 (0)