Android 自定义饱和度 实现黑白imageview

# Android 自定义饱和度 实现黑白imageview

@Auther: David
@email :david.forever.god@gmail.com
Learn from yesterday, live for today, hope for tomorrow.
                 start

step 1:得到Imageview,并附上图片:

        Resources res = getResources();Bitmap bmp= BitmapFactory.decodeResource(res, R.drawable.h1);imageview.setImageBitmap(bmp);


step 2:转换颜色饱和度,实现黑白效果:

        ColorMatrix cm = new ColorMatrix();cm.setSaturation(0f); // 设置饱和度:0为纯黑白,饱和度为0;1为饱和度为100,即原图;ColorMatrixColorFilter grayColorFilter = new ColorMatrixColorFilter(cm);imageview.setColorFilter(grayColorFilter);

                 end
@Auther: David
@email :david.forever.god@gmail.com
Learn from yesterday, live for today, hope for tomorrow.

本文链接:https://my.lmcjl.com/post/963.html

展开阅读全文

4 评论

留下您的评论.