0

嗨,我想从手机内存中加载图像并将其放在 ImageView 上。这是我加载图像的代码:

@Override
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();
        mImageCaptureUri = selectedImage;
        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.imgView);


        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(picturePath, options);

        imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath));
        imageView.setScaleType(ScaleType.FIT_XY);

        isBackgroundChange = true;

    }

}

此代码正在运行,但每次我加载大图像(分辨率)时,应用程序都会关闭。

4

0 回答 0