@@ -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"),
@@ -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)
@@ -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;
@@ -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);
@@ -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);
@@ -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)
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> --- kms++/inc/kms++/pixelformats.h | 5 +++++ kms++/src/pixelformats.cpp | 9 ++++++--- kms++util/inc/kms++util/color.h | 1 + kms++util/src/color.cpp | 5 +++++ kms++util/src/drawing.cpp | 14 ++++++++++++++ py/pykms/pykmsbase.cpp | 5 +++++ 6 files changed, 36 insertions(+), 3 deletions(-)