51 for (x = x1; x <= x2; ++x)
53 for (y = y1; y <= y2; ++y)
79 for (i = 0; i < (width * height); ++i)
82 int x = x1 + i % width;
83 int y = y1 + i / width;
109 if (abs (py2 - py1) > abs (px2 - px1))
125 int dy = abs (py2 - py1);
129 int ystep = (py1 < py2) ? 1 : -1;
132 for (x = px1; x <= px2; ++x)
167 for (i = 0; i < thick; ++i)
183 for (x = x1; x <= x2; ++x)
184 for (y = y1; y <= y2; ++y)
222 g15r_drawLine (canvas, x - xx, y - yy, x + xx, y - yy, color);
223 g15r_drawLine (canvas, x - xx, y + yy, x + xx, y + yy, color);
228 dd = dd - (2 * yy + 1);
233 dd = dd + (2 * xx + 1);
257 if (shave > (x2 - x1) / 2)
258 shave = (x2 - x1) / 2;
259 if (shave > (y2 - y1) / 2)
260 shave = (y2 - y1) / 2;
262 if ((x1 != x2) && (y1 != y2))
266 g15r_drawLine (canvas, x1 + shave, y1, x2 - shave, y1, color);
267 for (y = y1 + 1; y < y1 + shave; y++)
269 for (y = y1 + shave; y <= y2 - shave; y++)
271 for (y = y2 - shave + 1; y < y2; y++)
273 g15r_drawLine (canvas, x1 + shave, y2, x2 - shave, y2, color);
296 g15r_drawLine (canvas, x1 + shave, y1, x2 - shave, y1, color);
297 g15r_drawLine (canvas, x1, y1 + shave, x1, y2 - shave, color);
298 g15r_drawLine (canvas, x2, y1 + shave, x2, y2 - shave, color);
299 g15r_drawLine (canvas, x1 + shave, y2, x2 - shave, y2, color);
302 g15r_drawLine (canvas, x1 + 1, y1 + 1, x1 + shave - 1, y1 + 1,
304 g15r_drawLine (canvas, x2 - shave + 1, y1 + 1, x2 - 1, y1 + 1,
306 g15r_drawLine (canvas, x1 + 1, y2 - 1, x1 + shave - 1, y2 - 1,
308 g15r_drawLine (canvas, x2 - shave + 1, y2 - 1, x2 - 1, y2 - 1,
310 g15r_drawLine (canvas, x1 + 1, y1 + 1, x1 + 1, y1 + shave - 1,
312 g15r_drawLine (canvas, x1 + 1, y2 - 1, x1 + 1, y2 - shave + 1,
314 g15r_drawLine (canvas, x2 - 1, y1 + 1, x2 - 1, y1 + shave - 1,
316 g15r_drawLine (canvas, x2 - 1, y2 - 1, x2 - 1, y2 - shave + 1,
338 int num,
int max,
int type)
355 len = ((float) max / (
float) num);
356 length = (x2 - x1) / len;
360 g15r_pixelBox (canvas, x1, y1 - type, x2, y2 + type, color ^ 1, 1, 1);
361 g15r_pixelBox (canvas, x1, y1 - type, x2, y2 + type, color, 1, 0);
365 g15r_pixelBox (canvas, x1 - 2, y1 - type, x2 + 2, y2 + type, color ^ 1,
367 g15r_pixelBox (canvas, x1 - 2, y1 - type, x2 + 2, y2 + type, color, 1,
375 y1 + ((y2 - y1) / 2), color);
377 g15r_pixelBox (canvas, x1, y1, (
int) ceil (x1 + length), y2, color, 1, 1);
389 int width=0, height=0;
414 unsigned int pixel_offset = 0;
415 unsigned int byte_offset, bit_offset;
417 for (y=0; y < height - 1; y++)
418 for (x=0; x < width - 1; x++)
420 pixel_offset = y * width + x;
422 bit_offset = 7 - (pixel_offset %
BYTE_SIZE);
424 val = (buf[byte_offset] & (1 << bit_offset)) >> bit_offset;
446 unsigned int pixel_offset = 0;
447 unsigned int byte_offset, bit_offset;
449 for (y=0; y < height - 1; y++)
450 for (x=0; x < width - 1; x++)
452 pixel_offset = (y + start_y) * total_width + (x + start_x);
454 bit_offset = 7 - (pixel_offset %
BYTE_SIZE);
456 val = (buf[byte_offset] & (1 << bit_offset)) >> bit_offset;
475 unsigned int buflen,header=4;
476 unsigned char headerbytes[5];
477 unsigned int pixel_offset = 0;
478 unsigned int byte_offset, bit_offset;
480 wbmp_fd=open(filename,O_RDONLY);
485 retval=read(wbmp_fd,headerbytes,5);
488 if (headerbytes[2] & 1) {
489 *img_width = ((
unsigned char)headerbytes[2] ^ 1) | (
unsigned char)headerbytes[3];
490 *img_height = headerbytes[4];
493 *img_width = headerbytes[2];
494 *img_height = headerbytes[3];
497 int byte_width = *img_width / 8;
501 buflen = byte_width * (*img_height);
503 buf = (
char *)malloc (buflen);
508 buf[0]=headerbytes[4];
510 retval=read(wbmp_fd,buf+(5-header),buflen);
516 for (y = 0; y < *img_height; y++)
517 for (x = 0; x < *img_width; x++)
519 pixel_offset = y * (*img_width) + x;
521 bit_offset = 7 - (pixel_offset %
BYTE_SIZE);
523 val = (buf[byte_offset] & (1 << bit_offset)) >> bit_offset;
526 buf[byte_offset] = buf[byte_offset] | 1 << bit_offset;
528 buf[byte_offset] = buf[byte_offset] & ~(1 << bit_offset);
553 g15r_pixelBox (canvas, x1 +5, y1 +5, x2 -5, y2 - 6, 1 - color, 1, 1);
561 g15r_pixelBox (canvas, x1, y1+5, x2 -5, y1+((y2/2)-3), 1 - color, 1, 1);
562 g15r_pixelBox (canvas, x1+5, y1+((y2/2)+3), x2 , y2-6, 1 - color, 1, 1);
566 g15r_pixelBox (canvas, x1, y1+5, x2 -5, y1+((y2/2)-3), 1 - color, 1, 1);
567 g15r_pixelBox (canvas, x1, y1+((y2/2)+3), x2-5 , y2-6, 1 - color, 1, 1);
571 g15r_pixelBox (canvas, x1, y1+((y2/2)+3), x2 -5, y2, 1 - color, 1, 1);
572 g15r_pixelBox (canvas, x1+5, y1, x2-5 , y1+((y2/2)-3), 1 - color, 1, 1);
576 g15r_pixelBox (canvas, x1+5, y1+5, x2 , y1+((y2/2)-3), 1 - color, 1, 1);
577 g15r_pixelBox (canvas, x1, y1+((y2/2)+3), x2-5 , y2-6, 1 - color, 1, 1);
581 g15r_pixelBox (canvas, x1+5, y1+5, x2 , y1+((y2/2)-3), 1 - color, 1, 1);
582 g15r_pixelBox (canvas, x1+5, y1+((y2/2)+3), x2-5 , y2-6, 1 - color, 1, 1);
586 g15r_pixelBox (canvas, x1, y1+5, x2 -5, y2, 1 - color, 1, 1);
590 g15r_pixelBox (canvas, x1+5, y1+5, x2-5 , y1+((y2/2)-3), 1 - color, 1, 1);
591 g15r_pixelBox (canvas, x1+5, y1+((y2/2)+3), x2-5 , y2-6, 1 - color, 1, 1);
595 g15r_pixelBox (canvas, x1+5, y1+5, x2-5 , y1+((y2/2)-3), 1 - color, 1, 1);
596 g15r_pixelBox (canvas, x1, y1+((y2/2)+3), x2-5 , y2, 1 - color, 1, 1);
603 g15r_pixelBox (canvas, x1, y1+((y2/2)-2), x2, y1+((y2/2)+2), color, 1, 1);
void g15r_setPixel(g15canvas *canvas, unsigned int x, unsigned int y, int val)
Sets the value of the pixel at (x, y)
int g15r_getPixel(g15canvas *canvas, unsigned int x, unsigned int y)
Gets the value of the pixel at (x, y)
int g15r_loadWbmpSplash(g15canvas *canvas, char *filename)
Draw a splash screen from 160x43 wbmp file.
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)
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)
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)
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.
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.
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)
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.
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.
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)
void swap(int *x, int *y)
char * g15r_loadWbmpToBuf(char *filename, int *img_width, int *img_height)
Load a wbmp file into a buffer.
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.
This structure holds the data need to render objects to the LCD screen.
unsigned char buffer[G15_BUFFER_LEN]