Android ColorFilter - Porter-Duff Modes
android, colorfilter, colors, filter, porter-duff
Solution
`Sa` and `Sc` are shorts for "source alpha" and "source color", respectively. The `srcColor` parameter in the `PorterDuffColorFilter` constructor is the color used for these values.
For your case the `Mode.MULTIPLY` would probably work best.
Problem
I'm trying to solve a problem with android `ColorFilters`. Documentation is very poor, so the main method is trying different variants. The problem: There is a Bitmap. Some pixels have alpha=255, others have alpha=0. I'm trying to draw a circle with a specific color. I want alpha channel unchanged in the bitmap, but while drawing I want to multiply a color to the bitmap-alpha. So, while drawing a circle I want pixels with alpha=0 to be not painted, but pixels with alpha=255 to be painted in color which I want. Alpha channel shouldn't change. I'm trying to use porter-duff ColorFilter (PorterDuffColorFilter class in android sdk). there are too many modes and no-understandable description on official site here : http://developer.android.com/reference/android/graphics/PorterDuff.Mode.html I think I should use `DST_ATOP` or `SRC_ATOP`, but they don't work as I described. Also, there is a strange parameter `srcColor` in constructor of porter-duff colorfilter. I can't understand what "Sa" and "Sc" means in formulas `[Da, Sc * Da + (1 - Sa) * Dc]`. It can be from color which was passed into colorfilter constructor and also it can be color set by "paint.setColor". Anybody knows, how it works?