I have an android app in which I am increasing brightness of image with the code below. But this is very slow so does anyone knows a fast way to enhance image brightness of
The above answers didnt work for me as I had an imageview with image set using bitmap. So this is what it worked:
private ColorMatrixColorFilter brightness(float value) {
ColorMatrix cmB = new ColorMatrix();
cmB.set(new float[]{
1, 0, 0, 0, value,
0, 1, 0, 0, value,
0, 0, 1, 0, value,
0, 0, 0, 1, 0});
return new ColorMatrixColorFilter(cmB);
}
Have a seek bar with controls the brightness.Its range is from -255 to 255.
sbBrightness.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if(fromUser){
photoFilterView.getSource().setColorFilter(brightness(progress));
/* Filter brightness=new Filter();
brightness.addSubFilter(new BrightnessSubFilter(progress));
Bitmap ouputImage = brightness.processFilter(bm);
photoFilterView.getSource().setImageBitmap(ouputImage);*/
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
sbBrightness.setVisibility(View.GONE);
}
},1000);
}
});
Hope it helps some.