]> git.eshelyaron.com Git - emacs.git/commitdiff
color.el (color-name-to-rgb): Use the white color to find the max color component...
authorJulien Danjou <julien@danjou.info>
Thu, 19 Jan 2012 23:06:49 +0000 (23:06 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Thu, 19 Jan 2012 23:06:49 +0000 (23:06 +0000)
 (color-name-to-rgb): Add missing float conversion for max value.

lisp/ChangeLog
lisp/color.el

index 8fa8031d125a0b40444e59dfec0c3bd669a7ee4e..ab813e219227376817fe269e891acda939fa31cd 100644 (file)
@@ -1,3 +1,9 @@
+2012-01-19  Julien Danjou  <julien@danjou.info>
+
+       * color.el (color-name-to-rgb): Use the white color to find the max
+       color component value and return correctly computed values.
+       (color-name-to-rgb): Add missing float conversion for max value.
+
 2012-01-19  Martin Rudalics  <rudalics@gmx.at>
 
        * window.el (window--state-get-1, window-state-get): Do not use
index ff7f0eee4e6ad9b70f6cac749edb4b4dc4d4b2fa..6fab613ba69f7c2fedbe3e6689d7fb43a95c03bd 100644 (file)
@@ -53,7 +53,10 @@ numbers, (RED GREEN BLUE), each between 0.0 and 1.0 inclusive.
 Optional arg FRAME specifies the frame where the color is to be
 displayed.  If FRAME is omitted or nil, use the selected frame.
 If FRAME cannot display COLOR, return nil."
-  (mapcar (lambda (x) (/ x 65535.0)) (color-values color frame)))
+  ;; `colors-values' maximum value is either 65535 or 65280 depending on the
+  ;; display system. So we use a white conversion to get the max value.
+  (let ((valmax (float (car (color-values "#ffffff")))))
+    (mapcar (lambda (x) (/ x valmax)) (color-values color frame))))
 
 (defun color-rgb-to-hex  (red green blue)
   "Return hexadecimal notation for the color RED GREEN BLUE.