<div dir="ltr">Summary: Was cairo_add_color_stop_rgba_premultiplied (or equivalent) ever implemented? How else can I make Cairo gradients interpolate in premultiplied alpha space?<br><br><br>In 2006 (<a href="https://lists.freedesktop.org/archives/cairo/2006-June/007203.html">https://lists.freedesktop.org/archives/cairo/2006-June/007203.html</a>), Carl Worth proposed adding cairo_set_source_rgba_premultiplied and cairo_add_color_stop_rgba_premultiplied.<br><br>cairo_set_source_rgba_premultiplied is easy to fake on the caller-side (albeit unable to distinguish e.g. transparent red from transparent green). I can un-premultiply the red, green and blue arguments and pass to cairo_set_source_rgba, watching out for division by zero alpha.<br><br>cairo_add_color_stop_rgba_premultiplied is trickier. I can un-premultiply each stop's RGBA values in the same way. But I would also like the interpolation to happen in premultiplied space.<br><br>Suppose that two adjacent stops' RGBA values are opaque red = RGBA(1, 0, 0, 1) and transparent black = RGBA (0, 0, 0, 0). Note that the stop color semantics are equivalent in both premul and non-premul space.<div><br></div><div>The halfway point, mathematically, is RGBA(0.5, 0, 0, 0.5). This is 50% opaque, but the question is whether the red has 50% or 100% Value (in the HSV sense). Using the existing cairo_pattern_add_color_stop_rgba produces 50% Value.<br><br>I have a vector graphics file format that works entirely with premultiplied colors (unlike SVG). I'd like to rasterize it with Cairo, so I'd like to make Cairo gradients interpolate in premultiplied alpha space, yielding 100% Value instead in the example above.<br><br>The cairo_add_color_stop_rgba_premultiplied idea sounds very close to what I want, but it doesn't look like it was ever implemented. That 2006 post to the cairo@ list, linked above, is also literally the only search hit for [cairo_add_color_stop_rgba_premultiplied]. I guess nobody replied specificaly to the proposal.<br><br>I suppose that, on the caller-of-Cairo side, I could approximate two adjacent stops in the file format by N explicit stops in Cairo, doing the blend-in-premul-space myself, somewhat analogous to approximating a smooth Bézier segment by N line segments.<br><br>I skimmed the thread (split into three on the <a href="http://lists.freedesktop.org">lists.freedesktop.org</a> archives for some reason) that it was posted to:<div><a href="https://lists.freedesktop.org/archives/cairo/2006-June/007201.html">https://lists.freedesktop.org/archives/cairo/2006-June/007201.html</a></div><div><a href="https://lists.freedesktop.org/archives/cairo/2006-June/007206.html">https://lists.freedesktop.org/archives/cairo/2006-June/007206.html</a></div><div><a href="https://lists.freedesktop.org/archives/cairo/2006-June/007216.html">https://lists.freedesktop.org/archives/cairo/2006-June/007216.html</a></div><div>but didn't find an alternative.</div><div><br></div><div>Any other suggestions for how I can do this?<br></div></div></div>