Bitmaps: add bitmap mode

This new mode work in the same way as the existing font mode: It allows drawing
solid (both white and black pixels in the bitmap affect the output) or
transparent (only white pixels in the bitmap affect the output). Transparent
bitmaps may be used to draw multiple bitmaps over each other, for example when
drawing animations. As a side effect, transparent XOR mode now also works by
setting the bitmap mode to transparent and the draw color to 2.

Before this commit, the bitmaps XBM bitmaps were being drawn as solid
object, while the regular bitmaps were drawn as transparent.

The structure of the code is based on how `u8g2_font_decode_len()` handles the
same thing when drawing glyphs.
This commit is contained in:
Hendry Kaak
2017-03-15 17:58:35 +01:00
parent 731eecdd8a
commit fdb19f866e
3 changed files with 31 additions and 9 deletions
+2
View File
@@ -185,6 +185,8 @@ class U8G2 : public Print
{ u8g2_DrawLine(&u8g2, x1, y1, x2, y2); }
/* u8g2_bitmap.c */
void setBitmapMode(uint8_t is_transparent)
{ u8g2_SetBitmapMode(&u8g2, is_transparent); }
void drawBitmap(u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t cnt, u8g2_uint_t h, const uint8_t *bitmap)
{ u8g2_DrawBitmap(&u8g2, x, y, cnt, h, bitmap); }
void drawXBM(u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, const uint8_t *bitmap)