0

I created an Android application where I can process the filter to a bitmap in the onCreate method of the layout. However, I want to filter the bitmap in another thread instead of the UI thread.

0xCursor
  • 2,242
  • 4
  • 15
  • 33
Pankaj
  • 11
  • 1
  • 11

1 Answers1

0

Use an async task for the same
Let's say your global bitmap which you are displaying is mBitmap, tempbitmap on which you will do the processing is mBitmapTemp,

class EditActionTask extends AsyncTask<Void, Void, Bitmap> {    

    @Override 
    protected Bitmap doInBackground(Void... params) {           
            int position = params[0];
            Bitmap mBitmapTemp= mBitmap.copy(mBitmap.getConfig(), true);
            Bitmap bitmap  = ; // do your editing
            return bitmap;
    }

    @Override protected void onPostExecute(Bitmap result) {
        // update ui from result butmap         
    }
}

And use it like this

EditActionTask editActionTask = new EditActionTask();
editActionTask.execute();
maaz
  • 204
  • 3
  • 5