mirror of
https://github.com/Blinue/Magpie.git
synced 2026-06-24 02:04:10 +00:00
feat: 实现 PrintWindow 捕获方式
速度很慢,暂不支持 UWP 窗口
This commit is contained in:
parent
215114309e
commit
738db504b2
9 changed files with 65 additions and 7 deletions
25
Runtime/PrintWindowFrameSource.cpp
Normal file
25
Runtime/PrintWindowFrameSource.cpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#include "pch.h"
|
||||
#include "PrintWindowFrameSource.h"
|
||||
#include "App.h"
|
||||
|
||||
|
||||
extern std::shared_ptr<spdlog::logger> logger;
|
||||
|
||||
bool PrintWindowFrameSource::Update() {
|
||||
HDC hdcDest;
|
||||
HRESULT hr = _dxgiSurface->GetDC(TRUE, &hdcDest);
|
||||
if (FAILED(hr)) {
|
||||
SPDLOG_LOGGER_ERROR(logger, MakeComErrorMsg("从 Texture2D 获取 IDXGISurface1 失败", hr));
|
||||
return false;
|
||||
}
|
||||
|
||||
// https://chromium.googlesource.com/chromium/src.git/+/refs/heads/main/ui/snapshot/snapshot_win.cc
|
||||
// 不支持子窗口
|
||||
if (!PrintWindow(App::GetInstance().GetHwndSrc(), hdcDest, PW_CLIENTONLY | PW_RENDERFULLCONTENT)) {
|
||||
SPDLOG_LOGGER_ERROR(logger, MakeWin32ErrorMsg("PrintWindow 失败"));
|
||||
}
|
||||
|
||||
_dxgiSurface->ReleaseDC(nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue