Reputation: 7304
I have converted my color image to black and white as follow.
//convert color to black&white
private Bitmap convertColorIntoBlackAndWhiteImage(Bitmap orginalBitmap) {
ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.setSaturation(0);
ColorMatrixColorFilter colorMatrixFilter = new ColorMatrixColorFilter(
colorMatrix);
Bitmap blackAndWhiteBitmap = orginalBitmap.copy(Bitmap.Config.ARGB_8888, true);
Paint paint = new Paint();
paint.setColorFilter(colorMatrixFilter);
Canvas canvas = new Canvas(blackAndWhiteBitmap);
canvas.drawBitmap(blackAndWhiteBitmap, 0, 0, paint);
return blackAndWhiteBitmap;
}
How can I add half transparency, about 50% transparency, to the black and white image? Thanks
Upvotes: 1
Views: 856
Reputation: 263
BitmapDrawable bd =
new BitmapDrawable(convertColorIntoBlackAndWhiteImage(bMap));
bd.setAlpha(50);
imageView1.setImageDrawable(bd);
Upvotes: 1