libg15render
libg15render.h
Go to the documentation of this file.
1 #ifndef LIBG15RENDER_H_
2 #define LIBG15RENDER_H_
3 
4 #ifdef __cplusplus
5 extern "C"
6 {
7 #endif
8 
9 #include <string.h>
10 
11 #ifdef HAVE_CONFIG_H
12 #include "config.h"
13 #endif
14 
15 #ifdef TTF_SUPPORT
16 #include <ft2build.h>
17 #include FT_FREETYPE_H
18 #include FT_BITMAP_H
19 #endif
20 
21 #define BYTE_SIZE 8
22 #define G15_BUFFER_LEN 1048
23 #define G15_LCD_OFFSET 32
24 #define G15_LCD_HEIGHT 43
25 #define G15_LCD_WIDTH 160
26 #define G15_COLOR_WHITE 0
27 #define G15_COLOR_BLACK 1
28 #define G15_TEXT_SMALL 0
29 #define G15_TEXT_MED 1
30 #define G15_TEXT_LARGE 2
31 #define G15_PIXEL_NOFILL 0
32 #define G15_PIXEL_FILL 1
33 #define G15_MAX_FACE 5
34 
36  typedef struct g15canvas
37  {
39  unsigned char buffer[G15_BUFFER_LEN];
41  int mode_xor;
46 #ifdef TTF_SUPPORT
47  FT_Library ftLib;
48  FT_Face ttf_face[G15_MAX_FACE][sizeof (FT_Face)];
50 #endif
52 
54  void g15r_pixelReverseFill (g15canvas * canvas, int x1, int y1, int x2,
55  int y2, int fill, int color);
57  void g15r_pixelOverlay (g15canvas * canvas, int x1, int y1, int width,
58  int height, short colormap[]);
60  void g15r_drawLine (g15canvas * canvas, int px1, int py1, int px2, int py2,
61  const int color);
63  void g15r_pixelBox (g15canvas * canvas, int x1, int y1, int x2, int y2,
64  int color, int thick, int fill);
66  void g15r_drawCircle (g15canvas * canvas, int x, int y, int r, int fill,
67  int color);
69  void g15r_drawRoundBox (g15canvas * canvas, int x1, int y1, int x2, int y2,
70  int fill, int color);
72  void g15r_drawBar (g15canvas * canvas, int x1, int y1, int x2, int y2,
73  int color, int num, int max, int type);
75 int g15r_loadWbmpSplash(g15canvas *canvas, char *filename);
77 void g15r_drawIcon(g15canvas *canvas, char *buf, int my_x, int my_y, int width, int height);
79 void g15r_drawSprite(g15canvas *canvas, char *buf, int my_x, int my_y, int width, int height, int start_x, int start_y, int total_width);
81 char *g15r_loadWbmpToBuf(char *filename, int *img_width, int *img_height);
83 void g15r_drawBigNum (g15canvas * canvas, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int color, int num);
84 
86  int g15r_getPixel (g15canvas * canvas, unsigned int x, unsigned int y);
88  void g15r_setPixel (g15canvas * canvas, unsigned int x, unsigned int y,
89  int val);
91  void g15r_clearScreen (g15canvas * canvas, int color);
93  void g15r_initCanvas (g15canvas * canvas);
94 
96  extern unsigned char fontdata_8x8[];
98  extern unsigned char fontdata_7x5[];
100  extern unsigned char fontdata_6x4[];
101 
103  void g15r_renderCharacterLarge (g15canvas * canvas, int x, int y,
104  unsigned char character, unsigned int sx,
105  unsigned int sy);
107  void g15r_renderCharacterMedium (g15canvas * canvas, int x, int y,
108  unsigned char character, unsigned int sx,
109  unsigned int sy);
111  void g15r_renderCharacterSmall (g15canvas * canvas, int x, int y,
112  unsigned char character, unsigned int sx,
113  unsigned int sy);
115  void g15r_renderString (g15canvas * canvas, unsigned char stringOut[],
116  int row, int size, unsigned int sx,
117  unsigned int sy);
118 
119 #ifdef TTF_SUPPORT
120 
121  void g15r_ttfLoad (g15canvas * canvas, char *fontname, int fontsize,
122  int face_num);
124  void g15r_ttfPrint (g15canvas * canvas, int x, int y, int fontsize,
125  int face_num, int color, int center,
126  char *print_string);
127 #endif
128 
129 #ifdef __cplusplus
130 }
131 #endif
132 
133 #endif /*LIBG15RENDER_H_ */
g15r_setPixel
void g15r_setPixel(g15canvas *canvas, unsigned int x, unsigned int y, int val)
Sets the value of the pixel at (x, y)
Definition: screen.c:50
G15_MAX_FACE
#define G15_MAX_FACE
Definition: libg15render.h:33
g15r_initCanvas
void g15r_initCanvas(g15canvas *canvas)
Clears the canvas and resets the mode switches.
Definition: screen.c:91
g15r_drawLine
void g15r_drawLine(g15canvas *canvas, int px1, int py1, int px2, int py2, const int color)
Draws a line from (px1, py1) to (px2, py2)
Definition: pixel.c:99
g15r_pixelBox
void g15r_pixelBox(g15canvas *canvas, int x1, int y1, int x2, int y2, int color, int thick, int fill)
Draws a box bounded by (x1, y1) and (x2, y2)
Definition: pixel.c:163
G15_BUFFER_LEN
#define G15_BUFFER_LEN
Definition: libg15render.h:22
g15r_renderCharacterMedium
void g15r_renderCharacterMedium(g15canvas *canvas, int x, int y, unsigned char character, unsigned int sx, unsigned int sy)
Renders a character in the meduim font at (x, y)
Definition: text.c:50
g15r_drawBigNum
void g15r_drawBigNum(g15canvas *canvas, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int color, int num)
Draw a large number.
Definition: pixel.c:545
g15canvas::ttf_face
FT_Face ttf_face[G15_MAX_FACE][sizeof(FT_Face)]
Definition: libg15render.h:48
g15r_drawSprite
void g15r_drawSprite(g15canvas *canvas, char *buf, int my_x, int my_y, int width, int height, int start_x, int start_y, int total_width)
Draw a sprite to the screen from a wbmp buffer.
Definition: pixel.c:443
g15r_drawBar
void g15r_drawBar(g15canvas *canvas, int x1, int y1, int x2, int y2, int color, int num, int max, int type)
Draws a completion bar.
Definition: pixel.c:337
g15canvas::mode_xor
int mode_xor
Definition: libg15render.h:41
fontdata_7x5
unsigned char fontdata_7x5[]
Font data for the medium (7x5) font.
g15r_clearScreen
void g15r_clearScreen(g15canvas *canvas, int color)
Fills the screen with pixels of color.
Definition: screen.c:80
g15canvas::ttf_fontsize
int ttf_fontsize[G15_MAX_FACE]
Definition: libg15render.h:49
g15canvas
struct g15canvas g15canvas
This structure holds the data need to render objects to the LCD screen.
fontdata_8x8
unsigned char fontdata_8x8[]
Font data for the large (8x8) font.
g15r_ttfPrint
void g15r_ttfPrint(g15canvas *canvas, int x, int y, int fontsize, int face_num, int color, int center, char *print_string)
Prints a string in a given font.
Definition: text.c:283
g15r_renderString
void g15r_renderString(g15canvas *canvas, unsigned char stringOut[], int row, int size, unsigned int sx, unsigned int sy)
Renders a string with font size in row.
Definition: text.c:104
g15r_drawIcon
void g15r_drawIcon(g15canvas *canvas, char *buf, int my_x, int my_y, int width, int height)
Draw an icon to the screen from a wbmp buffer.
Definition: pixel.c:411
g15r_renderCharacterSmall
void g15r_renderCharacterSmall(g15canvas *canvas, int x, int y, unsigned char character, unsigned int sx, unsigned int sy)
Renders a character in the small font at (x, y)
Definition: text.c:77
g15r_loadWbmpSplash
int g15r_loadWbmpSplash(g15canvas *canvas, char *filename)
Draw a splash screen from 160x43 wbmp file.
Definition: pixel.c:387
g15r_drawCircle
void g15r_drawCircle(g15canvas *canvas, int x, int y, int r, int fill, int color)
Draws a circle centered at (x, y) with a radius of r.
Definition: pixel.c:203
g15canvas::mode_cache
int mode_cache
Definition: libg15render.h:43
g15r_drawRoundBox
void g15r_drawRoundBox(g15canvas *canvas, int x1, int y1, int x2, int y2, int fill, int color)
Draws a box with rounded corners bounded by (x1, y1) and (x2, y2)
Definition: pixel.c:252
fontdata_6x4
unsigned char fontdata_6x4[]
Font data for the small (6x4) font.
g15r_ttfLoad
void g15r_ttfLoad(g15canvas *canvas, char *fontname, int fontsize, int face_num)
Loads a font through the FreeType2 library.
Definition: text.c:145
g15canvas::ftLib
FT_Library ftLib
Definition: libg15render.h:47
g15r_pixelOverlay
void g15r_pixelOverlay(g15canvas *canvas, int x1, int y1, int width, int height, short colormap[])
Overlays a bitmap of size width x height starting at (x1, y1)
Definition: pixel.c:74
config.h
g15r_getPixel
int g15r_getPixel(g15canvas *canvas, unsigned int x, unsigned int y)
Gets the value of the pixel at (x, y)
Definition: screen.c:29
g15r_loadWbmpToBuf
char * g15r_loadWbmpToBuf(char *filename, int *img_width, int *img_height)
Load a wbmp file into a buffer.
Definition: pixel.c:469
g15canvas
This structure holds the data need to render objects to the LCD screen.
Definition: libg15render.h:37
g15canvas::buffer
unsigned char buffer[G15_BUFFER_LEN]
Definition: libg15render.h:39
g15r_renderCharacterLarge
void g15r_renderCharacterLarge(g15canvas *canvas, int x, int y, unsigned char character, unsigned int sx, unsigned int sy)
Renders a character in the large font at (x, y)
Definition: text.c:22
g15r_pixelReverseFill
void g15r_pixelReverseFill(g15canvas *canvas, int x1, int y1, int x2, int y2, int fill, int color)
Fills an area bounded by (x1, y1) and (x2, y2)
Definition: pixel.c:45
g15canvas::mode_reverse
int mode_reverse
Definition: libg15render.h:45