Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[Feature] TilesBrush Surface can be DPI Aware #4150

Closed
michael-hawker opened this issue Jul 30, 2021 · 0 comments
Closed

[Feature] TilesBrush Surface can be DPI Aware #4150

michael-hawker opened this issue Jul 30, 2021 · 0 comments
Assignees
Labels

Comments

@michael-hawker
Copy link
Member

Describe the problem this feature would solve

If you create a TilesBrush with a URI to an image that are context aware, then it only loads the normal scaled image instead of the one for the specific DPI of your monitor.

This is because SurfaceLoader.LoadImageAsync that is used is using the underlying CanvasBitmap.LoadAsync method from Win2D on the uri which bypasses the UWP contextual loading system. Therefore, the developer can't provide up-res textures for larger DPI monitors in order to keep the design aesthetic the same for a tiled background in the app.

Describe the solution

I believe there are a few improvements we can make here to help with this:

  • Add an extension to ResourceContext that can retrieve the context aware resource based on a uri (also see the ToAppxUri helpers too, as this slightly inverse), we may want a couple
    • Returns the resolved ResourceCandidate which can be used to get a stream or storageFile from.
    • Returns the Uri of the named resource (useful if you can use the UWP system to reload, though then uri should be sufficient?), maybe the resolved Uri instead?
  • Add logic to SurfaceLoader when dpiMode is a DisplayDpi* setting to use the ResourceContext instead for an ms-appx uri

To Investigate Also: May open another issue, but want to investigate adding an attached property for image, which can hook into the MapChanged event and automatically reload an image on context change (scale, theme, etc...) - not sure if that would work for a RequestedTheme change like we do on a sample-page with an app or only the system level change.

Describe alternatives you've considered

After exposing Horizontal/VerticalAlignmentRatio on the CompositionSurfaceBrush for TilesBrush in my testing, that alone was not sufficient with any other settings to get this scenario to work as expected.

Additional context & Screenshots

Current at 150 DPI:
image

At 100 DPI and expected result for both:
image

@michael-hawker michael-hawker added this to the 7.1 milestone Jul 30, 2021
@michael-hawker michael-hawker self-assigned this Jul 30, 2021
@michael-hawker michael-hawker modified the milestones: 7.1, 7.2/8.0? Aug 19, 2021
@ghost ghost removed this from the 7.2/8.0? milestone Aug 19, 2021
@CommunityToolkit CommunityToolkit locked and limited conversation to collaborators Jul 28, 2022
@LalithaNadimpalli LalithaNadimpalli converted this issue into discussion #4632 Jul 28, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

1 participant