mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-19 11:35:12 +00:00
lua-imlib2: Fix alpha mask so that its scaled
Previously if the source image was a different to the displayed image the alpha channel was incorrect, as it wasn't scaled leading to a series of artifacts.
This commit is contained in:
parent
01ca581259
commit
2e54b29450
@ -33,7 +33,7 @@ void cairo_draw_image(const char *file, cairo_surface_t *cs, int x, int y,
|
|||||||
double *return_scale_h) {
|
double *return_scale_h) {
|
||||||
int w, h, stride;
|
int w, h, stride;
|
||||||
double scaled_w, scaled_h;
|
double scaled_w, scaled_h;
|
||||||
Imlib_Image premul;
|
Imlib_Image alpha, premul;
|
||||||
cairo_surface_t *result;
|
cairo_surface_t *result;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
Imlib_Image *image = imlib_load_image(file);
|
Imlib_Image *image = imlib_load_image(file);
|
||||||
@ -64,6 +64,9 @@ void cairo_draw_image(const char *file, cairo_surface_t *cs, int x, int y,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* create scaled version of image to later extract the alpha channel */
|
||||||
|
alpha = imlib_create_cropped_scaled_image (0, 0, w, h, scaled_w, scaled_h);
|
||||||
|
|
||||||
/* create temporary image */
|
/* create temporary image */
|
||||||
premul = imlib_create_image(scaled_w, scaled_h);
|
premul = imlib_create_image(scaled_w, scaled_h);
|
||||||
if (!premul) {
|
if (!premul) {
|
||||||
@ -81,7 +84,7 @@ void cairo_draw_image(const char *file, cairo_surface_t *cs, int x, int y,
|
|||||||
imlib_blend_image_onto_image(image, 0, 0, 0, w, h, 0, 0, scaled_w, scaled_h);
|
imlib_blend_image_onto_image(image, 0, 0, 0, w, h, 0, 0, scaled_w, scaled_h);
|
||||||
|
|
||||||
/* and use the alpha channel of the source image */
|
/* and use the alpha channel of the source image */
|
||||||
imlib_image_copy_alpha_to_image(image, 0, 0);
|
imlib_image_copy_alpha_to_image(alpha, 0, 0);
|
||||||
|
|
||||||
stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, scaled_w);
|
stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, scaled_w);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user