question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] IconTintColorBehavior misaligns tinted image on Windows

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the “Reporting a bug” section on Contributing file?

Current Behavior

When applying the IconTintColorBehavior on an image, the tinted image is misaligned on Windows; it’s offset is not correct. image

Expected Behavior

Expecting the tinted image to correctly overlay the original image.

Steps To Reproduce

  1. New MAUI app
  2. Add MAUI Community Toolkit NuGet
  3. Add IcontTintColorBehavior to the dotnet_bot on MainPage.xaml
  4. Run

Link to public reproduction project repository

https://github.com/PieEatingNinjas/BugRep_MauiToolkit_IconTintWindow

Environment

- .NET MAUI CommunityToolkit: 5.2.0
- OS: Win11
- .NET MAUI: 7.0.100

Anything else?

When looking at the source code, I noticed this: currentSpriteVisual.Offset = offset; (https://github.com/CommunityToolkit/Maui/blob/61a64de37e7dc461cc1ea97db4c941c020a59185/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/IconTintColor/IconTintColorBehavior.windows.cs#LL181C3-L181C39) which is calculated using this formula: var offset = new Vector3(-width * .5f, -height * .5f, 0f); (https://github.com/CommunityToolkit/Maui/blob/61a64de37e7dc461cc1ea97db4c941c020a59185/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/IconTintColor/IconTintColorBehavior.windows.cs#LL160C3-L160C61)

It seems when I run locally and leave this offset logic out, it does behave as expected: image

I don’t know why the above offset-logic is in there, maybe @kperdlich can explain? As said, removing this logic fixes the issue, in my particular use case.

Issue Analytics

  • State:closed
  • Created 4 months ago
  • Reactions:2
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kperdlichcommented, Jun 28, 2023

@brminnick Yeah I’ll prepare a proposal.

1reaction
kperdlichcommented, Jun 27, 2023

Originally the offset was used to align the image correctly. A better way would be to use the AnchorPoint.

In the example it looks like the attribute HeightRequest breaks the position of the tinted image. I found a fix https://github.com/kperdlich/Maui/commit/27010e7f75255ec69ea2eb67dc5eb7aa6c919301 by first using the AnchorPoint instead of the Offset to align the image correctly + applying the offset whenever a specific size is requested. However, I’m still not sure why an additional offset is required. Perhaps its something done in the layout calculation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IconTintColorBehavior - .NET MAUI Community Toolkit
The IconTintColorBehavior is a behavior allows you to tint an image.
Read more >
Microsoft Photo Viewer automatically applies yellow tint to ...
Microsoft Photo Viewer applies a yellow filter to all images when I try to view them, if I'm skipping between photos quickly there's...
Read more >
Changing TintColor of IconTintColorBehavior at runtime ...
Hello I'm testing the new IconTintColorBehavior in CommunityToolkit.Maui 1.1.0. It works find, but only when starting the application. If I ...
Read more >
Maui Community Toolkit Icon Tint Behavior issues
This is a known issue that is tracked in Image Loaded Event isn't called under certain conditions on IOS #14622,you can follow up...
Read more >
Solution to yellow tint problem in Photos app and ...
I solved it by completing system calibration of screen in Windows 10. Visit Color Management, click the Advanced tab, click Calibrate display ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found