diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-08-06 03:32:42 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-08-06 05:09:16 +0300 |
commit | 41ffb17e22fba40b43575dbf1a516067878ed9e5 (patch) | |
tree | 4943b47173f9999a5c90a0f4b12edd21cef9ee62 /kms++util/src | |
parent | d29a12e5d9473d9b37b817db57d29ee2b886aac8 (diff) |
kms++: Add support for missing 8 -and 16-bit RGB formats
Add support for the RGB332, XRGB1555 and XRGB4444 formats to the
PixelFormat class, the Python API, and the drawing utilities.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'kms++util/src')
-rw-r--r-- | kms++util/src/color.cpp | 5 | ||||
-rw-r--r-- | kms++util/src/drawing.cpp | 14 |
2 files changed, 19 insertions, 0 deletions
diff --git a/kms++util/src/color.cpp b/kms++util/src/color.cpp index 80e4866..2d45eff 100644 --- a/kms++util/src/color.cpp +++ b/kms++util/src/color.cpp @@ -79,6 +79,11 @@ uint32_t RGB::bgra1010102() const return (b << 24) | (g << 14) | (r << 4) | (a >> 6); } +uint8_t RGB::rgb332() const +{ + return ((r >> 5) << 5) | ((g >> 5) << 2) | ((b >> 6) << 0); +} + uint16_t RGB::rgb565() const { return ((r >> 3) << 11) | ((g >> 2) << 5) | ((b >> 3) << 0); diff --git a/kms++util/src/drawing.cpp b/kms++util/src/drawing.cpp index c1c639a..3752f94 100644 --- a/kms++util/src/drawing.cpp +++ b/kms++util/src/drawing.cpp @@ -86,6 +86,12 @@ void draw_rgb_pixel(IFramebuffer& buf, unsigned x, unsigned y, RGB color) p[2] = color.b; break; } + case PixelFormat::RGB332: + { + uint8_t *p = (uint8_t*)(buf.map(0) + buf.stride(0) * y + x); + *p = color.rgb332(); + break; + } case PixelFormat::RGB565: { uint16_t *p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2); @@ -98,12 +104,14 @@ void draw_rgb_pixel(IFramebuffer& buf, unsigned x, unsigned y, RGB color) *p = color.bgr565(); break; } + case PixelFormat::XRGB4444: case PixelFormat::ARGB4444: { uint16_t *p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2); *p = color.argb4444(); break; } + case PixelFormat::XRGB1555: case PixelFormat::ARGB1555: { uint16_t *p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2); @@ -397,8 +405,11 @@ void draw_rect(IFramebuffer &fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, case PixelFormat::BGR888: case PixelFormat::RGB565: case PixelFormat::BGR565: + case PixelFormat::XRGB4444: + case PixelFormat::XRGB1555: case PixelFormat::ARGB4444: case PixelFormat::ARGB1555: + case PixelFormat::RGB332: for (j = 0; j < h; j++) { for (i = 0; i < w; i++) { draw_rgb_pixel(fb, x + i, y + j, color); @@ -486,8 +497,11 @@ static void draw_char(IFramebuffer& buf, uint32_t xpos, uint32_t ypos, char c, R case PixelFormat::BGR888: case PixelFormat::RGB565: case PixelFormat::BGR565: + case PixelFormat::XRGB4444: + case PixelFormat::XRGB1555: case PixelFormat::ARGB4444: case PixelFormat::ARGB1555: + case PixelFormat::RGB332: for (y = 0; y < 8; y++) { for (x = 0; x < 8; x++) { bool b = get_char_pixel(c, x, y); |