Remove dependencies on android bitmaps from KlottrDialog and WriteDocDialog

This commit is contained in:
Olof Hedman
2025-09-24 18:04:50 +02:00
parent 4af7d8c7fd
commit 298b73a387
5 changed files with 35 additions and 43 deletions

View File

@@ -37,6 +37,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
//TODO: OH: This file is obsolete and should be removed.
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun KlottrRoot(

View File

@@ -0,0 +1,19 @@
package app.klottr.images
import androidx.compose.ui.graphics.ImageBitmap
import org.jetbrains.compose.resources.decodeToImageBitmap
import app.klottr.net.ImageHandle
import app.klottr.net.ImageReader
/**
* Platform-independent: reads image bytes via ImageReader (expect/actual),
* then decodes to ImageBitmap using Compose MPP.
*/
suspend fun loadImageBitmap(handle: ImageHandle): ImageBitmap? {
val result = ImageReader.read(handle) ?: return null
return try {
result.bytes.decodeToImageBitmap()
} catch (_: Throwable) {
null
}
}

View File

@@ -1,13 +1,11 @@
package app.klottr.net
import kotlinx.cinterop.ExperimentalForeignApi
import okio.IOException
import kotlinx.cinterop.refTo
import platform.Foundation.NSData
import platform.Foundation.NSURL
import platform.Foundation.dataWithContentsOfURL
import platform.Foundation.isFileURL
import platform.Foundation.lastPathComponent
import platform.Foundation.pathExtension
import platform.posix.memmove
actual object ImageReader {
actual fun init(platformContext: Any?) {