Reputation: 333
I am working in a android project where in i have to change the color of the wall. For e.x if I take a picture of the wall having corners and select some color say blue. The color of the wall should change in such a way that the wall looks as if it is painted with that color. I mean to say that the shades at the corners of the wall should be retained after changing the color. Wall should not look like painted like flat rectangle.
Please let me know the way to do it.
Thanks in advance. Regards
Upvotes: 5
Views: 7164
Reputation: 333
Here is something I did for getting it done:
public static Bitmap changeImageColor(Bitmap srcBmp, int dstColor) {
int width = srcBmp.getWidth();
int height = srcBmp.getHeight();
float srcHSV[] = new float[3];
float dstHSV[] = new float[3];
Bitmap dstBitmap = Bitmap.createBitmap(width, height, Config.RGB_565);
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
Color.colorToHSV(srcBmp.getPixel(col, row), srcHSV);
Color.colorToHSV(dstColor, dstHSV);
// If it area to be painted set only value of original image
dstHSV[2] = srcHSV[2]; // value
dstBitmap.setPixel(col, row, Color.HSVToColor(dstHSV));
}
}
return dstBitmap;
}
Upvotes: 1
Reputation: 1761
Try the bellow link
How to change Bitmap image color in android?
Or
http://www.codeproject.com/Articles/17162/Fast-Color-Depth-Change-for-Bitmaps
OR
how to change the color of certain pixels in bitmap android
This may help You.
Upvotes: 4