coil-kt / coil

Image loading for Android and Compose Multiplatform.

Home Page:https://coil-kt.github.io/coil/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistency between compose `Image` and coil `AsyncImage` (ContentScale)

janbina opened this issue · comments

Describe the bug
AsyncImage shows different result then standard Image, while it should be presumably the same.

See the minimal example and resulting screenshot below. AsyncImage doesn't respect ContentScale.None and scales drawable to the full size. We can also omit contentScale and use wrapContentSize() modifier in standard Image for the same result, which also works differently in AsyncImage.

I was able to achieve desired result by creating ImageRequest manually and specifying size(Size.ORIGINAL), but should this be needed?

To Reproduce

Row {
  Image(
    modifier = Modifier
      .size(60.dp)
      .background(Color.Gray, CircleShape),
    painter = painterResource(id = R.drawable.ic_star_full),
    contentScale = ContentScale.None,
    contentDescription = null,
  )
  AsyncImage(
    modifier = Modifier
      .size(60.dp)
      .background(Color.Gray, CircleShape),
    model = R.drawable.ic_star_full,
    contentScale = ContentScale.None,
    contentDescription = null,
  )
}

Logs/Screenshots
Screenshot_20220328-161930

Version
Using coil 2.0.0-rc02 and compose 1.1.1

Yep, we should probably handle ContentScale.None as expected. It won't be possible to handle all ContentScales (especially custom ones), but ContentScale.None can be handled similar to ScaleType.CENTER.