【问题标题】:Get bitmap image from imageview and get it into bitmap variable从 imageview 获取位图图像并将其放入位图变量
【发布时间】:2012-09-18 13:49:56
【问题描述】:

通过单击一个按钮,我从图库中获取图像并将其设置到图像视图中......这是代码......

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

        }   
    }

现在我想在位图变量中获取此图像,并需要将其作为位图变量添加到数组列表中......有人可以帮助我吗?

【问题讨论】:

    标签: android-imageview


    【解决方案1】:

    您可以只为 Bitmap 使用一个变量,例如:

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

    紧接着:

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

    然后你就可以使用变量imagetopass了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-02
      • 1970-01-01
      • 1970-01-01
      • 2015-05-27
      相关资源
      最近更新 更多