Harsh Lakhani
Harsh Lakhani

Reputation: 125

Get bitmap image from imageview and get it into bitmap variable

By clicking a button i am picking up image from gallery and setting it up into the imageview... here is the code..

protected void onActivityResult(int requestCode, int resultCode, Intent data) 
    {
        super.onActivityResult(requestCode, resultCode, data);
        if(requestCode==RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data)
        {
              Uri selectedImage = data.getData();
                String[] filePathColumn = { MediaStore.Images.Media.DATA };

                Cursor cursor = getContentResolver().query(selectedImage,
                        filePathColumn, null, null, null);
                cursor.moveToFirst();

                int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
                String picturePath = cursor.getString(columnIndex);
                cursor.close();

                ImageView imageView = (ImageView) findViewById(R.id.iImage);
                imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath));

        }   
    }

Now i want to get this image in bitmap variable and need to add it to arraylist as a bitmap varialbe... can anybody help me ??

Upvotes: 3

Views: 959

Answers (1)

Mohit Verma
Mohit Verma

Reputation: 3025

You can just use a variable for Bitmap like:

Bitmap imagetopass;
imagetopass=BitmapFactory.decodeFile(picturePath);

just after:

imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath));

And then you can use the variable imagetopass.

Upvotes: 2

Related Questions