gfx.h File Reference

Copyright 2003, 2004, 2005, 2006 Develer S.r.l. More...

#include <cfg/compiler.h>
#include <cpu/attr.h>
#include <appconfig.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 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.
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.

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.

Variables

EXTERN_C_BEGIN typedef int coord_t
 Common type for coordinates expressed in pixel units.

Detailed Description

Copyright 2003, 2004, 2005, 2006 Develer S.r.l.

(http://www.develer.com/) Copyright 1999 Bernardo Innocenti <bernie@develer.com>

Version:
Id
gfx.h 930 2007-10-23 14:48:48Z batt

Author:
Bernardo Innocenti <bernie@develer.com>

Stefano Fedrigo <aleph@develer.com>

General pourpose graphics routines

Definition in file gfx.h.


Define Documentation

#define BITMAP_FMT_PLANAR_H_MSB   1

Planar pixels, horizontal bytes, MSB left.

Definition at line 27 of file gfx.h.

#define BITMAP_FMT_PLANAR_V_LSB   2

Planar pixels, vertical bytes, LSB top.

Definition at line 28 of file gfx.h.

#define RECT_HEIGHT (  )     ((r)->ymax - (r)->ymin)

Return the height of a rectangle in pixels.

Note:
The argument r is evaluated twice.

Definition at line 89 of file gfx.h.

#define RECT_WIDTH (  )     ((r)->xmax - (r)->xmin)

Return the width of a rectangle in pixels.

Note:
The argument r is evaluated twice.

Definition at line 82 of file gfx.h.


Function Documentation

void gfx_bitmapClear ( Bitmap bm  ) 

Clear the whole bitmap surface to the background color.

Note:
This function does not update the current pen position.

This function bypasses the current clipping area.

Definition at line 95 of file bitmap.c.

void gfx_bitmapInit ( Bitmap bm,
uint8_t *  raster,
coord_t  w,
coord_t  h 
)

Initialize a Bitmap structure with the provided parameters.

Note:
The pen position is reset to the origin.

Definition at line 60 of file bitmap.c.

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.

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.

Definition at line 162 of file bitmap.c.

void gfx_blitImage ( Bitmap dst,
coord_t  dxmin,
coord_t  dymin,
const Image image 
)

Blit an Image to a Bitmap.

See also:
gfx_blit()

Definition at line 220 of file bitmap.c.

void gfx_blitRaster ( Bitmap dst,
coord_t  dxmin,
coord_t  dymin,
const uint8_t *  raster,
coord_t  w,
coord_t  h,
coord_t  stride 
)

Blit a raster to a Bitmap.

See also:
gfx_blit()

Definition at line 195 of file bitmap.c.

void gfx_line ( Bitmap bm,
coord_t  x1,
coord_t  y1,
coord_t  x2,
coord_t  y2 
)

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.

Definition at line 183 of file line.c.

void gfx_lineTo ( Bitmap bm,
coord_t  x,
coord_t  y 
)

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()

Definition at line 263 of file line.c.

void gfx_moveTo ( Bitmap bm,
coord_t  x,
coord_t  y 
)

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.

Definition at line 249 of file line.c.

void gfx_rectClear ( Bitmap bm,
coord_t  x1,
coord_t  y1,
coord_t  x2,
coord_t  y2 
)

Clear a rectangular area.

Note:
The bottom-right border of the rectangle is not cleared.

This function does not update the current pen position.

Definition at line 353 of file line.c.

void gfx_rectDraw ( Bitmap bm,
coord_t  x1,
coord_t  y1,
coord_t  x2,
coord_t  y2 
)

Draw the perimeter of an hollow rectangle.

Note:
The bottom-right corner of the rectangle is drawn at (x2-1;y2-1).

This function does not update the current pen position.

Definition at line 276 of file line.c.

void gfx_rectFill ( Bitmap bm,
coord_t  x1,
coord_t  y1,
coord_t  x2,
coord_t  y2 
)

Draw a filled rectangle.

Note:
The bottom-right border of the rectangle is not drawn.

This function does not update the current pen position.

Definition at line 340 of file line.c.

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.

Note:
The bottom-right border of the rectangle is not drawn.

This function does not update the current pen position.

Definition at line 297 of file line.c.