0

In my application i want the image which is captured through the camera to appear as a pure black and white image , as i want the captured image image to be printed later..

I tried many codes to convert the into a black and white image but still the image comes as a gray scale image the pixels other than the black ones should become white.

The code that i am using is given as below :

    public static Bitmap blackNwhite(Bitmap bitmap)
{

    Bitmap bmpMonochrome = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bmpMonochrome);
    ColorMatrix ma = new ColorMatrix();
    ma.setSaturation(0);
    Paint paint = new Paint();
    paint.setColorFilter(new ColorMatrixColorFilter(ma));
    canvas.drawBitmap(bitmap, 0, 0, paint);
    return bmpMonochrome;

}

The image that i get as the output is enter image description here

which is not how i wanted as it is slightly greyish is color..

I want the image to be displayed as follows :

enter image description here

how can i achieve this????? Please help !!!

shivani
  • 702
  • 2
  • 22
  • 39

1 Answers1

0

You can go for following link:

What is the fastest way to convert an image to pure black and white in C#?

Using exact ColorMatrix, best results can be obtained.

Community
  • 1
  • 1
AnkitRox
  • 494
  • 1
  • 6
  • 16