@elextr 

> The problem is the use of binary floating point fractions to represent whole 
> numbers with differing resolutions (a GdkColor has 16 bits per component, 
> `#RRGGBB` has only 8)

Exactly. But GTK+ does this conversion as well — they too have a 
[`scale_round`](https://git.gnome.org/browse/gtk+/tree/gtk/gtkcolorsel.c?h=gtk-2-24&id=ca2e62da22d7a740800e577baeb67afa8b7f117a#n2150)
 function, and they use the formula that is commented out in Geany.

>  the `utils_scale_round` was probably changed because the first equation does 
> not handle out of range values.

The first equation is supposed to operate on doubles in the range of 0..1 
(GDK’s internal representation, same as in `GdkRGBA` in GTK+3). We can force 
`color->red` to 0..1 with `color->red / 65535.0`.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/issues/1527#issuecomment-312528823

Reply via email to