From a2ef5fb18db5f04a183ca7907c5abd21de17e485 Mon Sep 17 00:00:00 2001 From: Stefan Misch Date: Tue, 10 Jun 2025 16:24:27 +0200 Subject: [PATCH] fix short hand values #FCD is the short form for #FFCCDD but the old code parsed it to #F0C0D0 This fixes that. --- src/main.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1562890..74b62ff 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,15 +43,18 @@ Color getColor(const char* param, unsigned char maxval) { if(strlen(color) == 4 || strlen(color) == 7) { char flag = 0; std::string hex(color); - unsigned int red = 0, green = 0, blue = 0; + unsigned int red = 0, green = 0, blue = 0, temp = 0; if (strlen(color) == 4) { // Try to parse the color as a shorthand 3-character color (e.g. '#FFF') if (sscanf(hex.substr(1,1).c_str(), "%X", &red) + sscanf(hex.substr(2,1).c_str(), "%X", &green) + sscanf(hex.substr(3,1).c_str(), "%X", &blue) == 3) { - red = red << 4; - green = green << 4; - blue = blue << 4; + temp = red; + red = red << 4 + temp; + temp = green; + green = green << 4 + temp; + temp = blue; + blue = blue << 4 + temp; flag++; } } else if (strlen(color) == 7) {