0

Possible Duplicate:
how to force a photo into black and white

i want to store Black and white photo when i take photo from mobile camera.

Community
  • 1
  • 1
SAM Bhadani
  • 831
  • 2
  • 10
  • 13

1 Answers1

8

Something like this should work:

public Bitmap greyScaler(Bitmap b) {    
     Bitmap grayscaleBitmap = Bitmap.createBitmap(b.getWidth(),
            b.getHeight(), Bitmap.Config.RGB_565);
     Canvas c = new Canvas(grayscaleBitmap);
     Paint p = new Paint();
     ColorMatrix cm = new ColorMatrix();
     cm.setSaturation(0);
     ColorMatrixColorFilter filter = new ColorMatrixColorFilter(cm);
     p.setColorFilter(filter);
     c.drawBitmap(b, 0, 0, p);
     return grayscaleBitmap;
}
Twobard
  • 2,553
  • 1
  • 24
  • 27