Re: RGB channels are set to zero if alpha is 0.
Behdad Esfahbod <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <CAF63+7U+9snmJTUO3M5Ao_1E3enSgYVM3rx4PmMwJMLYB0R=-g@mail.gmail.com> |
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 <[email protected]> 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 > <[email protected]> wrote: > > > > El domingo, 27 de agosto de 2017, Bram Stolk <[email protected]> > 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 > > [email protected] > > https://lists.cairographics.org/mailman/listinfo/cairo > -- > cairo mailing list > [email protected] > https://lists.cairographics.org/mailman/listinfo/cairo > -- behdad http://behdad.org/ -- cairo mailing list [email protected] https://lists.cairographics.org/mailman/listinfo/cairo