首页 > 解决方案 > Switching *pointers instead of using BitBlt() in winAPI?

问题描述

As I read, BitBlt() function from winGDI from winAPI is the fastest to put some image on the screen. But "blitting" only copies a memory from one source to a destination.

So I was wondering, why we can't just have two bitmaps (buffers) and just switching the pointers that will point to the current buffer if it is complete. Like Double Buffering. It would be faster than mem copiyng.

Is it possible in winAPI?

标签: c++cwinapigraphicsbitmap

解决方案


The BitBlt method in GDI is to copy the contents of the back buffer to the redirection surface. A more efficient method has been implemented in directx.

The runtime uses the bit-block transfer (bitblt) and flip presentation models to present graphics content on display monitors. The biggest difference between bitblt and flip presentation models is how back-buffer contents get to the Windows 8 DWM for composition. In the bitblt model, contents of the back buffer are copied into the redirection surface on each call to IDXGISwapChain1::Present1. In the flip model, all back buffers are shared with the Desktop Window Manager (DWM). Therefore, the DWM can compose straight from those back buffers without any additional copy operations. In general, the flip model is more efficient. The flip model also provides more features, such as enhanced present statistics.

If you have legacy components that use Windows Graphics Device Interface (GDI) to write to an HWND directly, use the bitblt model.

For more details, please refer: Comparing the DXGI flip model and the BitBlt model

This article also gives a detailed explanation.


推荐阅读