[Interest] The "Proper" Way to Mix/Cross-Fade Images
andre at familiesomers.nl
Tue Mar 20 17:00:22 CET 2012
Op 20-3-2012 14:17, Josiah Bryan schreef:
> So it all boils down to this:
> Is there any way to force QPainter (or, heck, just do it on a raw
> OpenGL surface and skip QPainter/QImage all together) to blend things
> where 50% opacity + 50% opacity = 100% opacity in the resultant image?
> Or, as some might say, am I just waayyyy off base here? Perhaps the
> mere mention of this idea is causing Porter and/or Duff to want to
> smack me with a stick...I don't know. Any thoughts?
I *think* what you need to do, is this:
* Express the progress of your face as a value between 0 and 1. Let's
call this p
* Create a transparent image with the right size. This will be image F
* Render image A with 1-p opacity into F
* For each pixel in B, add the values for that pixel B*p to the
corresponding pixel in F
* Render F over your background image, at 100% opacity.
The result should be that a pixel i,j in F contains 255, 0, 0 at all
times if both images A and B contain that value at i, j. However, I
think the fourth step will be slow, but I don't thing there is a
standard composition mode that does what you want by default.
I'm not 100% sure how to deal with alpha channels in A and B though, if
they are not just 0 or 255.
More information about the Interest