diff options
author | Marvin W <git@larma.de> | 2019-01-02 15:24:03 +0100 |
---|---|---|
committer | Marvin W <git@larma.de> | 2019-01-02 15:36:41 +0100 |
commit | cdd4c0b854fd4d27fa1d9bd941df03888301780a (patch) | |
tree | 9a6643d693d9868c20da9d54e1e68b175e7d5571 /plugins/omemo/vapi/libqrencode.vapi | |
parent | 7012023d5997287b1ed300e03a4c5b91eb6c9c39 (diff) | |
download | dino-cdd4c0b854fd4d27fa1d9bd941df03888301780a.tar.gz dino-cdd4c0b854fd4d27fa1d9bd941df03888301780a.zip |
Find libqrencode using cmake/pkg-config logic
Diffstat (limited to 'plugins/omemo/vapi/libqrencode.vapi')
-rw-r--r-- | plugins/omemo/vapi/libqrencode.vapi | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/plugins/omemo/vapi/libqrencode.vapi b/plugins/omemo/vapi/libqrencode.vapi new file mode 100644 index 00000000..fc77c855 --- /dev/null +++ b/plugins/omemo/vapi/libqrencode.vapi @@ -0,0 +1,50 @@ +using Gdk; + +[CCode (cheader_filename = "qrencode.h")] +namespace Qrencode { + + [CCode (cname = "QRecLevel", cprefix = "QR_ECLEVEL_")] + public enum ECLevel { + L, + M, + Q, + H + } + + [CCode (cname = "QRencodeMode", cprefix = "QR_MODE_")] + public enum EncodeMode { + NUL, + NUM, + AN, + [CCode (cname = "QR_MODE_8")] + EIGHT_BIT, + KANJI, + STRUCTURE, + ECI, + FNC1FIRST, + FNC1SECOND + } + + [CCode (cname = "QRcode", free_function = "QRcode_free", has_type_id = false)] + [Compact] + public class QRcode { + private int version; + private int width; + [CCode (array_length = false)] + private uint8[] data; + + [CCode (cname = "QRcode_encodeString")] + public QRcode (string str, int version = 0, ECLevel level = ECLevel.L, EncodeMode hint = EncodeMode.EIGHT_BIT, bool casesensitive = true); + + public Pixbuf to_pixbuf() { + uint8[] bitmap = new uint8[3*width*width]; + for (int i = 0; i < width*width; i++) { + uint8 color = (data[i] & 1) == 1 ? 0 : 255; + bitmap[i*3] = color; + bitmap[i*3+1] = color; + bitmap[i*3+2] = color; + } + return new Pixbuf.from_data(bitmap, Colorspace.RGB, false, 8, width, width, width*3); + } + } +} |