summaryrefslogtreecommitdiff
path: root/libkms++util/drawing.cpp
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2016-06-07 17:00:08 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2016-06-07 17:02:08 +0300
commita688d32d209a45627da3e80128a933d70f5d48b6 (patch)
tree2bc9ab299010cae6abc4dc7f5342c6a5cc4c29b7 /libkms++util/drawing.cpp
parentd697a9546fa293df113fa9eec5ae82ca7ac2d192 (diff)
util: add simple text drawing
Diffstat (limited to 'libkms++util/drawing.cpp')
-rw-r--r--libkms++util/drawing.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/libkms++util/drawing.cpp b/libkms++util/drawing.cpp
index a71baf6..9018817 100644
--- a/libkms++util/drawing.cpp
+++ b/libkms++util/drawing.cpp
@@ -130,4 +130,25 @@ void draw_rect(IMappedFramebuffer &fb, uint32_t x, uint32_t y, uint32_t w, uint3
}
}
+static void draw_char(IMappedFramebuffer& buf, uint32_t xpos, uint32_t ypos, char c, RGB color)
+{
+#include "font_8x8.h"
+
+ for (uint32_t y = 0; y < 8; y++) {
+ uint8_t bits = fontdata_8x8[8 * c + y];
+
+ for (uint32_t x = 0; x < 8; x++) {
+ bool bit = (bits >> (7 - x)) & 1;
+
+ draw_rgb_pixel(buf, xpos + x, ypos + y, bit ? color : RGB());
+ }
+ }
+}
+
+void draw_text(IMappedFramebuffer& buf, uint32_t x, uint32_t y, const string& str, RGB color)
+{
+ for(unsigned i = 0; i < str.size(); i++)
+ draw_char(buf, (x + 8 * i), y, str[i], color);
+}
+
}