fastqr 1.0.1
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.
- checksums.yaml +7 -0
- data/BUILD.md +482 -0
- data/CHANGELOG.md +51 -0
- data/CMakeLists.txt +126 -0
- data/CONTRIBUTING.md +63 -0
- data/DISTRIBUTION.md +730 -0
- data/INSTALL.md +171 -0
- data/LICENSE +39 -0
- data/PREBUILT.md +171 -0
- data/README.md +312 -0
- data/VERSION +1 -0
- data/bindings/nodejs/binding.gyp +38 -0
- data/bindings/nodejs/fastqr_node.cpp +125 -0
- data/bindings/nodejs/index.d.ts +80 -0
- data/bindings/nodejs/index.js +187 -0
- data/bindings/nodejs/lib/platform.js +72 -0
- data/bindings/nodejs/package.json +45 -0
- data/bindings/nodejs/test/test.js +45 -0
- data/bindings/php/fastqr_php.cpp +85 -0
- data/bindings/php/src/FastQR.php +316 -0
- data/bindings/php/tests/FastQRTest.php +97 -0
- data/bindings/ruby/extconf.rb +29 -0
- data/bindings/ruby/fastqr_ruby.cpp +122 -0
- data/bindings/ruby/lib/fastqr/platform.rb +70 -0
- data/bindings/ruby/lib/fastqr/version.rb +6 -0
- data/bindings/ruby/lib/fastqr.rb +129 -0
- data/bindings/ruby/prebuilt/macos-arm64.tar.gz +1 -0
- data/bindings/ruby/prebuilt/macos-x86_64.tar.gz +1 -0
- data/build.sh +109 -0
- data/cmake/fastqrConfig.cmake.in +6 -0
- data/composer.json +36 -0
- data/docs/CLI_USAGE.md +478 -0
- data/docs/NODEJS_USAGE.md +694 -0
- data/docs/PHP_USAGE.md +815 -0
- data/docs/README.md +191 -0
- data/docs/RUBY_USAGE.md +537 -0
- data/examples/CMakeLists.txt +7 -0
- data/examples/basic.cpp +58 -0
- data/include/fastqr.h +97 -0
- data/include/stb_image.h +7988 -0
- data/include/stb_image_write.h +1724 -0
- data/phpunit.xml +18 -0
- data/prebuilt/README.md +131 -0
- data/scripts/README.md +248 -0
- data/scripts/build-binaries.sh +98 -0
- data/scripts/build-local.sh +18 -0
- data/scripts/install.sh +87 -0
- data/scripts/release.sh +78 -0
- data/scripts/update-version.sh +58 -0
- data/src/cli.cpp +316 -0
- data/src/fastqr.cpp +665 -0
- data/test.sh +86 -0
- metadata +155 -0
data/examples/basic.cpp
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* FastQR - Fast QR Code Generator Library
|
|
3
|
+
* Copyright (C) 2025 FastQR Project
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#include "fastqr.h"
|
|
7
|
+
#include <iostream>
|
|
8
|
+
|
|
9
|
+
int main() {
|
|
10
|
+
std::cout << "FastQR Basic Example\n\n";
|
|
11
|
+
|
|
12
|
+
// Basic usage
|
|
13
|
+
fastqr::QROptions options;
|
|
14
|
+
options.size = 400;
|
|
15
|
+
|
|
16
|
+
if (fastqr::generate("Hello, FastQR!", "basic_qr.png", options)) {
|
|
17
|
+
std::cout << "β Generated basic_qr.png\n";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Colored QR code
|
|
21
|
+
options.foreground = {255, 0, 0}; // Red
|
|
22
|
+
options.background = {255, 255, 200}; // Light yellow
|
|
23
|
+
|
|
24
|
+
if (fastqr::generate("Colored QR Code", "colored_qr.png", options)) {
|
|
25
|
+
std::cout << "β Generated colored_qr.png\n";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// UTF-8 support - Vietnamese
|
|
29
|
+
if (fastqr::generate("Xin chΓ o Viα»t Nam! π»π³", "vietnamese_qr.png", options)) {
|
|
30
|
+
std::cout << "β Generated vietnamese_qr.png (Vietnamese text)\n";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// UTF-8 support - Japanese
|
|
34
|
+
options.foreground = {0, 0, 255}; // Blue
|
|
35
|
+
if (fastqr::generate("γγγ«γ‘γ―ζ₯ζ¬", "japanese_qr.png", options)) {
|
|
36
|
+
std::cout << "β Generated japanese_qr.png (Japanese text)\n";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// High error correction
|
|
40
|
+
options.foreground = {0, 0, 0};
|
|
41
|
+
options.ec_level = fastqr::ErrorCorrectionLevel::HIGH;
|
|
42
|
+
|
|
43
|
+
if (fastqr::generate("High Error Correction", "high_ec_qr.png", options)) {
|
|
44
|
+
std::cout << "β Generated high_ec_qr.png (with HIGH error correction)\n";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Large QR code
|
|
48
|
+
options.size = 2000;
|
|
49
|
+
options.ec_level = fastqr::ErrorCorrectionLevel::MEDIUM;
|
|
50
|
+
|
|
51
|
+
if (fastqr::generate("Large QR Code - 2000x2000px", "large_qr.png", options)) {
|
|
52
|
+
std::cout << "β Generated large_qr.png (2000x2000)\n";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
std::cout << "\nAll examples completed successfully!\n";
|
|
56
|
+
return 0;
|
|
57
|
+
}
|
|
58
|
+
|
data/include/fastqr.h
ADDED
|
@@ -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
|
+
|