[Top][All Lists]

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

bug#25890: `color-values` gives wrong value

From: Rasmus
Subject: bug#25890: `color-values` gives wrong value
Date: Mon, 27 Feb 2017 18:09:46 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Hi Eli,

Eli Zaretskii <address@hidden> writes:

>> I try to get the color value of my background, "light yellow", with
>> color.el.  However, `color-values` from faces.el returns the wrong value.
>>   (color-values "#ffffff")      => (65280 65280 65280) ; The max values.
> Are you sure?
> What does the below produce?
>    (color-values "#fffffffff")

For that I get the right value:

    (color-values "#fffffffff") => (65520 65520 65520)
    (color-values "#ffffff")    => (65280 65280 65280)

>>   (color-values "#ffffe0")      => (65280 65280 57344) ; Light yellow hex.
>>   (color-values "light yellow") => (65535 65535 57568) ; The potential bug.
> On my system, I get these results:
>   (color-values "#ffffff")      => (65535 65535 65535)
>   (color-values "#ffffe0")      => (65535 65535 57568)
>   (color-values "light yellow") => (65535 65535 57568)

Which seems more reasonable.

>> That is the color value of "light yellow" exceeds the maximum value as
>> defined by the color values of white (cf. `color-rgb-to-hex').  This means
>> that the color.el functions won't work.
> I think this means your color resolution is greater than 24 bits.

Xorg tells me it's using 24 bits.

    $> xwininfo -root | grep Depth
    Depth: 24

> Or maybe I don't understand how the above affects your code.

I want to manipulate colors such as "light yellow" with color.el.  E.g.

    (set-frame-parameter (selected-frame) 'background-color
                         (color-darken-name "light yellow" 5))

This produces an "Undefined color" error because

    (color-darken-name "light yellow" 5) => "#100100c6".

This in turn points to `color-name-to-rgb', which uses (color-values
"#ffffff") as the denominator.  Because "#ffffff produces an RGB triplet
with smaller numbers than "light yellow", I get an RGB triple with
elements exceeding 1, which it shouldn't.

So an easy fix might be to use "#fffffffff" in `color-name-to-rgb', but
then I'd still not have equal color values for the white with and without

    (equal (color-values "#fffffffff") (color-values "#ffffff")) => nil

Thus, I suggested that the error was in the C code in my initial report.
I hope this explains the problem I'm seeing better.


Even a three-legged dog has three good legs to lose

reply via email to

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