summaryrefslogtreecommitdiff
path: root/kms++util
diff options
context:
space:
mode:
authorJyri Sarha <jsarha@ti.com>2016-08-10 23:16:39 +0300
committerJyri Sarha <jsarha@ti.com>2016-08-11 12:20:29 +0300
commit3788242e4fdc57b1421b4721120477ebb2298e52 (patch)
treec2b0c7fe512daaee254859fa530bafd5972a9796 /kms++util
parentbd5f6471e619a6ba2987bc7f66ef78a531f94d6c (diff)
Add BGR888 (BG24) and BGR565 (BG16) pixelformats.
Note colorbar does not support 24 bit modes (RGB888 or BGR888) yet.
Diffstat (limited to 'kms++util')
-rw-r--r--kms++util/inc/kms++util/color.h2
-rw-r--r--kms++util/src/color.cpp10
-rw-r--r--kms++util/src/colorbar.cpp5
-rw-r--r--kms++util/src/drawing.cpp16
4 files changed, 33 insertions, 0 deletions
diff --git a/kms++util/inc/kms++util/color.h b/kms++util/inc/kms++util/color.h
index ef85a67..ba2ed25 100644
--- a/kms++util/inc/kms++util/color.h
+++ b/kms++util/inc/kms++util/color.h
@@ -14,9 +14,11 @@ struct RGB
RGB(uint32_t argb);
uint32_t rgb888() const;
+ uint32_t bgr888() const;
uint32_t argb8888() const;
uint32_t abgr8888() const;
uint16_t rgb565() const;
+ uint16_t bgr565() const;
YUV yuv() const;
uint8_t b;
diff --git a/kms++util/src/color.cpp b/kms++util/src/color.cpp
index 4bfc33e..ae8a4b4 100644
--- a/kms++util/src/color.cpp
+++ b/kms++util/src/color.cpp
@@ -34,6 +34,11 @@ uint32_t RGB::rgb888() const
return (r << 16) | (g << 8) | (b << 0);
}
+uint32_t RGB::bgr888() const
+{
+ return (b << 16) | (g << 8) | (r << 0);
+}
+
uint32_t RGB::argb8888() const
{
return (a << 24) | (r << 16) | (g << 8) | (b << 0);
@@ -49,6 +54,11 @@ uint16_t RGB::rgb565() const
return ((r >> 3) << 11) | ((g >> 2) << 5) | ((b >> 3) << 0);
}
+uint16_t RGB::bgr565() const
+{
+ return ((b >> 3) << 11) | ((g >> 2) << 5) | ((r >> 3) << 0);
+}
+
YUV RGB::yuv() const
{
return YUV(*this);
diff --git a/kms++util/src/colorbar.cpp b/kms++util/src/colorbar.cpp
index bca8dc6..e2d257b 100644
--- a/kms++util/src/colorbar.cpp
+++ b/kms++util/src/colorbar.cpp
@@ -116,6 +116,11 @@ void draw_color_bar(IMappedFramebuffer& buf, int old_xpos, int xpos, int width)
drm_draw_color_bar_rgb565(buf, old_xpos, xpos, width);
break;
+ case PixelFormat::BGR565:
+ // XXX not right, red and blue are reversed
+ drm_draw_color_bar_rgb565(buf, old_xpos, xpos, width);
+ break;
+
case PixelFormat::XRGB8888:
drm_draw_color_bar_rgb888(buf, old_xpos, xpos, width);
break;
diff --git a/kms++util/src/drawing.cpp b/kms++util/src/drawing.cpp
index 157c799..44634e1 100644
--- a/kms++util/src/drawing.cpp
+++ b/kms++util/src/drawing.cpp
@@ -31,12 +31,26 @@ void draw_rgb_pixel(IMappedFramebuffer& buf, unsigned x, unsigned y, RGB color)
p[2] = color.b;
break;
}
+ case PixelFormat::BGR888:
+ {
+ uint8_t *p = buf.map(0) + buf.stride(0) * y + x * 3;
+ p[0] = color.b;
+ p[1] = color.g;
+ p[2] = color.r;
+ break;
+ }
case PixelFormat::RGB565:
{
uint16_t *p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
*p = color.rgb565();
break;
}
+ case PixelFormat::BGR565:
+ {
+ uint16_t *p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
+ *p = color.bgr565();
+ break;
+ }
default:
throw std::invalid_argument("invalid pixelformat");
}
@@ -159,7 +173,9 @@ static void draw_char(IMappedFramebuffer& buf, uint32_t xpos, uint32_t ypos, cha
case PixelFormat::ARGB8888:
case PixelFormat::ABGR8888:
case PixelFormat::RGB888:
+ case PixelFormat::BGR888:
case PixelFormat::RGB565:
+ case PixelFormat::BGR565:
for (y = 0; y < 8; y++) {
for (x = 0; x < 8; x++) {
bool b = get_char_pixel(c, x, y);