touchgfx::AbstractPainterRGB565 class
@class AbstractPainterRGB565 AbstractPainterRGB565.hpp touchgfx/widgets/canvas/AbstractPainterRGB565.hpp A Painter that will paint using a color and an alpha value. The AbstractPainterRGB565 class allows a shape to be filled with a given color and alpha value. This allows transparent, anti-aliased elements to be drawn. @see AbstractPainter
class AbstractPainterRGB565 : public AbstractPainter
{
public:
static const uint16_t RMASK = 0xF800;
static const uint16_t GMASK = 0x07E0;
static const uint16_t BMASK = 0x001F;
AbstractPainterRGB565()
{
assert(HAL::lcd().bitDepth() == 16 && "The chosen painter only works with 16bpp displays");
}
virtual ~AbstractPainterRGB565() {}
virtual void render(uint8_t* ptr, int x, int xAdjust, int y, unsigned count, const uint8_t* covers);
FORCE_INLINE_FUNCTION uint16_t mixColors(uint16_t newpix, uint16_t bufpix, uint16_t alpha, uint16_t shift)
{
return mixColors(newpix & RMASK, newpix & GMASK, newpix & BMASK, bufpix, alpha, shift);
}
FORCE_INLINE_FUNCTION uint16_t mixColors(uint16_t R, uint16_t G, uint16_t B, uint16_t bufpix, uint16_t alpha, uint16_t shift)
{
return (RMASK & ((((R - (bufpix & RMASK)) * alpha) >> shift) + (bufpix & RMASK))) |
(GMASK & ((((G - (bufpix & GMASK)) * alpha) >> shift) + (bufpix & GMASK))) |
(BMASK & ((((B - (bufpix & BMASK)) * alpha) >> shift) + (bufpix & BMASK)));
}
protected:
virtual bool renderInit()
{
return true;
}
virtual bool renderNext(uint8_t& red, uint8_t& green, uint8_t& blue, uint8_t& alpha) = 0;
virtual void renderPixel(uint16_t* p, uint8_t red, uint8_t green, uint8_t blue);
int currentX;
int currentY;
};
RMASK
GMASK
BMASK
currentX
currentY
Methods
render()
mixColors()
@fn FORCE_INLINE_FUNCTION uint16_t AbstractPainterRGB565::mixColors(uint16_t newpix, uint16_t bufpix, uint16_t alpha, uint16_t shift) Mix colors. Mix colors from a new pixel and a buffer pixel with the given alpha applied to the new pixel.
Read more...
mixColors()
@fn FORCE_INLINE_FUNCTION uint16_t AbstractPainterRGB565::mixColors(uint16_t newpix, uint16_t bufpix, uint16_t alpha, uint16_t shift) Mix colors. Mix colors from a new pixel and a buffer pixel with the given alpha applied to the new pixel.
Read more...
renderInit()
@fn virtual bool AbstractPainterRGB565::renderInit() Initialize rendering of a single scan line of pixels for the render. Initialize rendering of a single scan line of pixels for the render.
Read more...
renderNext()
@fn virtual bool AbstractPainterRGB565::renderNext(uint8_t& red, uint8_t& green, uint8_t& blue, uint8_t& alpha) = 0; Get the color of the next pixel in the scan line. Get the color of the next pixel in the scan line.
Read more...
renderPixel()
@fn virtual void AbstractPainterRGB565::renderPixel(uint16_t* p, uint8_t red, uint8_t green, uint8_t blue); Renders the pixel. Renders the pixel into the frame buffer. The colors are reduced from 8,8,8 to 5,6, 5.
Read more...
Examples
touchgfx::AbstractPainterRGB565 is referenced by
3 libraries and example projects.
Parent classes
Child classes
touchgfx::AbstractPainterRGB565