I have an ImageView
loading a bitmap. In this bitmap, I want to replace all pixels of a given color with another color. I've searched extensively for this, but most answers seem to either refer to using a standard ColorFilter
(which applies the tint to all pixels) or manually looping through all pixels and replacing the color if it matches a given input color.
Is there really not a more standardized way of applying a filter only to a given single color? Or creating a mask from a bitmap and a given single color and then apply the filter using that mask? I would be very surprised if I'd had to manually mutate the bitmap and write code to alter every pixel!?
Note that I also want to make sure antialiasing etc is not destroyed. When using standard ColorFilter
/android:tint
, antialiasing in rounded corners etc is preserved. I simply want to apply the filter selectively for a given color or range of colors. Is there any API for this?