diff --git a/Artemis/Artemis/Profiles/Layers/Types/AmbientLight/ScreenCapturing/DX9ScreenCapture.cs b/Artemis/Artemis/Profiles/Layers/Types/AmbientLight/ScreenCapturing/DX9ScreenCapture.cs index 13c8c02c3..a9b467703 100644 --- a/Artemis/Artemis/Profiles/Layers/Types/AmbientLight/ScreenCapturing/DX9ScreenCapture.cs +++ b/Artemis/Artemis/Profiles/Layers/Types/AmbientLight/ScreenCapturing/DX9ScreenCapture.cs @@ -2,6 +2,7 @@ using System.Runtime.InteropServices; using System.Windows.Forms; using System.Windows.Media; +using Microsoft.Win32; using SharpDX.Direct3D9; namespace Artemis.Profiles.Layers.Types.AmbientLight.ScreenCapturing @@ -15,6 +16,14 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.ScreenCapturing Width = Screen.PrimaryScreen.Bounds.Width; Height = Screen.PrimaryScreen.Bounds.Height; + //DarthAffe 08.04.2017: Fix for systems using windows-scaling. The primary screen size is reported 'wrong'. + double scaling = GetScaling(); + if (Math.Abs(scaling - 1.0) > 0.01) + { + Width = (int)(Width / scaling); + Height = (int)(Height / scaling); + } + var presentParams = new PresentParameters(Width, Height) { Windowed = true, @@ -24,7 +33,7 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.ScreenCapturing _device = new Device(new Direct3D(), 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.SoftwareVertexProcessing, presentParams); _surface = Surface.CreateOffscreenPlain(_device, Width, Height, Format.A8R8G8B8, Pool.Scratch); - _buffer = new byte[Width*Height*4]; + _buffer = new byte[Width * Height * 4]; } #endregion @@ -43,6 +52,19 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.ScreenCapturing #region Methods + private double GetScaling() + { + try + { + int currentDpi = (int)Registry.GetValue("HKEY_CURRENT_USER\\Control Panel\\Desktop", "LogPixels", 96); + return 96.0 / currentDpi; + } + catch + { + return 1.0; + } + } + public byte[] CaptureScreen() { _device.GetFrontBufferData(0, _surface);