- Zig 99.8%
- C 0.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| examples/images | ||
| src | ||
| .gitignore | ||
| build.zig | ||
| build.zig.zon | ||
| LICENSE.md | ||
| README.md | ||
QR Code - Zig
Bringing QR Codes to Zig.
This package uses the QR Code generator of nayuki.
Supported Zig version: 0.16.0
| Barcode Type | Example | License | Read | Write | Link to Repository | Link to Website |
|---|---|---|---|---|---|---|
| QR Code | ![]() |
MIT | ✅ | QR-Code-generator | Project Nayuki - QR Code generator library |
Running
zig buildwill most likely fail due to a unknown issue that has something to do with using thewriteToFilefunction ofzigimg. Please build withzig build -Doptimize=ReleaseFast!
Usage
This package offers the following:
- a command line application for generating QR Codes
- the
libqrcodegen.aandqrcodegen.hfiles - a Zig module
qrcodethat wrapslibqrcodegen
Command Line Application
Requires Zig version
0.16.0
First clone this repository and then change into its local directory:
git clone https://codeberg.org/r4gus/qrcode-zig.git
cd qrcode-zig
Next, run the following to build the command line application:
zig build cla -Doptimize=ReleaseFast
Afterwards you can find the application under zig-out/bin/, the library under zig-out/lib and the corresponding header file under zig-out/include.
Finally, run the following command as a test
./zig-out/bin/qrcode "https://eurozig.eu" --image png --file zig.png -s 16
The --image option allows you to specify the image type. Currently, only png is supported. As an alternative you can print the generated qr code to the console by leaving out the --image argument.
The --file option must be used in conjunction with the --image option and allows you to specify the name of the file to write the image to.
Finally, the -s or --scale option allows you to specify the scale of each qr code module in pixels.
Zig Module
To use this package (meaning the qrcode module or libqrcodegen.a) within your own application, first add this package as a dependency to your build.zig.zon:
Getting Started
zig fetch --save git+https://codeberg.org/r4gus/qrcode-zig.git
Next add the module to your build.zig:
const qrcode = b.dependency("qrcode_zig", .{});
exe.root_module.addImport("qrcode", qrcode.module("qrcode"));
or link the static library with:
my_mod.linkLibrary(qrcode.artifact("qrcodegen"));
Using the module
First import the qrcode module:
const qrcode = @import("qrcode");
TODO
