I am using a few of the stock Android resources, such as ic_menu_camera.png
:
The images have a transparent background (desired), but also some transparency in the coloured pixels, too (undesired).
I'm using a ColorMatrixColorFilter to apply a tint to these images and that's working fine, however, the small amount of transparency in the icons is causing the underlying background to bleed through, and fading the colour. I can't figure out a programmatic way to set all coloured pixels to be opaque. Any help?
Current colouring code:
public static void colorImageView(Context context, ImageView imageView, @ColorRes int colorResId) {
Drawable drawable = imageView.getDrawable();
int color = context.getResources().getColor(colorResId);
drawable.setColorFilter(new ColorMatrixColorFilter(new ColorMatrix(new float[] {
0, 0, 0, 0, Color.red(color),
0, 0, 0, 0, Color.green(color),
0, 0, 0, 0, Color.blue(color),
0, 0, 0, 1, 0,
})));
}
Current result:
(first icon's source image is opaque, whereas the other 3 have undesired transparency, leading to this off-blue colour)