gpt4 book ai didi

Android 发送捕获的图像在某些设备中旋转 90 度

转载 作者:太空狗 更新时间:2023-10-29 14:23:48 27 4
gpt4 key购买 nike

我正在开发 Android 应用程序。在我的应用程序中,我必须捕获图像并将该图像发送到服务器。在某些设备中,捕获的图像以 90 度旋转发布在服务器中。我在 stackoverflow 和其他一些网站中搜索了修复程序。我得到了解决方案 ..我使用了所有解决方案 例如:

Uri selectedImage = data.getData();


File imageFile = new File(selectedImage.toString());
ExifInterface exif;
try {
exif = new ExifInterface(imageFile.getAbsolutePath());

int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);

switch(orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:

rotate=90;

break;
case ExifInterface.ORIENTATION_ROTATE_180:

rotate=180;
break;
}

但不幸的是,我在每台设备上的方向始终为 0。即使在 90 度旋转的图像设备中。

请帮助解决我的问题的 friend 。

最佳答案

您使用:

int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);

因此,您发送 defaultValue ExifInterface.ORIENTATION_NORMAL。也许您的 exif 没有属性 TAG_ORIENTATION(或 ORIENTATION_UNDEFINED)而您得到默认值?

尝试:

int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1);

看看你得到了什么。

关于Android 发送捕获的图像在某些设备中旋转 90 度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14232328/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com