AbstractPainterBitmap
touchgfx/widgets/canvas/AbstractPainterBitmap.hpp
An abstract class for creating painter classes for drawing canvas widgets. All canvas widgets need a painter to fill the shape drawn with a CanvasWidgetRenderer. The painter must provide the color of a pixel on a given coordinate, which will the be blended into the framebuffer depending on the position of the canvas widget and the transparency of the given pixel.
The AbstractPainter also implements a function which will blend each pixel in a scanline snippet into the framebuffer, but for better performance, the function should be reimplemented in each painter.
Inherited by: PainterABGR2222Bitmap, PainterARGB2222Bitmap, PainterARGB8888Bitmap, PainterARGB8888L8Bitmap, PainterBGRA2222Bitmap, PainterBWBitmap, PainterGRAY2Bitmap, PainterGRAY4Bitmap, PainterRGB565Bitmap, PainterRGB565L8Bitmap, PainterRGB888Bitmap, PainterRGB888L8Bitmap, PainterRGBA2222Bitmap, PainterXRGB8888Bitmap, PainterXRGB8888L8Bitmap
Public Functions
AbstractPainterBitmap(const Bitmap & bmp =Bitmap(BITMAP_INVALID)) | |
Constructor. | |
Bitmap | getBitmap() const |
Gets the bitmap previously set using setBitmap(). | |
void | getOffset(int16_t & x, int16_t & y) |
Gets the bitmap offset previously set using setOffset(). | |
bool | getTiled() const |
Gets the tiled setting, previously set using setTiled(). | |
virtual void | setBitmap(const Bitmap & bmp) |
Sets a bitmap to be used when drawing the CanvasWidget. | |
virtual void | setOffset(int16_t x, int16_t y) |
Sets an offset for the bitmap used. | |
virtual void | setTiled(bool tiled) |
Instruct the painter to tile the bitmap specified. | |
virtual | ~AbstractPainterBitmap() |
Destructor. | |
Protected Functions
bool | adjustBitmapXY(int16_t & bitmapX, int16_t & bitmapY, int16_t & offset, int16_t & count) const |
Adjust bitmap x and y. | |
void | updateBitmapOffsets(int16_t widgetWidth) const |
Updates the bitmap offsets described by widgetWidth, these offset are used by bitmap painters adjust the coordinate position inside the widget. | |
Protected Attributes
Bitmap | bitmap |
The bitmap to be used when painting. | |
const uint8_t * | bitmapData |
Pointer to the bitmap data. | |
Bitmap::BitmapFormat | bitmapFormat |
Copy of the bitmap format (for speed reasons) | |
Rect | bitmapRect |
Bitmap rectangle translated to framebuffer coordinates. | |
bool | isTiled |
True if bitmap should be tiled, false if not. | |
int16_t | xOffset |
The x offset of the bitmap. | |
int16_t | yOffset |
The y offset of the bitmap. | |
Public Functions Documentation
AbstractPainterBitmap
AbstractPainterBitmap | ( | const Bitmap & | bmp =Bitmap(BITMAP_INVALID) | ) | |
Constructor.
bmp | (Optional) The bitmap to use in the painter. |
getBitmap
Bitmap getBitmap | ( | ) | const |
Gets the bitmap previously set using setBitmap().
The bitmap.
getOffset
void getOffset | ( | int16_t & | x , | ||
int16_t & | y | ||||
) |
Gets the bitmap offset previously set using setOffset().
x | The x coordinate. |
y | The y coordinate. |
getTiled
bool getTiled | ( | ) | const |
Gets the tiled setting, previously set using setTiled().
True if the bitmap is tiled, false otherwise.
setBitmap
Sets a bitmap to be used when drawing the CanvasWidget.
bmp | The bitmap. |
Reimplemented by: touchgfx::PainterABGR2222Bitmap::setBitmap, touchgfx::PainterARGB2222Bitmap::setBitmap, touchgfx::PainterARGB8888Bitmap::setBitmap, touchgfx::PainterARGB8888L8Bitmap::setBitmap, touchgfx::PainterBGRA2222Bitmap::setBitmap, touchgfx::PainterBWBitmap::setBitmap, touchgfx::PainterGRAY2Bitmap::setBitmap, touchgfx::PainterGRAY4Bitmap::setBitmap, touchgfx::PainterRGB565Bitmap::setBitmap, touchgfx::PainterRGB565L8Bitmap::setBitmap, touchgfx::PainterRGB888Bitmap::setBitmap, touchgfx::PainterRGB888L8Bitmap::setBitmap, touchgfx::PainterRGBA2222Bitmap::setBitmap, touchgfx::PainterXRGB8888Bitmap::setBitmap, touchgfx::PainterXRGB8888L8Bitmap::setBitmap
setOffset
virtual void setOffset | ( | int16_t | x , | ||
int16_t | y | ||||
) |
Sets an offset for the bitmap used.
The x and y coordinates specifies how far the bitmap should be moved to the right and down. This works for tiled bitmaps and non-tiled bitmaps.
x | The x coordinate. |
y | The y coordinate. |
setTiled
virtual void setTiled | ( | bool | tiled | ) | |
Instruct the painter to tile the bitmap specified.
The bitmap will be tiled both horizontally and vertically.
tiled | True if tiled. |
~AbstractPainterBitmap
virtual ~AbstractPainterBitmap | ( | ) |
Destructor.
Protected Functions Documentation
adjustBitmapXY
bool adjustBitmapXY | ( | int16_t & | bitmapX , | const | |
int16_t & | bitmapY , | const | |||
int16_t & | offset , | const | |||
int16_t & | count | const | |||
) | const |
Adjust bitmap x and y.
For a tiled bitmap painters, the coordinates are fixed to be inside the bitmap, for non-tiled bitmap painters, false is returned if the entire span (considering offset and count) is outside the bitmap - otherwise, the parameters are adjust to make sure that the requested number of pixels can be read from the bitmap at the given coordinate and count pixels ahead.
bitmapX | The bitmap x coordinate. |
bitmapY | The bitmap y coordinate. |
offset | The pointer x coordinate. |
count | Number of. |
True if anything should be painted, false if nothing has to be painted.
updateBitmapOffsets
void updateBitmapOffsets | ( | int16_t | widgetWidth | ) | |
Updates the bitmap offsets described by widgetWidth, these offset are used by bitmap painters adjust the coordinate position inside the widget.
widgetWidth | Width of the widget. |
Protected Attributes Documentation
bitmap
Bitmap bitmap
The bitmap to be used when painting.
bitmapData
const uint8_t * bitmapData
Pointer to the bitmap data.
bitmapFormat
Bitmap::BitmapFormat bitmapFormat
Copy of the bitmap format (for speed reasons)
bitmapRect
Rect bitmapRect
Bitmap rectangle translated to framebuffer coordinates.
isTiled
bool isTiled
True if bitmap should be tiled, false if not.
xOffset
int16_t xOffset
The x offset of the bitmap.
yOffset
int16_t yOffset
The y offset of the bitmap.