Blending pixels.

In this blog post I am providing you with a tool which will help to understand the possibilities behind PorterDuff modes without the need to study the PorterDuff composing algebra.

In simple words, you will be able to make a droid appear on a grass field. Of course you can digitally make anything to appear on anything, this was just an example :-).

Screen Shot 2015-12-27 at 13.21.25

In the previous blog post I have explained how to give a tint to your images by means of color filters and PorterDuff modes. This time I am going to extend that topic by showing what amazing results you can achieve with the PorterDuff modes when they are applied to two images.

In computer graphics, when two bitmaps are blended together, they are usually named source  (SRC) bitmap and destination (DST) bitmap. The goal of “blending” two bitmaps is to achieve the illusion that the elements in SRC and DST are actually part of the same scene. The image below shows an example of that illusion: the source image is a droid and the second is a grass field. Merging the two bitmaps together looks like the droid is sitting on the grass.


This is just one of the uses that can be done of the PorterDuff modes. Indeed those modes describes other way to compose the pixels of the SRC and DST. It is possible for example to cut-out the source from the destination, like showed below:


or to remove the DST from SRC when the pixel of the DST fall out of the borders of the SRC, as in the next image.


At this point, the best is to let you play with the sample app which I made specifically to learn what the PorterDuff modes do in a practical way. The sample code is available as usual on my GitHub. Fell free to play with it.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s