mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +01:00
fixed image clearing
This commit is contained in:
28
wrlib/misc.c
28
wrlib/misc.c
@@ -91,6 +91,33 @@ RBevelImage(RImage *image, int bevel_type)
|
|||||||
void
|
void
|
||||||
RClearImage(RImage *image, RColor *color)
|
RClearImage(RImage *image, RColor *color)
|
||||||
{
|
{
|
||||||
|
if (image->format == RRGBAFormat) {
|
||||||
|
unsigned char *d = image->data;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < image->width; i++) {
|
||||||
|
*d++ = color->red;
|
||||||
|
*d++ = color->green;
|
||||||
|
*d++ = color->blue;
|
||||||
|
*d++ = color->alpha;
|
||||||
|
}
|
||||||
|
for (i = 1; i < image->height; i++, d += image->width*4) {
|
||||||
|
memcpy(d, image->data, image->width*4);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unsigned char *d = image->data;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < image->width; i++) {
|
||||||
|
*d++ = color->red;
|
||||||
|
*d++ = color->green;
|
||||||
|
*d++ = color->blue;
|
||||||
|
}
|
||||||
|
for (i = 1; i < image->height; i++, d += image->width*3) {
|
||||||
|
memcpy(d, image->data, image->width*3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
if (color->alpha==255) {
|
if (color->alpha==255) {
|
||||||
if (image->format == RRGBAFormat) {
|
if (image->format == RRGBAFormat) {
|
||||||
unsigned char *d = image->data;
|
unsigned char *d = image->data;
|
||||||
@@ -144,6 +171,7 @@ RClearImage(RImage *image, RColor *color)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
|
|||||||
@@ -154,9 +154,8 @@ RLoadPNG(RContext *context, char *file, int index)
|
|||||||
if (sgamma==0)
|
if (sgamma==0)
|
||||||
sgamma = 1;
|
sgamma = 1;
|
||||||
} else {
|
} else {
|
||||||
/* no, this is correct. Old gimp versions are broken and save wrong
|
/* blah */
|
||||||
* data. Upgrade gimp. */
|
sgamma = 2.2;
|
||||||
sgamma = 2.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (png_get_gAMA(png, pinfo, &gamma))
|
if (png_get_gAMA(png, pinfo, &gamma))
|
||||||
|
|||||||
@@ -331,12 +331,12 @@ RCombineArea(RImage *image, RImage *src, int sx, int sy, unsigned width,
|
|||||||
|
|
||||||
swi = (src->width - width) * 4;
|
swi = (src->width - width) * 4;
|
||||||
s = src->data + (sy*(int)src->width + sx) * 4;
|
s = src->data + (sy*(int)src->width + sx) * 4;
|
||||||
if (!HAS_ALPHA(image)) {
|
if (dalpha) {
|
||||||
dwi = (image->width - width) * 3;
|
|
||||||
d = image->data + (dy*(int)image->width + dx) * 3;
|
|
||||||
} else {
|
|
||||||
dwi = (image->width - width) * 4;
|
dwi = (image->width - width) * 4;
|
||||||
d = image->data + (dy*(int)image->width + dx) * 4;
|
d = image->data + (dy*(int)image->width + dx) * 4;
|
||||||
|
} else {
|
||||||
|
dwi = (image->width - width) * 3;
|
||||||
|
d = image->data + (dy*(int)image->width + dx) * 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (y=0; y < height; y++) {
|
for (y=0; y < height; y++) {
|
||||||
|
|||||||
20
wrlib/view.c
20
wrlib/view.c
@@ -49,6 +49,23 @@ int main(int argc, char **argv)
|
|||||||
img = RScaleImage(img, img->width*atof(argv[2]),
|
img = RScaleImage(img, img->width*atof(argv[2]),
|
||||||
img->height*atof(argv[2]));
|
img->height*atof(argv[2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
RImage *tmp = RCreateImage(200, 200, True);
|
||||||
|
RColor col = {0,0,255,255};
|
||||||
|
|
||||||
|
if (img->format == RRGBAFormat)
|
||||||
|
puts("aklpha");
|
||||||
|
else
|
||||||
|
puts("no alpha");
|
||||||
|
|
||||||
|
RClearImage(tmp, &col);
|
||||||
|
|
||||||
|
RCombineArea(tmp, img, 0, 0, 20, 20, 10, 10);
|
||||||
|
img = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!RConvertImage(ctx, img, &pix)) {
|
if (!RConvertImage(ctx, img, &pix)) {
|
||||||
puts(RMessageForError(RErrorCode));
|
puts(RMessageForError(RErrorCode));
|
||||||
exit(1);
|
exit(1);
|
||||||
@@ -59,8 +76,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
|
|
||||||
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10,
|
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10,
|
||||||
img->width,
|
400, 400, 0, 0, 0);
|
||||||
img->height, 0, 0, 0);
|
|
||||||
XSetWindowBackgroundPixmap(dpy, win, pix);
|
XSetWindowBackgroundPixmap(dpy, win, pix);
|
||||||
XClearWindow(dpy, win);
|
XClearWindow(dpy, win);
|
||||||
XMapRaised(dpy, win);
|
XMapRaised(dpy, win);
|
||||||
|
|||||||
Reference in New Issue
Block a user