Porter/Duff in Android
2 days ago, i have a problem to blend 2 view. If you look Android Documentation about porter/duff and I said OMG, what the hell is this, this is not helping.
After searching i found a good blog explain porter duff. This blog writer is a software engineer from google.
As you can see, basic of porter duff is divide into 4 regions (Both, Source, Dest, Neither). But don’t forget we have 2 images source and destinations.
four regions :
One region where only the source is present, one where only the destination is present, one where both are present, and one where neither is present.
By deciding on what happens in each of the four regions, various effects can be generated. For example, if the destination-only region is treated as blank, the source-only region is filled with the source color, and the ‘both’ region is filled with the destination color like this:
the result will be :
The Porter/Duff operator that does this is called “Dest Atop”.
There are twelve of these operators, each one characterized by its behavior in the three regions: source, destination and both. The ‘neither’ region is always blank. The source and destination regions can either be blank or filled with the source or destination colors respectively.
formula of operators :
Where [s] is either 0 or the color of the source pixel, [d] either 0 or the color of the destination pixel, and [b] is either 0, the color of the source pixel, or the color of the destination pixel. With the alpha channel being interpreted as coverage, the areas are given by these formulas:
Here is a table of all the Porter/Duff operators:
And this is the result of all operator :
visit original souce