问题描述
我在 Android Studio 中使用 Java Google Drive API 从驱动器下载图像:
OutputStream outputStream = new FileOutputStream(mContext.getFilesDir() + "/" + destPath);
mDriveService.files().get(id).executeMediaAndDownloadTo(outputStream);
大多数图像正常保存在设备上(如驱动器上的原始图像)。但是有些图片会旋转保存。
我的意思是,例如,我在谷歌驱动器上有一张以纵向模式定向的照片。但是上面的代码下载到设备上后,设备上的照片是横向的。
解决方法
我发现问题实际上不是保存图像,而是我查看图像的方式(因为我在 ImageView 中将其显示为位图)。 在执行 decodeFile 时,图像正在旋转。
为此,我使用的解决方案在这里: Android: Bitmaps loaded from gallery are rotated in ImageView