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
BitmapDrawable BD = (BitmapDrawable) I. getDrawable(); bitmap = BD. getBitmap(); Then when ever user clicks the button we set the second bitmap variable with the first variable and change the color of the ImageView like this: O = Bitmap.
A bitmap is an array of bits that specifies the color of each pixel in a rectangular array of pixels. The number of bits devoted to an individual pixel determines the number of colors that can be assigned to that pixel.
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.
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With