Working with AsyncImagePainter when media dimensions are known ahead of time #1880
Unanswered
CalamityDeadshot
asked this question in
Q&A
Replies: 1 comment
-
Well, I ended up calculating desired height by hand and applying it to Image container. Still wondering if it is possible to do with Coil APIs though. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My API provides me with dimensions (width, height) for every piece of media along with its URL, and I use this information to distribute images inside a grid where each image in a row is weighted by its aspect ratio before the actual image is loaded. It looks like this:
I am also applying
Modifier.height(IntrinsicSize.Max)
to every row andModifier.fillMaxHeight()
to every image to make them equal in height and also take the space they need vertically based on available width. But because of the nature of intrinsic measurements image containers take whatever minimum height I specified whileAsyncImagePainter
is in aLoading
state, which results in a wild dance of row heights while all the images are being loaded.I unsuccessfully tried specifying sizes for my
Painter
s viaImageRequest.Builder
,ImageLoader
Interceptor
s, state transformations where I explicitly emit aState.Loading
with an emptyImageBitmap
of the size of my image and other methods, but nothing seems to work the way I want it to - the grid just looks differently with rows taking the max height I specified instead of the height they need. I guess it's because Coil downsamples bitmaps to save RAM if their container is smaller.Basically what I need is for my
AsyncImagePainter
's underlyingpainter
to have a size that I know before it is loaded, so Coil can automagically downsample it for a container size that I want.Are there Coil-Compose APIs I can use to achieve this? Can you please point me in the right direction?
Beta Was this translation helpful? Give feedback.
All reactions