From 8cae5dc48dcd6d0c1575a5ddb78944380639809c Mon Sep 17 00:00:00 2001 From: TangoCash Date: Mon, 24 Dec 2018 23:43:45 +0100 Subject: [PATCH] fix l4l alpha levels Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/de61085203195b59c7e3ceffd93908558829df43 Author: TangoCash Date: 2018-12-24 (Mon, 24 Dec 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/lcd4l.cpp | 19 +++++++++++++++++-- src/driver/lcd4l.h | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/driver/lcd4l.cpp b/src/driver/lcd4l.cpp index 068beffad..0395feafd 100644 --- a/src/driver/lcd4l.cpp +++ b/src/driver/lcd4l.cpp @@ -293,7 +293,7 @@ void CLCD4l::ParseInfo(uint64_t parseID, bool newID, bool firstRun) std::string fgcolor = hexStr(t.infobar_Text_red) + hexStr(t.infobar_Text_green) + hexStr(t.infobar_Text_blue) - + hexStr(t.infobar_Text_alpha); + + hexStrA2A(t.infobar_Text_alpha); if (m_fgcolor.compare(fgcolor)) { @@ -306,7 +306,7 @@ void CLCD4l::ParseInfo(uint64_t parseID, bool newID, bool firstRun) std::string bgcolor = hexStr(t.infobar_red) + hexStr(t.infobar_green) + hexStr(t.infobar_blue) - + hexStr(t.infobar_alpha); + + hexStrA2A(t.infobar_alpha); if (m_bgcolor.compare(bgcolor)) { @@ -1030,3 +1030,18 @@ std::string CLCD4l::hexStr(unsigned char data) snprintf(hexstr, sizeof hexstr, "%02x", (int)data * 255 / 100); return std::string(hexstr); } + +std::string CLCD4l::hexStrA2A(unsigned char data) +{ + char hexstr[3]; + int a = 100 - data; + int ret = a * 0xFF / 100; + + if(data == 0) + ret = 0xFF; + else if(data >= 100) + ret = 0x00; + + snprintf(hexstr, sizeof hexstr, "%02x", ret); + return std::string(hexstr); +} diff --git a/src/driver/lcd4l.h b/src/driver/lcd4l.h index 76a1c6dc3..696b0f40c 100644 --- a/src/driver/lcd4l.h +++ b/src/driver/lcd4l.h @@ -68,6 +68,7 @@ class CLCD4l bool CompareParseID(uint64_t &i_ParseID); std::string hexStr(unsigned char data); + std::string hexStrA2A(unsigned char data); void strReplace(std::string &orig, const std::string &fstr, const std::string &rstr); bool WriteFile(const char *file, std::string content = "", bool convert = false);