Added 8bit mask loading

This commit is contained in:
Raphael Coeffic
2021-05-15 01:09:57 +02:00
parent 6a492d9777
commit f603207a8e
2 changed files with 31 additions and 0 deletions
+29
View File
@@ -996,6 +996,20 @@ BitmapBuffer * BitmapBuffer::loadMask(const char * filename)
return bitmap;
}
BitmapBuffer * BitmapBuffer::load8bitMask(const uint8_t * lbm)
{
BitmapBuffer * bitmap = new BitmapBuffer(BMP_RGB565,lbm[0],lbm[1]);
if (bitmap) {
pixel_t * p = bitmap->getPixelPtrAbs(0, 0);
const uint8_t * src = lbm + 2;
for (int i = bitmap->width() * bitmap->height(); i > 0; i--) {
*((uint8_t *)p) = (*(src++) >> 4);
MOVE_TO_NEXT_RIGHT_PIXEL(p);
}
}
return bitmap;
}
BitmapBuffer * BitmapBuffer::invertMask() const
{
BitmapBuffer * result = new BitmapBuffer(format, width(), height());
@@ -1052,6 +1066,21 @@ BitmapBuffer * BitmapBuffer::loadMaskOnBackground(const char * filename, LcdFlag
return result;
}
BitmapBuffer * BitmapBuffer::load8bitMaskOnBackground(const uint8_t * lbm, LcdFlags foreground, LcdFlags background)
{
BitmapBuffer * result = nullptr;
BitmapBuffer * mask = BitmapBuffer::load8bitMask(lbm);
if (mask) {
result = new BitmapBuffer(BMP_RGB565, mask->width(), mask->height());
if (result) {
result->clear(background);
result->drawMask(0, 0, mask, foreground);
}
delete mask;
}
return result;
}
FIL imgFile __DMA;
BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
+2
View File
@@ -293,8 +293,10 @@ class BitmapBuffer: public BitmapBufferBase<pixel_t>
static BitmapBuffer * loadBitmap(const char * filename);
static BitmapBuffer * loadMask(const char * filename);
static BitmapBuffer * load8bitMask(const uint8_t * lbm);
static BitmapBuffer * loadMaskOnBackground(const char * filename, LcdFlags foreground, LcdFlags background);
static BitmapBuffer * load8bitMaskOnBackground(const uint8_t * lbm, LcdFlags foreground, LcdFlags background);
void drawMask(coord_t x, coord_t y, const BitmapBuffer * mask, LcdFlags flags, coord_t offsetX = 0, coord_t width = 0);