如何通过onActivityResult()中的Intent检索相同的原始图像质量?

时间:2019-02-19 11:04:18

标签: android android-intent bitmap

我有一个意图来明智地获取图库和相机的图像。我通过startActivityForResult()成功获取了图像,但是图像获取了数据并获取了该数据并获取了图像Url并设置了Imageplaceholder,但是图像质量是非常差,图像模糊。

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

        try {
            bmp = getBitmapFromUri(selectedImage);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        image_view.setImageBitmap(bmp);

        //to know about the selected image width and height
        Toast.makeText(MainActivity.this, image_view.getDrawable().getIntrinsicWidth()+" & "+image_view.getDrawable().getIntrinsicHeight(), Toast.LENGTH_SHORT).show();
    }

}

0 个答案:

没有答案