]> git.eshelyaron.com Git - emacs.git/commitdiff
Premultiply background color by alpha for images
authorPo Lu <luangruo@yahoo.com>
Mon, 14 Feb 2022 10:39:56 +0000 (18:39 +0800)
committerPo Lu <luangruo@yahoo.com>
Mon, 14 Feb 2022 10:43:44 +0000 (18:43 +0800)
* src/xterm.c (x_query_frame_background_color): Premultiply
colors as X wants them when built without Cairo.

src/xterm.c

index 9cde6c9a6832f853c8e41b9b0372f8364feb1604..cff4b07c6ea4b409913d9e01586c2f164de39ce9 100644 (file)
@@ -3146,13 +3146,35 @@ static void
 x_query_frame_background_color (struct frame *f, XColor *bgcolor)
 {
   unsigned long background = FRAME_BACKGROUND_PIXEL (f);
+#ifndef USE_CAIRO
+  XColor bg;
+#endif
 
   if (FRAME_DISPLAY_INFO (f)->alpha_bits)
     {
+#ifdef USE_CAIRO
       background = (background & ~FRAME_DISPLAY_INFO (f)->alpha_mask);
       background |= (((unsigned long) (f->alpha_background * 0xffff)
                      >> (16 - FRAME_DISPLAY_INFO (f)->alpha_bits))
                     << FRAME_DISPLAY_INFO (f)->alpha_offset);
+#else
+      if (FRAME_DISPLAY_INFO (f)->alpha_bits
+         && f->alpha_background < 1.0)
+       {
+         bg.pixel = background;
+         x_query_colors (f, &bg, 1);
+         bg.red *= f->alpha_background;
+         bg.green *= f->alpha_background;
+         bg.blue *= f->alpha_background;
+
+         background = x_make_truecolor_pixel (FRAME_DISPLAY_INFO (f),
+                                              bg.red, bg.green, bg.blue);
+         background &= ~FRAME_DISPLAY_INFO (f)->alpha_mask;
+         background |= (((unsigned long) (f->alpha_background * 0xffff)
+                         >> (16 - FRAME_DISPLAY_INFO (f)->alpha_bits))
+                        << FRAME_DISPLAY_INFO (f)->alpha_offset);
+       }
+#endif
     }
 
   bgcolor->pixel = background;