mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-21 09:45:48 +08:00
重构底层截图器,大幅提升截图器耗时 (#1302)
* to mat init * BitBlt 加锁 * 使用读写锁重构 Windows.Graphics.Capture,删除BGI自己命名的缓存设置 * dwm加锁并返回mat * 队伍中没有对应元素角色修复日志问题 * 清除所有 DispatcherTimerOperationEnum 内容 * 修复单测的编译错误 * HDR Support * 清理无用的截图器模式
This commit is contained in:
@@ -3,6 +3,7 @@ using BetterGenshinImpact.GameTask.Model.Area.Converter;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using Fischless.WindowsInput;
|
||||
using System.Drawing;
|
||||
using OpenCvSharp;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.Model.Area;
|
||||
|
||||
@@ -67,8 +68,8 @@ public class DesktopRegion : Region
|
||||
Simulation.SendInput.Mouse.MoveMouseBy((int)dx, (int)dy);
|
||||
}
|
||||
|
||||
public GameCaptureRegion Derive(Bitmap captureBitmap, int x, int y)
|
||||
public GameCaptureRegion Derive(Mat captureMat, int x, int y)
|
||||
{
|
||||
return new GameCaptureRegion(captureBitmap, x, y, this, new TranslationConverter(x, y));
|
||||
return new GameCaptureRegion(captureMat, x, y, this, new TranslationConverter(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace BetterGenshinImpact.GameTask.Model.Area;
|
||||
/// 游戏捕获区域类
|
||||
/// 主要用于转换到遮罩窗口的坐标
|
||||
/// </summary>
|
||||
public class GameCaptureRegion(Bitmap bitmap, int initX, int initY, Region? owner = null, INodeConverter? converter = null, DrawContent? drawContent = null) : ImageRegion(bitmap, initX, initY, owner, converter, drawContent)
|
||||
public class GameCaptureRegion(Mat mat, int initX, int initY, Region? owner = null, INodeConverter? converter = null, DrawContent? drawContent = null) : ImageRegion(mat, initX, initY, owner, converter, drawContent)
|
||||
{
|
||||
/// <summary>
|
||||
/// 在游戏捕获图像的坐标维度进行转换到遮罩窗口的坐标维度
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ImageRegion : Region
|
||||
_srcBitmap = bitmap;
|
||||
}
|
||||
|
||||
public ImageRegion(Mat mat, int x, int y, Region? owner = null, INodeConverter? converter = null) : base(x, y, mat.Width, mat.Height, owner, converter)
|
||||
public ImageRegion(Mat mat, int x, int y, Region? owner = null, INodeConverter? converter = null, DrawContent? drawContent = null) : base(x, y, mat.Width, mat.Height, owner, converter)
|
||||
{
|
||||
_srcMat = mat;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
|
||||
using System.Threading;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.Model;
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
namespace BetterGenshinImpact.GameTask.Model.Enum;
|
||||
|
||||
/// <summary>
|
||||
/// 调度器捕获模式, 影响以下内容:
|
||||
/// 1. 是否缓存图像
|
||||
/// 2. 是否执行触发器
|
||||
/// </summary>
|
||||
public enum DispatcherCaptureModeEnum
|
||||
{
|
||||
// 正常运行调度器
|
||||
NormalTrigger,
|
||||
|
||||
// 正常运行调度器,但不执行触发器,仅捕获并缓存图像模式
|
||||
OnlyCacheCapture,
|
||||
|
||||
// 正常运行调度器,捕获并缓存图像模式,并执行触发器
|
||||
CacheCaptureWithTrigger,
|
||||
|
||||
// --------------------------------------------
|
||||
// 下面两个模式无法直接设置,只能通过调度器的 StartTimer 和 StopTimer 方法来设置
|
||||
|
||||
// 停止运行整个调度器
|
||||
Stop,
|
||||
|
||||
// 启动整个调度器
|
||||
Start,
|
||||
|
||||
// --------------------------------------------
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
namespace BetterGenshinImpact.GameTask.Model.Enum;
|
||||
|
||||
/// <summary>
|
||||
/// 存在触发器运行的情况下,优先使用触发器的缓存图像
|
||||
/// 此枚举会影响调度器使用的 DispatcherCaptureModeEnum 模式
|
||||
/// </summary>
|
||||
public enum DispatcherTimerOperationEnum
|
||||
{
|
||||
// 关闭实时触发器,自己主动获取图像
|
||||
UseSelfCaptureImage,
|
||||
|
||||
// 使用实时触发器的缓存图模式,但是不执行触发器
|
||||
UseCacheImage,
|
||||
|
||||
// 使用实时触发器的缓存图模式,并执行触发器
|
||||
UseCacheImageWithTrigger,
|
||||
|
||||
// 使用实时触发器的缓存图模式,并清空当前已有触发器,执行触发器
|
||||
// 清空触发器是为了让js脚本手动添加触发器
|
||||
UseCacheImageWithTriggerEmpty,
|
||||
|
||||
// 不做任何操作
|
||||
None
|
||||
}
|
||||
Reference in New Issue
Block a user