|
|
@ -232,19 +232,19 @@ void fb_circle(fbpos_t x0, fbpos_t y0, fbpos_t radius, uint8_t thickness, fbcolo |
|
|
|
#if IS_AVR |
|
|
|
#if IS_AVR |
|
|
|
void fb_bitmap_ex_P(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, const uint8_t *map, fbcolor_t color) |
|
|
|
void fb_bitmap_ex_P(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, const uint8_t *map, fbcolor_t color) |
|
|
|
#else |
|
|
|
#else |
|
|
|
void fb_bitmap_ex(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, const uint8_t *map, fbcolor_t color) |
|
|
|
void fb_bitmap_ex(const fbpos_t x, const fbpos_t y, const fbpos_t w0, const fbpos_t h0, const uint8_t *map, fbcolor_t color) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (x >= FBW || y >= FBH || x < -w || h < -h) { return; } |
|
|
|
if (x >= FBW || y >= FBH || x < -w0 || y < -h0) { return; } |
|
|
|
const fbpos_t w0 = w; |
|
|
|
const fbpos_t w = MIN(FBW - x, w0); |
|
|
|
w = MIN(FBW - x - 1, w); |
|
|
|
fbpos_t h = MIN(FBH - y - 1, h0); // h is used as counter for rows
|
|
|
|
h = MIN(FBH - y - 1, h); |
|
|
|
|
|
|
|
const fbpos_t row = y / 8; |
|
|
|
const fbpos_t row = y / 8; |
|
|
|
const fbpos_t rowrem = y % 8; |
|
|
|
const fbpos_t rowrem = y % 8; |
|
|
|
fbsize_t cell = (fbsize_t) x + (fbsize_t) row * FBW; |
|
|
|
fbsize_t cell = (fbsize_t) x + (fbsize_t) row * FBW; |
|
|
|
|
|
|
|
const fbpos_t xskip = (x >= 0) ? 0 : (-x); |
|
|
|
|
|
|
|
|
|
|
|
if (rowrem + h <= 8) { |
|
|
|
if (rowrem + h <= 8) { |
|
|
|
for (fbpos_t i = 0; i < w; i++) { |
|
|
|
for (fbpos_t i = xskip; i < w; i++) { |
|
|
|
// all within one cell
|
|
|
|
// all within one cell
|
|
|
|
const uint8_t mask = (pgm_read_byte(&map[i]) & (0xFF >> (8 - h))) << rowrem; |
|
|
|
const uint8_t mask = (pgm_read_byte(&map[i]) & (0xFF >> (8 - h))) << rowrem; |
|
|
|
draw_mask(cell + i, mask, color); |
|
|
|
draw_mask(cell + i, mask, color); |
|
|
@ -256,7 +256,7 @@ void fb_bitmap_ex(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, const uint8_t *map |
|
|
|
// Draw the bitmap slice-by-slice based on how rows of the bitmap intersect with rows of the canvas.
|
|
|
|
// Draw the bitmap slice-by-slice based on how rows of the bitmap intersect with rows of the canvas.
|
|
|
|
// This could be optimized to walk each row of the canvas only once, but the code would get bigger.
|
|
|
|
// This could be optimized to walk each row of the canvas only once, but the code would get bigger.
|
|
|
|
while (h > 0) { |
|
|
|
while (h > 0) { |
|
|
|
for (fbpos_t i = 0; i < w; i++) { |
|
|
|
for (fbpos_t i = xskip; i < w; i++) { |
|
|
|
const uint8_t mask = (pgm_read_byte(&map[i + mapc0]) & (0xFF >> rowrem)) << rowrem; |
|
|
|
const uint8_t mask = (pgm_read_byte(&map[i + mapc0]) & (0xFF >> rowrem)) << rowrem; |
|
|
|
draw_mask(cell + i, mask, color); |
|
|
|
draw_mask(cell + i, mask, color); |
|
|
|
} |
|
|
|
} |
|
|
@ -264,7 +264,7 @@ void fb_bitmap_ex(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, const uint8_t *map |
|
|
|
cell += FBW; |
|
|
|
cell += FBW; |
|
|
|
|
|
|
|
|
|
|
|
if (rowrem != 0) { |
|
|
|
if (rowrem != 0) { |
|
|
|
for (fbpos_t i = 0; i < w; i++) { |
|
|
|
for (fbpos_t i = xskip; i < w; i++) { |
|
|
|
const uint8_t mask = (pgm_read_byte(&map[i + mapc0]) & (0xFF << (8 - rowrem))) >> (8 - rowrem); |
|
|
|
const uint8_t mask = (pgm_read_byte(&map[i + mapc0]) & (0xFF << (8 - rowrem))) >> (8 - rowrem); |
|
|
|
draw_mask(cell + i, mask, color); |
|
|
|
draw_mask(cell + i, mask, color); |
|
|
|
} |
|
|
|
} |
|
|
|