[Peek] Missing image aliasing
Microsoft PowerToys version
0.72.0
Installation method
Microsoft Store
Running as admin
Yes
Area(s) with issue?
Peek
Steps to reproduce
Create an image (tested PNG and JPEG) with diagonal clean lines and preview it with peek
✔️ Expected Behavior
Preview should look the same as when opening the image with Photos
❌ Actual Behavior
Image is lacking aliasing
Other Software
No response
Easy way to repro this is do a full desktop screenshot with text.
Hi, Can you share the 1.png file so I can work with the same file and test the changes? Thanks, /needinfo
I can't find the original image but it is noticeable with any image that has sharp details. Here is another one
Hi,
After thorough investigation and multiple attempts to address the image aliasing issue reported in Peek, I've determined that the root cause is tied to limitations within WinUI 3, specifically regarding the RenderOptions.BitmapScalingMode property. Despite extensive efforts to find a workaround or alternative solution within the scope of Peek's implementation, the limitation persists, impacting our ability to deliver high-quality image aliasing.
During the investigation, the following steps were taken to attempt to resolve the issue:
- Experimented with various image rendering options available within WinUI 3 to improve aliasing.
- Tested different image formats and resolutions to assess the impact on the aliasing quality.
- Tried with some other libraries.
- Searched the WinUI 3 documentation and community forums for potential undocumented workarounds or insights.
Unfortunately, due to the current constraints of WinUI 3, specifically the lack of support for setting BitmapScalingMode to "HighQuality," we're unable to achieve the desired image quality in Peek. This limitation not only affects Peek but potentially other applications developed with WinUI 3 that require high-quality image rendering.
To address this broader issue and seek solutions or workarounds, I have opened a new issue in the WinUI repository detailing this limitation and its impact on application development. You can find the issue here: https://github.com/microsoft/microsoft-ui-xaml/issues/9380
We will continue to monitor any updates or changes in WinUI 3 that might allow us to revisit and resolve this image quality issue in Peek.
Thank you for your understanding and support as we work through these technical challenges.
Quick solution would be to load the Image in XAML where possible, and not with a BitmapImage from codebehind - although if an explicit BitmapImage is actually needed (going by the code it does not look like it is), you can check the guidance for Right-sized decoding on this page https://learn.microsoft.com/en-us/windows/uwp/debug-test-perf/optimize-animations-and-media in regards to letting XAML render the image with better quality initially, circumventing this rendering behaviour (which is used for performance reasons).
(And if the codebehind decoding method is being stuck with, cancellationToken.ThrowIfCancellationRequested(); should be checked directly before Preview is set anywhere as there are async methods between it and the initial token check)
Fixed in the latest version! 🙂