Added 8bit PNG font loader

This commit is contained in:
Raphael Coeffic
2021-05-21 20:59:33 +02:00
parent 2d6ebc2ec1
commit 749d7d9037
2 changed files with 14 additions and 0 deletions
+12
View File
@@ -1436,3 +1436,15 @@ BitmapBuffer * BitmapBuffer::convert_stb_bitmap(uint8_t * img, int w, int h, int
return bmp;
}
uint8_t * BitmapBuffer::loadFont(const uint8_t * lbm, int len, int& w, int& h)
{
int n;
unsigned char * font = stbi_load_from_memory(lbm, len, &w, &h, &n, 1);
if (!font) {
TRACE("load_stb_buffer(%p,%d) failed: %s", font, len, stbi_failure_reason());
return nullptr;
}
return font;
}
+2
View File
@@ -299,6 +299,8 @@ class BitmapBuffer: public BitmapBufferBase<pixel_t>
static BitmapBuffer * loadMaskOnBackground(const char * filename, LcdFlags foreground, LcdFlags background);
static BitmapBuffer * load8bitMaskOnBackground(const uint8_t * lbm, LcdFlags foreground, LcdFlags background);
static uint8_t * loadFont(const uint8_t * lbm, int len, int& w, int& h);
void drawMask(coord_t x, coord_t y, const BitmapBuffer * mask, LcdFlags flags, coord_t offsetX = 0, coord_t width = 0);
void drawMask(coord_t x, coord_t y, const BitmapBuffer * mask, const BitmapBuffer * srcBitmap, coord_t offsetX = 0, coord_t offsetY = 0, coord_t width = 0, coord_t height = 0);