filipst
filipst

Reputation: 1573

Android desaturate specific color

I am making some kind of image filter, and I need to desaturate (remove saturation) for a specific color. For example red. I want my image to replace all red colors with gray.
Change this image enter image description here

To this enter image description here

Any idea?

Upvotes: 0

Views: 793

Answers (2)

Will Bobo
Will Bobo

Reputation: 424

It's say there http://developer.android.com/reference/android/graphics/ColorMatrixColorFilter.html that ColorMatrixColorFilter can be used to change saturation of pixel. But you have to play with math and ColorMatrix

Is that what you're researching ?

Edit : There is not such thing in Android standard library. Filter are written in NDK for performance issue, so you'll need to do the same for a custom filter.

Another idea without thinking of performance is : loop through all pixels and desaturate when it's "red"

Upvotes: 0

heloisasim
heloisasim

Reputation: 5016

I think you can use OR login to add a "filter" to your color RGB or ARGB

int filter = 0x00CC0000 | color;
myView.setBackgroundColor(filter);

Upvotes: 0

Related Questions