1

I want to Change color of an image on SeekBar OnProgress change event? I am showing an image in imageview and below that there is an SeekBar to change the color of an image.

I am using following way to change color of Imageview using seekbar

private SeekBar.OnSeekBarChangeListener seekBarChangeListener = new SeekBar.OnSeekBarChangeListener() {
    @Override
    public void onProgressChanged(SeekBar seekBar, int progress,
            boolean fromUser) {
        updateOuterColor();
    }

    @Override
    public void onStartTrackingTouch(SeekBar seekBar) {
    }

    @Override
    public void onStopTrackingTouch(SeekBar seekBar) {
    }
};

And updateOuterColor method will look something like this.

private void updateOuterColor() {
    seekR = seekBar1.getProgress();
    seekG = seekBar2.getProgress();
    seekB = seekBar3.getProgress();
    innerLips.setColorFilter(0xff000000 + seekR * 0x10000 + seekG * 0x100
            + seekB);
    eyeInnerOne.setColorFilter(0xff000000 + seekR * 0x10000 + seekG * 0x100
            + seekB);
    eyeInnerTwo.setColorFilter(0xff000000 + seekR * 0x10000 + seekG * 0x100
            + seekB);
}

Now the problem is when i am moving my seekbar this method overwrites my imageview. It means i am not able to see my imageview instead of that i can just see the different color over my image. I just want to apply that color on my image not over the image.

I have tried with some different code and android property but not able to figured it out.

If any one have idea then please help me...

InnocentKiller
  • 5,234
  • 7
  • 36
  • 84

2 Answers2

1

Update your onProgressChanged method like this

public void onProgressChanged(SeekBar arg0, int progress, boolean arg2) {

                if(progress >= 25 && progress < 50)
                  // set color on image here
                else if(progress >= 50 && progress < 75)
                  // set color on image here
                else if(progress >= 75 && progress <= 100)
                  // set color on image here
                else 
                  // set color on image here
            }

Also refer to this answer.

For changing Image Color see this answer.

Community
  • 1
  • 1
Jitender Dev
  • 6,907
  • 2
  • 24
  • 35
  • Thanks Brontok for your answer, But i am not getting that which property do i need to set for setting color on Imageview. Because if i use setColorFilter then it totally over writing my imageview means i am not able to see my image what i can see is color which i have applied over image. – InnocentKiller Oct 22 '13 at 10:41
  • Updated answer, check now. – Jitender Dev Oct 22 '13 at 11:04
-2

For this you have to first get each pixel of the image then you have edit each of its pixel