From 6e54d94908f9960f9118e18ebb930a769af4922b Mon Sep 17 00:00:00 2001 From: Andrew Mahone Date: Wed, 14 Jan 2009 08:15:35 +0000 Subject: reduce pictureflow's fade_color by one multiply, and a few shifts, while still maintaining reasonable quality git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19770 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/pictureflow.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/apps/plugins/pictureflow.c b/apps/plugins/pictureflow.c index a355283..739e97c 100644 --- a/apps/plugins/pictureflow.c +++ b/apps/plugins/pictureflow.c @@ -1067,20 +1067,22 @@ void recalc_table(void) #if (LCD_PIXELFORMAT == RGB565SWAPPED) static inline pix_t fade_color(pix_t c, unsigned int a) { + unsigned int result; c = swap16(c); - unsigned int result=0; - result |= (((c & 0x1f) * a) >> 8) & 0x1f; - result |= (((c & 0x7e0) * a) >> 8) & 0x7e0; - result |= (((c & 0xf800) * a) >> 8) & 0xf800; + a = (a + 2) & 0x1fc; + result = ((c & 0xf81f) * a) & 0xf81f00; + result |= ((c & 0x7e0) * a) & 0x7e000; + result >>= 8; return swap16(result); } #elif LCD_PIXELFORMAT == RGB565 static inline pix_t fade_color(pix_t c, unsigned int a) { - unsigned int result=0; - result |= (((c & 0x1f) * a) >> 8) & 0x1f; - result |= (((c & 0x7e0) * a) >> 8) & 0x7e0; - result |= (((c & 0xf800) * a) >> 8) & 0xf800; + unsigned int result; + a = (a + 2) & 0x1fc; + result = ((c & 0xf81f) * a) & 0xf81f00; + result |= ((c & 0x7e0) * a) & 0x7e000; + result >>= 8; return result; } #else -- cgit v1.1