I have actually traced the source of the problem. It happens because Geany and 
the `GtkColorSelection` take the same underlying `GdkColor` (0..65535 
resolution) and use *different* algorithms to convert it to `#RRGGBB` (0..255 
resolution), resulting in a slight discrepancy between what’s shown in the 
dialog and what’s inserted into the document.

This can be fixed by switching [the two lines in 
`utils_scale_round`](https://github.com/geany/geany/blob/35a5d457f48c92ecb71b5a2ecf7d718701d5ef63/src/utils.c#L456-L457)
 and [invoking 
it](https://github.com/geany/geany/blob/35a5d457f48c92ecb71b5a2ecf7d718701d5ef63/src/utils.c#L884-L886)
 like `utils_scale_round(... / 65535.0, 255)`. This gives me consistently the 
same result between Geany and GTK+. (See also `gtk/gtkcolorsel.c`, function 
`scale_round`.)

The only question, then, is why was the correct line in `utils_scale_round` 
commented out and replaced with a less correct one. But this [happened before 
the initial Git 
import](https://github.com/geany/geany/blob/8cb2cf0997409ec0397efb9554818a733d13f93c/src/utils.c#L1226-L1228),
 so probably nobody knows anymore.

-- 
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-312527185

Reply via email to