Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import androidx.annotation.OptIn
import androidx.camera.camera2.interop.Camera2CameraInfo
import com.margelo.nitro.camera.PixelFormat
import com.margelo.nitro.camera.extensions.converters.fromImageFormat
import com.margelo.nitro.camera.utils.PixelRange

@OptIn(androidx.camera.camera2.interop.ExperimentalCamera2Interop::class)
fun Camera2CameraInfo.getPixelFormats(): Array<PixelFormat> {
val streams =
this.getCameraCharacteristic(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)
?: return emptyArray()
return streams.outputFormats
.map { PixelFormat.fromImageFormat(it) }
.map { PixelFormat.fromImageFormat(it, PixelRange.UNKNOWN) }
.distinct()
.toTypedArray()
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
package com.margelo.nitro.camera.extensions

import android.annotation.SuppressLint
import android.graphics.ImageFormat
import android.hardware.DataSpace
import android.os.Build
import androidx.annotation.OptIn
import androidx.camera.core.ExperimentalGetImage
import androidx.camera.core.ImageProxy
import com.margelo.nitro.camera.DepthPixelFormat
import com.margelo.nitro.camera.PixelFormat
import com.margelo.nitro.camera.extensions.converters.fromImageFormat
import com.margelo.nitro.camera.utils.PixelRange

private val ImageProxy.pixelRange: PixelRange
@SuppressLint("WrongConstant")
@OptIn(ExperimentalGetImage::class)
get() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
return PixelRange.UNKNOWN
}

val dataSpace = image?.dataSpace ?: return PixelRange.UNKNOWN
val range = DataSpace.getRange(dataSpace)
return when (range) {
DataSpace.RANGE_LIMITED -> PixelRange.VIDEO
DataSpace.RANGE_FULL -> PixelRange.FULL
DataSpace.RANGE_EXTENDED -> PixelRange.EXTENDED
else -> PixelRange.UNKNOWN
}
}

val ImageProxy.pixelFormat: PixelFormat
get() = PixelFormat.fromImageFormat(format)
get() {
return PixelFormat.fromImageFormat(format, pixelRange)
}

val ImageProxy.depthPixelFormat: DepthPixelFormat
get() {
Expand Down
Loading
Loading