mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 01:19:33 +00:00
Improve code readability a bit.
This commit is contained in:
+4
-3
@@ -27,7 +27,7 @@ class VideoCompressorHelper(
|
|||||||
fun getOutputSize(inputSize: Size): Size {
|
fun getOutputSize(inputSize: Size): Size {
|
||||||
val resultMajor = min(inputSize.major(), maxSize)
|
val resultMajor = min(inputSize.major(), maxSize)
|
||||||
val aspectRatio = inputSize.major().toFloat() / inputSize.minor().toFloat()
|
val aspectRatio = inputSize.major().toFloat() / inputSize.minor().toFloat()
|
||||||
return if (inputSize.width >= inputSize.height) {
|
return if (inputSize.isLandscape()) {
|
||||||
Size(resultMajor, (resultMajor / aspectRatio).roundToInt())
|
Size(resultMajor, (resultMajor / aspectRatio).roundToInt())
|
||||||
} else {
|
} else {
|
||||||
Size((resultMajor / aspectRatio).roundToInt(), resultMajor)
|
Size((resultMajor / aspectRatio).roundToInt(), resultMajor)
|
||||||
@@ -46,5 +46,6 @@ class VideoCompressorHelper(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun Size.major(): Int = if (width > height) width else height
|
private fun Size.isLandscape(): Boolean = width > height
|
||||||
internal fun Size.minor(): Int = if (width < height) width else height
|
private fun Size.major(): Int = if (isLandscape()) width else height
|
||||||
|
private fun Size.minor(): Int = if (isLandscape()) height else width
|
||||||
|
|||||||
Reference in New Issue
Block a user