#include <fcntl.h>
#include "libg15render.h"
Go to the source code of this file.
Functions | |
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_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_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_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. | |
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_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. | |
int | g15r_loadWbmpSplash (g15canvas *canvas, char *filename) |
Draw a splash screen from 160x43 wbmp file. | |
char * | g15r_loadWbmpToBuf (char *filename, int *img_width, int *img_height) |
Load a wbmp file into a buffer. | |
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 | 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_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 | swap (int *x, int *y) |
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.
Given a maximum value, and a value between 0 and that maximum value, calculate and draw a bar showing that percentage.
canvas | A pointer to a g15canvas struct in which the buffer to be operated on is found. | |
x1 | Defines leftmost bound of the bar. | |
y1 | Defines uppermost bound of the bar. | |
x2 | Defines rightmost bound of the bar. | |
y2 | Defines bottommost bound of the bar. | |
color | The bar will be drawn this color. | |
num | Number of units relative to max filled. | |
max | Number of units equal to 100% filled. | |
type | Type of bar. 1=solid bar, 2=solid bar with border, 3 = solid bar with I-frame. |
Definition at line 337 of file pixel.c.
References g15r_drawLine(), and g15r_pixelBox().
00339 { 00340 float len, length; 00341 int x; 00342 if (max == 0) 00343 return; 00344 if (num > max) 00345 num = max; 00346 00347 if (type == 2) 00348 { 00349 y1 += 2; 00350 y2 -= 2; 00351 x1 += 2; 00352 x2 -= 2; 00353 } 00354 00355 len = ((float) max / (float) num); 00356 length = (x2 - x1) / len; 00357 00358 if (type == 1) 00359 { 00360 g15r_pixelBox (canvas, x1, y1 - type, x2, y2 + type, color ^ 1, 1, 1); 00361 g15r_pixelBox (canvas, x1, y1 - type, x2, y2 + type, color, 1, 0); 00362 } 00363 else if (type == 2) 00364 { 00365 g15r_pixelBox (canvas, x1 - 2, y1 - type, x2 + 2, y2 + type, color ^ 1, 00366 1, 1); 00367 g15r_pixelBox (canvas, x1 - 2, y1 - type, x2 + 2, y2 + type, color, 1, 00368 0); 00369 } 00370 else if (type == 3) 00371 { 00372 g15r_drawLine (canvas, x1, y1 - type, x1, y2 + type, color); 00373 g15r_drawLine (canvas, x2, y1 - type, x2, y2 + type, color); 00374 g15r_drawLine (canvas, x1, y1 + ((y2 - y1) / 2), x2, 00375 y1 + ((y2 - y1) / 2), color); 00376 } 00377 g15r_pixelBox (canvas, x1, y1, (int) ceil (x1 + length), y2, color, 1, 1); 00378 }
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.
Draw a large number to a canvas
canvas | A pointer to a g15canvas struct in which the buffer to be operated on is found. | |
x1 | Defines leftmost bound of the number. | |
y1 | Defines uppermost bound of the number. | |
x2 | Defines rightmost bound of the number. | |
y2 | Defines bottommost bound of the number. | |
num | The number to be drawn. |
Definition at line 545 of file pixel.c.
References g15r_pixelBox().
00546 { 00547 x1 += 2; 00548 x2 -= 2; 00549 00550 switch(num){ 00551 case 0: 00552 g15r_pixelBox (canvas, x1, y1, x2, y2 , color, 1, 1); 00553 g15r_pixelBox (canvas, x1 +5, y1 +5, x2 -5, y2 - 6, 1 - color, 1, 1); 00554 break; 00555 case 1: 00556 g15r_pixelBox (canvas, x2-5, y1, x2, y2 , color, 1, 1); 00557 g15r_pixelBox (canvas, x1, y1, x2 -5, y2, 1 - color, 1, 1); 00558 break; 00559 case 2: 00560 g15r_pixelBox (canvas, x1, y1, x2, y2 , color, 1, 1); 00561 g15r_pixelBox (canvas, x1, y1+5, x2 -5, y1+((y2/2)-3), 1 - color, 1, 1); 00562 g15r_pixelBox (canvas, x1+5, y1+((y2/2)+3), x2 , y2-6, 1 - color, 1, 1); 00563 break; 00564 case 3: 00565 g15r_pixelBox (canvas, x1, y1, x2, y2 , color, 1, 1); 00566 g15r_pixelBox (canvas, x1, y1+5, x2 -5, y1+((y2/2)-3), 1 - color, 1, 1); 00567 g15r_pixelBox (canvas, x1, y1+((y2/2)+3), x2-5 , y2-6, 1 - color, 1, 1); 00568 break; 00569 case 4: 00570 g15r_pixelBox (canvas, x1, y1, x2, y2 , color, 1, 1); 00571 g15r_pixelBox (canvas, x1, y1+((y2/2)+3), x2 -5, y2, 1 - color, 1, 1); 00572 g15r_pixelBox (canvas, x1+5, y1, x2-5 , y1+((y2/2)-3), 1 - color, 1, 1); 00573 break; 00574 case 5: 00575 g15r_pixelBox (canvas, x1, y1, x2, y2 , color, 1, 1); 00576 g15r_pixelBox (canvas, x1+5, y1+5, x2 , y1+((y2/2)-3), 1 - color, 1, 1); 00577 g15r_pixelBox (canvas, x1, y1+((y2/2)+3), x2-5 , y2-6, 1 - color, 1, 1); 00578 break; 00579 case 6: 00580 g15r_pixelBox (canvas, x1, y1, x2, y2 , color, 1, 1); 00581 g15r_pixelBox (canvas, x1+5, y1+5, x2 , y1+((y2/2)-3), 1 - color, 1, 1); 00582 g15r_pixelBox (canvas, x1+5, y1+((y2/2)+3), x2-5 , y2-6, 1 - color, 1, 1); 00583 break; 00584 case 7: 00585 g15r_pixelBox (canvas, x1, y1, x2, y2 , color, 1, 1); 00586 g15r_pixelBox (canvas, x1, y1+5, x2 -5, y2, 1 - color, 1, 1); 00587 break; 00588 case 8: 00589 g15r_pixelBox (canvas, x1, y1, x2, y2 , color, 1, 1); 00590 g15r_pixelBox (canvas, x1+5, y1+5, x2-5 , y1+((y2/2)-3), 1 - color, 1, 1); 00591 g15r_pixelBox (canvas, x1+5, y1+((y2/2)+3), x2-5 , y2-6, 1 - color, 1, 1); 00592 break; 00593 case 9: 00594 g15r_pixelBox (canvas, x1, y1, x2, y2 , color, 1, 1); 00595 g15r_pixelBox (canvas, x1+5, y1+5, x2-5 , y1+((y2/2)-3), 1 - color, 1, 1); 00596 g15r_pixelBox (canvas, x1, y1+((y2/2)+3), x2-5 , y2, 1 - color, 1, 1); 00597 break; 00598 case 10: 00599 g15r_pixelBox (canvas, x2-5, y1+5, x2, y1+10 , color, 1, 1); 00600 g15r_pixelBox (canvas, x2-5, y2-10, x2, y2-5 , color, 1, 1); 00601 break; 00602 case 11: 00603 g15r_pixelBox (canvas, x1, y1+((y2/2)-2), x2, y1+((y2/2)+2), color, 1, 1); 00604 break; 00605 case 12: 00606 g15r_pixelBox (canvas, x2-5, y2-5, x2, y2 , color, 1, 1); 00607 break; 00608 } 00609 }
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.
Draws a circle centered at (x, y) with a radius of r.
The circle will be filled if fill != 0.
canvas | A pointer to a g15canvas struct in which the buffer to be operated on is found. | |
x | Defines horizontal center of the circle. | |
y | Defines vertical center of circle. | |
r | Defines radius of circle. | |
fill | The circle will be filled with color if fill != 0. | |
color | Lines defining the circle will be drawn this color. |
Definition at line 203 of file pixel.c.
References g15r_drawLine(), and g15r_setPixel().
00204 { 00205 int xx, yy, dd; 00206 00207 xx = 0; 00208 yy = r; 00209 dd = 2 * (1 - r); 00210 00211 while (yy >= 0) 00212 { 00213 if (!fill) 00214 { 00215 g15r_setPixel (canvas, x + xx, y - yy, color); 00216 g15r_setPixel (canvas, x + xx, y + yy, color); 00217 g15r_setPixel (canvas, x - xx, y - yy, color); 00218 g15r_setPixel (canvas, x - xx, y + yy, color); 00219 } 00220 else 00221 { 00222 g15r_drawLine (canvas, x - xx, y - yy, x + xx, y - yy, color); 00223 g15r_drawLine (canvas, x - xx, y + yy, x + xx, y + yy, color); 00224 } 00225 if (dd + yy > 0) 00226 { 00227 yy--; 00228 dd = dd - (2 * yy + 1); 00229 } 00230 if (xx > dd) 00231 { 00232 xx++; 00233 dd = dd + (2 * xx + 1); 00234 } 00235 } 00236 }
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.
Draw an icon to a canvas
canvas | A pointer to a g15canvas struct in which the buffer to be operated in is found. | |
buf | A pointer to the buffer holding the icon to be displayed. | |
my_x | Leftmost boundary of image. | |
my_y | Topmost boundary of image. | |
width | Width of the image in buf. | |
height | Height of the image in buf. |
Definition at line 411 of file pixel.c.
References BYTE_SIZE, and g15r_setPixel().
00412 { 00413 int y,x,val; 00414 unsigned int pixel_offset = 0; 00415 unsigned int byte_offset, bit_offset; 00416 00417 for (y=0; y < height - 1; y++) 00418 for (x=0; x < width - 1; x++) 00419 { 00420 pixel_offset = y * width + x; 00421 byte_offset = pixel_offset / BYTE_SIZE; 00422 bit_offset = 7 - (pixel_offset % BYTE_SIZE); 00423 00424 val = (buf[byte_offset] & (1 << bit_offset)) >> bit_offset; 00425 g15r_setPixel (canvas, x + my_x, y + my_y, val); 00426 } 00427 }
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).
A line of color is drawn from (px1, py1) to (px2, py2).
canvas | A pointer to a g15canvas struct in which the buffer to be operated on is found. | |
px1 | X component of point 1. | |
py1 | Y component of point 1. | |
px2 | X component of point 2. | |
py2 | Y component of point 2. | |
color | Line will be drawn this color. |
Definition at line 99 of file pixel.c.
References g15r_setPixel(), and swap().
Referenced by g15r_drawBar(), g15r_drawCircle(), g15r_drawRoundBox(), and g15r_pixelBox().
00101 { 00102 /* 00103 * Bresenham's Line Algorithm 00104 * http://en.wikipedia.org/wiki/Bresenham's_algorithm 00105 */ 00106 00107 int steep = 0; 00108 00109 if (abs (py2 - py1) > abs (px2 - px1)) 00110 steep = 1; 00111 00112 if (steep) 00113 { 00114 swap (&px1, &py1); 00115 swap (&px2, &py2); 00116 } 00117 00118 if (px1 > px2) 00119 { 00120 swap (&px1, &px2); 00121 swap (&py1, &py2); 00122 } 00123 00124 int dx = px2 - px1; 00125 int dy = abs (py2 - py1); 00126 00127 int error = 0; 00128 int y = py1; 00129 int ystep = (py1 < py2) ? 1 : -1; 00130 int x = 0; 00131 00132 for (x = px1; x <= px2; ++x) 00133 { 00134 if (steep) 00135 g15r_setPixel (canvas, y, x, color); 00136 else 00137 g15r_setPixel (canvas, x, y, color); 00138 00139 error += dy; 00140 if (2 * error >= dx) 00141 { 00142 y += ystep; 00143 error -= dx; 00144 } 00145 } 00146 }
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).
Draws a rounded box around the area bounded by (x1, y1) and (x2, y2).
The box will be filled if fill != 0.
canvas | A pointer to a g15canvas struct in which the buffer to be operated on is found. | |
x1 | Defines leftmost bound of the box. | |
y1 | Defines uppermost bound of the box. | |
x2 | Defines rightmost bound of the box. | |
y2 | Defines bottommost bound of the box. | |
fill | The box will be filled with color if fill != 0. | |
color | Lines defining the box will be drawn this color. |
Definition at line 252 of file pixel.c.
References G15_COLOR_BLACK, G15_COLOR_WHITE, g15r_drawLine(), and g15r_setPixel().
00254 { 00255 int y, shave = 3; 00256 00257 if (shave > (x2 - x1) / 2) 00258 shave = (x2 - x1) / 2; 00259 if (shave > (y2 - y1) / 2) 00260 shave = (y2 - y1) / 2; 00261 00262 if ((x1 != x2) && (y1 != y2)) 00263 { 00264 if (fill) 00265 { 00266 g15r_drawLine (canvas, x1 + shave, y1, x2 - shave, y1, color); 00267 for (y = y1 + 1; y < y1 + shave; y++) 00268 g15r_drawLine (canvas, x1 + 1, y, x2 - 1, y, color); 00269 for (y = y1 + shave; y <= y2 - shave; y++) 00270 g15r_drawLine (canvas, x1, y, x2, y, color); 00271 for (y = y2 - shave + 1; y < y2; y++) 00272 g15r_drawLine (canvas, x1 + 1, y, x2 - 1, y, color); 00273 g15r_drawLine (canvas, x1 + shave, y2, x2 - shave, y2, color); 00274 if (shave == 4) 00275 { 00276 g15r_setPixel (canvas, x1 + 1, y1 + 1, 00277 color == 00278 G15_COLOR_WHITE ? G15_COLOR_BLACK : 00279 G15_COLOR_WHITE); 00280 g15r_setPixel (canvas, x1 + 1, y2 - 1, 00281 color == 00282 G15_COLOR_WHITE ? G15_COLOR_BLACK : 00283 G15_COLOR_WHITE); 00284 g15r_setPixel (canvas, x2 - 1, y1 + 1, 00285 color == 00286 G15_COLOR_WHITE ? G15_COLOR_BLACK : 00287 G15_COLOR_WHITE); 00288 g15r_setPixel (canvas, x2 - 1, y2 - 1, 00289 color == 00290 G15_COLOR_WHITE ? G15_COLOR_BLACK : 00291 G15_COLOR_WHITE); 00292 } 00293 } 00294 else 00295 { 00296 g15r_drawLine (canvas, x1 + shave, y1, x2 - shave, y1, color); 00297 g15r_drawLine (canvas, x1, y1 + shave, x1, y2 - shave, color); 00298 g15r_drawLine (canvas, x2, y1 + shave, x2, y2 - shave, color); 00299 g15r_drawLine (canvas, x1 + shave, y2, x2 - shave, y2, color); 00300 if (shave > 1) 00301 { 00302 g15r_drawLine (canvas, x1 + 1, y1 + 1, x1 + shave - 1, y1 + 1, 00303 color); 00304 g15r_drawLine (canvas, x2 - shave + 1, y1 + 1, x2 - 1, y1 + 1, 00305 color); 00306 g15r_drawLine (canvas, x1 + 1, y2 - 1, x1 + shave - 1, y2 - 1, 00307 color); 00308 g15r_drawLine (canvas, x2 - shave + 1, y2 - 1, x2 - 1, y2 - 1, 00309 color); 00310 g15r_drawLine (canvas, x1 + 1, y1 + 1, x1 + 1, y1 + shave - 1, 00311 color); 00312 g15r_drawLine (canvas, x1 + 1, y2 - 1, x1 + 1, y2 - shave + 1, 00313 color); 00314 g15r_drawLine (canvas, x2 - 1, y1 + 1, x2 - 1, y1 + shave - 1, 00315 color); 00316 g15r_drawLine (canvas, x2 - 1, y2 - 1, x2 - 1, y2 - shave + 1, 00317 color); 00318 } 00319 } 00320 } 00321 }
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.
Draw a sprite to a canvas
canvas | A pointer to a g15canvas struct in which the buffer to be operated in is found. | |
buf | A pointer to the buffer holding a set of sprites. | |
my_x | Leftmost boundary of image. | |
my_y | Topmost boundary of image. | |
width | Width of the sprite. | |
height | Height of the sprite. | |
start_x | X offset for reading sprite from buf. | |
start_y | Y offset for reading sprite from buf. | |
total_width | Width of the set of sprites held in buf. |
Definition at line 443 of file pixel.c.
References BYTE_SIZE, and g15r_setPixel().
00444 { 00445 int y,x,val; 00446 unsigned int pixel_offset = 0; 00447 unsigned int byte_offset, bit_offset; 00448 00449 for (y=0; y < height - 1; y++) 00450 for (x=0; x < width - 1; x++) 00451 { 00452 pixel_offset = (y + start_y) * total_width + (x + start_x); 00453 byte_offset = pixel_offset / BYTE_SIZE; 00454 bit_offset = 7 - (pixel_offset % BYTE_SIZE); 00455 00456 val = (buf[byte_offset] & (1 << bit_offset)) >> bit_offset; 00457 g15r_setPixel (canvas, x + my_x, y + my_y, val); 00458 } 00459 }
int g15r_loadWbmpSplash | ( | g15canvas * | canvas, | |
char * | filename | |||
) |
Draw a splash screen from 160x43 wbmp file.
wbmp splash screen loader - assumes image is 160x43
canvas | A pointer to a g15canvas struct in which the buffer to be operated on is found. | |
filename | A string holding the path to the wbmp to be displayed. |
Definition at line 387 of file pixel.c.
References g15canvas::buffer, G15_BUFFER_LEN, and g15r_loadWbmpToBuf().
00388 { 00389 int width=0, height=0; 00390 char *buf; 00391 00392 buf = g15r_loadWbmpToBuf(filename, 00393 &width, 00394 &height); 00395 00396 memcpy (canvas->buffer, buf, G15_BUFFER_LEN); 00397 return 0; 00398 }
char* g15r_loadWbmpToBuf | ( | char * | filename, | |
int * | img_width, | |||
int * | img_height | |||
) |
Load a wbmp file into a buffer.
basic wbmp loader - loads a wbmp image into a buffer.
filename | A string holding the path to the wbmp to be loaded. | |
img_width | A pointer to an int that will hold the image width on return. | |
img_height | A pointer to an int that will hold the image height on return. |
Definition at line 469 of file pixel.c.
References BYTE_SIZE.
Referenced by g15r_loadWbmpSplash().
00470 { 00471 int wbmp_fd; 00472 int retval; 00473 int x,y,val; 00474 char *buf; 00475 unsigned int buflen,header=4; 00476 unsigned char headerbytes[5]; 00477 unsigned int pixel_offset = 0; 00478 unsigned int byte_offset, bit_offset; 00479 00480 wbmp_fd=open(filename,O_RDONLY); 00481 if(!wbmp_fd){ 00482 return NULL; 00483 } 00484 00485 retval=read(wbmp_fd,headerbytes,5); 00486 00487 if(retval){ 00488 if (headerbytes[2] & 1) { 00489 *img_width = ((unsigned char)headerbytes[2] ^ 1) | (unsigned char)headerbytes[3]; 00490 *img_height = headerbytes[4]; 00491 header = 5; 00492 } else { 00493 *img_width = headerbytes[2]; 00494 *img_height = headerbytes[3]; 00495 } 00496 00497 int byte_width = *img_width / 8; 00498 if (*img_width %8) 00499 byte_width++; 00500 00501 buflen = byte_width * (*img_height); 00502 00503 buf = (char *)malloc (buflen); 00504 if (buf == NULL) 00505 return NULL; 00506 00507 if (header == 4) 00508 buf[0]=headerbytes[4]; 00509 00510 retval=read(wbmp_fd,buf+(5-header),buflen); 00511 00512 close(wbmp_fd); 00513 } 00514 00515 /* now invert the image */ 00516 for (y = 0; y < *img_height; y++) 00517 for (x = 0; x < *img_width; x++) 00518 { 00519 pixel_offset = y * (*img_width) + x; 00520 byte_offset = pixel_offset / BYTE_SIZE; 00521 bit_offset = 7 - (pixel_offset % BYTE_SIZE); 00522 00523 val = (buf[byte_offset] & (1 << bit_offset)) >> bit_offset; 00524 00525 if (!val) 00526 buf[byte_offset] = buf[byte_offset] | 1 << bit_offset; 00527 else 00528 buf[byte_offset] = buf[byte_offset] & ~(1 << bit_offset); 00529 } 00530 00531 return buf; 00532 }
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).
Draws a box around the area bounded by (x1, y1) and (x2, y2).
The box will be filled if fill != 0 and the sides will be thick pixels wide.
canvas | A pointer to a g15canvas struct in which the buffer to be operated on is found. | |
x1 | Defines leftmost bound of the box. | |
y1 | Defines uppermost bound of the box. | |
x2 | Defines rightmost bound of the box. | |
y2 | Defines bottommost bound of the box. | |
color | Lines defining the box will be drawn this color. | |
thick | Lines defining the box will be this many pixels thick. | |
fill | The box will be filled with color if fill != 0. |
Definition at line 163 of file pixel.c.
References g15r_drawLine(), and g15r_setPixel().
Referenced by g15r_drawBar(), and g15r_drawBigNum().
00165 { 00166 int i = 0; 00167 for (i = 0; i < thick; ++i) 00168 { 00169 g15r_drawLine (canvas, x1, y1, x2, y1, color); /* Top */ 00170 g15r_drawLine (canvas, x1, y1, x1, y2, color); /* Left */ 00171 g15r_drawLine (canvas, x2, y1, x2, y2, color); /* Right */ 00172 g15r_drawLine (canvas, x1, y2, x2, y2, color); /* Bottom */ 00173 x1++; 00174 y1++; 00175 x2--; 00176 y2--; 00177 } 00178 00179 int x = 0, y = 0; 00180 00181 if (fill) 00182 { 00183 for (x = x1; x <= x2; ++x) 00184 for (y = y1; y <= y2; ++y) 00185 g15r_setPixel (canvas, x, y, color); 00186 } 00187 00188 }
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).
A 1-bit bitmap defined in colormap[] is drawn to the canvas with an upper left corner at (x1, y1) and a lower right corner at (x1+width, y1+height).
canvas | A pointer to a g15canvas struct in which the buffer to be operated on is found. | |
x1 | Defines the leftmost bound of the area to be drawn. | |
y1 | Defines the uppermost bound of the area to be drawn. | |
width | Defines the width of the bitmap to be drawn. | |
height | Defines the height of the bitmap to be drawn. | |
colormap | An array containing width*height entries of value 0 for pixel off or != 0 for pixel on. |
Definition at line 74 of file pixel.c.
References G15_COLOR_BLACK, G15_COLOR_WHITE, and g15r_setPixel().
00076 { 00077 int i = 0; 00078 00079 for (i = 0; i < (width * height); ++i) 00080 { 00081 int color = (colormap[i] ? G15_COLOR_BLACK : G15_COLOR_WHITE); 00082 int x = x1 + i % width; 00083 int y = y1 + i / width; 00084 g15r_setPixel (canvas, x, y, color); 00085 } 00086 }
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).
The area with an upper left corner at (x1, y1) and lower right corner at (x2, y2) will be filled with color if fill>0 or the current contents of the area will be reversed if fill==0.
canvas | A pointer to a g15canvas struct in which the buffer to be operated on is found. | |
x1 | Defines leftmost bound of area to be filled. | |
y1 | Defines uppermost bound of area to be filled. | |
x2 | Defines rightmost bound of area to be filled. | |
y2 | Defines bottommost bound of area to be filled. | |
fill | Area will be filled with color if fill != 0, else contents of area will have color values reversed. | |
color | If fill != 0, then area will be filled if color == 1 and emptied if color == 0. |
Definition at line 45 of file pixel.c.
References g15r_getPixel(), and g15r_setPixel().
00047 { 00048 int x = 0; 00049 int y = 0; 00050 00051 for (x = x1; x <= x2; ++x) 00052 { 00053 for (y = y1; y <= y2; ++y) 00054 { 00055 if (!fill) 00056 color = !g15r_getPixel (canvas, x, y); 00057 g15r_setPixel (canvas, x, y, color); 00058 } 00059 } 00060 }
void swap | ( | int * | x, | |
int * | y | |||
) |