1

我已将彩色图像转换为黑白图像,如下所示。

        //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;
        }

如何为黑白图像添加半透明度,大约 50% 的透明度?谢谢

4

1 回答 1

1
BitmapDrawable bd =
    new BitmapDrawable(convertColorIntoBlackAndWhiteImage(bMap));
bd.setAlpha(50);
imageView1.setImageDrawable(bd);
于 2013-06-30T07:38:03.587 回答