Use separate background image for alpha layer; fixes issue #132
This commit is contained in:
parent
72f1b1ca6f
commit
4fde8c8cbc
2
Makefile
2
Makefile
@ -1,4 +1,4 @@
|
|||||||
VERSION = git-20140205
|
VERSION = git-20140206
|
||||||
|
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
MANPREFIX = $(PREFIX)/share/man
|
MANPREFIX = $(PREFIX)/share/man
|
||||||
|
38
image.c
38
image.c
@ -441,6 +441,8 @@ void img_render(img_t *img)
|
|||||||
win_t *win;
|
win_t *win;
|
||||||
int sx, sy, sw, sh;
|
int sx, sy, sw, sh;
|
||||||
int dx, dy, dw, dh;
|
int dx, dy, dw, dh;
|
||||||
|
Imlib_Image bg;
|
||||||
|
unsigned long c;
|
||||||
|
|
||||||
if (img == NULL || img->im == NULL || img->win == NULL)
|
if (img == NULL || img->im == NULL || img->win == NULL)
|
||||||
return;
|
return;
|
||||||
@ -456,8 +458,11 @@ void img_render(img_t *img)
|
|||||||
if (!img->dirty)
|
if (!img->dirty)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* calculate source and destination offsets */
|
/* calculate source and destination offsets:
|
||||||
if (img->x < 0) {
|
* - part of image drawn on full window, or
|
||||||
|
* - full image drawn on part of window
|
||||||
|
*/
|
||||||
|
if (img->x <= 0) {
|
||||||
sx = -img->x / img->zoom;
|
sx = -img->x / img->zoom;
|
||||||
sw = win->w / img->zoom;
|
sw = win->w / img->zoom;
|
||||||
dx = 0;
|
dx = 0;
|
||||||
@ -468,7 +473,7 @@ void img_render(img_t *img)
|
|||||||
dx = img->x;
|
dx = img->x;
|
||||||
dw = img->w * img->zoom;
|
dw = img->w * img->zoom;
|
||||||
}
|
}
|
||||||
if (img->y < 0) {
|
if (img->y <= 0) {
|
||||||
sy = -img->y / img->zoom;
|
sy = -img->y / img->zoom;
|
||||||
sh = win->h / img->zoom;
|
sh = win->h / img->zoom;
|
||||||
dy = 0;
|
dy = 0;
|
||||||
@ -484,13 +489,30 @@ void img_render(img_t *img)
|
|||||||
|
|
||||||
imlib_context_set_image(img->im);
|
imlib_context_set_image(img->im);
|
||||||
imlib_context_set_anti_alias(img->aa);
|
imlib_context_set_anti_alias(img->aa);
|
||||||
|
|
||||||
if (!img->alpha && imlib_image_has_alpha())
|
|
||||||
win_draw_rect(win, win->pm, dx, dy, dw, dh, True, 0, win->white);
|
|
||||||
|
|
||||||
imlib_context_set_drawable(win->pm);
|
imlib_context_set_drawable(win->pm);
|
||||||
imlib_render_image_part_on_drawable_at_size(sx, sy, sw, sh, dx, dy, dw, dh);
|
|
||||||
|
|
||||||
|
if (imlib_image_has_alpha()) {
|
||||||
|
bg = imlib_create_image(dw, dh);
|
||||||
|
imlib_context_set_image(bg);
|
||||||
|
imlib_image_set_has_alpha(0);
|
||||||
|
|
||||||
|
if (img->alpha)
|
||||||
|
c = win->fullscreen ? win->fscol : win->bgcol;
|
||||||
|
else
|
||||||
|
c = win->white;
|
||||||
|
imlib_context_set_color(c >> 16 & 0xFF, c >> 8 & 0xFF, c & 0xFF, 0xFF);
|
||||||
|
imlib_image_fill_rectangle(0, 0, dw, dh);
|
||||||
|
|
||||||
|
imlib_blend_image_onto_image(img->im, 0, sx, sy, sw, sh, 0, 0, dw, dh);
|
||||||
|
imlib_context_set_color_modifier(NULL);
|
||||||
|
imlib_render_image_on_drawable(dx, dy);
|
||||||
|
|
||||||
|
imlib_free_image();
|
||||||
|
if (img->gamma != 0)
|
||||||
|
imlib_context_set_color_modifier(img->cmod);
|
||||||
|
} else {
|
||||||
|
imlib_render_image_part_on_drawable_at_size(sx, sy, sw, sh, dx, dy, dw, dh);
|
||||||
|
}
|
||||||
img->dirty = false;
|
img->dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user