1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00
This commit is contained in:
id
2000-12-17 16:23:43 +00:00
parent 210ff264b9
commit 37f811de3e

View File

@@ -93,65 +93,36 @@ RCreateImageFromXImage(RContext *context, XImage *image, XImage *mask)
data = img->data; data = img->data;
if (image->depth==1) { if (image->depth==1) {
if (mask) { for (y = 0; y < image->height; y++) {
for (y = 0; y < image->height; y++) { for (x = 0; x < image->width; x++) {
for (x = 0; x < image->width; x++) { pixel = XGetPixel(image, x, y);
pixel = XGetPixel(image, x, y); if (pixel) {
if (pixel) { *data++ = 0;
*data++ = 0; *data++ = 0;
*data++ = 0; *data++ = 0;
*data++ = 0; } else {
} else { *data++ = 0xff;
*data++ = 0xff; *data++ = 0xff;
*data++ = 0xff; *data++ = 0xff;
*data++ = 0xff;
}
data++;
}
}
} else {
for (y = 0; y < image->height; y++) {
for (x = 0; x < image->width; x++) {
pixel = XGetPixel(image, x, y);
if (pixel) {
*data++ = 0;
*data++ = 0;
*data++ = 0;
} else {
*data++ = 0xff;
*data++ = 0xff;
*data++ = 0xff;
}
}
} }
if (mask) data++;
}
} }
} else { } else {
if (mask) { for (y = 0; y < image->height; y++) {
for (y = 0; y < image->height; y++) { for (x = 0; x < image->width; x++) {
for (x = 0; x < image->width; x++) { pixel = XGetPixel(image, x, y);
pixel = XGetPixel(image, x, y); *(data++) = NORMALIZE_RED(pixel);
*(data++) = NORMALIZE_RED(pixel); *(data++) = NORMALIZE_GREEN(pixel);
*(data++) = NORMALIZE_GREEN(pixel); *(data++) = NORMALIZE_BLUE(pixel);
*(data++) = NORMALIZE_BLUE(pixel); if (mask) data++;
data++; }
}
}
} else {
for (y = 0; y < image->height; y++) {
for (x = 0; x < image->width; x++) {
pixel = XGetPixel(image, x, y);
*(data++) = NORMALIZE_RED(pixel);
*(data++) = NORMALIZE_GREEN(pixel);
*(data++) = NORMALIZE_BLUE(pixel);
}
}
} }
} }
#define MIN(a,b) ((a)<(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b))
if (mask) { if (mask) {
data = img->data; data = img->data + 3; /* Skip R, G & B */
data += 3; /* Skip R, G & B */
for (y = 0; y < MIN(mask->height, image->height); y++) { for (y = 0; y < MIN(mask->height, image->height); y++) {
for (x = 0; x < MIN(mask->width, image->width); x++) { for (x = 0; x < MIN(mask->width, image->width); x++) {
if (mask->width <= image->width && XGetPixel(mask, x, y)) { if (mask->width <= image->width && XGetPixel(mask, x, y)) {