【问题标题】:How to show high resolution images with bitmap?如何用位图显示高分辨率图像?
【发布时间】:2019-01-10 06:19:22
【问题描述】:

如何用位图在imageView中显示高分辨率图像?

我正在尝试使用位图显示图像。低分辨率图像在 imageView 中显示良好,但不是高分辨率图像。当我选择任何高分辨率图像时,它会使 imageView 变白。 我该如何解决这个问题?

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


            }
    }

}

【问题讨论】:

    标签: android bitmap android-image android-bitmap android-glide


    【解决方案1】:

    找到了使用 Glide from here 加载高分辨率图像的方法。

    如果图像需要很长时间才能设置,请在此处更改质量

    bitmap.compress(Bitmap.CompressFormat.JPEG, 50, out);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-12
      • 1970-01-01
      • 1970-01-01
      • 2014-11-20
      • 1970-01-01
      相关资源
      最近更新 更多