HandyControl icon indicating copy to clipboard operation
HandyControl copied to clipboard

截图功能在4K分辨率下出现像素尺寸识别错误!

Open eture-server opened this issue 3 years ago • 5 comments

鼠标框选范围和实际图片剪裁区域不符

eture-server avatar Sep 24 '20 09:09 eture-server

已购买4k显示器,到货后将尝试解决这个问题

NaBian avatar Jan 26 '21 15:01 NaBian

可能是DPI缩放问题,我这里3K显示器DPI放缩%175 出现了截图位移

musli avatar Oct 09 '21 02:10 musli

截圖功能重複使用記憶體會一直累加 不會釋放掉,有解決辦法嗎?

sam321526 avatar Nov 19 '21 08:11 sam321526

以前遇到DPI縮放問題用以下方式處理,給你參考看看

#region Win32 API

    [DllImport("user32.dll")]
    private static extern IntPtr GetDC(IntPtr ptr);

    [DllImport("gdi32.dll")]
    private static extern int GetDeviceCaps(
    IntPtr hdc, // handle to DC
    int nIndex // index of capability
    );

    [DllImport("user32.dll", EntryPoint = "ReleaseDC")]
    private static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDc);

    #endregion Win32 API

    #region DeviceCaps常量

    private const int DESKTOPHORZRES = 118;
    private const int DESKTOPVERTRES = 117;
    private const int HORZRES = 8;
    private const int LOGPIXELSX = 88;
    private const int LOGPIXELSY = 90;
    private const int VERTRES = 10;

    #endregion DeviceCaps常量

    /// <summary>
    /// 獲取真實設置的桌面分辨率大小
    /// </summary>
    public static Size DESKTOP
    {
        get
        {
            IntPtr hdc = GetDC(IntPtr.Zero);
            Size size = new Size();
            size.Width = GetDeviceCaps(hdc, DESKTOPHORZRES);
            size.Height = GetDeviceCaps(hdc, DESKTOPVERTRES);
            ReleaseDC(IntPtr.Zero, hdc);
            return size;
        }
    }

sam321526 avatar Nov 22 '21 07:11 sam321526

在联想T490上也会出现这个现象,在项目中使用Screenshot 图片剪裁区域展示的图片和实际鼠标框选范围不符,下载的demo中 也是这样

wantPoorAllHard avatar Aug 16 '23 07:08 wantPoorAllHard