package eu.friedcutlet.yokan.ui.image import androidx.compose.ui.graphics.ImageBitmap import eu.friedcutlet.yokan.services.files.createPlatformLocalFileService import org.jetbrains.compose.resources.decodeToImageBitmap /** * Decode the image at [path] into an [ImageBitmap]. Used by the theme system to * derive a Material seed color from a user-chosen image via MaterialKolor's * `themeColor(image: ImageBitmap, …)` extension. * * Bytes come from the platform [eu.friedcutlet.yokan.services.files.LocalFileService], so * picker results that are not plain paths (Android `content://`, iOS security-scoped URLs, * browser-selected files) decode too. Returns null when the file is missing or undecodable. */ internal fun decodeImageBitmap(path: String): ImageBitmap? = runCatching { createPlatformLocalFileService().readBytes(path).decodeToImageBitmap() }.getOrNull()