无法加载大于2000像素android的图像

时间:2013-11-13 07:38:10

标签: android

您好我想从手机内存加载图片并将其放在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;

    }

}

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

0 个答案:

没有答案