increase or decrease image brightness works very slow using seekbar
<p>I'm using brightness code using seek bar.It is taking very long time to show the brightness in imageview.</p>

<p>Below I have posted the code :</p>

<p><strong>BrightActivity.java:</strong></p>

<pre><code>import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.os.Bundle;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;

import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;

public class BrightActivity extends Activity {


    SeekBar seekbarbrightness;

    Bitmap largeIcon;

    ImageView ivDisImage;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.bright_activity);



        seekbarbrightness = (SeekBar) findViewById(R.id.seekBar1);
        ivDisImage = (ImageView)findViewById(R.id.imageView1);

         largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.lhota);



        seekbarbrightness.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {


            @Override
            public void onStopTrackingTouch(SeekBar arg0) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onStartTrackingTouch(SeekBar arg0) {
                // TODO Auto-generated method stub

            }

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

                // TODO Auto-generated method stub

                Bitmap bitmap=doBrightness(largeIcon, progress);
                ivDisImage.setImageBitmap(bitmap);
                ivDisImage.setColorFilter(brightIt(100));

            }
        });


    }


    public static Bitmap doBrightness(Bitmap src, int value) {
        // image size
        int width = src.getWidth();
        int height = src.getHeight();
        // create output bitmap
        Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig());
        // color information
        int A, R, G, B;
        int pixel;

        // scan through all pixels
        for(int x = 0; x &lt; width; ++x) {
            for(int y = 0; y &lt; height; ++y) {
                // get pixel color
                pixel = src.getPixel(x, y);
                A = Color.alpha(pixel);
                R = Color.red(pixel);
                G = Color.green(pixel);
                B = Color.blue(pixel);

                // increase/decrease each channel
                R += value;
                if(R &gt; 255) { R = 255; }
                else if(R &lt; 0) { R = 0; }

                G += value;
                if(G &gt; 255) { G = 255; }
                else if(G &lt; 0) { G = 0; }

                B += value;
                if(B &gt; 255) { B = 255; }
                else if(B &lt; 0) { B = 0; }

                // apply new pixel color to output bitmap
                bmOut.setPixel(x, y, Color.argb(A, R, G, B));
            }
        }

        // return final image
        return bmOut;
    }

    public static ColorMatrixColorFilter brightIt(int fb) {
        ColorMatrix cmB = new ColorMatrix();
        cmB.set(new float[] {
                1, 0, 0, 0, fb,
                0, 1, 0, 0, fb,
                0, 0, 1, 0, fb,
                0, 0, 0, 1, 0   });

        ColorMatrix colorMatrix = new ColorMatrix();
        colorMatrix.set(cmB);
//Canvas c = new Canvas(b2);
//Paint paint = new Paint();
        ColorMatrixColorFilter f = new ColorMatrixColorFilter(colorMatrix);
//paint.setColorFilter(f);
        return f;
    }



}
</code></pre>

<p><strong>bright_activity.java:</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" &gt;

    &lt;TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="20dp"
        android:text="Brightness"
        android:textAppearance="?android:attr/textAppearanceLarge" /&gt;

    &lt;SeekBar
        android:id="@+id/seekBar1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/textView2"
        android:layout_marginTop="20dp" /&gt;

    &lt;ImageView
        android:id="@+id/imageView1"
        android:layout_width="fill_parent"
        android:layout_height="200dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/seekBar1"
        android:layout_marginTop="18dp"
        android:src="@drawable/lhota" /&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p>Anyone know how to increase and decrease brightness of image faster using seekbar.</p>