-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
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
ResourceContextthat can retrieve the context aware resource based on a uri (also see theToAppxUrihelpers too, as this slightly inverse), we may want a couple- Returns the resolved
ResourceCandidatewhich 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?
- Returns the resolved
- Add logic to
SurfaceLoaderwhendpiModeis aDisplayDpi*setting to use theResourceContextinstead 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.

