Compare commits

...
Author SHA1 Message Date
辉鸭蛋 00f680f4ec 修改屏幕缩放问题 2026-05-03 13:01:40 +08:00
2 changed files with 11 additions and 6 deletions

No files matched your search

@@ -63,15 +63,15 @@ public class GameCaptureRegion(Mat mat, int initX, int initY, Region? owner = nu
/// <returns></returns>
public ImageRegion DeriveTo1080P()
{
if (Width <= 1920)
if (Width <= 1920 || Height <= 1080)
{
return this;
}
var scale = Width / 1920d;
var scale = SystemInfo.MinZoomOut1080PRatio(Width, Height);
var newMat = new Mat();
Cv2.Resize(SrcMat, newMat, new Size(1920, Height / scale));
Cv2.Resize(SrcMat, newMat, new Size(Width / scale, Height / scale));
Dispose();
return new ImageRegion(newMat, 0, 0, this, new ScaleConverter(scale));
// return new ImageRegion(newMat, 0, 0, this, new TranslationConverter(0, 0));
@@ -81,12 +81,12 @@ namespace BetterGenshinImpact.GameTask.Model
}
// 0.28 改动,素材缩放比例不可以超过 1,也就是图像识别时分辨率大于 1920x1080 的情况下直接进行缩放
if (GameScreenSize.Width < 1920)
if (GameScreenSize.Width < 1920 || GameScreenSize.Height < 1080)
{
ZoomOutMax1080PRatio = GameScreenSize.Width / 1920d;
ZoomOutMax1080PRatio = MinZoomOut1080PRatio(GameScreenSize.Width, GameScreenSize.Height);
AssetScale = ZoomOutMax1080PRatio;
}
ScaleTo1080PRatio = GameScreenSize.Width / 1920d; // 1080P 为标准
ScaleTo1080PRatio = MinZoomOut1080PRatio(GameScreenSize.Width, GameScreenSize.Height); // 1080P 为标准
CaptureAreaRect = SystemControl.GetCaptureRect(hWnd);
if (CaptureAreaRect.Width > 1920)
@@ -99,5 +99,10 @@ namespace BetterGenshinImpact.GameTask.Model
ScaleMax1080PCaptureRect = new Rect(CaptureAreaRect.X, CaptureAreaRect.Y, CaptureAreaRect.Width, CaptureAreaRect.Height);
}
}
public static double MinZoomOut1080PRatio(double width, double height)
{
return Math.Min(width / 1920d, height / 1080d);
}
}
}