SeekBar通过滑块位置来标识数值,且允许用户拖动滑块来改变值。下面利用三条SeeKBar来调整图片的色度(Hue)、饱和度(Saturation)、亮度(Lum)。
布局文件为一个ImageView,三条SeekBar,布局简单,在此省略。
首先创建一个图像处理类ImageHelper:
public class ImageHelper {
public static Bitmap handleImage(Bitmap bmp, float hue, float saturation, float lum){
Bitmap bm = Bitmap.createBitmap(bmp.getWidth(),bmp.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bm);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
ColorMatrix hueMatrix = new ColorMatrix();
hueMatrix.setRotate(0,hue);
hueMatrix.setRotate(1,hue);
hueMatrix.setRotate(2,hue);
ColorMatrix satMatrix = new ColorMatrix();
satMatrix.setSaturation(saturation);
ColorMatrix lumMatrix = new ColorMatrix();
lumMatrix.setScale(lum,lum,lum,1); //涓変釜閫氶亾鍜岄�忔槑搴�
ColorMat