mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-22 16:40:31 +02:00
current stand for proper video size
This commit is contained in:
parent
ec1f91e483
commit
dd9fd930f5
@ -62,16 +62,20 @@ fun RecorderScreen(
|
|||||||
if (supportedPreviewSizes != null) {
|
if (supportedPreviewSizes != null) {
|
||||||
val previewSize = getOptimalPreviewSize(supportedPreviewSizes, width, height);
|
val previewSize = getOptimalPreviewSize(supportedPreviewSizes, width, height);
|
||||||
|
|
||||||
val optimalWidth = previewSize.width
|
val ratio = if (previewSize.height >= previewSize.width)
|
||||||
val optimalHeight = previewSize.height
|
(previewSize.height / previewSize.width).toFloat()
|
||||||
|
else (previewSize.width / previewSize.height).toFloat()
|
||||||
|
|
||||||
|
val optimalWidth = width
|
||||||
|
val optimalHeight = (width * ratio).toInt()
|
||||||
|
|
||||||
// Make sure the camera preview uses the whole screen
|
// Make sure the camera preview uses the whole screen
|
||||||
val widthScaleRatio = 1f ?: width.toFloat() / optimalWidth
|
val widthScaleRatio = optimalWidth.toFloat() / previewSize.width
|
||||||
val heightScaleUpRatio = 1f ?: height.toFloat() / optimalHeight
|
val heightScaleUpRatio = optimalHeight.toFloat() / previewSize.height
|
||||||
|
|
||||||
setMeasuredDimension(
|
setMeasuredDimension(
|
||||||
(optimalWidth * widthScaleRatio).toInt(),
|
(previewSize.width * widthScaleRatio).toInt(),
|
||||||
(optimalHeight * heightScaleUpRatio).toInt()
|
(previewSize.height * heightScaleUpRatio).toInt()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user