From 6c6c0ba3d943ba9f46432a961c5c6adfe0cc83c8 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 21 Oct 2011 20:55:39 +0000 Subject: [PATCH] Add some RGB color macros git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4056 42af7a65-404d-4744-a932-0658087f49c3 --- include/nuttx/nx/nx.h | 4 ++-- include/nuttx/rgbcolors.h | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/nuttx/nx/nx.h b/include/nuttx/nx/nx.h index c848b91e5f..d582256fb7 100644 --- a/include/nuttx/nx/nx.h +++ b/include/nuttx/nx/nx.h @@ -747,8 +747,8 @@ EXTERN int nx_move(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, * * Input Parameters: * hwnd - The window that will receive the bitmap image - * dest - Describes the rectangular on the display that will receive the - * the bit map. + * dest - Describes the rectangular region on the display that will + * receive the bit map. * src - The start of the source image. This is an array source * images of size CONFIG_NX_NPLANES. * origin - The origin of the upper, left-most corner of the full bitmap. diff --git a/include/nuttx/rgbcolors.h b/include/nuttx/rgbcolors.h index 7dc6ef42dd..0a154a8b5b 100644 --- a/include/nuttx/rgbcolors.h +++ b/include/nuttx/rgbcolors.h @@ -50,16 +50,34 @@ #define RGBTO24(r,g,b) \ ((uint32_t)((r) & 0xff) << 16 | (uint32_t)((g) & 0xff) << 8 | (uint32_t)((b) & 0xff)) +/* And these macros perform the inverse transformation */ + +#define RBG24RED(rgb) (((rgb) >> 16) & 0xff) +#define RBG24GREEN(rgb) (((rgb) >> 8) & 0xff) +#define RBG24BLUE(rgb) ( (rgb) & 0xff) + /* This macro creates RGB16 (5:6:5) from 8:8:8 RGB */ #define RGBTO16(r,g,b) \ ((((uint16_t)(r) << 11) & 0xf800) | (((uint16_t)(r) << 5) & 0x07e0) | ((uint16_t)(r) & 0x001f)) +/* And these macros perform the inverse transformation */ + +#define RBG16RED(rgb) (((rgb) >> 8) & 0xf8) +#define RBG16GREEN(rgb) (((rgb) >> 3) & 0xfc) +#define RBG16BLUE(rgb) (((rgb) << 3) & 0xf8) + /* This macro creates RGB8 (3:3:2) from 8:8:8 RGB */ #define RGBTO8(r,g,b) \ ((((uint8_t)(r) << 5) & 0xe0) | (((uint8_t)(r) << 2) & 0x1c) | ((uint8_t)(r) & 0x03)) +/* And these macros perform the inverse transformation */ + +#define RBG8RED(rgb) ( (rgb) & 0xe0) +#define RBG8GREEN(rgb) (((rgb) << 3) & 0xe0) +#define RBG8BLUE(rgb) (((rgb) << 6) & 0xc0) + /* This macro converts RGB24 (8:8:8) to RGB16 (5:6:5): * * 00000000 RRRRRRRR BBBBBBBB GGGGGGGG -> RRRRRBBB BBBGGGGG