Add more clipping

This commit is contained in:
Bertrand Songis
2021-04-11 11:58:38 +02:00
parent 41c5a2fe7c
commit 125a0b8266
2 changed files with 41 additions and 72 deletions
+35
View File
@@ -515,6 +515,41 @@ class BitmapBuffer: public BitmapBufferBase<pixel_t>
protected:
static BitmapBuffer * load_bmp(const char * filename);
static BitmapBuffer * load_stb(const char * filename);
inline bool applyClippingRect(coord_t & x, coord_t & y, coord_t & w, coord_t & h)
{
if (h < 0) {
y += h;
h = -h;
}
if (w < 0) {
x += w;
w = -w;
}
if (x >= xmax || y >= ymax)
return false;
if (y < ymin) {
h += y - ymin;
y = ymin;
}
if (x < xmin) {
w += x - xmin;
x = xmin;
}
if (y + h > ymax)
h = ymax - y;
if (x + w > xmax)
w = xmax - x;
return data && h > 0 && w > 0;
}
uint8_t drawChar(coord_t x, coord_t y, const uint8_t * font, const uint16_t * spec, unsigned int index, LcdFlags flags);
void drawHorizontalLineAbs(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags flags);
};