Skip to content
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

ColorMatrix value range for 5th column is incorrect on Skiko backed platforms #3461

Closed
chrisbanes opened this issue Aug 5, 2023 · 1 comment · Fixed by JetBrains/compose-multiplatform-core#739
Assignees
Labels
bug Something isn't working p:high High priority skiko

Comments

@chrisbanes
Copy link

Describe the bug

On Android, the matrix is passed to Android's own ColorMatrix class. That treats the final column in the range of -255..255. On Skiko backed platforms though, it is passed directly to Skia, and that treats the final column in the range of -1f..1f.

The docs on androidx.compose.ui.graphics.ColorMatrix in CMP list out the range -255..255, so it sounds like there's need to be a mapping before the matrix is set to Skiko?

Example:

val cm = ColorMatrix().apply {
    this[0, 4] = 64f
    this[1, 4] = 64f
    this[2, 4] = 64f
}

Image(
    ...,
    colorFilter = ColorFilter.colorMatrix(colorMatrix),
)

On Android, the image will look brighter. On iOS, the image will be completely white.

Affected platforms
Select one of the platforms below:

  • Skiko backed platforms
@elijah-semyonov
Copy link
Contributor

Will be fixed in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p:high High priority skiko
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants