I have a piece of code that was originally written as directly draw lines,
fonts, polygons with anti-aliasing on an image.
But later on, we decided to use layer approach which is the following
create a layer, and draw that layer.
we can have multiple layers...
and then compose all the layers onto a white background image to get a
final image.
The problem is, because of the alpha handling (we clear each layer to
rgba(255,255,255,0)), it effectively blends the transparency twice,
resulting incorrect final color.
I did a bit calculation, the alpha of the layer vs the actual color is
something like
newAlpha = 16 * sqrt (originalApha)
I could change the fill color manually to achieve the result for some
stuff, but for fonts / line drawing etc, that would not work due to the
underlying anti-aliasing logic.
I am wondering what is the general terminology for this problem as well as
the agg specific way of doing it. The reason why I am asking is because
there appears to be multiple places that could do it, but I am not sure
which one would be the "correct" way doing it.
If you want to do compositing, the (destination) layers need to be pixfmt_rgba32_pre. You can find a brief explanation in the version 2.2 release notes.
By the way, rgba(1, 1, 1, 0) is not valid in premultiplied space, since each rgb component should be <= alpha.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I have a piece of code that was originally written as directly draw lines,
fonts, polygons with anti-aliasing on an image.
But later on, we decided to use layer approach which is the following
final image.
The problem is, because of the alpha handling (we clear each layer to
rgba(255,255,255,0)), it effectively blends the transparency twice,
resulting incorrect final color.
I did a bit calculation, the alpha of the layer vs the actual color is
something like
newAlpha = 16 * sqrt (originalApha)
I could change the fill color manually to achieve the result for some
stuff, but for fonts / line drawing etc, that would not work due to the
underlying anti-aliasing logic.
I am wondering what is the general terminology for this problem as well as
the agg specific way of doing it. The reason why I am asking is because
there appears to be multiple places that could do it, but I am not sure
which one would be the "correct" way doing it.
Here is my current layer creation in agg:
Could anyone help?
Thanks,
Heng Yuan
If you want to do compositing, the (destination) layers need to be pixfmt_rgba32_pre. You can find a brief explanation in the version 2.2 release notes.
By the way, rgba(1, 1, 1, 0) is not valid in premultiplied space, since each rgb component should be <= alpha.
Thanks a lot. I will try it out.