summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-07-15 23:03:47 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-07-16 09:17:17 +0200
commit322d8a509ed2e60623ee7828a7ffbc0dfda30728 (patch)
tree4e43a60d73578ef26ba0938b35d0d2e3c39ab7c5 /lib
parent3ea4dee7fddd7a04f663da5884596501c434a771 (diff)
downloadbarebox-322d8a509ed2e60623ee7828a7ffbc0dfda30728.tar.gz
barebox-322d8a509ed2e60623ee7828a7ffbc0dfda30728.tar.xz
graphics_utils: add function to create pixel from rgb triplet
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/gui/graphic_utils.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/lib/gui/graphic_utils.c b/lib/gui/graphic_utils.c
index 516e90312b..7302611cb4 100644
--- a/lib/gui/graphic_utils.c
+++ b/lib/gui/graphic_utils.c
@@ -8,6 +8,31 @@
#include <malloc.h>
/**
+ * gu_get_pixel_rgb - convert a rgb triplet color to fb format
+ * @info: The framebuffer info to convert the pixel for
+ * @r: red component
+ * @g: green component
+ * @b: blue component
+ * @t: transparent component
+ *
+ * This converts a color to the format suitable for writing directly into
+ * the framebuffer.
+ *
+ * Return: The pixel suitable for the framebuffer
+ */
+u32 gu_rgb_to_pixel(struct fb_info *info, u8 r, u8 g, u8 b, u8 t)
+{
+ u32 px;
+
+ px = (t >> (8 - info->transp.length)) << info->transp.offset |
+ (r >> (8 - info->red.length)) << info->red.offset |
+ (g >> (8 - info->green.length)) << info->green.offset |
+ (b >> (8 - info->blue.length)) << info->blue.offset;
+
+ return px;
+}
+
+/**
* gu_hex_to_pixel - convert a 32bit color to fb format
* @info: The framebuffer info to convert the pixel for
* @color: The color in 0xttrrggbb format
@@ -30,12 +55,7 @@ u32 gu_hex_to_pixel(struct fb_info *info, u32 color)
return px;
}
- px = (t >> (8 - info->transp.length)) << info->transp.offset |
- (r >> (8 - info->red.length)) << info->red.offset |
- (g >> (8 - info->green.length)) << info->green.offset |
- (b >> (8 - info->blue.length)) << info->blue.offset;
-
- return px;
+ return gu_rgb_to_pixel(info, r, g, b, t);
}
static void memsetw(void *s, u16 c, size_t n)