Kamel-Media / Kamel

Kotlin asynchronous media loading and caching library for Compose.
Apache License 2.0
595 stars 23 forks source link

Support for bitmap or drawable in Android target #46

Open klusi opened 1 year ago

klusi commented 1 year ago

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()
    }
}
luca992 commented 1 year ago

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

klusi commented 1 year ago

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.