summaryrefslogtreecommitdiff
path: root/kms++util/src
diff options
context:
space:
mode:
Diffstat (limited to 'kms++util/src')
-rw-r--r--kms++util/src/color.cpp10
-rw-r--r--kms++util/src/colorbar.cpp5
-rw-r--r--kms++util/src/drawing.cpp16
3 files changed, 31 insertions, 0 deletions
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);