From e0ca7581ef8fa8adbd99f53dd76f3057c3a62add Mon Sep 17 00:00:00 2001 From: Paul Peavyhouse Date: Fri, 4 Oct 2019 17:03:40 -0700 Subject: [PATCH] Initial commit of only 565 to 888; will check others next --- src/lv_misc/lv_color.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lv_misc/lv_color.h b/src/lv_misc/lv_color.h index a73ab8c88..f4bd7d52c 100644 --- a/src/lv_misc/lv_color.h +++ b/src/lv_misc/lv_color.h @@ -305,9 +305,14 @@ static inline uint32_t lv_color_to32(lv_color_t color) #elif LV_COLOR_DEPTH == 16 #if LV_COLOR_16_SWAP == 0 lv_color32_t ret; - ret.ch.red = color.ch.red * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/ - ret.ch.green = color.ch.green * 4; /*(2^8 - 1)/(2^6 - 1) = 255/63 = 4*/ - ret.ch.blue = color.ch.blue * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/ + /** + * Per https://docs.google.com/spreadsheets/d/1PppX8FJpddauAPasHwlNgIPGIuPGPNvRbhilIQ8w-7g/edit#gid=0 + * Truly any of the listed multipliers and adders would work. + * The below numbers seem the most precise. + */ + ret.ch.red = ( color.ch.red * 33 - 3 ) >> 2; + ret.ch.green = ( color.ch.green * 4 + 3 ); + ret.ch.blue = ( color.ch.blue * 33 - 3 ) >> 2; ret.ch.alpha = 0xFF; return ret.full; #else