emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 9844b152a5: Premultiply background color by alpha for images


From: Po Lu
Subject: master 9844b152a5: Premultiply background color by alpha for images
Date: Mon, 14 Feb 2022 05:43:56 -0500 (EST)

branch: master
commit 9844b152a5c96d7aa0203a0573767241a1bbd043
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Premultiply background color by alpha for images
    
    * src/xterm.c (x_query_frame_background_color): Premultiply
    colors as X wants them when built without Cairo.
---
 src/xterm.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/xterm.c b/src/xterm.c
index 9cde6c9a68..cff4b07c6e 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -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;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]