<div dir="ltr">Really? Majority of PNG files are premultiplied and they render visually alright?!  Hard to believe...<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 28, 2017 at 10:31 AM, Bill Spitzak <span dir="ltr"><<a href="mailto:spitzak@gmail.com" target="_blank">spitzak@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">src/cairo-png.c has an unpremultiply_data function that is explicitly<br>
setting the output to zero if the alpha is zero, to avoid<br>
divide-by-zero. (It outputs a garbage value of (c/a)%256 if the alpha<br>
is non-zero but less than any of the color channels). Note that some<br>
work I have seen with trying to support unpremultiplied it is far more<br>
common to output ((!c || c>a) ? c : c/a).<br>
<br>
IMHO it is probably better for Cairo to write and read the channels<br>
unchanged. Despite the spec, the majority of png files actually are<br>
premultipled, since the majority of software just writes their<br>
channels unchanged to the png library, and almost all compositing<br>
graphics (including Cairo) more naturally works with premultiplied<br>
data. Nuke at one time tried to guess whether it was premultipled, but<br>
this had to be abandoned as the guess would screw up people using<br>
emission color like you and it quickly became clear that almost all<br>
images are premultiplied.<br>
<br>
Removing this conversion from Cairo would probably be a good idea. It<br>
would make Cairo match other software, it would remove surprises for<br>
uses such as you, it would be faster, and write+read of png data would<br>
be lossless. Use the fact that it is the "toy" api if you want an<br>
excuse for ignoring the png spec.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On Sun, Aug 27, 2017 at 11:55 AM, Guillermo Rodriguez<br>
<<a href="mailto:guillerodriguez.dev@gmail.com">guillerodriguez.dev@gmail.com</a><wbr>> wrote:<br>
><br>
> El domingo, 27 de agosto de 2017, Bram Stolk <<a href="mailto:b.stolk@gmail.com">b.stolk@gmail.com</a>> escribió:<br>
>><br>
>> I must say that PNG then makes for a very poor choice of writing to by<br>
>> Cairo.<br>
><br>
><br>
> Note that PNG support in Cairo is explicitly described as a "toy API",<br>
> intended to be used for testing and quick demos, but not much more.<br>
><br>
> Guillermo<br>
><br>
><br>
><br>
</div></div><div class="HOEnZb"><div class="h5">> --<br>
> cairo mailing list<br>
> <a href="mailto:cairo@cairographics.org">cairo@cairographics.org</a><br>
> <a href="https://lists.cairographics.org/mailman/listinfo/cairo" rel="noreferrer" target="_blank">https://lists.cairographics.<wbr>org/mailman/listinfo/cairo</a><br>
--<br>
cairo mailing list<br>
<a href="mailto:cairo@cairographics.org">cairo@cairographics.org</a><br>
<a href="https://lists.cairographics.org/mailman/listinfo/cairo" rel="noreferrer" target="_blank">https://lists.cairographics.<wbr>org/mailman/listinfo/cairo</a></div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">behdad<br><a href="http://behdad.org/" target="_blank">http://behdad.org/</a></div>
</div>