From ef30e0aef2ef9aac02c03707f73d9d0acd78329d Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 3 Nov 2011 22:27:53 +0000 Subject: [PATCH] Fix some RGB color macros git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4081 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/ChangeLog | 3 +++ nuttx/include/nuttx/rgbcolors.h | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 0dd5c1f3e..b752b8ec3 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -2192,3 +2192,6 @@ supports using "clusters" of AT24 pages as blocks. This allows bigger block sizes and more efficient use of EEPROM when the AT24 is used to support a file system (such as NXFFS). (Contributed by Hal Glenn). + * include/nuttx/rgbcolors.h: More fixes to RGB color conversion + macros. + diff --git a/nuttx/include/nuttx/rgbcolors.h b/nuttx/include/nuttx/rgbcolors.h index 93212f6e1..0f15d8158 100644 --- a/nuttx/include/nuttx/rgbcolors.h +++ b/nuttx/include/nuttx/rgbcolors.h @@ -56,10 +56,15 @@ #define RBG24GREEN(rgb) (((rgb) >> 8) & 0xff) #define RBG24BLUE(rgb) ( (rgb) & 0xff) -/* This macro creates RGB16 (5:6:5) from 8:8:8 RGB */ +/* This macro creates RGB16 (5:6:5) from 8:8:8 RGB: + * + * R[7:3] -> RGB[15:11] + * G[7:2] -> RGB[10:5] + * B[7:3] -> RGB[4:0] + */ #define RGBTO16(r,g,b) \ - ((((uint16_t)(r) << 11) & 0xf800) | (((uint16_t)(g) << 5) & 0x07e0) | ((uint16_t)(b) & 0x001f)) + ((((uint16_t)(r) << 8) & 0xf800) | (((uint16_t)(g) << 3) & 0x07e0) | (((uint16_t)(b) >> 3) & 0x001f)) /* And these macros perform the inverse transformation */