PainterGRAY2Bitmap
PainterGRAY2Bitmap will take the color for a given point in the shape from a bitmap. Please be aware, the the bitmap is used by the CanvasWidgetRenderer (not Shape), so any rotation you might specify for a CanvasWidget (e.g. Shape) is not applied to the bitmap as CWR is not aware of this rotation.
See: AbstractPainter
Inherits from: AbstractPainterGRAY2, AbstractPainter
Public Functions
PainterGRAY2Bitmap(const Bitmap & bmp =Bitmap(BITMAP_INVALID)) | |
Initializes a new instance of the PainterGRAY2Bitmap class. | |
virtual void | render(uint8_t ptr, int x, int xAdjust, int y, unsigned count, const uint8_t covers) |
Paint a designated part of the RenderingBuffer with respect to the amount of coverage of each pixel given by the parameter covers. | |
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. | |
Protected Functions
virtual bool | renderInit() |
Initialize rendering of a single scan line of pixels for the render. | |
Protected Attributes
Bitmap | bitmap |
The bitmap to be used when painting. | |
const uint8_t * | bitmapAlphaPointer |
Pointer to the bitmap alpha data for GRAY2. | |
const uint8_t * | bitmapGRAY2Pointer |
Pointer to the bitmap (GRAY2) | |
Rect | bitmapRectToFrameBuffer |
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. | |
Additional inherited members
Public Functions inherited from AbstractPainterGRAY2
Protected Functions inherited from AbstractPainterGRAY2
virtual bool | renderNext(uint8_t & gray, uint8_t & alpha) |
Get the color of the next pixel in the scan line to blend into the framebuffer. | |
virtual void | renderPixel(uint8_t * p, uint16_t offset, uint8_t gray) |
Renders (writes) the specified color into the framebuffer. | |
Protected Attributes inherited from AbstractPainterGRAY2
int | currentX |
Current x coordinate relative to the widget. | |
int | currentY |
Current y coordinate relative to the widget. | |
Public Functions inherited from AbstractPainter
AbstractPainter() | |
Initializes a new instance of the AbstractPainter class. | |
virtual | ~AbstractPainter() |
Finalizes an instance of the AbstractPainter class. | |
Protected Functions inherited from AbstractPainter
void | setAreaOffset(uint16_t offsetX, uint16_t offsetY) |
Sets the offset of the area being drawn. | |
void | setWidgetAlpha(const uint8_t alpha) |
Sets the widget alpha to allow an entire canvas widget to easily be faded without changing the painter of the widget. | |
FORCE_INLINE_FUNCTION bool | compatibleFramebuffer(Bitmap::BitmapFormat format) |
Helper function to check if the provided bitmap format matches the current framebuffer format. | |
Protected Attributes inherited from AbstractPainter
int16_t | areaOffsetX |
The offset x coordinate of the area being drawn. | |
int16_t | areaOffsetY |
The offset y coordinate of the area being drawn. | |
uint8_t | widgetAlpha |
The alpha of the widget using the painter. | |
Public Functions Documentation
PainterGRAY2Bitmap
PainterGRAY2Bitmap | ( | const Bitmap & | bmp =Bitmap(BITMAP_INVALID) | ) | |
Initializes a new instance of the PainterGRAY2Bitmap class.
bmp | (Optional) The bitmap, default is BITMAP_INVALID. |
render
virtual void render | ( | uint8_t * | ptr , | ||
int | x , | ||||
int | xAdjust , | ||||
int | y , | ||||
unsigned | count , | ||||
const uint8_t * | covers | ||||
) |
Paint a designated part of the RenderingBuffer with respect to the amount of coverage of each pixel given by the parameter covers.
The cover is the alpha for each pixel, which is what makes it possible to have smooth anti-aliased edges on the shapes drawn with CanvasWidgetRenderer.
ptr | Pointer to the row in the RenderingBuffer. |
x | The x coordinate. |
xAdjust | The minor adjustment of x (used when a pixel is smaller than a byte to specify that the ptr should have been advanced "xAdjust" pixels futher into the byte). |
y | The y coordinate. |
count | Number of pixels to fill. |
covers | The coverage in of each pixel. |
Note
The implementation of render() in the AbstractPainter classes is a generic (i.e. slow) implementation that should be completely implemented in subclasses of AbstractPainter for better performance.
Reimplements: touchgfx::AbstractPainterGRAY2::render
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. |
Protected Functions Documentation
renderInit
virtual bool renderInit | ( | ) |
Initialize rendering of a single scan line of pixels for the render.
If renderInit returns false, the scanline will not be rendered.
true if it succeeds, false if it fails.
Reimplements: touchgfx::AbstractPainterGRAY2::renderInit
Protected Attributes Documentation
bitmap
Bitmap bitmap
The bitmap to be used when painting.
bitmapAlphaPointer
const uint8_t * bitmapAlphaPointer
Pointer to the bitmap alpha data for GRAY2.
bitmapGRAY2Pointer
const uint8_t * bitmapGRAY2Pointer
Pointer to the bitmap (GRAY2)
bitmapRectToFrameBuffer
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.