Windows Scratch Screen Technology

Source: Internet
Author: User

Some common screen capture techniques in Windows desktop Sharing 1. BitBlt  I want to do Windows development should know this API, it can achieve a copy of the content between DCs, if we designate the source DC as a monitor DC or desktop DC, it can realize the capture screen function. For the capture screen in this way, there are 2 points that need special reminders:
A. Under XP we can use the last copy flag to control whether to copy layered window, only srccpy means the copy content does not contain layered window, if it is srccpy | The CAPTUREBLT represents a copy of all windows, including the layered window. This flag is invalidated after the Vista system (WIN7/WIN8), which opens the DWM, because in this case all windows are layered window.
B. In this way the capture screen after Vista, the case of open DWM, the capture screen speed is very slow (30ms +), the specific reason is not known because the system does not cache the entire screen of data or GPU to memory copy data is too slow, there are know friends can prompt.
2. Mirror driver  This approach should be the most efficient capture screen before Win8, and Microsoft's recommended Remote Desktop Sharing scheme, which directly obtains the final screen change data by creating a virtual image driver. The method also has some drawbacks:
A. Related to driver installation, technical difficulties, system requirements are also high
B. The program has failed on WIN8, but there are methods, see Remote Display Drivers


3. GDI Hooks  This method should be said to be the XP era of the more popular screen capture method, because all the drawing is through the GDI32.dll in the drawing function to achieve, so we just intercept these functions, the system of all the drawing has let us control. This method should also be a very efficient capture screen, screen changes can also allow us to intercept, and because a lot of drawing functions are implemented in a vector way, all the captured packets are very small, even at low bandwidth, but also very good effect. Here are some of the drawbacks of this approach:
A. Hook technology itself has its own complexity and instability, especially hook all processes
B. Vista there are only a growing number of programs using D2D/D3D to draw, and GDI hooks are powerless on these plots.
c. Vista after UAC is turned on, if our program permissions are not high enough, the hook does not reach a higher privileged program.

4. Windows Media API  Windows Media 9.0 supports using the Windows Media Encoder 9 API to capture the screen. It has an encoder called Windows Media Video 9 screen codec, especially optimized for capture screens. The Windows Media Encoder API provides an IWMEncoder2 interface that can be used to capture screen images efficiently. Because this set of API is not familiar with this screen capture method I have not tried, specifically visible various methods for capturing the screens, the most disadvantage of this method is that the user machine needs to install Windows Media Encoder 9.

5. DirectX

Each DirectX program contains an area of memory that we call buffering, which stores the video memory content associated with the program, which is referred to as background buffering (back buffer) in the program, and some programs have more than one background buffer. There is also a buffer that can be accessed by default for each program-foreground buffering. The foreground buffer preserves the memory content associated with the desktop and is essentially a screen image. Our program can capture the contents of the current screen by accessing the foreground buffer. The above sake also contains the implementation of this method, is based on DirectX9, we can refer to, according to my test this method in the case of the DWM open to capture the entire screen also about 30ms. After Vista, DirectX 10/11 has changed very much relative to DirectX 9, and the code above the new interface does not necessarily work correctly.
6. Printwindow
 The method itself cannot be used directly as a screen capture method, but sometimes we want to get the contents of a window, even if he is covered by other windows, this function is useful. The principle of this usage is to send wm_print or wm_printclient messages to the target window, so if the target window is not responding, the call may block the capture thread. In this case, it is best to use SendMessageTimeout to detect if the target window is responding before grabbing the screen. In addition, the method can not catch the contents of the D3D window.
7. Dwm/dxgi Hook
 After Vista Microsoft abandoned the XP era of XPDM, the use of a new WDDM video driver model, now Win8.1 is already wddm1.3.vista after the bottom of all the rendering is based on D3D technology, In addition, we also know that the system in the DWM.exe of the window frame painting and synthesis, so theoretically we can hook dwm/d3d/dxgi to intercept the entire system screen content. Of course, as a hook technique, it also has a similar problem with GDI hooks above.

8. Magnification  This set of APIs is open to us after Microsoft Vista developed Magnifier program, it provides an API let us intercept to display content, unfortunately this key API Magsetimagescalingcallback Microsoft has declared obsolete. In addition, the method of screen capture efficiency is not high, the entire screen needs about four Ms.

9. Desktop duplication  This is the screen capture technology recommended by Microsoft Win8 to abandon mirror driver, all based on D3D/DXGI technology, which is highly efficient and contains a varied area and a screen mouse cursor. Its disadvantage is that it is impossible to crawl the contents of a window.


Ten. GETWINDOWDC
This method is similar to Printwindow, but it does not have a Printwindow permission problem or a timeout problem.
This capture screen in the case of Win7/win8 DWM open screen, the results will subvert our knowledge of the XP era, because even if the window is overwritten, it can be correctly crawled to the content of the covered window, WEBRTC is in this way to share application.
The main problem is that some Windows capture content that does not contain a non-client area, and some windows, such as the taskbar's thumbnail window, will not catch the content. Http://www.cppblog.com/weiym/archive/2013/12/01/204536.html

Windows Scratch Screen Technology

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.