comparison mupdf-source/include/mupdf/fitz/barcode.h @ 3:2c135c81b16c

MERGE: upstream PyMuPDF 1.26.4 with MuPDF 1.26.7
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:44:09 +0200
parents b50eed0cc0ef
children
comparison
equal deleted inserted replaced
0:6015a75abc2d 3:2c135c81b16c
1 // Copyright (C) 2004-2025 Artifex Software, Inc.
2 //
3 // This file is part of MuPDF.
4 //
5 // MuPDF is free software: you can redistribute it and/or modify it under the
6 // terms of the GNU Affero General Public License as published by the Free
7 // Software Foundation, either version 3 of the License, or (at your option)
8 // any later version.
9 //
10 // MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Affero General Public License
16 // along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
17 //
18 // Alternative licensing terms are available from the licensor.
19 // For commercial licensing, see <https://www.artifex.com/> or contact
20 // Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
21 // CA 94129, USA, for further information.
22
23 #ifndef MUPDF_FITZ_BARCODE_H
24 #define MUPDF_FITZ_BARCODE_H
25
26 #include "mupdf/fitz/system.h"
27 #include "mupdf/fitz/context.h"
28 #include "mupdf/fitz/geometry.h"
29 #include "mupdf/fitz/image.h"
30 #include "mupdf/fitz/document.h"
31 #include "mupdf/fitz/display-list.h"
32
33 typedef enum
34 {
35 FZ_BARCODE_NONE = 0,
36 FZ_BARCODE_AZTEC,
37 FZ_BARCODE_CODABAR,
38 FZ_BARCODE_CODE39,
39 FZ_BARCODE_CODE93,
40 FZ_BARCODE_CODE128,
41 FZ_BARCODE_DATABAR,
42 FZ_BARCODE_DATABAREXPANDED,
43 FZ_BARCODE_DATAMATRIX,
44 FZ_BARCODE_EAN8,
45 FZ_BARCODE_EAN13,
46 FZ_BARCODE_ITF,
47 FZ_BARCODE_MAXICODE,
48 FZ_BARCODE_PDF417,
49 FZ_BARCODE_QRCODE,
50 FZ_BARCODE_UPCA,
51 FZ_BARCODE_UPCE,
52 FZ_BARCODE_MICROQRCODE,
53 FZ_BARCODE_RMQRCODE,
54 FZ_BARCODE_DXFILMEDGE,
55 FZ_BARCODE_DATABARLIMITED,
56
57 FZ_BARCODE__LIMIT
58 } fz_barcode_type;
59
60 /**
61 Return barcode string matching one of the above barcode types.
62 All lowercase, e.g. "none", "aztec" etc.
63 */
64 const char *fz_string_from_barcode_type(fz_barcode_type type);
65
66 /**
67 Helper function to search the above list (case insensitively)
68 for an exact match. Returns FZ_BARCODE_NONE if no match found.
69 */
70 fz_barcode_type fz_barcode_type_from_string(const char *str);
71
72
73 /**
74 Create an fz_image from a barcode definition.
75
76 type: The type of barcode to create.
77 value: The value of the barcode.
78 size: The size of the barcode.
79 ec_level: error correction level 0-8.
80 quiet: whether to include quiet zones (0 or 1).
81 hrt: whether to include human readable text below the barcode (0 or 1).
82
83 returns a created fz_image.
84 */
85 fz_image *fz_new_barcode_image(fz_context *ctx, fz_barcode_type type, const char *value, int size, int ec_level, int quiet, int hrt);
86
87 /**
88 Create an fz_pixmap from a barcode definition.
89
90 type: The type of barcode to create.
91 value: The value of the barcode.
92 size: The size of the barcode.
93 ec_level: error correction level 0-8.
94 quiet: whether to include quiet zones (0 or 1).
95 hrt: whether to include human readable text below the barcode (0 or 1).
96
97 returns a created fz_pixmap.
98 */
99 fz_pixmap *fz_new_barcode_pixmap(fz_context *ctx, fz_barcode_type type, const char *value, int size, int ec_level, int quiet, int hrt);
100
101
102 /**
103 Decode a barcode from a page.
104
105 type: NULL, or a pointer to recieve the barcode type decoded.
106 page: The page to decode.
107 subarea: subarea of the page to decode.
108 rotate: 0, 90, 180, or 270.
109
110 returns the decoded value.
111 */
112 char *fz_decode_barcode_from_page(fz_context *ctx, fz_barcode_type *type, fz_page *page, fz_rect subarea, int rotate);
113
114 /**
115 Decode a barcode from a pixmap.
116
117 type: NULL, or a pointer to recieve the barcode type decoded.
118 pix: The pixmap to decode.
119 rotate: 0, 90, 180, or 270.
120
121 returns the decoded value as an fz_malloced block. Should
122 be fz_free'd by the caller.
123 */
124 char *fz_decode_barcode_from_pixmap(fz_context *ctx, fz_barcode_type *type, fz_pixmap *pix, int rotate);
125
126 /**
127 Decode a barcode from a display list.
128
129 type: NULL, or a pointer to recieve the barcode type decoded.
130 list: The display list to render to get the barcode.
131 subarea: subarea of the page to decode.
132 rotate: 0, 90, 180, or 270.
133
134 returns the decoded value.
135 */
136 char *fz_decode_barcode_from_display_list(fz_context *ctx, fz_barcode_type *type, fz_display_list *list, fz_rect subarea, int rotate);
137
138 #endif /* MUPDF_FITZ_BARCODE_H */