我想从图库中获取图像并将其存储在ImageView中。我已经成功完成了此操作,但是我从图库中拍摄的图像始终向左旋转(不包括屏幕截图)。我该如何解决?
这些是我使用的两个功能:
//Choose image from folder
private void choseImage() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
}
// Check if image is requested, upload image to image view
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK
&& data != null && data.getData() != null) {
filePath = data.getData();
try {
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), filePath);
imgBook.setImageBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
}
}
}
这是结果。图像在图库中显示为正常。并在ImageView中向左旋转。