[cairo] Image Format / Pre-Multiplied Alpha Related Feature Request

Bill Spitzak spitzak at gmail.com
Thu Jan 28 12:11:32 PST 2016


Non-premultiplying of the destination buffer would involve changing all the
compositing math.

For instance OVER changes from A+B(1-a) to (A+Bb(1-a))/(a+b-ab)

This almost always is more complicated, which is why premultiplied is
almost always used in rendering and compositing. Also in most cases the
background image has to be stored in floating point, as the multiply and
division here will get you the same inaccuracy you are having with
premultiplied.

If your Cairo rendering is a solid color (ie paths and fill and fonts, but
all using the same color) then you can get a non-premultiplied version by
saving only the alpha channel and replacing the color with the solid color.
This may cover a lot of the uses you want for texture maps. You may also be
able to bleed out the color from alpha=1 pixels into neighboring
transparent pixels, I have used this as a method to remove premultiplied
inaccuracy.

A floating-point format for Cairo would be a good solution however, as it
would be accurate, whether or not it is premultiplied.

Non-premultiplied source images are supported in most cases by choosing the
correct compositing operations and using the alpha as a mask.


On Thu, Jan 28, 2016 at 1:40 AM, Lawrence D'Oliveiro <
ldo at geek-central.gen.nz> wrote:

> On Thu, 28 Jan 2016 02:39:17 -0500, William Kappler wrote:
>
> > The issue is not any external format like OpenEXR, but that so far as
> > I am aware, there is no way to extract non-pre-multiplied information
> > out of Cairo.
>
> If you really wanted to, you could trade off resolution for bit depth
> by doing oversampling.
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20160128/a20c9b2d/attachment.html>


More information about the cairo mailing list