Fix header.
[bertos.git] / mware / gfx.h
1 /*!
2  * \file
3  * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
4  * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
5  * This file is part of DevLib - See devlib/README for information.
6  *
7  * \version $Id$
8  *
9  * \author Bernardo Innocenti <bernie@develer.com>
10  * \author Stefano Fedrigo <aleph@develer.com>
11  *
12  * \brief General pourpose graphics routines
13  */
14
15 /*#*
16  *#* $Log$
17  *#* Revision 1.7  2004/09/20 03:29:06  bernie
18  *#* Conditionalize AVR-specific code.
19  *#*
20  *#* Revision 1.6  2004/09/14 21:01:08  bernie
21  *#* Rename rectangle drawing functions; Unify filled/cleared implementations.
22  *#*
23  *#* Revision 1.4  2004/08/10 07:00:16  bernie
24  *#* Add missing header.
25  *#*
26  *#* Revision 1.3  2004/08/04 03:16:59  bernie
27  *#* Switch to new DevLib CONFIG_ convention.
28  *#*
29  *#* Revision 1.2  2004/06/03 11:27:09  bernie
30  *#* Add dual-license information.
31  *#*
32  *#* Revision 1.1  2004/05/23 15:43:16  bernie
33  *#* Import mware modules.
34  *#*/
35
36 #ifndef MWARE_GFX_H
37 #define MWARE_GFX_H
38
39 #include <compiler.h>
40 #include <config.h>
41
42
43 /*! Common type for coordinates expressed in pixel units */
44 typedef int coord_t;
45
46 #if CONFIG_GFX_VCOORDS
47 /*! Common type for coordinates expressed in logical units */
48 typedef float vcoord_t;
49 #endif /* CONFIG_GFX_VCOORDS */
50
51
52 typedef struct Rect { coord_t xmin, ymin, xmax, ymax; } Rect;
53
54
55 /*!
56  * Control structure to draw in a bitmap
57  */
58 typedef struct Bitmap
59 {
60         uint8_t *raster;        /*!< Pointer to byte array to hold the data */
61         coord_t width, height;  /*!< Width/Height in pixels */
62         coord_t penX, penY;     /*!< Current pen position MoveTo()/LineTo() */
63
64         Rect cr;                /*!< Clip drawing inside this rectangle */
65
66 #if CONFIG_GFX_VCOORDS
67         /*!
68          * \name Logical coordinate system
69          * \{
70          */
71         vcoord_t orgX, orgY;
72         vcoord_t scaleX, scaleY;
73         /*\}*/
74 #endif /* CONFIG_GFX_VCOORDS */
75
76 } Bitmap;
77
78
79 /* Function prototypes */
80 extern void gfx_InitBitmap(Bitmap *bm, uint8_t *raster, coord_t w, coord_t h);
81 extern void gfx_ClearBitmap(Bitmap *bm);
82 extern void gfx_DrawLine(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
83 extern void gfx_RectDraw(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
84 extern void gfx_RectFillC(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t color);
85 extern void gfx_RectFill(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
86 extern void gfx_RectClear(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
87 extern void gfx_MoveTo(Bitmap *bm, coord_t x, coord_t y);
88 extern void gfx_LineTo(Bitmap *bm, coord_t x, coord_t y);
89 extern void gfx_SetClipRect(Bitmap *bm, coord_t xmin, coord_t ymin, coord_t xmax, coord_t ymax);
90
91 #if CPU_AVR
92         #include <avr/pgmspace.h>
93         extern void gfx_blitBitmap_P(Bitmap *bm, const prog_uchar *raster);
94 #endif /* CPU_AVR */
95
96 /* DEPRECATED names */
97 #define gfx_DrawRect  gfx_RectDraw
98 #define gfx_FillRect  gfx_RectFill
99 #define gfx_ClearRect gfx_RectClear
100
101 #if CONFIG_GFX_VCOORDS
102 extern void gfx_SetViewRect(Bitmap *bm, vcoord_t x1, vcoord_t y1, vcoord_t x2, vcoord_t y2);
103 extern coord_t gfx_TransformX(Bitmap *bm, vcoord_t x);
104 extern coord_t gfx_TransformY(Bitmap *bm, vcoord_t y);
105 extern void gfx_VDrawLine(Bitmap *bm, vcoord_t x1, vcoord_t y1, vcoord_t x2, vcoord_t y2);
106 #endif /* CONFIG_GFX_VCOORDS */
107
108 #endif /* MWARE_GFX_H */