mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 05/12] graphics_utils: add function to create pixel from rgb triplet
Date: Thu, 16 Jul 2015 09:31:45 +0200	[thread overview]
Message-ID: <1437031912-24754-6-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1437031912-24754-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 include/gui/graphic_utils.h |  1 +
 lib/gui/graphic_utils.c     | 32 ++++++++++++++++++++++++++------
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/include/gui/graphic_utils.h b/include/gui/graphic_utils.h
index 136cac1..161f8d6 100644
--- a/include/gui/graphic_utils.h
+++ b/include/gui/graphic_utils.h
@@ -12,6 +12,7 @@
 #include <gui/gui.h>
 
 u32 gu_hex_to_pixel(struct fb_info *info, u32 color);
+u32 gu_rgb_to_pixel(struct fb_info *info, u8 r, u8 g, u8 b, u8 t);
 void gu_rgba_blend(struct fb_info *info, struct image *img, void* dest, int height,
 	int width, int startx, int starty, bool is_rgba);
 void gu_set_pixel(struct fb_info *info, void *adr, u32 px);
diff --git a/lib/gui/graphic_utils.c b/lib/gui/graphic_utils.c
index 516e903..7302611 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)
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2015-07-16  7:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16  7:31 Framebuffer console patches Sascha Hauer
2015-07-16  7:31 ` [PATCH 01/12] graphic_utils: Add a common namespace to functions Sascha Hauer
2015-07-16  7:31 ` [PATCH 02/12] gui: Fix typo in function name Sascha Hauer
2015-07-16  7:31 ` [PATCH 03/12] graphics_utils: Add function to invert an area Sascha Hauer
2015-07-16  7:31 ` [PATCH 04/12] graphics_utils: Export get_pixel Sascha Hauer
2015-07-16  7:31 ` Sascha Hauer [this message]
2015-07-16  7:31 ` [PATCH 06/12] import lib/fonts framework from linux kernel Sascha Hauer
2015-07-16  7:31 ` [PATCH 07/12] lib/fonts: add "MINI4x6" font Sascha Hauer
2015-07-16  7:31 ` [PATCH 08/12] fonts: Add 7x14 font Sascha Hauer
2015-07-16  7:31 ` [PATCH 09/12] fb: Add fb_enable/disable functions Sascha Hauer
2015-07-16  7:31 ` [PATCH 10/12] fb: sdl: create graphics window on enabling Sascha Hauer
2015-07-16  7:31 ` [PATCH 11/12] graphics_utils: Let fb_open allocate the screen Sascha Hauer
2015-07-16  7:31 ` [PATCH 12/12] video: implement framebuffer console Sascha Hauer
2015-07-16  8:36   ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1437031912-24754-6-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox