-
Notifications
You must be signed in to change notification settings - Fork 661
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
BitmapImage doesn't use logical pixels when decoding a stream #6257
Comments
Still experiencing this problem in Windows App SDK v1.1.2. Also note that I eventually resorted to calling Win32 APIs directly to get the scaling factor and multiply it with the desired logical pixel size to get the corresponding physical pixel size, and then assign that to using System;
using System.Runtime.InteropServices;
using WinRT.Interop;
public static double GetWindowScaleFactor(Window window)
{
IntPtr hwnd = WindowNative.GetWindowHandle(window);
IntPtr hMon = MonitorFromWindow(hwnd, 1);
int hresult = GetScaleFactorForMonitor(hMon, out int scale);
return hresult == 0 ? scale / 100.0 : 0;
}
[DllImport("User32.dll")]
private static extern IntPtr MonitorFromWindow(IntPtr hwnd, uint dwFlags);
[DllImport("Shcore.dll")]
private static extern int GetScaleFactorForMonitor(IntPtr hMon, out int pScale); |
This issue is still present in WinAppSDK 1.2.2.
This results in DecodePixelWidth/Height being very inconvenient to use. As it can only be set in code and calculations with current DPI are needed. Seems like this was deactivated during the transition to 3.0 and not fixed afterwards? I wonder if this is tracked internally? I wonder who would know, maybe @codendone? |
I've hit this as well. Giving it a bump. |
This issue should be fixed in WinAppSDK 1.3. |
It looks like the fix may not have made it into 1.3, but it is in1.4. |
Describe the bug
Currently, setting
DecodePixelType = DecodePixelType.Logical
doesn't seem to make any difference in a WinUI 3 desktop application.Steps to reproduce the bug
DecodePixelWidth
andDecodePixelHeight
.DecodePixelType = DecodePixelType.Logical
.Expected behavior
BitmapImage will scale decode pixel width and height accordingly to the monitor scaling when pixel type is set to logical.
Screenshots
Here's a comparison between UWP on the left and WinUI 3 on the right:
NuGet package version
WinUI 3 - Windows App SDK 0.8: 0.8.0 (If you're seeing your issue in older previews of WinUI 3, please try this release)
Windows app type
Device form factor
Desktop
Windows version
Insider Build (xxxxx)
Additional context
No response
The text was updated successfully, but these errors were encountered: