public void changeImageColor2(ImageView imageView, int color, Context context) {
if (isGrayScale) {
// 如果已经是灰度图,则恢复原色
imageView.clearColorFilter();
isGrayScale = false;
//Toast.makeText(context, "is grey", Toast.LENGTH_SHORT).show();
} else {
// 将图片设置为黑白色
ColorMatrix matrix = new ColorMatrix();
matrix.setSaturation(color); // 设置饱和度为0,即变为灰度图
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
imageView.setColorFilter(filter);
isGrayScale = true;
//}
}
}
更改饱和度,
最新推荐文章于 2024-05-31 10:46:10 发布