diff --git a/streamdeck-magnifier/streamdeck-magnifier/Helpers/ImageHelper.cs b/streamdeck-magnifier/streamdeck-magnifier/Helpers/ImageHelper.cs index ff59b28..f64be6f 100644 --- a/streamdeck-magnifier/streamdeck-magnifier/Helpers/ImageHelper.cs +++ b/streamdeck-magnifier/streamdeck-magnifier/Helpers/ImageHelper.cs @@ -45,5 +45,22 @@ internal static Image CopyFromScreen(int zoomLevel) return img; } + + internal static void DrawCrosshair(Image image) + { + using (var graphics = Graphics.FromImage(image)) + { + var color = ((Bitmap)image).GetPixel(72, 72); + var pen = new Pen(IsDarkColor(color) ? Color.White : Color.Black, 1); + graphics.DrawLine(pen, 0, 72, 144, 72); + graphics.DrawLine(pen, 72, 0, 72, 144); + } + } + + internal static bool IsDarkColor(Color color) + { + var luminance = 0.212655 * color.R + 0.715158 * color.G + 0.072187 * color.B; + return luminance < 150; + } } } diff --git a/streamdeck-magnifier/streamdeck-magnifier/Helpers/ScreenHelper.cs b/streamdeck-magnifier/streamdeck-magnifier/Helpers/ScreenHelper.cs index 29f4673..07971f7 100644 --- a/streamdeck-magnifier/streamdeck-magnifier/Helpers/ScreenHelper.cs +++ b/streamdeck-magnifier/streamdeck-magnifier/Helpers/ScreenHelper.cs @@ -19,9 +19,6 @@ private enum ProcessDPIAwareness [DllImport("User32.Dll")] private static extern long SetCursorPos(int x, int y); - [DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)] - private static extern int BitBlt(IntPtr hDC, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, int dwRop); - [DllImport("shcore.dll")] private static extern int SetProcessDpiAwareness(ProcessDPIAwareness value); diff --git a/streamdeck-magnifier/streamdeck-magnifier/Images/magnifier.ico b/streamdeck-magnifier/streamdeck-magnifier/Images/magnifier.ico new file mode 100644 index 0000000..565d191 Binary files /dev/null and b/streamdeck-magnifier/streamdeck-magnifier/Images/magnifier.ico differ diff --git a/streamdeck-magnifier/streamdeck-magnifier/Magnifier.cs b/streamdeck-magnifier/streamdeck-magnifier/Magnifier.cs index 0328925..ca5cda8 100644 --- a/streamdeck-magnifier/streamdeck-magnifier/Magnifier.cs +++ b/streamdeck-magnifier/streamdeck-magnifier/Magnifier.cs @@ -3,6 +3,7 @@ using Magnifier.Helpers; using System; using System.Threading.Tasks; +using System.Drawing; namespace Magnifier { @@ -37,6 +38,12 @@ public override void OnTick() { var img = ImageHelper.CopyFromScreen(settings.ZoomLevel); img = ImageHelper.ResizeImage(img, 144, 144); + + if (settings.UseCrosshair) + { + ImageHelper.DrawCrosshair(img); + } + Connection.SetImageAsync(img); } } diff --git a/streamdeck-magnifier/streamdeck-magnifier/MagnifierSettings.cs b/streamdeck-magnifier/streamdeck-magnifier/MagnifierSettings.cs index 07b985d..8ee64c7 100644 --- a/streamdeck-magnifier/streamdeck-magnifier/MagnifierSettings.cs +++ b/streamdeck-magnifier/streamdeck-magnifier/MagnifierSettings.cs @@ -13,6 +13,9 @@ public static MagnifierSettings CreateDefaultSettings() [JsonProperty(PropertyName = "zoomLevel")] public string PIZoomLevel { get; set; } + [JsonProperty(PropertyName = "useCrosshair")] + public bool UseCrosshair { get; set; } + public int ZoomLevel { get; set; } } } diff --git a/streamdeck-magnifier/streamdeck-magnifier/Properties/AssemblyInfo.cs b/streamdeck-magnifier/streamdeck-magnifier/Properties/AssemblyInfo.cs index 31725a1..3bc5032 100644 --- a/streamdeck-magnifier/streamdeck-magnifier/Properties/AssemblyInfo.cs +++ b/streamdeck-magnifier/streamdeck-magnifier/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.1.0.0")] +[assembly: AssemblyFileVersion("1.1.0.0")] diff --git a/streamdeck-magnifier/streamdeck-magnifier/PropertyInspector/MagnifierPI.html b/streamdeck-magnifier/streamdeck-magnifier/PropertyInspector/MagnifierPI.html index aca2746..8c3afa1 100644 --- a/streamdeck-magnifier/streamdeck-magnifier/PropertyInspector/MagnifierPI.html +++ b/streamdeck-magnifier/streamdeck-magnifier/PropertyInspector/MagnifierPI.html @@ -5,7 +5,7 @@ -