mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-04-13 20:43:31 +08:00
* BitBlt 优化 * BitBlt恢复Top-down * 渲染时翻转图像 * CaptureSession引用计数 * 恢复成无拷贝Mat * 合法性检查 * 优化截图预览窗口 * 保存截图文件必要时需要克隆一份Mat * BitBlt内存池 * 返回拷贝就不用对Session做引用计数了 * 移除CaptureImageRes * 优化DirectX * 更好地处理padding * BitBlt去掉padding 1920*1080的游戏窗口是4字节对齐的,因此不会有性能影响。这里主要用于测试。 * 修复修改窗口大小 * 合并CreateStagingTexture * 修复设备丢失崩溃 * WGC截图支持HDR * fix typo * CodeQA * 去掉1px窗口边框 * DirectX截图去掉A通道 * HDR转换使用GPU加速 --------- Co-authored-by: 辉鸭蛋 <huiyadanli@gmail.com>
77 lines
2.4 KiB
C#
77 lines
2.4 KiB
C#
using BetterGenshinImpact.Core.Simulator;
|
|
using BetterGenshinImpact.GameTask.Model.Area.Converter;
|
|
using BetterGenshinImpact.Helpers;
|
|
using Fischless.WindowsInput;
|
|
using System.Drawing;
|
|
using Fischless.GameCapture;
|
|
using OpenCvSharp;
|
|
|
|
namespace BetterGenshinImpact.GameTask.Model.Area;
|
|
|
|
/// <summary>
|
|
/// 桌面区域类
|
|
/// 无缩放的桌面屏幕大小
|
|
/// 主要用于点击操作
|
|
/// </summary>
|
|
public class DesktopRegion : Region
|
|
{
|
|
private readonly IMouseSimulator mouse;
|
|
public DesktopRegion() : base(0, 0, PrimaryScreen.WorkingArea.Width, PrimaryScreen.WorkingArea.Height)
|
|
{
|
|
mouse = Simulation.SendInput.Mouse;
|
|
}
|
|
|
|
public DesktopRegion(IMouseSimulator mouse) : base(0, 0, PrimaryScreen.WorkingArea.Width, PrimaryScreen.WorkingArea.Height)
|
|
{
|
|
this.mouse = mouse;
|
|
}
|
|
|
|
|
|
public void DesktopRegionClick(int x, int y, int w, int h)
|
|
{
|
|
if (mouse == null)
|
|
{
|
|
throw new System.NullReferenceException();
|
|
}
|
|
mouse.MoveMouseTo((x + (w * 1d / 2)) * 65535 / Width,
|
|
(y + (h * 1d / 2)) * 65535 / Height).LeftButtonClick().Sleep(50).LeftButtonUp();
|
|
}
|
|
|
|
public void DesktopRegionMove(int x, int y, int w, int h)
|
|
{
|
|
if (mouse == null)
|
|
{
|
|
throw new System.NullReferenceException();
|
|
}
|
|
mouse.MoveMouseTo((x + (w * 1d / 2)) * 65535 / Width,
|
|
(y + (h * 1d / 2)) * 65535 / Height);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 静态方法,每次都会重新计算屏幕大小
|
|
/// </summary>
|
|
/// <param name="cx"></param>
|
|
/// <param name="cy"></param>
|
|
public static void DesktopRegionClick(double cx, double cy)
|
|
{
|
|
Simulation.SendInput.Mouse.MoveMouseTo(cx * 65535 * 1d / PrimaryScreen.WorkingArea.Width,
|
|
cy * 65535 * 1d / PrimaryScreen.WorkingArea.Height).LeftButtonDown().Sleep(50).LeftButtonUp();
|
|
}
|
|
|
|
public static void DesktopRegionMove(double cx, double cy)
|
|
{
|
|
Simulation.SendInput.Mouse.MoveMouseTo(cx * 65535 * 1d / PrimaryScreen.WorkingArea.Width,
|
|
cy * 65535 * 1d / PrimaryScreen.WorkingArea.Height);
|
|
}
|
|
|
|
public static void DesktopRegionMoveBy(double dx, double dy)
|
|
{
|
|
Simulation.SendInput.Mouse.MoveMouseBy((int)dx, (int)dy);
|
|
}
|
|
|
|
public GameCaptureRegion Derive(Mat captureMat, int x, int y)
|
|
{
|
|
return new GameCaptureRegion(captureMat, x, y, this, new TranslationConverter(x, y));
|
|
}
|
|
}
|