1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 04:20:27 +01:00

RCombineArea* will detect the intersec geometry.

This commit is contained in:
id
2000-12-06 03:07:51 +00:00
parent 5d0157cf7b
commit 83824dbcc3

View File

@@ -272,6 +272,36 @@ RCombineImagesWithOpaqueness(RImage *image, RImage *src, int opaqueness)
#undef OP #undef OP
} }
int
calculateCombineArea(RImage *des, RImage *src,
int *sx, int *sy,
int *swidth, int *sheight,
int *dx, int *dy) {
if (*dx < 0) {
*sx = -*dx;
*swidth = *swidth + *dx;
*dx = 0;
}
if (*dx + *swidth > des->width) {
*swidth = des->width - *dx;
}
if (*dy < 0) {
*sy = -*dy;
*sheight = *sheight + *dy;
*dy = 0;
}
if (*dy + *sheight > des->height) {
*sheight = des->height - *dy;
}
if (*sheight > 0 && *swidth > 0) {
return True;
} else return False;
}
void void
RCombineArea(RImage *image, RImage *src, int sx, int sy, unsigned width, RCombineArea(RImage *image, RImage *src, int sx, int sy, unsigned width,
@@ -282,18 +312,8 @@ RCombineArea(RImage *image, RImage *src, int sx, int sy, unsigned width,
unsigned char *s; unsigned char *s;
int alpha, calpha; int alpha, calpha;
if(!calculateCombineArea(image, src, &sx, &sy, &width, &height, &dx, &dy))
assert(dy < image->height); return;
assert(dx < image->width);
assert(sy + height <= src->height);
assert(sx + width <= src->width);
if (width > image->width - dx)
width = image->width - dx;
if (height > image->height - dy)
height = image->height - dy;
if (!HAS_ALPHA(src)) { if (!HAS_ALPHA(src)) {
if (!HAS_ALPHA(image)) { if (!HAS_ALPHA(image)) {
@@ -372,19 +392,8 @@ RCombineAreaWithOpaqueness(RImage *image, RImage *src, int sx, int sy,
int dalpha = HAS_ALPHA(image); int dalpha = HAS_ALPHA(image);
int dch = (dalpha ? 4 : 3); int dch = (dalpha ? 4 : 3);
assert(dy < image->height); if(!calculateCombineArea(image, src, &sx, &sy, &width, &height, &dx, &dy))
assert(dx < image->width); return;
assert(sy + height <= src->height);
assert(sx + width <= src->width);
/* clip */
width -= sx;
height -= sy;
if (height > image->height - dy)
height = image->height - dy;
d = image->data + (dy*image->width + dx) * dch; d = image->data + (dy*image->width + dx) * dch;
dwi = (image->width - width)*dch; dwi = (image->width - width)*dch;