From c37f66ff91a86019a34f209661322b9cfc2b8503 Mon Sep 17 00:00:00 2001 From: Ralf Ramsauer Date: Thu, 21 May 2015 13:56:20 +0200 Subject: [PATCH] Improved Epaper QR code generation --- doorlockd/config.h.in | 2 ++ doorlockd/epaper.cpp | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/doorlockd/config.h.in b/doorlockd/config.h.in index c4a36e9..bc9a7e5 100644 --- a/doorlockd/config.h.in +++ b/doorlockd/config.h.in @@ -17,4 +17,6 @@ #define DEFAULT_LOG_FILE "/var/log/doorlockd.log" #define DEFAULT_PID_FILE "/var/run/doorlockd.pid" +#define TEMPLATE_LOCATION "@CMAKE_INSTALL_PREFIX@/share/doorlockd/template.png" + #endif diff --git a/doorlockd/epaper.cpp b/doorlockd/epaper.cpp index 9dc329a..1b4ba3a 100644 --- a/doorlockd/epaper.cpp +++ b/doorlockd/epaper.cpp @@ -10,6 +10,7 @@ extern "C" { } #include "epaper.h" +#include "config.h" using namespace std; @@ -34,10 +35,12 @@ Epaper &Epaper::get() void Epaper::draw(const string &uri) { unsigned char buffer[_ARRAY_SIZE]; - snprintf((char*)buffer, _ARRAY_SIZE, "qrencode -l M -d 100 -s 5 \"%s\" -o /tmp/qr.png", uri.c_str()); - system((char*)buffer); + snprintf((char*)buffer, _ARRAY_SIZE, + "qrencode -l M -d 100 -s 5 \"%s\" -t png -o -" + "| composite -geometry +90+0 /dev/stdin " TEMPLATE_LOCATION " -colorspace gray -depth 1 gray:-", + uri.c_str()); - FILE* f = popen("composite -geometry +90+0 /tmp/qr.png /usr/local/share/doorlockd/template.png -colorspace gray -depth 1 gray:-", "r"); + FILE* f = popen((const char*)buffer, "r"); int i = fread(buffer, _ARRAY_SIZE, 1, f); if (i != 1) {