跳转到主要内容

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.
BitmapgetBitmap() const
Gets the bitmap previously set using setBitmap().
voidgetOffset(int16_t & x, int16_t & y)
Gets the bitmap offset previously set using setOffset().
boolgetTiled() const
Gets the tiled setting, previously set using setTiled().
virtual voidsetBitmap(const Bitmap & bmp)
Sets a bitmap to be used when drawing the CanvasWidget.
virtual voidsetOffset(int16_t x, int16_t y)
Sets an offset for the bitmap used.
virtual voidsetTiled(bool tiled)
Instruct the painter to tile the bitmap specified.
virtual ~AbstractPainterBitmap()
Destructor.

Protected Functions​

booladjustBitmapXY(int16_t & bitmapX, int16_t & bitmapY, int16_t & offset, int16_t & count) const
Adjust bitmap x and y.
voidupdateBitmapOffsets(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​

Bitmapbitmap
The bitmap to be used when painting.
const uint8_t *bitmapData
Pointer to the bitmap data.
Bitmap::BitmapFormatbitmapFormat
Copy of the bitmap format (for speed reasons)
RectbitmapRect
Bitmap rectangle translated to framebuffer coordinates.
boolisTiled
True if bitmap should be tiled, false if not.
int16_txOffset
The x offset of the bitmap.
int16_tyOffset
The y offset of the bitmap.

Public Functions Documentation​

AbstractPainterBitmap​

AbstractPainterBitmap(const Bitmap &bmp =Bitmap(BITMAP_INVALID))

Constructor.

Parameters:
bmp(Optional) The bitmap to use in the painter.

getBitmap​

Bitmap getBitmap()const

Gets the bitmap previously set using setBitmap().

Returns:

The bitmap.

getOffset​

void getOffset(int16_t &x ,
int16_t &y
)

Gets the bitmap offset previously set using setOffset().

Parameters:
xThe x coordinate.
yThe y coordinate.

getTiled​

bool getTiled()const

Gets the tiled setting, previously set using setTiled().

Returns:

True if the bitmap is tiled, false otherwise.

setBitmap​

setOffset​

virtual void setOffset(int16_tx ,
int16_ty
)

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.

Parameters:
xThe x coordinate.
yThe y coordinate.
See also:

setTiled​

virtual void setTiled(booltiled)

Instruct the painter to tile the bitmap specified.

The bitmap will be tiled both horizontally and vertically.

Parameters:
tiledTrue if tiled.
See also:

~AbstractPainterBitmap​

Destructor.

Protected Functions Documentation​

adjustBitmapXY​

bool adjustBitmapXY(int16_t &bitmapX ,const
int16_t &bitmapY ,const
int16_t &offset ,const
int16_t &countconst
)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.

Parameters:
bitmapXThe bitmap x coordinate.
bitmapYThe bitmap y coordinate.
offsetThe pointer x coordinate.
countNumber of.
Returns:

True if anything should be painted, false if nothing has to be painted.

updateBitmapOffsets​

void updateBitmapOffsets(int16_twidgetWidth)

Updates the bitmap offsets described by widgetWidth, these offset are used by bitmap painters adjust the coordinate position inside the widget.

Parameters:
widgetWidthWidth 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.