0

How to display high resolution image in imageView with bitmap?

I am trying to display image with bitmap. Low resolution images are displaying fine in imageView but not high resolution images. When I select any high resolution image it makes the imageView white. How can I solve this?

  @Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {

    switch (requestCode) {
        case 1:
            if (resultCode == RESULT_OK) {
                Uri selectedImage = data.getData();

                String[] fillPathColumn = {MediaStore.Images.Media.DATA};

                Cursor cursor = getContentResolver().query(selectedImage, fillPathColumn, null, null, null);

                cursor.moveToFirst();

                String picPath = cursor.getString(cursor.getColumnIndex(fillPathColumn[0]));
                cursor.close();


                BitmapFactory.Options options = new BitmapFactory.Options();
                options.inPreferredConfig = Bitmap.Config.ARGB_8888;

                Bitmap bitmap = BitmapFactory.decodeFile(picPath, options);


                ByteArrayOutputStream out = new ByteArrayOutputStream();
                bitmap.compress(Bitmap.CompressFormat.JPEG, 0, out);


                imageView.setImageBitmap(bitmap);


            }
    }

}
Makarand
  • 983
  • 9
  • 27

1 Answers1

0

Found way to load high resolution image with Glide from here.

If images are taking long time to set then change the quality here

bitmap.compress(Bitmap.CompressFormat.JPEG, 50, out);
Makarand
  • 983
  • 9
  • 27