properly handle zooming at images rotated by exif

This commit is contained in:
tibbi 2017-12-29 21:35:13 +01:00
parent bc848e077c
commit 30374930bd

View file

@ -6,6 +6,7 @@ import android.graphics.BitmapFactory
import android.graphics.Color import android.graphics.Color
import android.graphics.Matrix import android.graphics.Matrix
import android.graphics.drawable.ColorDrawable import android.graphics.drawable.ColorDrawable
import android.media.ExifInterface.*
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -137,9 +138,9 @@ class PhotoFragment : ViewPagerFragment() {
} }
private fun degreesForRotation(orientation: Int) = when (orientation) { private fun degreesForRotation(orientation: Int) = when (orientation) {
8 -> 270 ORIENTATION_ROTATE_270 -> 270
3 -> 180 ORIENTATION_ROTATE_180 -> 180
6 -> 90 ORIENTATION_ROTATE_90 -> 90
else -> 0 else -> 0
} }
@ -253,7 +254,9 @@ class PhotoFragment : ViewPagerFragment() {
override fun onReady() { override fun onReady() {
background = ColorDrawable(if (context.config.blackBackground) Color.BLACK else context.config.backgroundColor) background = ColorDrawable(if (context.config.blackBackground) Color.BLACK else context.config.backgroundColor)
setDoubleTapZoomScale(getDoubleTapZoomScale(sWidth, sHeight)) val useWidth = if (orient == ORIENTATION_ROTATE_90 || orient == ORIENTATION_ROTATE_270) sHeight else sWidth
val useHeight = if (orient == ORIENTATION_ROTATE_90 || orient == ORIENTATION_ROTATE_270) sWidth else sHeight
setDoubleTapZoomScale(getDoubleTapZoomScale(useWidth, useHeight))
} }
override fun onTileLoadError(e: Exception?) { override fun onTileLoadError(e: Exception?) {