repo: rxvt-unicode-sixel
action: commit
revision: 
path_from: 
revision_from: 2dd447a51495053c4b6aa65ba8022d32566c7b50:
path_to: 
revision_to: 
git.thebackupbox.net
rxvt-unicode-sixel
git clone git://git.thebackupbox.net/rxvt-unicode-sixel
commit 2dd447a51495053c4b6aa65ba8022d32566c7b50
Author: Marc Lehmann 
Date:   Wed Dec 17 16:03:51 2014 +0000

    divide by alpha to avoid black holes

diff --git a/Changes b/Changes
index d7e624743637e1ac4921151fba1ddd82370105f6..
index ..c51bb45ee98bcba938050cc6ffd469790fdc4208 100644
--- a/Changes
+++ b/Changes
@@ -43,6 +43,10 @@ TODO: open question, what does the nested set_color calls in get_coplours actual
           same height but different ascent.
         - implement cvvis in terminfo as blinking cursor, to distinguish it
           from cnorm (emacs uses cvvis which is commonly a blinking cursor).
+        - when xft support was compiled in, color queries errornously returned
+          premultiplied values, this also affected internal queries, for example
+          when calculating faded colors. alpha is now divided out when possible,
+          which is more correct but loses color resolution.
 	- add DECSCUSR xterm extension to set the cursor to a vertical bar.
 	- add 'extension:string' action, and associated on_action perl
 	  hook, for keysym resources that invokes actions provided by
diff --git a/src/rxvttoolkit.C b/src/rxvttoolkit.C
index 6cf5f5adedb6ec9e1b35af33f4cee7e13a4d9bb6..
index ..69fe450ddcbef2086597f6b2b5f8b7635dfbdb53 100644
--- a/src/rxvttoolkit.C
+++ b/src/rxvttoolkit.C
@@ -924,16 +924,26 @@ void
 rxvt_color::get (rgba &color) const
 {
 #if XFT
-  //TODO premultiplied alpha??
+
   color.r = c.color.red;
   color.g = c.color.green;
   color.b = c.color.blue;
   color.a = c.color.alpha;
+
+  if (IN_RANGE_INC (color.a, 0x0001, 0xfffe))
+    {
+      color.r = color.r * 0xffff / color.a;
+      color.g = color.g * 0xffff / color.a;
+      color.b = color.b * 0xffff / color.a;
+    }
+
 #else
+
   color.r = c.red;
   color.g = c.green;
   color.b = c.blue;
   color.a = rgba::MAX_CC;
+
 #endif
 }

-----END OF PAGE-----