0

I have a picture (https://i.stack.imgur.com/T5HnP.png) which I opening via Bitmap.decodeFile(path);. But what I can do with my bitmap to get this picture (https://i.stack.imgur.com/Io7ga.png) as result? I think I need to apply some kind of color mask on the Bitmap. How I can do that?

UPD I used following code to achieve my result:


image.setImageDrawable(convert(original, 0x7F00FF00));



public BitmapDrawable convert(Bitmap src, int color) {
    BitmapDrawable temp = new BitmapDrawable(src);
    temp.setColorFilter(new LightingColorFilter(0, color));
    return temp;
}

UPD I did my code work! I've just replaced new LightingColorFilter(0, color) with new LightingColorFilter(color, 0). Thank you guys for all your help!

Helisia
  • 568
  • 2
  • 7
  • 23

2 Answers2

2

try something like this.

Bitmap bitmap = Bitmap.decodeFile(path);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
paint.setColorFilter(new LightingColorFilter(0, 0x005500));
canvas.drawPaint(paint);

This should do what you want (I haven't tried it), although the value for the lightingColorFilter will probably have to be tweaked for the effect you are trying to achieve.

Greg Giacovelli
  • 10,164
  • 2
  • 47
  • 64
-1

you need to remove the green color channel.

you can open the file as buffered image as the variable named `imagè and then use the following code:

    for(int i=0;i<image.getWidth();i++)
     for(int j=0;j<image.getHeight();j++){
        Color c=new Color(image.getRGB(i,j));
         int pixel=c.getRed()<<16|c.getBlue();
         image.setRGB(pixel);
     }

the resultant `imagè will be your image with no green channel.