我正在捕捉图像并将其设置为图像视图.
public void captureImage() {
Intent intentCamera = new Intent("android.media.action.IMAGE_CAPTURE");
File filePhoto = new File(Environment.getExternalStorageDirectory(), "Pic.jpg");
imageUri = Uri.fromFile(filePhoto);
MyApplicationGlobal.imageUri = imageUri.getPath();
intentCamera.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intentCamera, TAKE_PICTURE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intentFromCamera) {
super.onActivityResult(requestCode, resultCode, intentFromCamera);
if (resultCode == RESULT_OK && requestCode == TAKE_PICTURE) {
if (intentFromCamera != null) {
Bundle extras = intentFromCamera.getExtras();
if (extras.containsKey("data")) {
bitmap = (Bitmap) extras.get("data");
}
else {
bitmap = getBitmapFromUri();
}
}
else {
bitmap = getBitmapFromUri();
}
// …Run Code Online (Sandbox Code Playgroud) 我看了一下,但似乎没有一个坚实的答案/解决方案,非常恼人的问题.
我以纵向拍摄照片,当我点击保存/放弃时,按钮的方向也正确.问题是,当我稍后检索图像时,它是横向的(图片已逆时针旋转90度)
我不想强迫用户以特定方向使用相机.
有没有办法可以检测照片是以纵向模式拍摄,然后解码位图并以正确的方式翻转它?