adding some int helper extensions for getting orientation/degrees
This commit is contained in:
parent
ec39ec0ba8
commit
85e9f29777
2 changed files with 16 additions and 1 deletions
|
@ -6,7 +6,7 @@ buildscript {
|
|||
propMinSdkVersion = 16
|
||||
propTargetSdkVersion = propCompileSdkVersion
|
||||
propVersionCode = 1
|
||||
propVersionName = '3.17.19'
|
||||
propVersionName = '3.17.21'
|
||||
kotlin_version = '1.2.31'
|
||||
support_libs = '27.1.0'
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.simplemobiletools.commons.extensions
|
||||
|
||||
import android.graphics.Color
|
||||
import android.media.ExifInterface
|
||||
import java.util.*
|
||||
|
||||
fun Int.getContrastColor(): Int {
|
||||
|
@ -82,3 +83,17 @@ private fun hsv2hsl(hsv: FloatArray): FloatArray {
|
|||
|
||||
return floatArrayOf(hue, newSat, newHue / 2f)
|
||||
}
|
||||
|
||||
fun Int.orientationFromDegrees() = when (this) {
|
||||
270 -> ExifInterface.ORIENTATION_ROTATE_270
|
||||
180 -> ExifInterface.ORIENTATION_ROTATE_180
|
||||
90 -> ExifInterface.ORIENTATION_ROTATE_90
|
||||
else -> ExifInterface.ORIENTATION_NORMAL
|
||||
}.toString()
|
||||
|
||||
fun Int.degreesFromOrientation() = when (this) {
|
||||
ExifInterface.ORIENTATION_ROTATE_270 -> 270
|
||||
ExifInterface.ORIENTATION_ROTATE_180 -> 180
|
||||
ExifInterface.ORIENTATION_ROTATE_90 -> 90
|
||||
else -> 0
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue