https://kotlinlang.org logo
#compose-desktop
Title
# compose-desktop
s

Shubhasai Mohapatra

12/30/2022, 5:23 AM
I was building a Compose Multiplatform project (Android and Desktop). I want to add Images to shared Common Main file and use the image files for UI in commonMain. I tried creating a resource folder in commonMain and added Image in those. And tried to use them by following
Copy code
val file = File("resources/dogImage.jpg")
val imageBitmap: ImageBitmap = remember(file) {
    loadImageBitmap(file.inputStream())
}
Image(
    painter = BitmapPainter(image = imageBitmap),
    contentDescription = null)
It is showing error that file not found is there any way for it
m

Michael Paus

12/30/2022, 10:41 AM
s

Shubhasai Mohapatra

12/30/2022, 11:30 AM
Thanks it worked
13 Views