Add ability to scroll 1bpp Sprites

New example added: Sprite_scroll_1bit
This commit is contained in:
Bodmer
2018-11-24 23:30:40 +00:00
parent 329b794950
commit b0d56ce394
2 changed files with 162 additions and 1 deletions
+15 -1
View File
@@ -657,7 +657,21 @@ void TFT_eSprite::scroll(int16_t dx, int16_t dy)
fyp += iw;
}
}
else return; // TODO add scroll for 1 bpp
else if (_bpp == 1)
{
if (dx > 0) { tx += w; fx += w; } // Start from right edge
while (h--)
{ // move pixels one by one
for (uint16_t xp = 0; xp < w; xp++)
{
if (dx <= 0) drawPixel(tx + xp, ty, readPixel(fx + xp, fy));
if (dx > 0) drawPixel(tx - xp, ty, readPixel(fx - xp, fy));
}
if (dy <= 0) { ty++; fy++; }
else { ty--; fy--; }
}
}
else return; // Not 1, 8 or 16 bpp
// Fill the gap left by the scrolling
if (dx > 0) fillRect(_sx, _sy, dx, _sh, _scolor);