<p>I have actually traced the source of the problem. It happens because Geany and the <code>GtkColorSelection</code> take the same underlying <code>GdkColor</code> (0..65535 resolution) and use <em>different</em> algorithms to convert it to <code>#RRGGBB</code> (0..255 resolution), resulting in a slight discrepancy between what’s shown in the dialog and what’s inserted into the document.</p>
<p>This can be fixed by switching <a href="https://github.com/geany/geany/blob/35a5d457f48c92ecb71b5a2ecf7d718701d5ef63/src/utils.c#L456-L457">the two lines in <code>utils_scale_round</code></a> and <a href="https://github.com/geany/geany/blob/35a5d457f48c92ecb71b5a2ecf7d718701d5ef63/src/utils.c#L884-L886">invoking it</a> like <code>utils_scale_round(... / 65535.0, 255)</code>. This gives me consistently the same result between Geany and GTK+. (See also <code>gtk/gtkcolorsel.c</code>, function <code>scale_round</code>.)</p>
<p>The only question, then, is why was the correct line in <code>utils_scale_round</code> commented out and replaced with a less correct one. But this <a href="https://github.com/geany/geany/blob/8cb2cf0997409ec0397efb9554818a733d13f93c/src/utils.c#L1226-L1228">happened before the initial Git import</a>, so probably nobody knows anymore.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/issues/1527#issuecomment-312527185">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJ_R01D9wnGYUk00fC5h1rfYRxQuPks5sKDmagaJpZM4OLpgI">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJ1fJ_lwoBdPvQKA9oL5xEGt3ps0qks5sKDmagaJpZM4OLpgI.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/geany/geany/issues/1527#issuecomment-312527185"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/geany/geany","title":"geany/geany","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/geany/geany"}},"updates":{"snippets":[{"icon":"PERSON","message":"@vfaronov in #1527: 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.\r\n\r\nThis 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`.)\r\n\r\nThe 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."}],"action":{"name":"View Issue","url":"https://github.com/geany/geany/issues/1527#issuecomment-312527185"}}}</script>