1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 10:24:26 +01:00

Improved Epaper QR code generation

This commit is contained in:
Ralf Ramsauer 2015-05-21 13:56:20 +02:00
parent f44bf630aa
commit 218e273c26
2 changed files with 8 additions and 3 deletions

View File

@ -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

View File

@ -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)
{