|
|
@ -116,21 +116,27 @@ void image_rotate (ImageRaw *img, int deg) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void image_draw_pixel (ImageRaw *img, int x, int y, int col) {
|
|
|
|
|
|
|
|
if (img == NULL || img->data == NULL) return;
|
|
|
|
|
|
|
|
if (x < 0 || x >= img->w) return;
|
|
|
|
|
|
|
|
if (y < 0 || y >= img->h) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memcpy (img->data+3*(x+y*img->w), &col, 3);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void image_draw_rect (ImageRaw *img, Rect *r, int col) {
|
|
|
|
void image_draw_rect (ImageRaw *img, Rect *r, int col) {
|
|
|
|
if (r == NULL || img == NULL || img->data == NULL) return;
|
|
|
|
if (r == NULL || img == NULL || img->data == NULL) return;
|
|
|
|
if (r->x + r->w > img->w || r->y + r->h > img->h) return;
|
|
|
|
if (r->x + r->w > img->w || r->y + r->h > img->h) return;
|
|
|
|
int x, y;
|
|
|
|
int x, y;
|
|
|
|
unsigned char pixel[3];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memcpy (pixel, &col, 3);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (x = 0; x < r->w; x++) {
|
|
|
|
for (x = 0; x < r->w && x + r->x < img->w; x++) {
|
|
|
|
copypixel (img->data+3*(r->x+x+(r->y)*img->w), pixel);
|
|
|
|
image_draw_pixel (img, x, r->y, col);
|
|
|
|
copypixel (img->data+3*(r->x+x+(r->y+r->h)*img->w), pixel);
|
|
|
|
image_draw_pixel (img, x, r->y+r->h-1, col);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (y = 0; y < r->h; y++) {
|
|
|
|
for (y = 0; y < r->h && y + r->y < img->h; y++) {
|
|
|
|
copypixel (img->data+3*(r->x+(r->y+y)*img->w), pixel);
|
|
|
|
image_draw_pixel (img, r->x, y, col);
|
|
|
|
copypixel (img->data+3*(r->x+r->w+(r->y+y)*img->w), pixel);
|
|
|
|
image_draw_pixel (img, r->x + r->w - 1, y, col);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|