Commit ad013030 authored by Bodmer's avatar Bodmer

Add pushToSprite with transparent colour

New function:
pushToSprite(TFT_eSprite *spr, int32_t x, int32_t y, uint16_t transp)
// Note: The following sprite to sprite colour depths are currently supported:
//    Source    Destination
//    16bpp  -> 16bpp
//    16bpp  ->  8bpp
//     8bpp  ->  8bpp
//     1bpp  ->  1bpp
parent 42e6fc87
...@@ -734,30 +734,59 @@ bool TFT_eSprite::pushToSprite(TFT_eSprite *dspr, int32_t x, int32_t y) ...@@ -734,30 +734,59 @@ bool TFT_eSprite::pushToSprite(TFT_eSprite *dspr, int32_t x, int32_t y)
** Function name: pushToSprite ** Function name: pushToSprite
** Description: Push the sprite to another sprite at x, y with transparent colour ** Description: Push the sprite to another sprite at x, y with transparent colour
***************************************************************************************/ ***************************************************************************************/
/* >>>>>> Using a transparent color is not supported at the moment <<<<<< // Note: The following sprite to sprite colour depths are currently supported:
void TFT_eSprite::pushToSprite(TFT_eSprite *spr, int32_t x, int32_t y, uint16_t transp) // Source Destination
// 16bpp -> 16bpp
// 16bpp -> 8bpp
// 8bpp -> 8bpp
// 1bpp -> 1bpp
bool TFT_eSprite::pushToSprite(TFT_eSprite *dspr, int32_t x, int32_t y, uint16_t transp)
{ {
if (!_created) return; if ( !_created || !dspr->_created) return false; // Check Sprites exist
if (_bpp == 16) // Check destination sprite compatibility
{ int8_t ds_bpp = dspr->getColorDepth();
bool oldSwapBytes = spr->getSwapBytes(); if (_bpp == 16 && ds_bpp != 16 && ds_bpp != 8) return false;
spr->setSwapBytes(false); if (_bpp == 8 && ds_bpp != 8) return false;
spr->pushImage(x, y, _dwidth, _dheight, _img, transp ); if (_bpp == 4 || ds_bpp == 4) return false;
spr->setSwapBytes(oldSwapBytes); if (_bpp == 1 && ds_bpp != 1) return false;
bool oldSwapBytes = dspr->getSwapBytes();
uint16_t sline_buffer[width()];
transp = transp>>8 | transp<<8;
// Scan destination bounding box and fetch transformed pixels from source Sprite
for (int32_t ys = 0; ys < height(); ys++) {
int32_t ox = x;
uint32_t pixel_count = 0;
for (int32_t xs = 0; xs < width(); xs++) {
uint16_t rp = 0;
if (_bpp == 16) rp = _img[xs + ys * width()];
else { rp = readPixel(xs, ys); rp = rp>>8 | rp<<8; }
//dspr->drawPixel(xs, ys, rp);
if (transp == rp) {
if (pixel_count) {
dspr->pushImage(ox, y, pixel_count, 1, sline_buffer, _bpp);
ox += pixel_count;
pixel_count = 0;
} }
else if (_bpp == 8) else ox++;
{ }
transp = (uint8_t)((transp & 0xE000)>>8 | (transp & 0x0700)>>6 | (transp & 0x0018)>>3); else {
spr->pushImage(x, y, _dwidth, _dheight, _img8, (uint8_t)transp, (bool)true); sline_buffer[pixel_count++] = rp;
} }
else if (_bpp == 4)
{
spr->pushImage(x, y, _dwidth, _dheight, _img4, (uint8_t)(transp & 0x0F), false, _colorMap);
} }
else spr->pushImage(x, y, _dwidth, _dheight, _img8, 0, (bool)false); if (pixel_count) dspr->pushImage(ox, y, pixel_count, 1, sline_buffer);
y++;
}
dspr->setSwapBytes(oldSwapBytes);
return true;
} }
*/
/*************************************************************************************** /***************************************************************************************
** Function name: pushSprite ** Function name: pushSprite
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#ifndef _TFT_eSPIH_ #ifndef _TFT_eSPIH_
#define _TFT_eSPIH_ #define _TFT_eSPIH_
#define TFT_ESPI_VERSION "2.3.5" #define TFT_ESPI_VERSION "2.3.51"
// Bit level feature flags // Bit level feature flags
// Bit 0 set: viewport capability // Bit 0 set: viewport capability
......
{ {
"name": "TFT_eSPI", "name": "TFT_eSPI",
"version": "2.3.5", "version": "2.3.51",
"keywords": "Arduino, tft, ePaper, display, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789, RM68140", "keywords": "Arduino, tft, ePaper, display, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789, RM68140",
"description": "A TFT and ePaper SPI graphics library with optimisation for ESP8266, ESP32 and STM32", "description": "A TFT and ePaper SPI graphics library with optimisation for ESP8266, ESP32 and STM32",
"repository": "repository":
......
name=TFT_eSPI name=TFT_eSPI
version=2.3.5 version=2.3.51
author=Bodmer author=Bodmer
maintainer=Bodmer maintainer=Bodmer
sentence=TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32 sentence=TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment