Reputation: 756
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
which is not how i wanted as it is slightly greyish is color..
I want the image to be displayed as follows :
how can i achieve this????? Please help !!!
Upvotes: 0
Views: 4186
Reputation: 544
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.
Upvotes: 0