[英]Image from Google Drive Android Studio API gets rotated
I am using the Java Google Drive API in Android Studio to download an image from the drive:我在 Android Studio 中使用 Java Google Drive API 从驱动器下载图像:
OutputStream outputStream = new FileOutputStream(mContext.getFilesDir() + "/" + destPath);
mDriveService.files().get(id).executeMediaAndDownloadTo(outputStream);
Most images get saved normally on the device (like the original on drive).大多数图像都会正常保存在设备上(如驱动器上的原始图像)。 But some images get saved rotated.但是有些图像会旋转保存。
What I mean is, for example, I have a photo on google drive which is orientated in portrait mode.我的意思是,例如,我在谷歌驱动器上有一张以纵向模式定向的照片。 But after the code above downloads it on the device, the photo on the device is in landscape mode.但是上面的代码在设备上下载后,设备上的照片是横向模式。
I found out the problem was actually not saving the image, but the way I was looking at the image (because I was displaying it in an ImageView as a Bitmap).我发现问题实际上不是保存图像,而是我查看图像的方式(因为我在 ImageView 中将其显示为位图)。 While doing decodeFile, the image was getting rotated.在执行 decodeFile 时,图像正在旋转。
For that, the solution I used is here: Android: Bitmaps loaded from gallery are rotated in ImageView为此,我使用的解决方案是: Android:从画廊加载的位图在 ImageView 中旋转
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.