mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-12-22 18:34:25 +01:00
Improved Epaper QR code generation
This commit is contained in:
parent
e6cba90b37
commit
c37f66ff91
@ -17,4 +17,6 @@
|
|||||||
#define DEFAULT_LOG_FILE "/var/log/doorlockd.log"
|
#define DEFAULT_LOG_FILE "/var/log/doorlockd.log"
|
||||||
#define DEFAULT_PID_FILE "/var/run/doorlockd.pid"
|
#define DEFAULT_PID_FILE "/var/run/doorlockd.pid"
|
||||||
|
|
||||||
|
#define TEMPLATE_LOCATION "@CMAKE_INSTALL_PREFIX@/share/doorlockd/template.png"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -10,6 +10,7 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include "epaper.h"
|
#include "epaper.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -34,10 +35,12 @@ Epaper &Epaper::get()
|
|||||||
void Epaper::draw(const string &uri)
|
void Epaper::draw(const string &uri)
|
||||||
{
|
{
|
||||||
unsigned char buffer[_ARRAY_SIZE];
|
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());
|
snprintf((char*)buffer, _ARRAY_SIZE,
|
||||||
system((char*)buffer);
|
"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);
|
int i = fread(buffer, _ARRAY_SIZE, 1, f);
|
||||||
if (i != 1)
|
if (i != 1)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user