我有一个hue
效果代码,我想将它与 a 一起使用seek bar
,applyHueFilter( bitmap, level )
当我将搜索栏的圆圈向右移动时,色调过滤器会增加,而当我将它向左移动时,色调过滤器会减少(删除)..
public static Bitmap applyHueFilter(Bitmap source, int level) {
// get image size
int width = source.getWidth();
int height = source.getHeight();
int[] pixels = new int[width * height];
float[] HSV = new float[3];
// get pixel array from source
source.getPixels(pixels, 0, width, 0, 0, width, height);
int index = 0;
// iteration through pixels
for(int y = 0; y < height; ++y) {
for(int x = 0; x < width; ++x) {
// get current index in 2D-matrix
index = y * width + x;
// convert to HSV
Color.colorToHSV(pixels[index], HSV);
// increase Saturation level
HSV[1] *= level;
HSV[1] = (float) Math.max(0.0, Math.min(HSV[1], 1.0));
// take color back
pixels[index] |= Color.HSVToColor(HSV);
}
}
// output bitmap
myBitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return myBitmap;
}
当时我applyHueFilter
在progressChanged
..
hueSB.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
applyHueFilter(myBitmap, 100);
}
public void onStartTrackingTouch(SeekBar seekBar) {
}
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
发生的情况是,当我将seekbar
其向右移动时,色调适用,但当我将其向左移动时,它不会被移除(减少)..