I am using StretchDIBits function to draw four different Bitmap's pixeldata(DIBits) to different parts of a window.
StretchDIBits immediately displays the copied bits in the window. I was wondering if there was a way to  defer showing the copied bitmap's bits until after all bitmaps are drawn.
            Asked
            
        
        
            Active
            
        
            Viewed 964 times
        
    0
            
            
        
        thunderbird
        
- 2,715
 - 5
 - 27
 - 51
 
- 
                    2Have you heard of double buffering? – CodeCaster Nov 03 '14 at 11:26
 - 
                    you mean something like the front and back buffers of a swapchain? – thunderbird Nov 03 '14 at 11:27
 - 
                    Something like that should work: render it offscreen and swap buffers when everything has been rendered. – CodeCaster Nov 03 '14 at 11:28
 - 
                    i was actually thinking of rendering everything in a bitmap and then rendering the bitmap to the window but i didn't want to involve a 5th Bitmap. Also, all my bitmaps would change dynamically within a very short time say like 16 ms or even less. Would double buffering be better than a 5th Bitmap? – thunderbird Nov 03 '14 at 11:48
 - 
                    *double buffering* in your case **is** the *5th Bitmap*. *...front and back buffers of a swapchain* is a directX orology – γηράσκω δ' αεί πολλά διδασκόμε Nov 03 '14 at 15:49
 - 
                    Why are you obsessively suggesting, that there would be a difference between *double buffering* and *using an n+1-th bitmap*? There is conceptually no difference. Read about [Device Contexts](http://msdn.microsoft.com/en-us/library/dd183553.aspx), [`CreateCompatibleDC`](http://msdn.microsoft.com/en-us/library/dd183489.aspx) followed by [`CreateCompatibleBitmap`](http://msdn.microsoft.com/en-us/library/dd183488.aspx). And done. – IInspectable Nov 03 '14 at 15:51
 - 
                    i was more like asking....by double buffering i actually meant like maintaining two different buffers instead of one bitmap and just wanted to know how that would be different if at all. – thunderbird Nov 03 '14 at 16:51
 - 
                    3*double buffering* is a **technique** of drawing first to offscreen *buffer*. The *buffer* is just a memory place. In directX there are the *back buffer* and *front buffer*. In windows when you check *double buffering = true* the system does it automatically. In your case the *front buffer* is the window hdc and the offscreen buffer is the 5th bitmap hdc. – γηράσκω δ' αεί πολλά διδασκόμε Nov 03 '14 at 17:12
 - 
                    that clarifies things up..thanks a lot! – thunderbird Nov 04 '14 at 02:56