From 731c0e590ea80d0eae78b2e7babb939cfd036bea Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 19 Jan 2012 13:50:00 +0100 Subject: [PATCH] color: make color-name-to-rgb work on all display system Signed-off-by: Julien Danjou --- lisp/ChangeLog | 5 +++++ lisp/color.el | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e284cb81b..d1a7da48d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-01-19 Julien Danjou + + * color.el (color-name-to-rgb): Use the white color to find the max + color component value and return correctly computed values. + 2012-01-10 Teodor Zlatanov * nntp.el (nntp-send-authinfo): Query `auth-source-search' with the diff --git a/lisp/color.el b/lisp/color.el index ff7f0eee4..3112e0d87 100644 --- a/lisp/color.el +++ b/lisp/color.el @@ -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 (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. -- 2.34.1