mirror of
https://github.com/babalae/better-genshin-impact
synced 2025-01-08 11:57:53 +08:00
simplify GraphicsCaptureItem creation
This commit is contained in:
parent
cfd03833ab
commit
a2025264b4
@ -30,7 +30,6 @@ GetWindowTextLength
|
||||
D3D11CreateDevice
|
||||
ID3D11Device3
|
||||
IDirect3DDxgiInterfaceAccess
|
||||
IGraphicsCaptureItemInterop
|
||||
|
||||
// Constants
|
||||
D3D11_SDK_VERSION
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System.Drawing;
|
||||
using Vision.WindowCapture.GraphicsCapture.Helpers;
|
||||
using Windows.Foundation.Metadata;
|
||||
using Windows.Graphics;
|
||||
using Windows.Graphics.Capture;
|
||||
using Windows.Graphics.DirectX;
|
||||
using Windows.Win32.Foundation;
|
||||
|
@ -24,39 +24,23 @@
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Windows.Graphics.Capture;
|
||||
using Windows.Win32;
|
||||
using Windows.UI;
|
||||
using Windows.Win32.Foundation;
|
||||
using Windows.Win32.System.WinRT.Graphics.Capture;
|
||||
using WinRT;
|
||||
using WinRT.Interop;
|
||||
|
||||
namespace Vision.WindowCapture.GraphicsCapture.Helpers;
|
||||
|
||||
public static class CaptureHelper
|
||||
{
|
||||
static readonly Guid IGraphicsCaptureItemGuid = Guid.Parse("79C3F95B-31F7-4EC2-A464-632EF5D30760");
|
||||
|
||||
public static void SetWindow(this GraphicsCapturePicker picker, IntPtr hwnd)
|
||||
{
|
||||
InitializeWithWindow.Initialize(picker, hwnd);
|
||||
}
|
||||
|
||||
[return:MaybeNull]
|
||||
public static GraphicsCaptureItem CreateItemForWindow(HWND hwnd)
|
||||
public static unsafe GraphicsCaptureItem CreateItemForWindow(HWND hwnd)
|
||||
{
|
||||
GraphicsCaptureItem
|
||||
.As<IGraphicsCaptureItemInterop>()
|
||||
.CreateForWindow(hwnd, IGraphicsCaptureItemGuid, out var thisPtr);
|
||||
|
||||
try
|
||||
{
|
||||
return GraphicsCaptureItem.FromAbi(thisPtr);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// TODO: not sure if release is needed
|
||||
MarshalInspectable<GraphicsCaptureItem>.DisposeAbi(thisPtr);
|
||||
}
|
||||
return GraphicsCaptureItem.TryCreateFromWindowId(*(WindowId*)&hwnd);
|
||||
}
|
||||
|
||||
//public static GraphicsCaptureItem CreateItemForMonitor(IntPtr hmon)
|
||||
|
Loading…
Reference in New Issue
Block a user