<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">Hi Uli,</div>
<div class="moz-cite-prefix"><br>
</div>
thank you for the kind reply!
<blockquote type="cite"
cite="mid:99be1575-3d64-881a-4234-41ec4ac8d842@znc.in">
<pre class="moz-quote-pre" wrap="">Could you explain a bit more what exactly you want to achieve? E.g.,
what should happen when tinting with r=0.5, g=1, b=0, a=0.5 to colors
such as full red and... basically all the other colors.
</pre>
</blockquote>
<br>
<div class="moz-cite-prefix">I think you understood my issue very
well, but I will try to explain it with more examples. Here are
some example images (the checkerboard visualizes the alpha
channel). All colors below are given in [r,g,b,a] in
non-premultiplied form.<br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix"><img
src="cid:part1.802D081B.9B6BB61D@simonschneegans.de" alt=""></div>
<div class="moz-cite-prefix"> <br>
<ul>
<li>(a) This is my input image, which I want to colorize. It
contains two linear gradients, the top from [1, 1, 1, 1] to
[1, 1, 1, 0], the bottom one from [0, 0, 0, 1] to [0, 0, 0, 0,
0]. </li>
<li>(b) By colorizing (a) with [1, 0, 0, 1], I want to achieve
(b). All color components should be multiplied pair-wise; the
alpha component of the tint-color does not really matter, but
would be nice-to-have to support this as well.</li>
<li>(c) If I use the code I posted earlier (basically first
paint input image, then paint tint-color with
Cairo.Operator.MULTIPLY masked by the input image's alpha
channel) I get (c). Note how the top gradient actually fades
to transparent white and the bottom one to transparent red.</li>
<li>(d) If I paint the tint-color over the entire image and then
use Cairo.Operator.DEST_IN to restore the input image's alpha
channel, I get (d). The upper gradient looks good, but the
bottom one still fails.</li>
<li>(e) If I initialize my surface with [0,0,0,1] before
executing the code for (d), I get (e). This fixes the bottom
gradient but now the top one fades to transparent black.</li>
</ul>
</div>
<blockquote type="cite"
cite="mid:99be1575-3d64-881a-4234-41ec4ac8d842@znc.in">
<pre class="moz-quote-pre" wrap="">Do I understand correctly that you want to transform a given (r,g,b,a)
into (0.5*r, 1*g, 0*b, 0.5*a)? (numbers for my example above)</pre>
</blockquote>
<p>Exactly that.<br>
</p>
<blockquote type="cite"
cite="mid:99be1575-3d64-881a-4234-41ec4ac8d842@znc.in">
<pre class="moz-quote-pre" wrap="">Is the alpha part really needed or could you live with no support for an
alpha component for the color "to tint with"?</pre>
</blockquote>
It is not strictly required. The input image has an alpha channel
which should be preserved if the tint-color is only RGB. However, it
would be a nice addition if the tint-color could be RGBA as well! In
this case a tint-alpha of 0.5 would mean that all alpha values of
the input image are multiplied with 0.5.<br>
<blockquote type="cite"
cite="mid:99be1575-3d64-881a-4234-41ec4ac8d842@znc.in">
<pre class="moz-quote-pre" wrap="">Also, do you know the following page? It explains precisely what each of
the operators does.
<a class="moz-txt-link-freetext" href="https://www.cairographics.org/operators/">https://www.cairographics.org/operators/</a>
</pre>
</blockquote>
Yes, I looked into them but failed to figure out a combination which
could solve my issue.<br>
<p>Does this explain my problem?</p>
<p><br>
</p>
<p>Thank you,<br>
</p>
<p>Simon<br>
</p>
</body>
</html>