mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +01:00
RCombineArea* will detect the intersec geometry.
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user