不連續的 BitBlt 捕獲 (discontinuous BitBlt capture)


問題描述

不連續的 BitBlt 捕獲 (discontinuous BitBlt capture)

I am using BitBlt heavily in my project. I create a number of threads and in each thread I capture the screen by BitBlt. It works great and as expected for now except the following problem.

The problem happens when the user clicks on a running program or for example already opened explorer on the taskbar. You know when you click on the running program on the taskbar, it either minimizes or appears on the screen. The issue that I am talking about happens just in this transition. At that moment, something like an interrupt, all threads stop capturing the screen for a fraction of a second and then they continue capturing. The same thing happen when you move down or up the thing on the volume control window. Could you please shed some light why this is happening and how I can prevent this happening?

Thanks.

Jay

‑‑‑‑‑

參考解法

方法 1:

It could be a scheduling issue.  When you activate an app, it gets a small, momentary boost in its priority (so that it can seem responsive in the UI).  This boost might last about as long as the animation and momentarily pre‑empt your screen capture threads.

It's also possible that the desktop manager is serializing stuff, and your bitblts are simply stalled until the animation is over. Even if you've turned Aero off, I believe the desktop window manager may still be in compositing mode, which has the effect Hans Passant was describing in the comments.

If you're trying to make a video from the screen, I think it's going to be impossible to rely on GDI.  I strongly suggest reading about the Desktop Window Manager. For example, this caveat directly applies to what you're trying to do:

  

Avoid reading from or writing to a display DC. Although supported by DWM, we do not recommend it because of decreased performance.

When you use GDI to try to read the screen, DWM has to stop what it's doing, possibly render a fresh copy of the desktop to video memory, and to copy data from video memory back to system memory.  It's possible that the DWM treats these as lower‑priority requests than an animation in progress, so by the time it responds to the BitBlt, the animation is over.

This question suggests that DirectShow with a screen capture filter might be the way to go.

(by DundarAdrian McCarthy)

參考文件

  1. discontinuous BitBlt capture (CC BY‑SA 3.0/4.0)

#interrupt #API #bitblt #capture #Windows






相關問題

無法在 java 命令行程序中捕獲中斷 (Unable to catch interrupt in java command line program)

不連續的 BitBlt 捕獲 (discontinuous BitBlt capture)

GPIO 更改狀態時如何更新 sysfs? (How is sysfs updated when a GPIO changes state?)

Linux IRQ 處理程序中的固有競爭條件 (Inherent race condition in Linux IRQ handlers)

STM32 外部中斷僅在調試模式下響應 (STM32 external interrupt responds only in debug mode)

Java中的線程 (Threading in Java)

如何在被 Python 殺死之前運行最後一個函數? (How to run one last function before getting killed in Python?)

在 C++ 中處理中斷 (Handling Interrupt in C++)

應用程序中斷瘋狂 (Application interrupts like crazy)

SetPriorityClass(REALTIME_PRIORITY_CLASS) 實際上做了什麼? (What does SetPriorityClass(REALTIME_PRIORITY_CLASS) actually do?)

如何找出軟件掛起的原因?(qemu + zephyr + tfm 的問題) (How to find out the cause of hanging software? (problem with qemu + zephyr + tfm))

將參數傳遞給系統調用 (Passing arguments to system calls)







留言討論