.pio/libdeps/m5stack-core2/M5Core2/src/utility/Sprite.cpp
uint16_t TFT_eSprite::readPixel(int32_t x, int32_t y)
{
  if ((x < 0) || (x >= _iwidth) || (y < 0) || (y >= _iheight) || !_created) return 0;

  if (_bpp == 16)
  {
    uint16_t color = _img[x + y * _iwidth];
    return (color >> 8) | (color << 8);
  }
  
  if (_bpp == 8)
  {
    uint16_t color = _img8[x + y * _iwidth];
    if (color != 0)
    {
    uint8_t  blue[] = {0, 11, 21, 31};
      color =   (color & 0xE0)<<8 | (color & 0xC0)<<5
              | (color & 0x1C)<<6 | (color & 0x1C)<<3
              | blue[color & 0x03];
    }
    return color;
  }

  if (_rotation == 1)
  {
    uint16_t tx = x;
    x = _dwidth - y - 1;
    y = tx;
  }
  else if (_rotation == 2)
  {
    x = _dwidth - x - 1;
    y = _dheight - y - 1;
  }
  else if (_rotation == 3)
  {
    uint16_t tx = x;
    x = y;
    y = _dheight - tx - 1;
  }

  uint16_t color = (_img8[(x + y * _bitwidth)>>3] << (x & 0x7)) & 0x80;

  return color >> 7;
}
/***************************************************************************************
** Function name:           readPixel
** Description:             Read 565 colour of a pixel at defined coordinates
*************************************************************************************x*/
Function name:           readPixel
Description:             Read 565 colour of a pixel at defined coordinates
x
Function name : readPixel Description : Read 565 colour of a pixel at defined coordinates x
uint16_t TFT_eSprite::readPixel(int32_t x, int32_t y)
{
  if ((x < 0) || (x >= _iwidth) || (y < 0) || (y >= _iheight) || !_created) return 0;
  if (_bpp == 16)
  {
    uint16_t color = _img[x + y * _iwidth];
    return (color >> 8) | (color << 8);
  }
  if (_bpp == 8)
  {
    uint16_t color = _img8[x + y * _iwidth];
    if (color != 0)
    {
    uint8_t  blue[] = {0, 11, 21, 31};
      color =   (color & 0xE0)<<8 | (color & 0xC0)<<5
              | (color & 0x1C)<<6 | (color & 0x1C)<<3
              | blue[color & 0x03];
    }
    return color;
  }
  if (_rotation == 1)
  {
    uint16_t tx = x;
    x = _dwidth - y - 1;
    y = tx;
  }
  else if (_rotation == 2)
  {
    x = _dwidth - x - 1;
    y = _dheight - y - 1;
  }
  else if (_rotation == 3)
  {
    uint16_t tx = x;
    x = y;
    y = _dheight - tx - 1;
  }
  uint16_t color = (_img8[(x + y * _bitwidth)>>3] << (x & 0x7)) & 0x80;
  return color >> 7;
}
uint16_t TFT_eSprite :: readPixel ( int32_t x , int32_t y ) { if ( ( x < 0 ) || ( x >= _iwidth ) || ( y < 0 ) || ( y >= _iheight ) || ! _created ) return 0 ; if ( _bpp == 16 ) { uint16_t color = _img [ x + y * _iwidth ] ; return ( color >> 8 ) | ( color << 8 ) ; } if ( _bpp == 8 ) { uint16_t color = _img8 [ x + y * _iwidth ] ; if ( color != 0 ) { uint8_t blue [ ] = { 0 , 11 , 21 , 31 } ; color = ( color & 0xE0 ) << 8 | ( color & 0xC0 ) << 5 | ( color & 0x1C ) << 6 | ( color & 0x1C ) << 3 | blue [ color & 0x03 ] ; } return color ; } if ( _rotation == 1 ) { uint16_t tx = x ; x = _dwidth - y - 1 ; y = tx ; } else if ( _rotation == 2 ) { x = _dwidth - x - 1 ; y = _dheight - y - 1 ; } else if ( _rotation == 3 ) { uint16_t tx = x ; x = y ; y = _dheight - tx - 1 ; } uint16_t color = ( _img8 [ ( x + y * _bitwidth ) >> 3 ] << ( x & 0x7 ) ) & 0x80 ; return color >> 7 ; }
Function name:           readPixel
Description:             Read 565 colour of a pixel at defined coordinates
x
Function name : readPixel Description : Read 565 colour of a pixel at defined coordinates x