int x2 = x + size - 1;
int y1 = y - size + 1;
int y2 = y + size - 1;
- int i, j;
+ int clipx = 0, clipy = 0, stride;
+ int i, j, jj;
if (x1 >= img_width)
return;
- if (x1 < 0)
+ if (x1 < 0) {
+ clipx = -x1;
x1 = 0;
+ }
if (x2 >= img_width)
x2 = img_width - 1;
if (x2 < 0)
return;
if (y1 >= img_height)
return;
- if (y1 < 0)
+ if (y1 < 0) {
+ clipy = -y1;
y1 = 0;
+ }
if (y2 >= img_height)
y2 = img_height - 1;
if (y2 < 0)
if (paint)
paint = mark_selected + 1;
- mask = brushs[size];
+ stride = size + size - 1;
+ mask = brushs[size] + stride * clipy + clipx;
for (i = y1; i <= y2; i++) {
- for (j = x1; j <= x2; j++) {
- if (*mask++ == '#')
+ for (j = x1, jj = 0; j <= x2; j++, jj++) {
+ if (mask[jj] == '#')
img_mark_buffer[j+img_width*i] = paint;
}
+ mask += stride;
}
}