Android - 从图库获取图像时,肖像图像以风景形式返回(旋转 90 度)

发布于 2024-10-04 10:26:57 字数 362 浏览 0 评论 0原文

Android - 从图库获取图像时,它们的方向错误。

例如,如果它们是横向图像,则可以,但如果它们是纵向图像,则将它们旋转 90 度并再次显示为横向。

这就是我开始拾取图像活动的方式:

    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("image/*");

当我获得路径时,这就是我解码图像的方式:

    userPic = BitmapFactory.decodeFile(path);

如何解决/解决这个问题?我做错了什么吗?

Android - when getting images from Gallery, they are with wrong orientation.

For example, if they are landscape images, they are ok, but if they are portrait, they are rotated 90 degrees and again shown as landscape.

This is how I start the activity for picking images:

    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("image/*");

And when I get the path, this is how I decode the image:

    userPic = BitmapFactory.decodeFile(path);

How can I workaround/fix this issue? Is there anything I am doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

辞慾 2024-10-11 10:26:57

我的猜测是,图像在存储时正确显示,但它们的 EXIF 数据表明方向应旋转 90 度。如果您正在为 Android 2.0 及更高版本构建应用程序,请查看 ExifInterface 类。如果您的目标是早期版本的 Android,请查看 这个答案

My guess is that the images are correctly being displayed as they are stored but they have EXIF data saying that the orientation should be rotated 90 degrees. If you're building your app for Android 2.0 and above, take a look at the ExifInterface class. If you're targeting earlier versions of Android, take a look at this answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文