Skip to content

Instantly share code, notes, and snippets.

@owahltinez
Created October 11, 2018 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save owahltinez/d6f6180eda036834ac9243f542722ab0 to your computer and use it in GitHub Desktop.
Save owahltinez/d6f6180eda036834ac9243f542722ab0 to your computer and use it in GitHub Desktop.
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