If you want to change the color of an image then you can use the following code :
public Bitmap changeColor(Bitmap srcBitmap, int color) {
Bitmap resBitmap = Bitmap.createBitmap(srcBitmap, 0, 0,
srcBitmap.getWidth() - 1, srcBitmap.getHeight() - 1);
Paint p = new Paint();
ColorFilter filter = new LightingColorFilter(color, 1);
p.setColorFilter(filter);
Canvas canvas = new Canvas(resBitmap);
canvas.drawBitmap(resBitmap, 0, 0, p);
return resBitmap;
}
In the above method you have to send bitmap of an imageview and color code of new color that you want to set on that image.
Color filter like LightingColorFilter multiplies the RGB channels by one color, and then adds a second color. Then you can sent this color filter on paint object and using canvas you can draw new bitmap on that image.
0 Comment(s)