Jérémy Morel wrote:
The formula for blending is : (256-a_source) / 256 * destination +
a_source/256*source
where:
* a_source is the alpha component of the source,
* destination is one of the color component of the destination
* source is the same color component, but for the source
Let's consider for example the red component (it works with any
component)
Our source is 01ff ff ff, ie white with a minimal alpha component,
and its red component is therefore 255
Our destination can be any colour, let's assume its red component is 50.
each time I apply my filter, the color of the destination becomes :
(256 - 1)/256 * destination + 1/256*255
This is an sequence defined by u_{n+1} = 255/256 * u_{n} + 255/256,
which generic term is:
u_n = (255/256)^n * (50 - 255) + 255
which will tend to 255. Therefore it should work.
Not quite. Or rather, yes/no.
A default surface will be assumed "non-premultiplied" which means that
the colour 01ffffff will be premultiplied first, so the resulting colour
is (a,r*a,b*a,g*a) = 01010101, leading to ((256-1)*dst)/256 + (1*src)
leading, on a black surface, to 0 + 1, and on the resulting surface
(with 1) also to 0 + 1 (or rather 255/256 + 1, rounded to 1), so the
surface will be stuck at 1 or 01010101 to be precise.
When you specify PREMULTIPLIED at surface creation, DirectFB assumes
that this premultiplication has already been performed (e.g. by a
previous blit) and will then use 01ffffff instead of 01010101, leading
to (again starting on black): 0 + 255, giving instant white with an
alpha of 1. which will be stuck at 1, so result colour is 01ffffff.
Havn't tried this, so hope my math is right :)
However, a simple verification shows that 1000 iterations will only
get you to 251, which means that the residue shape is perfectly normal.
I'm sorry for this mathematical post, but it explains the phenomena.
Thanks for the blending formula, I had no idea how it was done.
Hee, no worries, it's all mathematics inside this bit of DirectFB :)
--
Jérémy
_______________________________________________
directfb-users mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users
--
.------------------------------------------.
| DirectFB - Hardware accelerated graphics |
| http://www.directfb.org/ |
"------------------------------------------"
_______________________________________________
directfb-users mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users