From 6e6c474d770905ae6be5bfe3590f3cc3c5e26349 Mon Sep 17 00:00:00 2001 From: LTFan Date: Sun, 5 May 2024 14:13:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=9E=E9=99=85=E7=B1=BB=E6=9C=AA?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E9=A2=84=E6=9C=9F=E7=B1=BB=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/platform/Camera.android.kt | 4 ++-- .../src/commonMain/kotlin/platform/Camera.kt | 24 ++++++++++++++++++- .../kotlin/platform/Camera.wasmJs.kt | 4 ++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/compose-app/src/androidMain/kotlin/platform/Camera.android.kt b/compose-app/src/androidMain/kotlin/platform/Camera.android.kt index 02fe0f0..f0698d3 100644 --- a/compose-app/src/androidMain/kotlin/platform/Camera.android.kt +++ b/compose-app/src/androidMain/kotlin/platform/Camera.android.kt @@ -20,7 +20,7 @@ package xyz.xfqlittlefan.fhraise.platform import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.SharedFlow actual class Camera { actual companion object { @@ -43,7 +43,7 @@ actual class Camera { actual var streamingJob: Job? get() = TODO("Not yet implemented") set(value) {} - actual val frameFlow: StateFlow + actual val frameFlow: SharedFlow get() = TODO("Not yet implemented") actual suspend fun open() { diff --git a/compose-app/src/commonMain/kotlin/platform/Camera.kt b/compose-app/src/commonMain/kotlin/platform/Camera.kt index efbb76c..75b2f9a 100644 --- a/compose-app/src/commonMain/kotlin/platform/Camera.kt +++ b/compose-app/src/commonMain/kotlin/platform/Camera.kt @@ -57,7 +57,29 @@ data class CameraImage( val width: Int, val height: Int, val content: ByteArray, -) +) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || this::class != other::class) return false + + other as CameraImage + + if (format != other.format) return false + if (width != other.width) return false + if (height != other.height) return false + if (!content.contentEquals(other.content)) return false + + return true + } + + override fun hashCode(): Int { + var result = format.hashCode() + result = 31 * result + width + result = 31 * result + height + result = 31 * result + content.contentHashCode() + return result + } +} enum class FrameFormat { AndroidRgba8888, Rgb, Bgr, RgbInt, ArgbInt diff --git a/compose-app/src/wasmJsMain/kotlin/platform/Camera.wasmJs.kt b/compose-app/src/wasmJsMain/kotlin/platform/Camera.wasmJs.kt index 02fe0f0..f0698d3 100644 --- a/compose-app/src/wasmJsMain/kotlin/platform/Camera.wasmJs.kt +++ b/compose-app/src/wasmJsMain/kotlin/platform/Camera.wasmJs.kt @@ -20,7 +20,7 @@ package xyz.xfqlittlefan.fhraise.platform import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.SharedFlow actual class Camera { actual companion object { @@ -43,7 +43,7 @@ actual class Camera { actual var streamingJob: Job? get() = TODO("Not yet implemented") set(value) {} - actual val frameFlow: StateFlow + actual val frameFlow: SharedFlow get() = TODO("Not yet implemented") actual suspend fun open() {