mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Reverse QR code colors and add padding
All QR scanners should be able to recognize this, as it is now the correct color with some padding to prevent blending. Signed-off-by: swirl <swurl@swurl.xyz>
This commit is contained in:
parent
9a9a97868d
commit
d64cb38240
@ -9778,4 +9778,3 @@ cmd_mood(ProfWin* window, const char* const command, gchar** args)
|
|||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -871,24 +871,37 @@ cons_show_omemo_qrcode(const char* const text)
|
|||||||
{
|
{
|
||||||
#ifdef HAVE_QRENCODE
|
#ifdef HAVE_QRENCODE
|
||||||
static const size_t ZOOM_SIZE = 10;
|
static const size_t ZOOM_SIZE = 10;
|
||||||
QRcode *qrcode = QRcode_encodeString(text, 0, QR_ECLEVEL_L, QR_MODE_8, 1);
|
QRcode* qrcode = QRcode_encodeString(text, 0, QR_ECLEVEL_L, QR_MODE_8, 1);
|
||||||
|
|
||||||
int width = (qrcode->width * ZOOM_SIZE);
|
int width = (qrcode->width * ZOOM_SIZE);
|
||||||
unsigned char *data = qrcode->data;
|
unsigned char* data = qrcode->data;
|
||||||
|
|
||||||
ProfWin* console = wins_get_console();
|
ProfWin* console = wins_get_console();
|
||||||
|
|
||||||
char buf[(width * 4) + 1];
|
char buf[(width * 4) + 1];
|
||||||
memset(buf, 0, sizeof buf);
|
memset(buf, 0, sizeof buf);
|
||||||
for (size_t y = 0; y < width; y+=ZOOM_SIZE) {
|
|
||||||
for (size_t x = 0; x < width; x+=ZOOM_SIZE) {
|
char tmp[(width * 4) + 5];
|
||||||
strcat(buf, (*data & 1) ? "\u2588\u2588" : "\u2800\u2800");
|
memset(tmp, 0, sizeof tmp);
|
||||||
|
|
||||||
|
for (int i = 0; i < width + 2 * ZOOM_SIZE; i += ZOOM_SIZE) {
|
||||||
|
strcat(tmp, "\u2588\u2588");
|
||||||
|
}
|
||||||
|
|
||||||
|
win_println(console, THEME_DEFAULT, "", tmp);
|
||||||
|
for (size_t y = 0; y < width; y += ZOOM_SIZE) {
|
||||||
|
for (size_t x = 0; x < width; x += ZOOM_SIZE) {
|
||||||
|
strcat(buf, !(*data & 1) ? "\u2588\u2588" : "\u2800\u2800");
|
||||||
|
|
||||||
data++;
|
data++;
|
||||||
}
|
}
|
||||||
win_println(console, THEME_DEFAULT, "", "%s", buf);
|
|
||||||
|
// The extra squares are for padding, so that the QR code doesn't
|
||||||
|
// "blend in" with the rest of the terminal window.
|
||||||
|
win_println(console, THEME_DEFAULT, "", "\u2588\u2588%s\u2588\u2588", buf);
|
||||||
memset(buf, 0, sizeof buf);
|
memset(buf, 0, sizeof buf);
|
||||||
}
|
}
|
||||||
|
win_println(console, THEME_DEFAULT, "", "%s", tmp);
|
||||||
|
|
||||||
QRcode_free(qrcode);
|
QRcode_free(qrcode);
|
||||||
#endif
|
#endif
|
||||||
@ -2926,4 +2939,3 @@ cons_remove_alert(ProfWin* window)
|
|||||||
g_list_free_full(item, g_free);
|
g_list_free_full(item, g_free);
|
||||||
free(win_name);
|
free(win_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user