I have hundreds of png files in assets folder and I want to load them into Image composable. But what I can use only images in drawable folder.
how to load images from assets into Image?
How to load image from assets in Jetpack Compose
2.8k Views Asked by Hadi Ahmadi At
        	2
        	
        There are 2 best solutions below
0
                
                        
                            
                        
                        
                            On
                            
                                                    
                    
                Example:
var bitmapState by remember{ mutableStateOf<Bitmap?>(null) }
val context = LocalContext.current
LaunchedEffect(Unit) {
    bitmapState = BitmapFactory.decodeStream(context.assets.open("assetsImage.png"))
}
if (null != bitmapState) {
    val bitmap = bitmapState!!.asImageBitmap()
    Image(
        bitmap = bitmap,
        "assetsImage",
        modifier = Modifier.fillMaxSize(),
        colorFilter = null
    )
}
                        
@Halifax solution works but I have some performance issue with it. by using Coil it is much smoother and cleaner.
in build.gradle (:app) :
and then: