Android图库导入
我正在使用图库选择器从图库中选取图像。相机在人像模式下拍摄的照片在图库中显示为直线。但是当我导入照片时,我得到的照片是旋转的(横向)。只有画廊将这张照片直接显示。如何解决这个问题?我希望所有照片都是其实际方向。 提前致谢
private void addImageFromGallery() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"),
GALLERY_CODE);
}
I am using gallery picker for picking an image from gallery. The photos taken by the camera in portrait mode is shown in the gallery as straight. But when I import the photos, i get the photo as rotated (landscape). Only gallery is showing this picture as straight. How to manage this problem? I want all photos as its actual orientation.
Thanks in advance
private void addImageFromGallery() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"),
GALLERY_CODE);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
得到答案了。方向以 EXIF 格式与图像一起保存。我们必须读取每个图像数据的方向标签。
旋转值可用于纠正照片的方向,如下所示:
Got the answer. The orientation is saved with the image in EXIF format. We have to read the Orientation tag of the data for each image..
The rotation value can be used to correct a photo’s orientation as follows:
设置为imageview时,检查图像的宽度是否大于高度,如果需要,将其旋转到90
while setting it to the imageview, check if the width of the image is greater than height or not and rotate it to 90 if needed