[cairo] RGB channels are set to zero if alpha is 0.

Behdad Esfahbod behdad at cs.toronto.edu
Mon Aug 28 17:42:33 UTC 2017


Really? Majority of PNG files are premultiplied and they render visually
alright?!  Hard to believe...

On Mon, Aug 28, 2017 at 10:31 AM, Bill Spitzak <spitzak at gmail.com> wrote:

> src/cairo-png.c has an unpremultiply_data function that is explicitly
> setting the output to zero if the alpha is zero, to avoid
> divide-by-zero. (It outputs a garbage value of (c/a)%256 if the alpha
> is non-zero but less than any of the color channels). Note that some
> work I have seen with trying to support unpremultiplied it is far more
> common to output ((!c || c>a) ? c : c/a).
>
> IMHO it is probably better for Cairo to write and read the channels
> unchanged. Despite the spec, the majority of png files actually are
> premultipled, since the majority of software just writes their
> channels unchanged to the png library, and almost all compositing
> graphics (including Cairo) more naturally works with premultiplied
> data. Nuke at one time tried to guess whether it was premultipled, but
> this had to be abandoned as the guess would screw up people using
> emission color like you and it quickly became clear that almost all
> images are premultiplied.
>
> Removing this conversion from Cairo would probably be a good idea. It
> would make Cairo match other software, it would remove surprises for
> uses such as you, it would be faster, and write+read of png data would
> be lossless. Use the fact that it is the "toy" api if you want an
> excuse for ignoring the png spec.
>
>
> On Sun, Aug 27, 2017 at 11:55 AM, Guillermo Rodriguez
> <guillerodriguez.dev at gmail.com> wrote:
> >
> > El domingo, 27 de agosto de 2017, Bram Stolk <b.stolk at gmail.com>
> escribió:
> >>
> >> I must say that PNG then makes for a very poor choice of writing to by
> >> Cairo.
> >
> >
> > Note that PNG support in Cairo is explicitly described as a "toy API",
> > intended to be used for testing and quick demos, but not much more.
> >
> > Guillermo
> >
> >
> >
> > --
> > cairo mailing list
> > cairo at cairographics.org
> > https://lists.cairographics.org/mailman/listinfo/cairo
> --
> cairo mailing list
> cairo at cairographics.org
> https://lists.cairographics.org/mailman/listinfo/cairo
>



-- 
behdad
http://behdad.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20170828/638f19e7/attachment.html>


More information about the cairo mailing list