【发布时间】: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