comparison mupdf-source/thirdparty/zxing-cpp/wrappers/c/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 # C bindings for zxing-cpp
2
3 This is about the C-API of zxing-cpp. If you have any comments or feedback, please have a look at https://github.com/zxing-cpp/zxing-cpp/discussions/583.
4
5 ## Installation
6
7 To enable the C-API, the library needs to be configured with `cmake -DZXING_C_API=ON`.
8
9 Probably the easiest way to play with the C-API is to just modify the [ZXingCTest.c](https://github.com/zxing-cpp/zxing-cpp/blob/master/wrappers/c/ZXingCTest.c) file.
10
11 ## Usage
12
13 The following is close to the most trivial use case scenario that is supported.
14
15 ```c
16 #include "ZXing/ZXingC.h"
17
18 int main(int argc, char** argv)
19 {
20 int width, height;
21 unsigned char* data;
22 /* load your image data from somewhere. ZXing_ImageFormat_Lum assumes grey scale image data. */
23
24 ZXing_ImageView* iv = ZXing_ImageView_new(data, width, height, ZXing_ImageFormat_Lum, 0, 0);
25
26 ZXing_ReaderOptions* opts = ZXing_ReaderOptions_new();
27 /* set ReaderOptions properties, if requried, e.g. */
28 ZXing_ReaderOptions_setFormats(ZXing_BarcodeFormat_QRCode | ZXing_BarcodeFromat_EAN13);
29
30 ZXing_Barcodes* barcodes = ZXing_ReadBarcodes(iv, opts);
31
32 ZXing_ImageView_delete(iv);
33 ZXing_ReaderOptions_delete(opts);
34
35 if (barcodes) {
36 for (int i = 0, n = ZXing_Barcodes_size(barcodes); i < n; ++i) {
37 const ZXing_Barcode* barcode = ZXing_Barcodes_at(barcodes, i);
38
39 char* format = ZXing_BarcodeFormatToString(ZXing_Barcode_format(barcode));
40 printf("Format : %s\n", format);
41 ZXing_free(format);
42
43 char* text = ZXing_Barcode_text(barcode);
44 printf("Text : %s\n", text);
45 ZXing_free(text);
46 }
47 ZXing_Barcodes_delete(barcodes);
48 } else {
49 char* error = ZXing_LastErrorMsg();
50 fprintf(stderr, "%s\n", error);
51 ZXing_free(error);
52 }
53
54 return 0;
55 }
56 ```
57