From 73fa0b0c617920ccb5923bbacaa2c2230e29e435 Mon Sep 17 00:00:00 2001 From: Shaojun Li Date: Tue, 2 Aug 2022 11:21:32 +0800 Subject: [PATCH] Use Math.Round to caculate win32 physical size. (#17) At some dpi, dpi * wpf size may get non-integer win32 physical size. And convert it to integer directly may cause that the browser size is one pixel smaller than expected. --- CefSharp.Wpf.HwndHost/ChromiumWebBrowser.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CefSharp.Wpf.HwndHost/ChromiumWebBrowser.cs b/CefSharp.Wpf.HwndHost/ChromiumWebBrowser.cs index 2975aa2c1..4e54c999f 100644 --- a/CefSharp.Wpf.HwndHost/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf.HwndHost/ChromiumWebBrowser.cs @@ -1680,8 +1680,8 @@ namespace CefSharp.Wpf.HwndHost { if (dpiScale > 1) { - width = (int)(width * dpiScale); - height = (int)(height * dpiScale); + width = (int)Math.Round(width * dpiScale); + height = (int)Math.Round(height * dpiScale); } managedCefBrowserAdapter.Resize(width, height);