-
Notifications
You must be signed in to change notification settings - Fork 669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add real image size information to image result #1213
Comments
ExecuteCallback is not supported , I used ExecuteCallback like this painter = rememberImagePainter(
data = localId ?: attachment.cloudUrl!!,
builder = { size(OriginalSize) },
onExecute = { previous, current ->
val newHeight = with(density) { current.size.height.toDp() }
if (leastHeightImage == 0.dp || leastHeightImage > newHeight) {
leastHeightImage = newHeight
}
current.state == ImagePainter.State.Empty || previous?.request != current.request
}
) This is a row of images , I am getting the least image height from the row of images then setting that as height of every image because I want every image on that row to be equal to the height of least image height This used to work but now I can't do this , Please help me achieve this with the newer version of coil compose which does not support onExecute ! I tried this layout as well , doesn't work @Composable
private fun MinHeightRow(modifier: Modifier = Modifier, content: @Composable () -> Unit) {
Layout(
modifier = modifier,
content = content
) { measurables, constraints ->
// Don't constrain child views further, measure them with given constraints
// List of measured children
val placeables = measurables.map { measurable ->
// Measure each children
measurable.measure(constraints)
}
var minHeight = 0
for (placeable in placeables) {
if (minHeight == 0 || placeable.height < minHeight) {
minHeight = placeable.height
}
}
// Set the size of the layout as big as it can
// I tried constraints that minHeight too , this layout didn't work
layout(constraints.maxWidth, minHeight) {
// Track the y co-ord we have placed children up to
var xPosition = 0
// Place children in the parent layout
placeables.forEach { placeable ->
// Position item on the screen
placeable.placeRelative(x = xPosition, y = 0)
// Record the y co-ord placed up to
xPosition += placeable.width
}
}
}
} |
Hi @rustamsmax could you please share your code which can let me have the image size ! THanks in advance |
Same needs as @rustamsmax , I thought about seveal ways to get the original size.
Can't believe this |
Reading the size or other metadata of a file does not require reading it entirely. |
Sometimes we need real image size in order to draw extra decoration over an image
For example: I've multiple photos with label metadata. In order to draw labels at it's relative positions over an image I must know the the real image size
As a workaround I'm extending ImageLoader and setting decode factory to a custom one where I return custom drawable with real size info
The text was updated successfully, but these errors were encountered: