Kamel-Media / Kamel

Kotlin asynchronous media loading and caching library for Compose.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for bitmap or drawable in Android target

klusi opened this issue · comments

Would it be possible to provide a Bitmap or Drawable in addition to Painter when the image is successfully downloaded in Android target similar to Coil-Compose?
Coil:

DisposableEffect(url) {
    val request = ImageRequest.Builder(context)
        .data(data = url)
        .target { drawable ->
            val bitmap = drawable.toBitmapOrNull() ?: return@target
            // TODO use bitmap
        }
        .build()

    val disposable = ImageLoader.Builder(context)
        .components { add(SvgDecoder.Factory()) }
        .build()
        .enqueue(request)

    onDispose {
        disposable.dispose()
    }
}

So you want to load a svg as a placeholder before loading a bitmap?

No, I would like to download svg and get a Bitmap or Drawable in addition to Painter as a result. There are still few Compose components (for example Google Maps Markers) that required bitmap instead of Painter and I don't want to use different library for it.