Created
December 19, 2015 21:01
-
-
Save fmthoma/f76a1b44e00d5ca972bb to your computer and use it in GitHub Desktop.
Fix semi-transparent artifacts in w3m-img when used with 32-bit color (e.g. urxvt)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/w3mimg/x11/x11_w3mimg.c b/w3mimg/x11/x11_w3mimg.c | |
index d24213e..c534393 100644 | |
--- a/w3mimg/x11/x11_w3mimg.c | |
+++ b/w3mimg/x11/x11_w3mimg.c | |
@@ -378,6 +378,10 @@ x11_load_image(w3mimg_op * self, W3MImage * img, char *fname, int w, int h) | |
w = imlib_image_get_width(); | |
if (h <= 0) | |
h = imlib_image_get_height(); | |
+ | |
+ im = imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), w, h); | |
+ imlib_context_set_image(im); | |
+ | |
XGetWindowAttributes(xi->display, xi->window, &attr); | |
img->pixmap = (void *)XCreatePixmap(xi->display, xi->parent, w, h, | |
attr.depth); | |
@@ -389,7 +393,7 @@ x11_load_image(w3mimg_op * self, W3MImage * img, char *fname, int w, int h) | |
imlib_context_set_visual(attr.visual); | |
imlib_context_set_colormap(attr.colormap); | |
imlib_context_set_drawable((Drawable) img->pixmap); | |
- imlib_render_image_on_drawable_at_size(0, 0, w, h); | |
+ imlib_render_image_on_drawable(0, 0); | |
imlib_free_image(); | |
#elif defined(USE_GDKPIXBUF) | |
max_anim = self->max_anim; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
imlib_render_image_on_drawable_at_size()
tended to leave nasty semi-transparent artifacts in 32-bit mode. Apparently, resizing an image in 32-bit mode affects the alpha channel even if there is no transparency in the image. With this patch, resizing is done in 24-bit mode (or whatever depth the original image has) before converting the image to 32-bit and rendering it on the display.