fix: closest to mouse not clamped

This commit is contained in:
2025-10-17 20:45:02 -04:00
parent cce3b91be8
commit 4e3f39a323
3 changed files with 20 additions and 8 deletions
+13 -1
View File
@@ -66,9 +66,21 @@ namespace Spectrum.Detection
config.ImageHeight config.ImageHeight
); );
} }
var screenshot = null as Bitmap;
var screenRect = new Rectangle(0, 0, screenSize.Width, screenSize.Height);
bounds = Rectangle.Intersect(bounds, screenRect);
if (bounds.Width <= 0 || bounds.Height <= 0)
{
renderer?.CommitDetectionDrawCommands();
Thread.Sleep(2);
continue;
}
Bitmap? screenshot = null;
if (config.CaptureMethod == CaptureMethod.DirectX && _captureManager.IsDirectXAvailable) if (config.CaptureMethod == CaptureMethod.DirectX && _captureManager.IsDirectXAvailable)
{
screenshot = _captureManager.CaptureScreenshotDirectX(bounds); screenshot = _captureManager.CaptureScreenshotDirectX(bounds);
}
else else
{ {
if (_captureManager.IsInitialized) if (_captureManager.IsInitialized)
+1 -1
View File
@@ -744,7 +744,7 @@ namespace Spectrum
} }
else else
{ {
_ = InputManager.GetCursorPos(out System.Drawing.Point mousePos); InputManager.GetCursorPos(out System.Drawing.Point mousePos);
topLeft = new(mousePos.X - (config.ImageWidth / 2), mousePos.Y - (config.ImageHeight / 2)); topLeft = new(mousePos.X - (config.ImageWidth / 2), mousePos.Y - (config.ImageHeight / 2));
bottomRight = new(mousePos.X + (config.ImageWidth / 2), mousePos.Y + (config.ImageHeight / 2)); bottomRight = new(mousePos.X + (config.ImageWidth / 2), mousePos.Y + (config.ImageHeight / 2));
} }