我正在尝试创建一个应用程序,通过调整每个字段的滑动条来调整图像的色相、饱和度、亮度、对比度和锐度,就像http://ronbigelow.com/articles/workflow_basic/hue-saturation_tool.jpg上的工具一样。我不知道该如何实现这一点,也找不到任何在线教程。Android是否已经有了这样的功能?我必须操纵单个像素的颜色吗?如果我必须处理像素,我该怎么做?
private Bitmap adjustedHue(Bitmap o, int deg)
{
Bitmap srca = o;
Bitmap bitmap = srca.copy(Bitmap.Config.ARGB_8888, true);
for(int x = 0;x < bitmap.getWidth();x++)
for(int y = 0;y < bitmap.getHeight();y++){
int newPixel = hueChange(bitmap.getPixel(x,y),deg);
bitmap.setPixel(x, y, newPixel);
}
return bitmap;
}
private int hueChange(int startpixel,int deg){
float[] hsv = new float[3]; //array to store HSV values
Color.colorToHSV(startpixel,hsv); //get original HSV values of pixel
hsv[0]=hsv[0]+deg; //add the shift to the HUE of HSV array
hsv[0]=hsv[0]%360; //confines hue to values:[0,360]
return Color.HSVToColor(Color.alpha(startpixel),hsv);
}