Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问一下, wgc 如何一次把主屏副屏都截取? #2

Open
six7ths opened this issue Nov 28, 2024 · 8 comments
Open

请问一下, wgc 如何一次把主屏副屏都截取? #2

six7ths opened this issue Nov 28, 2024 · 8 comments

Comments

@six7ths
Copy link

six7ths commented Nov 28, 2024

感觉截图都是调用桌面复制,所以,其实每次截图都是一次性把主屏副屏都截图了,但是根据设置,显示一部分。

我用
wgcp := wincapture.WGC(0)
bm_buf:= wgcp.capture()
pBitmap := Gdip_CreateBitmapFromHBITMAP(bm_buf.HBITMAP())

然后得到了pBitmap 就是主屏副屏 都有的一个长图。说明,截屏一次性截取了整个桌面。

但因为我不会处理完pBitmap后,不出问题的扔进rapidocr(在lib那里,我问的就是这个问题),所以,没法用这个方法做预处理。

所以,请问一下,wincapture.WGC()有没有参数,可以直接两块屏幕一起截屏?

Gdip_CreateBitmapFromHBITMAP(hBitmap, Palette:=0)
{
DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "UPtr", hBitmap, "UPtr", Palette, "UPtr*", &pBitmap:=0)
return pBitmap
}

@thqby
Copy link
Owner

thqby commented Nov 28, 2024

桌面复制也只能一次截一屏

@six7ths
Copy link
Author

six7ths commented Nov 28, 2024

桌面复制也只能一次截一屏

pBitmap指针确实是两块屏幕都有,不论用wincapture.WGC(0)或者wincapture.WGC(1)去截图,生成pBitmap指针后,整块屏幕(屏幕1和2)的截图都可以显示出来

@thqby
Copy link
Owner

thqby commented Nov 28, 2024

生成pBitmap指针后,整块屏幕(屏幕1和2)的截图都可以显示出来

不太可能,转换前后图像长宽变了?

有可能越界访问了,导致错误

@six7ths
Copy link
Author

six7ths commented Nov 28, 2024

我刚才试了一下,调用Gdip_CreateBitmapFromHBITMAP前,若我调用了Gdip_Startup()
则返回的pBitmap就是 我扔进去的截屏区域指定的屏幕和区域

若是忘记调用Gdip_Startup()
pBitmap则是整个两块屏幕全部范围,我两个4k,就是3840*2,2160,没有越界访问错误。我也是偶尔发现的,我猜测底层截屏应该是一次性从显存中把整个桌面frame全部读出,然后再包装接口返回对应的范围。

我用ImagePutWindow({ image: p_bm_buf, scale: 0.5 })进行显示。

这个可以100%复现

@thqby
Copy link
Owner

thqby commented Nov 28, 2024

没有startup(),调用Gdip_CreateBitmapFromHBITMAP是没pbitmap的

@six7ths
Copy link
Author

six7ths commented Nov 28, 2024

没有startup(),调用Gdip_CreateBitmapFromHBITMAP是没pbitmap的

真奇怪,我没startup(),结果就是显示整个屏幕。这跟系统和驱动有关系吗?我win11 23H2,nvidia的显卡和驱动

@six7ths
Copy link
Author

six7ths commented Nov 28, 2024

其实,一个月前,我也用过一次c++的 dxgi截屏,里面需要选择adapter,也是选择0或1,但没有选择全部屏幕截取下来,但是偶尔也会保存下载两个屏幕的一个超长截屏,但我没太注意,因为那时我只需要副屏。以后有时间再研究吧。 主要目的是两个屏幕数字在变化,一前一后截屏会有差异,不太好分析,所以希望一次截取整个屏幕,数据一致。现在改为先截取0,再直接截取1,看了看时间在1ms左右,应该可以用了。

@six7ths
Copy link
Author

six7ths commented Nov 28, 2024

是10ms左右

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants