diff options
-rw-r--r-- | kms++/inc/kms++/pixelformats.h | 5 | ||||
-rw-r--r-- | kms++/src/pixelformats.cpp | 9 | ||||
-rw-r--r-- | kms++util/inc/kms++util/color.h | 1 | ||||
-rw-r--r-- | kms++util/src/color.cpp | 5 | ||||
-rw-r--r-- | kms++util/src/drawing.cpp | 14 | ||||
-rw-r--r-- | py/pykms/pykmsbase.cpp | 5 |
6 files changed, 36 insertions, 3 deletions
diff --git a/kms++/inc/kms++/pixelformats.h b/kms++/inc/kms++/pixelformats.h index 746f9e2..4e453a2 100644 --- a/kms++/inc/kms++/pixelformats.h +++ b/kms++/inc/kms++/pixelformats.h @@ -45,9 +45,14 @@ enum class PixelFormat : uint32_t RGB888 = MakeFourCC("RG24"), BGR888 = MakeFourCC("BG24"), + RGB332 = MakeFourCC("RGB8"), + RGB565 = MakeFourCC("RG16"), BGR565 = MakeFourCC("BG16"), + XRGB4444 = MakeFourCC("XR12"), + XRGB1555 = MakeFourCC("XR15"), + ARGB4444 = MakeFourCC("AR12"), ARGB1555 = MakeFourCC("AR15"), diff --git a/kms++/src/pixelformats.cpp b/kms++/src/pixelformats.cpp index fe86fca..2c60c1e 100644 --- a/kms++/src/pixelformats.cpp +++ b/kms++/src/pixelformats.cpp @@ -24,9 +24,15 @@ static const map<PixelFormat, PixelFormatInfo> format_info_array = { { PixelFormat::YVU422, { PixelColorType::YUV, 3, { { 8, 1, 1, }, { 8, 2, 1 }, { 8, 2, 1 } }, } }, { PixelFormat::YUV444, { PixelColorType::YUV, 3, { { 8, 1, 1, }, { 8, 1, 1 }, { 8, 1, 1 } }, } }, { PixelFormat::YVU444, { PixelColorType::YUV, 3, { { 8, 1, 1, }, { 8, 1, 1 }, { 8, 1, 1 } }, } }, + /* RGB8 */ + { PixelFormat::RGB332, { PixelColorType::RGB, 1, { { 8, 1, 1 } }, } }, /* RGB16 */ { PixelFormat::RGB565, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } }, { PixelFormat::BGR565, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } }, + { PixelFormat::XRGB4444, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } }, + { PixelFormat::XRGB1555, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } }, + { PixelFormat::ARGB4444, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } }, + { PixelFormat::ARGB1555, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } }, /* RGB24 */ { PixelFormat::RGB888, { PixelColorType::RGB, 1, { { 24, 1, 1 } }, } }, { PixelFormat::BGR888, { PixelColorType::RGB, 1, { { 24, 1, 1 } }, } }, @@ -50,9 +56,6 @@ static const map<PixelFormat, PixelFormatInfo> format_info_array = { { PixelFormat::ABGR2101010, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } }, { PixelFormat::RGBA1010102, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } }, { PixelFormat::BGRA1010102, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } }, - - { PixelFormat::ARGB4444, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } }, - { PixelFormat::ARGB1555, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } }, }; const struct PixelFormatInfo& get_pixel_format_info(PixelFormat format) diff --git a/kms++util/inc/kms++util/color.h b/kms++util/inc/kms++util/color.h index 2bf6e66..fa05fbc 100644 --- a/kms++util/inc/kms++util/color.h +++ b/kms++util/inc/kms++util/color.h @@ -34,6 +34,7 @@ struct RGB uint32_t rgba1010102() const; uint32_t bgra1010102() const; + uint8_t rgb332() const; uint16_t rgb565() const; uint16_t bgr565() const; uint16_t argb4444() const; 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); diff --git a/py/pykms/pykmsbase.cpp b/py/pykms/pykmsbase.cpp index 3e6defc..0448e02 100644 --- a/py/pykms/pykmsbase.cpp +++ b/py/pykms/pykmsbase.cpp @@ -206,9 +206,14 @@ void init_pykmsbase(py::module &m) .value("RGB888", PixelFormat::RGB888) .value("BGR888", PixelFormat::BGR888) + .value("RGB332", PixelFormat::RGB332) + .value("RGB565", PixelFormat::RGB565) .value("BGR565", PixelFormat::BGR565) + .value("XRGB4444", PixelFormat::XRGB4444) + .value("XRGB1555", PixelFormat::XRGB1555) + .value("ARGB4444", PixelFormat::ARGB4444) .value("ARGB1555", PixelFormat::ARGB1555) |