Created
October 11, 2018 18:33
-
-
Save owahltinez/d6f6180eda036834ac9243f542722ab0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <T>getMaximumOutputSize( | |
characteristics: CameraCharacteristics, targetClass: Class<T>, format: Int? = null): | |
Size { | |
val config = characteristics.get( | |
CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP) | |
// If image format is provided, use it to determine supported sizes; else use target class | |
val allSizes = if (format == null) | |
config.getOutputSizes(targetClass) else config.getOutputSizes(format) | |
return allSizes.sortedWith(compareBy { it.height * it.width }).reversed()[0] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment