5

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

Kantesh
  • 333
  • 4
  • 13

2 Answers2

4

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.

Community
  • 1
  • 1
bashu
  • 1,710
  • 12
  • 16
  • I have tried these Thanks! In first link I am not getting how to form the color matrix to get the color I need as the resultant color in bitmap. – Kantesh Sep 26 '12 at 12:25
1

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;
}
Kantesh
  • 333
  • 4
  • 13