comparison mupdf-source/thirdparty/zint/extras/ida_2d.c @ 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 /*
2 * ida_2d.c
3 *
4 * This code uses Zint to encode data into a QR Code and then outputs
5 * the symbol as text suitable for use with the IDAutomation2D font
6 *
7 * This code can be adapted to use any matrix symbology by changing the
8 * line indicated.
9 *
10 * This code can be compiled with:
11 *
12 * gcc -o ida_2d ida_2d.c -lzint
13 *
14 * Fonts can be downloaded from https://www.idautomation.com/
15 *
16 */
17
18 #include <stdio.h>
19 #include <zint.h>
20 #include <string.h>
21 int main(int argc, char **argv)
22 {
23 struct zint_symbol *my_symbol;
24 int error = 0;
25 int x, y, sub, glyph;
26
27 my_symbol = ZBarcode_Create();
28
29 my_symbol->symbology = BARCODE_QRCODE; // Change symbology here
30 my_symbol->output_options = OUT_BUFFER_INTERMEDIATE;
31
32 error = ZBarcode_Encode(my_symbol, argv[1], strlen(argv[1]));
33 if (error != 0)
34 {
35 printf("%s\n", my_symbol->errtxt);
36 }
37 if (error >= ZINT_ERROR_TOO_LONG)
38 {
39 ZBarcode_Delete(my_symbol);
40 return 1;
41 }
42
43 for (y = 0; y < my_symbol->rows; y += 4) {
44 for (x = 0; x < my_symbol->width; x++) {
45 glyph = 0;
46 for (sub = 0; sub < 4; sub++) {
47 glyph *= 2;
48 if ((y + sub) < my_symbol->rows) {
49 if (((my_symbol->encoded_data[y + sub][x / 8] >> (x % 8)) & 1) == 0) {
50 glyph += 1;
51 }
52 } else {
53 glyph += 1;
54 }
55 }
56 glyph += 'A';
57 printf("%c", glyph);
58 }
59 printf("\n");
60 }
61
62 ZBarcode_Delete(my_symbol);
63 return 0;
64 }