19. Invert
Inverts colors on a portion of a region.
<<funcdefs>>=
void btprnt_invert(btprnt_region *r,
int xoff, int yoff,
int w, int h);
Later, add bounds checking.
<<funcs>>=
void btprnt_invert(btprnt_region *r,
int xoff, int yoff,
int w, int h)
{
int x, y;
/* TODO: add bounds checking */
for (x = 0; x < w; x++) {
for (y = 0; y < h; y ++) {
int s;
int xp, yp;
xp = x + xoff;
yp = y + yoff;
s = btprnt_region_read(r, xp, yp);
if (s) {
btprnt_region_draw(r, xp, yp, 0);
} else {
btprnt_region_draw(r, xp, yp, 1);
}
}
}
}
prev | home | next