private void adjustContrast(float contrast) {
ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.set(new float[] {
contrast, 0, 0, 0, 128 * (1 - contrast),
0, contrast, 0, 0, 128 * (1 - contrast),
0, 0, contrast, 0, 128 * (1 - contrast),
0, 0, 0, 1, 0
});
ColorMatrixColorFilter colorFilter = new ColorMatrixColorFilter(colorMatrix);
iv_backgroundPhoto.setColorFilter(colorFilter);
}
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
// 根据SeekBar的进度来调整图片的对比度
float contrast = 1 - ((float) progress / 100);
adjustContrast(contrast);
}