Coil preloading does not work if contentScale is specified #2710
-
Good afternoon, in our application user can set a wallpaper from the gallery, take a photo or choose from the available ones. When selecting from the gallery, the image is copied to the application folder (getFilesDir/dir) and later will be used to display after logging into the account, this approach has a disadvantage - if the user sets an image of large size (4000x6000) and weighing several megabytes, the image will be displayed after a second, which is very long. I tried to preload the image, but I encountered that due to specifying ContentScale.Crop in AsyncImage, the image keeps loading after a second instead of immediately from memory and after displaying with ContentScale.Crop type, the memory cache increases. If you use AsyncImage with ContentScale by default, the image will be shown instantly from memory and memory cache will not increase. How can the problem be solved? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi, here is a basic implementation to compress bitmaps -
|
Beta Was this translation helpful? Give feedback.
-
If you enable debug logging it will log why the image isn't served from the cache. You likely need to set |
Beta Was this translation helpful? Give feedback.
If you enable debug logging it will log why the image isn't served from the cache. You likely need to set
Scale.FILL
on your image request to match theContentScale.Crop
. Without it, the image will be smaller than needed to fill theAsyncImage
.