gfx.h File Reference
#include "cfg/cfg_gfx.h"#include <cfg/compiler.h>#include <cpu/attr.h>Go to the source code of this file.
Data Structures | |
| struct | Rect |
| Describe a rectangular area with coordinates expressed in pixels. More... | |
| struct | Bitmap |
| Control structure to draw in a bitmap. More... | |
| struct | Image |
| Hold image pixels. More... | |
Defines | |
| #define | CONFIG_CHART_TYPE_X uint8_t |
| Type for the chart dataset. | |
| #define | CONFIG_CHART_TYPE_Y uint8_t |
| Type for the chart dataset. | |
| #define | RECT_WIDTH(r) ((r)->xmax - (r)->xmin) |
| Return the width of a rectangle in pixels. | |
| #define | RECT_HEIGHT(r) ((r)->ymax - (r)->ymin) |
| Return the height of a rectangle in pixels. | |
| #define | RAST_SIZE(width, height) ( (((width) + 7) / 8) * (height) ) |
| Compute the size in bytes of a raster suitable for holding a bitmap of width x height pixels. | |
Known pixel formats for bitmap representation. | |
| #define | BITMAP_FMT_PLANAR_H_MSB 1 |
| Planar pixels, horizontal bytes, MSB left. | |
| #define | BITMAP_FMT_PLANAR_V_LSB 2 |
| Planar pixels, vertical bytes, LSB top. | |
Typedefs | |
| typedef float | vcoord_t |
| Common type for coordinates expressed in logical units. | |
| typedef struct Rect | Rect |
| Describe a rectangular area with coordinates expressed in pixels. | |
| typedef struct Bitmap | Bitmap |
| Control structure to draw in a bitmap. | |
| typedef struct Image | Image |
| Hold image pixels. | |
Functions | |
| void | gfx_bitmapInit (Bitmap *bm, uint8_t *raster, coord_t w, coord_t h) |
| Initialize a Bitmap structure with the provided parameters. | |
| void | gfx_bitmapClear (Bitmap *bm) |
| Clear the whole bitmap surface to the background color. | |
| void | gfx_blit (Bitmap *dst, const Rect *rect, const Bitmap *src, coord_t srcx, coord_t srcy) |
| Copy a rectangular area of a bitmap on another bitmap. | |
| void | gfx_blitRaster (Bitmap *dst, coord_t dx, coord_t dy, const uint8_t *raster, coord_t w, coord_t h, coord_t stride) |
| Blit a raster to a Bitmap. | |
| void | gfx_blitImage (Bitmap *dst, coord_t dx, coord_t dy, const Image *image) |
| Blit an Image to a Bitmap. | |
| void | gfx_line (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2) |
| Draw a sloped line segment. | |
| void | gfx_rectDraw (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2) |
| Draw the perimeter of an hollow rectangle. | |
| void | gfx_rectFillC (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t color) |
| Fill a rectangular area with color. | |
| void | gfx_rectFill (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2) |
| Draw a filled rectangle. | |
| void | gfx_rectClear (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2) |
| Clear a rectangular area. | |
| void | gfx_moveTo (Bitmap *bm, coord_t x, coord_t y) |
| Move the current pen position to the specified coordinates. | |
| void | gfx_lineTo (Bitmap *bm, coord_t x, coord_t y) |
| Draw a line from the current pen position to the new coordinates. | |
| void | gfx_setClipRect (Bitmap *bm, coord_t xmin, coord_t ymin, coord_t xmax, coord_t ymax) |
| Set the bitmap clipping rectangle to the specified coordinates. | |
| void | gfx_setViewRect (Bitmap *bm, vcoord_t x1, vcoord_t y1, vcoord_t x2, vcoord_t y2) |
| Imposta gli estremi del sistema di coordinate cartesiane rispetto al rettangolo di clipping della bitmap. | |
| coord_t | gfx_transformX (Bitmap *bm, vcoord_t x) |
| Transform a coordinate from the current reference system to a pixel offset within the bitmap. | |
| coord_t | gfx_transformY (Bitmap *bm, vcoord_t y) |
| Transform a coordinate from the current reference system to a pixel offset within the bitmap. | |
| void | gfx_vline (Bitmap *bm, vcoord_t x1, vcoord_t y1, vcoord_t x2, vcoord_t y2) |
| Draw a line from (x1;y1) to (x2;y2). | |
Variables | |
| EXTERN_C_BEGIN typedef int | coord_t |
| Common type for coordinates expressed in pixel units. | |
Detailed Description
Definition in file gfx.h.
Define Documentation
| #define BITMAP_FMT_PLANAR_H_MSB 1 |
| #define BITMAP_FMT_PLANAR_V_LSB 2 |
| #define RECT_HEIGHT | ( | r | ) | ((r)->ymax - (r)->ymin) |
| #define RECT_WIDTH | ( | r | ) | ((r)->xmax - (r)->xmin) |
Typedef Documentation
Describe a rectangular area with coordinates expressed in pixels.
The rectangle is represented in terms of its top/left and right/bottom borders.
In some cases, rectangles are assumed to obey to the following invariants:
xmin <= xmax ymin <= ymax
Oddly, the xmin and ymin coordinates are inclusive, while the xmax and ymax coordinates are non-inclusive. This design decision makes several computations simpler and lets you specify empty (0x0) rectangles without breaking the invariants.
Computing the size of a rectangle can be done by simply subtracting the maximum X or Y coordinate from the minimum X or Y coordinate.
Function Documentation
| void gfx_bitmapClear | ( | Bitmap * | bm | ) |
Copy a rectangular area of a bitmap on another bitmap.
Blitting is a common copy operation involving two bitmaps. A rectangular area of the source bitmap is copied bit-wise to a different position in the destination bitmap.
- Note:
- Using the same bitmap for src and dst is unsupported.
- Parameters:
-
dst Bitmap where the operation writes. rect The (xmin;ymin) coordinates provide the top/left offset for drawing in the destination bitmap. If the source bitmap is larger than the rectangle, drawing is clipped. src Bitmap containing the source pixels. srcx Starting X offset in the source bitmap. srcy Starting Y offset in the source bitmap.
Draw a sloped line segment.
Draw a sloped line segment identified by the provided start and end coordinates on the bitmap bm.
The line endpoints are clipped inside the current bitmap clipping rectangle using the Cohen-Sutherland algorithm, which is very fast.
- Note:
- The point at coordinates x2 y2 is not drawn.
- This function does not update the current pen position.
Draw a line from the current pen position to the new coordinates.
- Note:
- This function moves the current pen position to the new coordinates.
- See also:
- gfx_line()
Move the current pen position to the specified coordinates.
The pen position is used for drawing operations such as gfx_lineTo(), which can be used to draw polygons.
Set the bitmap clipping rectangle to the specified coordinates.
All drawing performed on the bitmap will be clipped inside this rectangle.
The clipping rectangle is also used as a bounding box for the logical view of the virtual coordinate system.
- Note:
- Following the convention used for all other operations, the top-left pixels of the rectangle are included, while the bottom-right pixels are considered outside the clipping region.
- See also:
- gfx_setViewRect
