fastqr 1.0.1 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,97 @@
1
+ /*
2
+ * FastQR - Fast QR Code Generator Library
3
+ * Copyright (C) 2025 FastQR Project
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ */
15
+
16
+ #ifndef FASTQR_H
17
+ #define FASTQR_H
18
+
19
+ #include <string>
20
+ #include <cstdint>
21
+
22
+ namespace fastqr {
23
+
24
+ /**
25
+ * QR Code error correction level
26
+ */
27
+ enum class ErrorCorrectionLevel {
28
+ LOW, // Level L - ~7% correction
29
+ MEDIUM, // Level M - ~15% correction
30
+ QUARTILE, // Level Q - ~25% correction
31
+ HIGH // Level H - ~30% correction
32
+ };
33
+
34
+ /**
35
+ * Options for QR code generation
36
+ */
37
+ struct QROptions {
38
+ // Output image size (QR codes are square)
39
+ int size = 300;
40
+
41
+ // Optimize size - round up to nearest integer multiple for best performance
42
+ bool optimize_size = false;
43
+
44
+ // QR code colors (RGB)
45
+ struct Color {
46
+ uint8_t r = 0;
47
+ uint8_t g = 0;
48
+ uint8_t b = 0;
49
+ };
50
+
51
+ Color foreground = {0, 0, 0}; // QR code color (default: black)
52
+ Color background = {255, 255, 255}; // Background color (default: white)
53
+
54
+ // Error correction level
55
+ ErrorCorrectionLevel ec_level = ErrorCorrectionLevel::MEDIUM;
56
+
57
+ // Logo options
58
+ std::string logo_path = ""; // Path to logo image
59
+ int logo_size_percent = 20; // Logo size as percentage of QR code (default: 20%)
60
+
61
+ // Output format
62
+ std::string format = "png"; // png, jpg, webp, etc.
63
+ int quality = 95; // For lossy formats (1-100)
64
+ };
65
+
66
+ /**
67
+ * Generate QR code and save to file
68
+ *
69
+ * @param data The data to encode (supports UTF-8)
70
+ * @param output_path Path to save the generated QR code image
71
+ * @param options QR code generation options
72
+ * @return true if successful, false otherwise
73
+ */
74
+ bool generate(const std::string& data, const std::string& output_path, const QROptions& options = QROptions());
75
+
76
+ /**
77
+ * Generate QR code and return image data as buffer
78
+ *
79
+ * @param data The data to encode (supports UTF-8)
80
+ * @param buffer Output buffer for image data
81
+ * @param buffer_size Size of the output buffer
82
+ * @param options QR code generation options
83
+ * @return Size of image data written to buffer, or -1 on error
84
+ */
85
+ int generate_to_buffer(const std::string& data, void* buffer, size_t buffer_size, const QROptions& options = QROptions());
86
+
87
+ /**
88
+ * Get library version
89
+ *
90
+ * @return Version string (e.g., "1.0.0")
91
+ */
92
+ const char* version();
93
+
94
+ } // namespace fastqr
95
+
96
+ #endif // FASTQR_H
97
+