简体   繁体   English

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

[英]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.

相关问题 从相机/图库加载图像位图后会旋转[Android 9] - Image Bitmap gets rotated when loaded from camera/gallery [Android 9] Android Studio和Google Drive API(将视频上传到Google Drive) - Android Studio and Google Drive API (Uploading video to Google Drive) 使用Images API,只是原始图像旋转而不是缩放图像 - Using Images API, just the original image gets rotated not the scaled images 谷歌驱动器配额使用android api驱动器 - google drive quota using android api for drive 从带有URI的Google云端硬盘下载文件,而无需Android中的Google云端硬盘API - Download file from Google Drive with its URI, without Google Drive API in Android 在Android上使用ASyncTask通过Google Drive API读取文件 - Using ASyncTask for Reading from a File with Google Drive API on Android 如何使用Google Drive Android API删除Google Drive上的文件 - How to delete a file on google drive using Google Drive Android API 无法使用驱动器 Api 在 Android Studio 中获取特定的驱动器文件缩略图链接 - Unable to get specific Drive File thumbnailLink in Android Studio with Drive Api 在Android中从Google Places API检索图像 - Retrieving Image from Google Places API in Android 使用 Google Drive API 从 Google Drive 直接下载 - Direct download from Google Drive using Google Drive API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM