From d36ce4ab8d585da02c8f0fcbb3e419918c9d5255 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 28 Jan 2018 16:20:15 +0100 Subject: [PATCH] fix target resolution of fullscreen media in case the image is rotated --- .../gallery/fragments/PhotoFragment.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index 92135eee8..603cc8546 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -194,8 +194,14 @@ class PhotoFragment : ViewPagerFragment() { private fun loadBitmap(degrees: Float = 0f) { if (degrees == 0f) { - val targetWidth = if (ViewPagerActivity.screenWidth == 0) Target.SIZE_ORIGINAL else ViewPagerActivity.screenWidth - val targetHeight = if (ViewPagerActivity.screenHeight == 0) Target.SIZE_ORIGINAL else ViewPagerActivity.screenHeight + var targetWidth = if (ViewPagerActivity.screenWidth == 0) Target.SIZE_ORIGINAL else ViewPagerActivity.screenWidth + var targetHeight = if (ViewPagerActivity.screenHeight == 0) Target.SIZE_ORIGINAL else ViewPagerActivity.screenHeight + val exif = android.media.ExifInterface(medium.path) + val orientation = exif.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, -1) + if (orientation == ORIENTATION_ROTATE_90) { + targetWidth = targetHeight + targetHeight = Target.SIZE_ORIGINAL + } val options = RequestOptions() .signature(medium.path.getFileSignature()) @@ -231,7 +237,7 @@ class PhotoFragment : ViewPagerFragment() { } private fun addZoomableView() { - if ((medium.isImage()) && isFragmentVisible && view.subsampling_view.isGone() && !medium.isDng()) { + if (medium.isImage() && isFragmentVisible && view.subsampling_view.isGone() && !medium.isDng()) { val defaultOrientation = -1 var orient = defaultOrientation