<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">Thanks for that suggestion. I will give it a try if I notice transition distortions due to the pre-mult. Although, I think if there's a chance of at some point getting some sort of floating point format, I will just keep directly converting the pre-multiplied values until then; my library won't be ready for release for a good while.<br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font size="1"><span style="font-family:trebuchet ms,sans-serif"><br>:-:-:-</span></font><span style="color:rgb(68,68,68)"><font size="1"><span style="font-family:trebuchet ms,sans-serif">:-:-:-</span></font></span><span style="color:rgb(102,102,102)"><font size="1"><span style="font-family:trebuchet ms,sans-serif">:-:-:-</span></font></span><span style="color:rgb(153,153,153)"><font size="1"><span style="font-family:trebuchet ms,sans-serif">:-:-:-</span></font></span><span style="color:rgb(204,204,204)"><font size="1"><span style="font-family:trebuchet ms,sans-serif">:-:-:-</span></font></span><span style="color:rgb(238,238,238)"><font size="1"><span style="font-family:trebuchet ms,sans-serif">:-:-:-</span></font></span><span style="color:rgb(243,243,243)"><font size="1"><span style="font-family:trebuchet ms,sans-serif">:-:-:-</span></font></span><br><span style="font-family:verdana,sans-serif">William E. Kappler II<br><font size="1"><a href="https://www.linkedin.com/in/williamkappler" target="_blank">LinkedIn</a> · <a href="http://williamkappler.blogspot.com/" target="_blank">Blog</a> · <a href="https://github.com/WilliamKappler/onathacar/wiki" target="_blank">Project Website</a></font></span></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Jan 28, 2016 at 6:12 PM, Lawrence D'Oliveiro <span dir="ltr"><<a href="mailto:ldo@geek-central.gen.nz" target="_blank">ldo@geek-central.gen.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, 28 Jan 2016 17:18:04 -0500, William Kappler wrote:<br>
<br>
> perhaps I could render color without alpha and then alpha on its own,<br>
> and just blend the data together on my end.<br>
<br>
</span>Try oversampling.<br>
<br>
Say you want to create an image that is m × n pixels. Create it at,<br>
say, 2m x 2n pixels instead. Undo the premultiplied alpha, then add<br>
each square grouping of 2 × 2 pixel values into a new, deeper pixel<br>
value, creating an image at m × n pixels.<br>
<br>
Each original pixel component value in CAIRO_FORMAT_ARGB32 format is 8<br>
bits, with a range of 0..255. Adding together 4 of these gives a range<br>
of 0..1020; replicate the top 2 bits into the bottom 2 to extend the<br>
dynamic range to 0..1023. This gives you an effective bit depth of log₂<br>
1021 ≅ 10 bits. Even if not all 8 bits were meaningful to begin with<br>
(e.g. because of rounding caused by the original premultiplied alpha),<br>
you still gain log₂ 1021 - 8 ≅ 2 extra bits regardless.<br>
<br>
If that’s not enough, you can try starting with a 4m × 4n image, and<br>
add together groupings of 4 × 4 pixels to end up with a maximum of log₂<br>
4081 ≅ 12 bits per pixel component at m × n resolution. Here you<br>
replicate the top 4 bits into the bottom 4 bits to extend the 0..4080<br>
dynamic range to 0..4095. And again, even if not all the bits are<br>
meaningful, you still gain log₂ 4081 - 8 ≅ 4 extra bits per pixel<br>
component.<br>
<br>
That’s oversampling in a nutshell.<br>
<div class="HOEnZb"><div class="h5">--<br>
cairo mailing list<br>
<a href="mailto:cairo@cairographics.org">cairo@cairographics.org</a><br>
<a href="http://lists.cairographics.org/mailman/listinfo/cairo" rel="noreferrer" target="_blank">http://lists.cairographics.org/mailman/listinfo/cairo</a></div></div></blockquote></div><br></div>