来自 Google Drive Android Studio API 的图像被旋转

Image from Google Drive Android Studio API gets rotated

我正在 Android Studio 中使用 Java Google 驱动器 API 从驱动器下载图像:

OutputStream outputStream = new FileOutputStream(mContext.getFilesDir() + "/" + destPath); 
mDriveService.files().get(id).executeMediaAndDownloadTo(outputStream);

大多数图像都能正常保存在设备上(就像驱动器上的原始图像一样)。但是有些图像会旋转保存。

我的意思是,例如,我在 google 驱动器上有一张纵向模式的照片。但是上面的代码在设备上下载后,设备上的照片是横向模式。

我发现问题实际上不是保存图像,而是我查看图像的方式(因为我在 ImageView 中将其显示为位图)。 在执行 decodeFile 时,图像正在旋转。

为此,我使用的解决方案是: Android: Bitmaps loaded from gallery are rotated in ImageView