从imageview获取位图图像并将其转换为位图变量

时间:2012-09-17 14:04:54

标签: android-imageview

通过点击按钮,我从图库中取出图像并将其设置到图像视图中...这里是代码..

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));

        }   
    }

现在我想在位图变量中获取此图像,需要将其添加到arraylist作为位图varialbe ...任何人都可以帮助我?

1 个答案:

答案 0 :(得分:2)

您可以将变量用于Bitmap,如:

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

紧随其后:

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

然后你可以使用变量imagetopass。